Unit test for BufferPool.insertTuple()
()
| 71 | * Unit test for BufferPool.insertTuple() |
| 72 | */ |
| 73 | @Test public void insertTuple() throws Exception { |
| 74 | // we should be able to add 504 tuples on an empty page. |
| 75 | for (int i = 0; i < 504; ++i) { |
| 76 | Tuple t = Utility.getHeapTuple(i, 2); |
| 77 | Database.getBufferPool().insertTuple(tid, empty.getId(), t); |
| 78 | HeapPage p = (HeapPage) Database.getBufferPool().getPage(tid, t.getRecordId().getPageId(), Permissions.READ_ONLY); |
| 79 | assertEquals(504-i-1, p.getNumEmptySlots()); |
| 80 | } |
| 81 | |
| 82 | // the next 504 additions should live on a new page |
| 83 | for (int i = 0; i < 504; ++i) { |
| 84 | Tuple t = Utility.getHeapTuple(i, 2); |
| 85 | Database.getBufferPool().insertTuple(tid, empty.getId(), t); |
| 86 | HeapPage p = (HeapPage) Database.getBufferPool().getPage(tid, t.getRecordId().getPageId(), Permissions.READ_ONLY); |
| 87 | assertEquals(504-i-1, p.getNumEmptySlots()); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Unit test for BufferPool.deleteTuple() |
nothing calls this directly
no test coverage detected