BAEL-5729 Convert Hex to RGB Using Java (#13432)
This commit is contained in:
parent
5fb9fe4642
commit
749cace098
0
core-java-modules/core-java-hex/README.md
Normal file
0
core-java-modules/core-java-hex/README.md
Normal file
25
core-java-modules/core-java-hex/pom.xml
Normal file
25
core-java-modules/core-java-hex/pom.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>core-java-hex</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-hex</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,25 @@
|
||||
package com.baeldung.hextorgb;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class HexToRgbUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenHexCode_whenConvertedToRgb_thenCorrectRgbValuesAreReturned() {
|
||||
String hexCode = "FF9933";
|
||||
int red = 255;
|
||||
int green = 153;
|
||||
int blue = 51;
|
||||
|
||||
int resultRed = Integer.valueOf(hexCode.substring(0, 2), 16);
|
||||
int resultGreen = Integer.valueOf(hexCode.substring(2, 4), 16);
|
||||
int resultBlue = Integer.valueOf(hexCode.substring(4, 6), 16);
|
||||
|
||||
assertEquals(red, resultRed);
|
||||
assertEquals(green, resultGreen);
|
||||
assertEquals(blue, resultBlue);
|
||||
}
|
||||
|
||||
}
|
@ -62,6 +62,7 @@
|
||||
<module>core-java-exceptions-4</module>
|
||||
<module>core-java-function</module>
|
||||
<module>core-java-functional</module>
|
||||
<module>core-java-hex</module>
|
||||
<module>core-java-io</module>
|
||||
<module>core-java-io-2</module>
|
||||
<module>core-java-io-3</module>
|
||||
|
Loading…
x
Reference in New Issue
Block a user