Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cassert>
- #include "bimap.h"
- #include <string>
- void TestBenchmarkMove()
- {
- BiMap bimap;
- int N = 3e5;
- for (auto i = 0; i < N; i++) {
- auto key = "very long word key- very long word key-" + std::to_string(i);
- auto val = "very long word value- very long word value-" + std::to_string(i);
- bimap.Add(std::string_view(key), std::string_view(val));
- }
- BiMap moved_bimap(bimap);
- for (auto i = 0; i < N / 1000; i++) {
- int index = i;
- auto key = "very long word key- very long word key-" + std::to_string(index);
- auto val = "very long word value- very long word value-" + std::to_string(index);
- assert(moved_bimap.FindKey(val) == key);
- assert(moved_bimap.FindValue(key) == val);
- }
- BiMap move_assigned_bimap;
- move_assigned_bimap = std::move(moved_bimap);
- for (auto i = 0; i < N / 1000; i++) {
- int index = i;
- auto key = "very long word key- very long word key-" + std::to_string(index);
- auto val = "very long word value- very long word value-" + std::to_string(index);
- assert(move_assigned_bimap.FindKey(val) == key);
- assert(move_assigned_bimap.FindValue(key) == val);
- }
- }
- int main() {
- TestBenchmarkMove();
- puts("Good job!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement