View Javadoc
1   package com.github.davidmoten.rx2.internal.flowable.buffertofile;
2   
3   import static org.junit.Assert.assertEquals;
4   
5   import java.io.File;
6   import java.util.concurrent.Callable;
7   
8   import org.junit.Test;
9   
10  public class PageListTest {
11  
12      private static final Callable<File> factory = new Callable<File>() {
13          int i = 0;
14  
15          @Override
16          public File call() throws Exception {
17              return new File("target/test" + (++i));
18          }
19      };
20  
21      @Test
22      public void testPutOneAndReadLessThanPageSize() {
23          Pages p = new Pages(factory, 8);
24          p.putInt(1);
25          assertEquals(1, p.getInt());
26      }
27  
28      @Test
29      public void testPutTwoAndReadLessThanPageSize() {
30          Pages p = new Pages(factory, 12);
31          p.putInt(1);
32          p.putInt(2);
33          assertEquals(1, p.getInt());
34          assertEquals(2, p.getInt());
35      }
36  
37      @Test
38      public void testPutTwoAndReadEqualsPageSize() {
39          Pages p = new Pages(factory, 8);
40          p.putInt(1);
41          p.putInt(2);
42          assertEquals(1, p.getInt());
43          assertEquals(2, p.getInt());
44      }
45  
46      @Test
47      public void testPutTwoAndReadMoreThanPageSize() {
48          Pages p = new Pages(factory, 4);
49          p.putInt(1);
50          p.putInt(2);
51          assertEquals(1, p.getInt());
52          assertEquals(2, p.getInt());
53      }
54  
55      @Test
56      public void testPutSixAndReadMultiplePages() {
57          Pages p = new Pages(factory, 8);
58          p.putInt(1);
59          p.putInt(2);
60          p.putInt(3);
61          p.putInt(4);
62          p.putInt(5);
63          p.putInt(6);
64          assertEquals(1, p.getInt());
65          assertEquals(2, p.getInt());
66          assertEquals(3, p.getInt());
67          assertEquals(4, p.getInt());
68          assertEquals(5, p.getInt());
69          assertEquals(6, p.getInt());
70      }
71  
72      // TODO test rewrite marking
73  }