Advertisement
cepxuozab

Pimpl

Oct 8th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <cassert>
  2.  
  3. #include "bimap.h"
  4. #include <string>
  5.  
  6. void TestBenchmarkMove()
  7. {
  8.     BiMap bimap;
  9.     int N = 3e5;
  10.     for (auto i = 0; i < N; i++) {
  11.         auto key = "very long word key- very long word key-" + std::to_string(i);
  12.         auto val = "very long word value- very long word value-" + std::to_string(i);
  13.         bimap.Add(std::string_view(key), std::string_view(val));
  14.     }
  15.  
  16.     BiMap moved_bimap(bimap);
  17.  
  18.     for (auto i = 0; i < N / 1000; i++) {
  19.         int index = i;
  20.         auto key = "very long word key- very long word key-" + std::to_string(index);
  21.         auto val = "very long word value- very long word value-" + std::to_string(index);
  22.         assert(moved_bimap.FindKey(val) == key);
  23.         assert(moved_bimap.FindValue(key) == val);
  24.     }
  25.  
  26.     BiMap move_assigned_bimap;
  27.     move_assigned_bimap = std::move(moved_bimap);
  28.  
  29.     for (auto i = 0; i < N / 1000; i++) {
  30.         int index = i;
  31.         auto key = "very long word key- very long word key-" + std::to_string(index);
  32.         auto val = "very long word value- very long word value-" + std::to_string(index);
  33.         assert(move_assigned_bimap.FindKey(val) == key);
  34.         assert(move_assigned_bimap.FindValue(key) == val);
  35.     }
  36. }
  37.  
  38. int main() {
  39.     TestBenchmarkMove();
  40.     puts("Good job!");
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement