Added the Binary Examples
This commit is contained in:
parent
5b68d315b8
commit
0828e8c3cd
@ -17,6 +17,15 @@ public class StringToIntOrIntegerUnitTest {
|
|||||||
assertThat(result).isEqualTo(42);
|
assertThat(result).isEqualTo(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBinaryString_whenParsingInt_shouldConvertToInt() {
|
||||||
|
String givenString = "101010";
|
||||||
|
|
||||||
|
int result = Integer.parseInt(givenString, 2);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(42);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenCallingIntegerValueOf_shouldConvertToInt() {
|
public void givenString_whenCallingIntegerValueOf_shouldConvertToInt() {
|
||||||
String givenString = "42";
|
String givenString = "42";
|
||||||
@ -26,6 +35,15 @@ public class StringToIntOrIntegerUnitTest {
|
|||||||
assertThat(result).isEqualTo(new Integer(42));
|
assertThat(result).isEqualTo(new Integer(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenBinaryString_whenCallingIntegerValueOf_shouldConvertToInt() {
|
||||||
|
String givenString = "101010";
|
||||||
|
|
||||||
|
Integer result = Integer.valueOf(givenString, 2);
|
||||||
|
|
||||||
|
assertThat(result).isEqualTo(new Integer(42));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenCallingIntegerConstructor_shouldConvertToInt() {
|
public void givenString_whenCallingIntegerConstructor_shouldConvertToInt() {
|
||||||
String givenString = "42";
|
String givenString = "42";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user