You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. #include "gtest/gtest.h"
  2. #include <cstdint>
  3. #include "src/storage/BitVector.h"
  4. #include "src/storage/BitVectorHashMap.h"
  5. TEST(BitVectorHashMapTest, FindOrAdd) {
  6. storm::storage::BitVectorHashMap<uint64_t> map(64, 3);
  7. storm::storage::BitVector first(64);
  8. first.set(4);
  9. first.set(47);
  10. ASSERT_NO_THROW(map.findOrAdd(first, 1));
  11. storm::storage::BitVector second(64);
  12. second.set(8);
  13. second.set(18);
  14. ASSERT_NO_THROW(map.findOrAdd(second, 2));
  15. EXPECT_EQ(1, map.findOrAdd(first, 3));
  16. storm::storage::BitVector third(64);
  17. third.set(10);
  18. third.set(63);
  19. ASSERT_NO_THROW(map.findOrAdd(third, 3));
  20. storm::storage::BitVector fourth(64);
  21. fourth.set(12);
  22. fourth.set(14);
  23. ASSERT_NO_THROW(map.findOrAdd(fourth, 4));
  24. storm::storage::BitVector fifth(64);
  25. fifth.set(44);
  26. fifth.set(55);
  27. ASSERT_NO_THROW(map.findOrAdd(fifth, 5));
  28. storm::storage::BitVector sixth(64);
  29. sixth.set(45);
  30. sixth.set(55);
  31. ASSERT_NO_THROW(map.findOrAdd(sixth, 6));
  32. EXPECT_EQ(1, map.findOrAdd(first, 0));
  33. EXPECT_EQ(2, map.findOrAdd(second, 0));
  34. EXPECT_EQ(3, map.findOrAdd(third, 0));
  35. EXPECT_EQ(4, map.findOrAdd(fourth, 0));
  36. EXPECT_EQ(5, map.findOrAdd(fifth, 0));
  37. EXPECT_EQ(6, map.findOrAdd(sixth, 0));
  38. }