mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
refactor: BinaryToDecimal
(#5330)
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
package com.thealgorithms.conversions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
public class BinaryToDecimalTest {
|
||||
|
||||
@ -30,4 +33,10 @@ public class BinaryToDecimalTest {
|
||||
assertEquals(262144L, BinaryToDecimal.binaryToDecimal(1000000000000000000L));
|
||||
assertEquals(524287L, BinaryToDecimal.binaryToDecimal(1111111111111111111L));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"2", "1234", "11112", "101021"})
|
||||
void testNotCorrectBinaryInput(long binaryNumber) {
|
||||
assertThrows(IllegalArgumentException.class, () -> BinaryToDecimal.binaryToDecimal(binaryNumber));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user