SolutionTest.java 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package leetcode.p1009;
  2. import org.junit.Test;
  3. import org.junit.runner.RunWith;
  4. import org.junit.runners.Parameterized;
  5. import java.util.Arrays;
  6. import java.util.Collection;
  7. import static org.junit.Assert.assertEquals;
  8. /**
  9. * @ProjectName: LeetCode
  10. * @FileName: SolutionTest
  11. * @Author: 杨逸
  12. * @Data:2026/3/11 20:15
  13. * @Description:
  14. */
  15. @RunWith(Parameterized.class)
  16. public class SolutionTest {
  17. public static final Solution solution = new Solution();
  18. private final int n;
  19. private final int expected;
  20. @Parameterized.Parameters
  21. public static Collection<Object[]> data(){
  22. return Arrays.asList(new Object[][]{
  23. {5,2},
  24. {7,0},
  25. {10,5},
  26. {0,1},
  27. });
  28. }
  29. public SolutionTest(int n, int expected) {
  30. this.n = n;
  31. this.expected = expected;
  32. }
  33. @Test
  34. public void bitwiseComplement() {
  35. assertEquals(expected, solution.bitwiseComplement(n));
  36. }
  37. }