File tree Expand file tree Collapse file tree 1 file changed +12
-12
lines changed
src/test/java/com/thealgorithms/bitmanipulation Expand file tree Collapse file tree 1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 22
33import static org .junit .jupiter .api .Assertions .assertEquals ;
44
5- import org .junit .jupiter .api .Test ;
5+ import org .junit .jupiter .params .ParameterizedTest ;
6+ import org .junit .jupiter .params .provider .CsvSource ;
67
78class SwapAdjacentBitsTest {
89
9- @ Test
10- void testSwapAdjacentBits () {
11- assertEquals (1 , SwapAdjacentBits .swapAdjacentBits (2 ));
12-
13- assertEquals (23 , SwapAdjacentBits .swapAdjacentBits (43 ));
14-
15- assertEquals (102 , SwapAdjacentBits .swapAdjacentBits (153 ));
16-
17- assertEquals (15 , SwapAdjacentBits .swapAdjacentBits (15 ));
18-
19- assertEquals (0 , SwapAdjacentBits .swapAdjacentBits (0 ));
10+ @ ParameterizedTest
11+ @ CsvSource ({
12+ "2, 1" , // 2 (10 in binary) should become 1 (01 in binary)
13+ "43, 23" , // 43 should become 23
14+ "153, 102" , // 153 should become 102
15+ "15, 15" , // 15 (1111) remains 15 (1111)
16+ "0, 0" // 0 (0000) remains 0 (0000)
17+ })
18+ void testSwapAdjacentBits (int input , int expected ) {
19+ assertEquals (expected , SwapAdjacentBits .swapAdjacentBits (input ));
2020 }
2121}
You can’t perform that action at this time.
0 commit comments