Unit test for HeapFile.addTuple()
()
| 33 | * Unit test for HeapFile.addTuple() |
| 34 | */ |
| 35 | @Test public void addTuple() throws Exception { |
| 36 | // we should be able to add 504 tuples on an empty page. |
| 37 | for (int i = 0; i < 504; ++i) { |
| 38 | empty.insertTuple(tid, Utility.getHeapTuple(i, 2)); |
| 39 | assertEquals(1, empty.numPages()); |
| 40 | } |
| 41 | |
| 42 | // the next 512 additions should live on a new page |
| 43 | for (int i = 0; i < 504; ++i) { |
| 44 | System.out.println(empty.getFile().length()); |
| 45 | System.out.println(Utility.getHeapTuple(i, 2)); |
| 46 | empty.insertTuple(tid, Utility.getHeapTuple(i, 2)); |
| 47 | System.out.println(empty.numPages()); |
| 48 | System.out.println(empty.getFile().length()); |
| 49 | assertEquals(2, empty.numPages()); |
| 50 | } |
| 51 | |
| 52 | // and one more, just for fun... |
| 53 | empty.insertTuple(tid, Utility.getHeapTuple(0, 2)); |
| 54 | assertEquals(3, empty.numPages()); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void testAlternateEmptyAndFullPagesThenIterate() throws Exception { |
nothing calls this directly
no test coverage detected