Skip to content

Commit

Permalink
fixed #107 - Added missing unit tests for engine/utils/*
Browse files Browse the repository at this point in the history
  • Loading branch information
dzc34 committed Nov 19, 2017
1 parent daacab2 commit fefc24a
Show file tree
Hide file tree
Showing 6 changed files with 828 additions and 156 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ none
### Task
- [#104 - Added maven-jxr-plugin (needed for maven-checkstyle-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/104)
- [#106 - Added unit tests coverage report (jacoco-maven-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/106)
- [#107 - Added missing unit tests for engine/utils/*](https://github.com/Asqatasun/Contrast-Finder/issues/107)



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static Color offsetHsbColor(Color color, float offsetHue, float offsetSat

/**
* @param color
* @return the brightness of the given color
* @return the brightness (hsb) of the given color
*/
public static Float getBrightness(Color color) {
float[] hsbValues = new float[MAX_COMPONENT];
Expand All @@ -92,7 +92,7 @@ public static Float getBrightness(Color color) {

/**
* @param color
* @return the saturation of the given color
* @return the saturation (hsb) of the given color
*/
public static Float getSaturation(Color color) {
float[] hsbValues = new float[MAX_COMPONENT];
Expand All @@ -104,7 +104,7 @@ public static Float getSaturation(Color color) {

/**
* @param color
* @return the hue of the given color
* @return the hue (hsb) of the given color
*/
public static Float getHue(Color color) {
float[] hsbValues = new float[MAX_COMPONENT];
Expand All @@ -115,6 +115,9 @@ public static Float getHue(Color color) {
}

/**
* @todo check if offset* is valid for Color (ex: WHITE 255,255,255 with +10)
* @todo check if color is not null
*
* @param bgColor
* @param offsetRed
* @param offsetGreen
Expand Down Expand Up @@ -175,7 +178,7 @@ public static Color colorFromStr(String colorStr) {


/**
* @param colorStr ex: silver, red, SteelBlue, ...
* @param colorStr color name (ex: silver, red, SteelBlue, ...)
* @return Color object or NULL
*/
public static Color colorFromColorName(String colorStr) {
Expand Down Expand Up @@ -213,20 +216,22 @@ public static Color colorFromRgbStr(String colorStr) {
* @return the RGB Color from hex Color
*/
public static Color hex2Rgb(String colorStr) {
if (colorStr.charAt(0) == '#') {
String str = colorStr.substring(1);
if (str.matches(HEXADECIMAL_DICTIONNARY)
if(colorStr.length() > 0){
if (colorStr.charAt(0) == '#') {
String str = colorStr.substring(1);
if (str.matches(HEXADECIMAL_DICTIONNARY)
&& str.length() == RGB_HEXA_LENGTH) {
return getNewColor(str);
} else if (str.matches(HEXADECIMAL_DICTIONNARY)
return getNewColor(str);
} else if (str.matches(HEXADECIMAL_DICTIONNARY)
&& str.length() == RGB_SHORT_HEXA_LENGTH) {
return getNewColorShortHexa(str);
}
} else if (colorStr.matches(HEXADECIMAL_DICTIONNARY)) {
if (colorStr.length() == RGB_HEXA_LENGTH) {
return getNewColor(colorStr);
} else if (colorStr.length() == RGB_SHORT_HEXA_LENGTH) {
return getNewColorShortHexa(colorStr);
return getNewColorShortHexa(str);
}
} else if (colorStr.matches(HEXADECIMAL_DICTIONNARY)) {
if (colorStr.length() == RGB_HEXA_LENGTH) {
return getNewColor(colorStr);
} else if (colorStr.length() == RGB_SHORT_HEXA_LENGTH) {
return getNewColorShortHexa(colorStr);
}
}
}
return null;
Expand Down
Loading

0 comments on commit fefc24a

Please sign in to comment.