File tree 1 file changed +12
-12
lines changed
src/test/java/com/thealgorithms/bitmanipulation
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
5
- import org .junit .jupiter .api .Test ;
5
+ import org .junit .jupiter .params .ParameterizedTest ;
6
+ import org .junit .jupiter .params .provider .CsvSource ;
6
7
7
8
class SwapAdjacentBitsTest {
8
9
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 ));
20
20
}
21
21
}
You can’t perform that action at this time.
0 commit comments