mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add FirstDifferentBit algorithm (#5866)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.thealgorithms.bitmanipulation;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
public class FirstDifferentBitTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"10, 8, 1", "7, 5, 1", "15, 14, 0", "1, 2, 0"})
|
||||
void testFirstDifferentBit(int x, int y, int expected) {
|
||||
assertEquals(expected, FirstDifferentBit.firstDifferentBit(x, y));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user