mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 09:06:51 +08:00
Add OneBitDifference
algorithm (#5864)
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 OneBitDifferenceTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"7, 5, true", "3, 2, true", "10, 8, true", "15, 15, false", "4, 1, false"})
|
||||
void testDifferByOneBit(int x, int y, boolean expected) {
|
||||
assertEquals(expected, OneBitDifference.differByOneBit(x, y));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user