Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. TEST_F(BTreeTest, Insert2)
  2. {
  3. std::string& fn = getFn("Insert2.xibt");
  4.  
  5. ByteComparator comparator;
  6. FileBaseBTree bt(2, 1, &comparator, fn);
  7.  
  8.  
  9. Byte k = 0x03;
  10. bt.insert(&k);
  11.  
  12. k = 0x02;
  13. bt.insert(&k);
  14.  
  15. k = 0x01;
  16. bt.insert(&k);
  17.  
  18. k = 0x04;
  19. bt.insert(&k);
  20.  
  21. FileBaseBTree::PageWrapper wp1(&bt);
  22. wp1.readPage(1);
  23.  
  24. ASSERT_EQ(wp1.getKeysNum(), 1);
  25. ASSERT_EQ(*(wp1.getKey(0)),0x01);
  26. ASSERT_TRUE(wp1.isLeaf());
  27.  
  28. wp1.readPage(2);
  29.  
  30. ASSERT_EQ(wp1.getKeysNum(), 1);
  31. ASSERT_EQ(*(wp1.getKey(0)),0x02);
  32.  
  33. ASSERT_EQ(wp1.getCursor(0), 1);
  34. ASSERT_EQ(wp1.getCursor(1), 3);
  35. ASSERT_TRUE(wp1.isRoot());
  36.  
  37. wp1.readPage(3);
  38.  
  39. ASSERT_EQ(wp1.getKeysNum(), 2);
  40. ASSERT_EQ(*(wp1.getKey(0)),0x03);
  41. ASSERT_EQ(*(wp1.getKey(1)),0x04);
  42. ASSERT_TRUE(wp1.isLeaf());
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement