forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDecimalToBinaryTest.java
More file actions
21 lines (16 loc) · 837 Bytes
/
DecimalToBinaryTest.java
File metadata and controls
21 lines (16 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.thealgorithms.conversions;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
public class DecimalToBinaryTest {
@ParameterizedTest
@CsvSource({"0, 0", "1, 1", "2, 10", "5, 101", "10, 1010", "15, 1111", "100, 1100100"})
void testConvertUsingConventionalAlgorithm(int decimal, int expectedBinary) {
assertEquals(expectedBinary, DecimalToBinary.convertUsingConventionalAlgorithm(decimal));
}
@ParameterizedTest
@CsvSource({"0, 0", "1, 1", "2, 10", "5, 101", "10, 1010", "15, 1111", "100, 1100100"})
void testConvertUsingBitwiseAlgorithm(int decimal, int expectedBinary) {
assertEquals(expectedBinary, DecimalToBinary.convertUsingBitwiseAlgorithm(decimal));
}
}