test/java/util/BitSet/BitSetStreamTest.java

Print this page
rev 7312 : 8016448: java/util/BitSet/BitSetStreamTest.java no longer compiles, missed by 8015895
Reviewed-by:


  48  */
  49 public class BitSetStreamTest {
  50     static class Fibs implements IntSupplier {
  51         private int n1 = 0;
  52         private int n2 = 1;
  53 
  54         static int fibs(int n) {
  55             Fibs f = new Fibs();
  56             while (n-- > 0) f.getAsInt();
  57             return f.getAsInt();
  58         }
  59 
  60         public int getAsInt() { int s = n1; n1 = n2; n2 = s + n1; return s; }
  61     }
  62 
  63     private static final Object[][] testcases = new Object[][] {
  64         { "none", IntStream.empty() },
  65         { "index 0", IntStream.of(0) },
  66         { "index 255", IntStream.of(255) },
  67         { "every bit", IntStream.range(0, 255) },
  68         { "step 2", IntStream.range(0, 255, 2) },
  69         { "step 3", IntStream.range(0, 255, 3) },
  70         { "step 5", IntStream.range(0, 255, 5) },
  71         { "step 7", IntStream.range(0, 255, 7) },
  72         { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
  73         { "25 fibs", IntStream.generate(new Fibs()).limit(25) }
  74     };
  75 
  76     @DataProvider(name = "cases")
  77     public static Object[][] produceCases() {
  78         return testcases;
  79     }
  80 
  81     @Test
  82     public void testFibs() {
  83         Fibs f = new Fibs();
  84         assertEquals(0, f.getAsInt());
  85         assertEquals(1, f.getAsInt());
  86         assertEquals(1, f.getAsInt());
  87         assertEquals(2, f.getAsInt());
  88         assertEquals(3, f.getAsInt());
  89         assertEquals(5, f.getAsInt());
  90         assertEquals(8, f.getAsInt());
  91         assertEquals(13, f.getAsInt());




  48  */
  49 public class BitSetStreamTest {
  50     static class Fibs implements IntSupplier {
  51         private int n1 = 0;
  52         private int n2 = 1;
  53 
  54         static int fibs(int n) {
  55             Fibs f = new Fibs();
  56             while (n-- > 0) f.getAsInt();
  57             return f.getAsInt();
  58         }
  59 
  60         public int getAsInt() { int s = n1; n1 = n2; n2 = s + n1; return s; }
  61     }
  62 
  63     private static final Object[][] testcases = new Object[][] {
  64         { "none", IntStream.empty() },
  65         { "index 0", IntStream.of(0) },
  66         { "index 255", IntStream.of(255) },
  67         { "every bit", IntStream.range(0, 255) },
  68         { "step 2", IntStream.range(0, 255).map(f -> f * 2) },
  69         { "step 3", IntStream.range(0, 255).map(f -> f * 3) },
  70         { "step 5", IntStream.range(0, 255).map(f -> f * 5) },
  71         { "step 7", IntStream.range(0, 255).map(f -> f * 7) },
  72         { "1, 10, 100, 1000", IntStream.of(1, 10, 100, 1000) },
  73         { "25 fibs", IntStream.generate(new Fibs()).limit(25) }
  74     };
  75 
  76     @DataProvider(name = "cases")
  77     public static Object[][] produceCases() {
  78         return testcases;
  79     }
  80 
  81     @Test
  82     public void testFibs() {
  83         Fibs f = new Fibs();
  84         assertEquals(0, f.getAsInt());
  85         assertEquals(1, f.getAsInt());
  86         assertEquals(1, f.getAsInt());
  87         assertEquals(2, f.getAsInt());
  88         assertEquals(3, f.getAsInt());
  89         assertEquals(5, f.getAsInt());
  90         assertEquals(8, f.getAsInt());
  91         assertEquals(13, f.getAsInt());