Removal of unwanted spaces
This commit is contained in:
parent
8090117cb6
commit
625676f7cb
@ -7,38 +7,38 @@ import java.math.BigInteger;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class StringToBigIntegerUnitTest {
|
public class StringToBigIntegerUnitTest {
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenGetStringWithOutRadix_thenOK() {
|
|
||||||
final String inputString = "878";
|
|
||||||
BigInteger result = new BigInteger(inputString);
|
|
||||||
assertEquals("878", result.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenGetStringWithRadix_thenOK() {
|
public void whenGetStringWithOutRadix_thenOK() {
|
||||||
final String inputString = "290f98";
|
final String inputString = "878";
|
||||||
BigInteger result = new BigInteger(inputString, 16);
|
BigInteger result = new BigInteger(inputString);
|
||||||
assertEquals("2690968", result.toString());
|
assertEquals("878", result.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NumberFormatException.class)
|
@Test
|
||||||
public void whenGetStringWithOutRadix_thenThrowError() {
|
public void whenGetStringWithRadix_thenOK() {
|
||||||
final String inputString = "290f98";
|
final String inputString = "290f98";
|
||||||
new BigInteger(inputString);
|
BigInteger result = new BigInteger(inputString, 16);
|
||||||
}
|
assertEquals("2690968", result.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = NumberFormatException.class)
|
@Test(expected = NumberFormatException.class)
|
||||||
public void whenGetStringWithRadix_thenThrowError() {
|
public void whenGetStringWithOutRadix_thenThrowError() {
|
||||||
final String inputString = "Hello Baeldung";
|
final String inputString = "290f98";
|
||||||
new BigInteger(inputString, 7);
|
new BigInteger(inputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = NumberFormatException.class)
|
||||||
public void whenGetStringUsingByte_thenOk() {
|
public void whenGetStringWithRadix_thenThrowError() {
|
||||||
final String inputString = "Hello Baeldung";
|
final String inputString = "Hello Baeldung";
|
||||||
byte[] inputStringBytes = inputString.getBytes();
|
new BigInteger(inputString, 7);
|
||||||
BigInteger result = new BigInteger(inputStringBytes);
|
}
|
||||||
assertEquals("Hello Baeldung", new String(result.toByteArray()));
|
|
||||||
}
|
@Test
|
||||||
|
public void whenGetStringUsingByte_thenOk() {
|
||||||
|
final String inputString = "Hello Baeldung";
|
||||||
|
byte[] inputStringBytes = inputString.getBytes();
|
||||||
|
BigInteger result = new BigInteger(inputStringBytes);
|
||||||
|
assertEquals("Hello Baeldung", new String(result.toByteArray()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user