| File: | root/firefox-clang/mfbt/tests/TestHashTable.cpp |
| Warning: | line 31, column 3 Method called on moved-from object 'map' |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* This Source Code Form is subject to the terms of the Mozilla Public | |||
| 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, | |||
| 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
| 4 | ||||
| 5 | #include <utility> | |||
| 6 | ||||
| 7 | #include "mozilla/CompactPair.h" | |||
| 8 | #include "mozilla/HashTable.h" | |||
| 9 | #include "mozilla/PairHash.h" | |||
| 10 | ||||
| 11 | void TestMoveConstructor() { | |||
| 12 | using namespace mozilla; | |||
| 13 | ||||
| 14 | HashMap<int, int> map; | |||
| 15 | MOZ_RELEASE_ASSERT(map.putNew(3, 32))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(3, 32))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(3, 32)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(3, 32)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 15); do { } while (false); do { MOZ_CrashSequence(__null, 15); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| ||||
| 16 | MOZ_RELEASE_ASSERT(map.putNew(4, 42))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(4, 42))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(4, 42)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(4, 42)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 16); do { } while (false); do { MOZ_CrashSequence(__null, 16); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 17 | MOZ_RELEASE_ASSERT(map.count() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 2" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 17); do { } while (false); do { MOZ_CrashSequence(__null, 17); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 18 | MOZ_RELEASE_ASSERT(!map.empty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.empty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.empty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.empty()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 18); do { } while (false); do { MOZ_CrashSequence(__null, 18 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 19 | MOZ_RELEASE_ASSERT(!map.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 19); do { } while (false); do { MOZ_CrashSequence(__null, 19); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 20 | MOZ_RELEASE_ASSERT(map.lookup(3)->value() == 32)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(3)->value() == 32)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(3)->value() == 32))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(3)->value() == 32", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 20); do { } while (false); do { MOZ_CrashSequence(__null, 20 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 21 | MOZ_RELEASE_ASSERT(map.lookup(4)->value() == 42)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(4)->value() == 42)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(4)->value() == 42))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(4)->value() == 42", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 21); do { } while (false); do { MOZ_CrashSequence(__null, 21 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 22 | ||||
| 23 | HashMap<int, int> moved = std::move(map); | |||
| 24 | MOZ_RELEASE_ASSERT(moved.count() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(moved.count() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(moved.count() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("moved.count() == 2" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 24); do { } while (false); do { MOZ_CrashSequence(__null, 24); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 25 | MOZ_RELEASE_ASSERT(!moved.empty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!moved.empty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!moved.empty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!moved.empty()" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 25); do { } while (false); do { MOZ_CrashSequence(__null, 25); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 26 | MOZ_RELEASE_ASSERT(!moved.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!moved.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!moved.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!moved.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 26); do { } while (false); do { MOZ_CrashSequence(__null, 26); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 27 | MOZ_RELEASE_ASSERT(moved.lookup(3)->value() == 32)do { static_assert( mozilla::detail::AssertionConditionType< decltype(moved.lookup(3)->value() == 32)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(moved.lookup(3)->value() == 32))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("moved.lookup(3)->value() == 32", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 27); do { } while (false); do { MOZ_CrashSequence(__null, 27 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 28 | MOZ_RELEASE_ASSERT(moved.lookup(4)->value() == 42)do { static_assert( mozilla::detail::AssertionConditionType< decltype(moved.lookup(4)->value() == 42)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(moved.lookup(4)->value() == 42))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("moved.lookup(4)->value() == 42", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 28); do { } while (false); do { MOZ_CrashSequence(__null, 28 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 29 | ||||
| 30 | MOZ_RELEASE_ASSERT(map.empty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.empty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.empty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.empty()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 30); do { } while (false); do { MOZ_CrashSequence(__null, 30 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 31 | MOZ_RELEASE_ASSERT(!map.count())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.count())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.count()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.count()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 31); do { } while (false); do { MOZ_CrashSequence(__null, 31 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| ||||
| 32 | } | |||
| 33 | ||||
| 34 | void CheckSwapMap1(const mozilla::HashMap<int, int>& map1) { | |||
| 35 | MOZ_RELEASE_ASSERT(map1.count() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map1.count() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map1.count() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map1.count() == 2" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 35); do { } while (false); do { MOZ_CrashSequence(__null, 35); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 36 | MOZ_RELEASE_ASSERT(!map1.empty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map1.empty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map1.empty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map1.empty()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 36); do { } while (false); do { MOZ_CrashSequence(__null, 36); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 37 | MOZ_RELEASE_ASSERT(!map1.lookup(3))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map1.lookup(3))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map1.lookup(3)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map1.lookup(3)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 37); do { } while (false); do { MOZ_CrashSequence(__null, 37); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 38 | MOZ_RELEASE_ASSERT(!map1.lookup(4))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map1.lookup(4))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map1.lookup(4)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map1.lookup(4)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 38); do { } while (false); do { MOZ_CrashSequence(__null, 38); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 39 | MOZ_RELEASE_ASSERT(map1.lookup(1)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map1.lookup(1)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map1.lookup(1)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map1.lookup(1)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 39); do { } while (false); do { MOZ_CrashSequence(__null, 39 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 40 | MOZ_RELEASE_ASSERT(map1.lookup(2)->value() == 20)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map1.lookup(2)->value() == 20)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map1.lookup(2)->value() == 20))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map1.lookup(2)->value() == 20", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 40); do { } while (false); do { MOZ_CrashSequence(__null, 40 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 41 | } | |||
| 42 | ||||
| 43 | void CheckSwapMap2(const mozilla::HashMap<int, int>& map2) { | |||
| 44 | MOZ_RELEASE_ASSERT(map2.count() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.count() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.count() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map2.count() == 2" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 44); do { } while (false); do { MOZ_CrashSequence(__null, 44); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 45 | MOZ_RELEASE_ASSERT(!map2.empty())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map2.empty())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map2.empty()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map2.empty()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 45); do { } while (false); do { MOZ_CrashSequence(__null, 45); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 46 | MOZ_RELEASE_ASSERT(!map2.lookup(1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map2.lookup(1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map2.lookup(1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map2.lookup(1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 46); do { } while (false); do { MOZ_CrashSequence(__null, 46); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 47 | MOZ_RELEASE_ASSERT(!map2.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map2.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map2.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map2.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 47); do { } while (false); do { MOZ_CrashSequence(__null, 47); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 48 | MOZ_RELEASE_ASSERT(map2.lookup(3)->value() == 30)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.lookup(3)->value() == 30)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.lookup(3)->value() == 30))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map2.lookup(3)->value() == 30", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 48); do { } while (false); do { MOZ_CrashSequence(__null, 48 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 49 | MOZ_RELEASE_ASSERT(map2.lookup(4)->value() == 40)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.lookup(4)->value() == 40)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.lookup(4)->value() == 40))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map2.lookup(4)->value() == 40", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 49); do { } while (false); do { MOZ_CrashSequence(__null, 49 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 50 | } | |||
| 51 | ||||
| 52 | void TestSwap() { | |||
| 53 | using namespace mozilla; | |||
| 54 | ||||
| 55 | HashMap<int, int> map1; | |||
| 56 | MOZ_RELEASE_ASSERT(map1.putNew(1, 10))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map1.putNew(1, 10))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map1.putNew(1, 10)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map1.putNew(1, 10)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 56); do { } while (false); do { MOZ_CrashSequence(__null, 56); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 57 | MOZ_RELEASE_ASSERT(map1.putNew(2, 20))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map1.putNew(2, 20))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map1.putNew(2, 20)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map1.putNew(2, 20)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 57); do { } while (false); do { MOZ_CrashSequence(__null, 57); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 58 | CheckSwapMap1(map1); | |||
| 59 | ||||
| 60 | HashMap<int, int> map2; | |||
| 61 | MOZ_RELEASE_ASSERT(map2.putNew(3, 30))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.putNew(3, 30))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.putNew(3, 30)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map2.putNew(3, 30)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 61); do { } while (false); do { MOZ_CrashSequence(__null, 61); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 62 | MOZ_RELEASE_ASSERT(map2.putNew(4, 40))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.putNew(4, 40))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.putNew(4, 40)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map2.putNew(4, 40)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 62); do { } while (false); do { MOZ_CrashSequence(__null, 62); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 63 | CheckSwapMap2(map2); | |||
| 64 | ||||
| 65 | map1.swap(map2); | |||
| 66 | CheckSwapMap2(map1); | |||
| 67 | CheckSwapMap1(map2); | |||
| 68 | } | |||
| 69 | ||||
| 70 | enum SimpleEnum { SIMPLE_1, SIMPLE_2 }; | |||
| 71 | ||||
| 72 | enum class ClassEnum : int { | |||
| 73 | CLASS_ENUM_1, | |||
| 74 | CLASS_ENUM_2, | |||
| 75 | }; | |||
| 76 | ||||
| 77 | void TestEnumHash() { | |||
| 78 | using namespace mozilla; | |||
| 79 | ||||
| 80 | HashMap<SimpleEnum, int> map; | |||
| 81 | MOZ_RELEASE_ASSERT(map.put(SIMPLE_1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.put(SIMPLE_1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.put(SIMPLE_1, 1)))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("map.put(SIMPLE_1, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 81); do { } while (false); do { MOZ_CrashSequence(__null, 81); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 82 | MOZ_RELEASE_ASSERT(map.put(SIMPLE_2, 2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.put(SIMPLE_2, 2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.put(SIMPLE_2, 2)))), 0)) ) { do { } while (false); MOZ_ReportAssertionFailure("map.put(SIMPLE_2, 2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 82); do { } while (false); do { MOZ_CrashSequence(__null, 82); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 83 | ||||
| 84 | MOZ_RELEASE_ASSERT(map.lookup(SIMPLE_1)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(SIMPLE_1)->value() == 1)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(! !(map.lookup(SIMPLE_1)->value() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.lookup(SIMPLE_1)->value() == 1" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 84); do { } while (false); do { MOZ_CrashSequence(__null, 84); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 85 | MOZ_RELEASE_ASSERT(map.lookup(SIMPLE_2)->value() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(SIMPLE_2)->value() == 2)>::isValid, "invalid assertion condition"); if ((__builtin_expect(!!(!(! !(map.lookup(SIMPLE_2)->value() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.lookup(SIMPLE_2)->value() == 2" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 85); do { } while (false); do { MOZ_CrashSequence(__null, 85); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 86 | ||||
| 87 | HashMap<ClassEnum, int> map2; | |||
| 88 | MOZ_RELEASE_ASSERT(map2.put(ClassEnum::CLASS_ENUM_1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.put(ClassEnum::CLASS_ENUM_1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.put(ClassEnum::CLASS_ENUM_1 , 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map2.put(ClassEnum::CLASS_ENUM_1, 1)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 88); do { } while (false); do { MOZ_CrashSequence(__null, 88 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 89 | MOZ_RELEASE_ASSERT(map2.put(ClassEnum::CLASS_ENUM_2, 2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.put(ClassEnum::CLASS_ENUM_2, 2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map2.put(ClassEnum::CLASS_ENUM_2 , 2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map2.put(ClassEnum::CLASS_ENUM_2, 2)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 89); do { } while (false); do { MOZ_CrashSequence(__null, 89 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 90 | ||||
| 91 | MOZ_RELEASE_ASSERT(map2.lookup(ClassEnum::CLASS_ENUM_1)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.lookup(ClassEnum::CLASS_ENUM_1)->value() == 1 )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(map2.lookup(ClassEnum::CLASS_ENUM_1)->value() == 1 ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "map2.lookup(ClassEnum::CLASS_ENUM_1)->value() == 1", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 91); do { } while (false); do { MOZ_CrashSequence(__null, 91 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 92 | MOZ_RELEASE_ASSERT(map2.lookup(ClassEnum::CLASS_ENUM_2)->value() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map2.lookup(ClassEnum::CLASS_ENUM_2)->value() == 2 )>::isValid, "invalid assertion condition"); if ((__builtin_expect (!!(!(!!(map2.lookup(ClassEnum::CLASS_ENUM_2)->value() == 2 ))), 0))) { do { } while (false); MOZ_ReportAssertionFailure( "map2.lookup(ClassEnum::CLASS_ENUM_2)->value() == 2", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 92); do { } while (false); do { MOZ_CrashSequence(__null, 92 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 93 | } | |||
| 94 | ||||
| 95 | void TestHashPair() { | |||
| 96 | using namespace mozilla; | |||
| 97 | ||||
| 98 | // Test with std::pair | |||
| 99 | { | |||
| 100 | HashMap<std::pair<int, bool>, int, PairHasher<int, bool>> map; | |||
| 101 | std::pair<int, bool> key1 = std::make_pair(1, true); | |||
| 102 | MOZ_RELEASE_ASSERT(map.putNew(key1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key1, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key1, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 102); do { } while (false); do { MOZ_CrashSequence(__null, 102); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 103 | MOZ_RELEASE_ASSERT(map.has(key1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.has(key1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.has(key1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.has(key1)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 103); do { } while (false); do { MOZ_CrashSequence(__null, 103); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 104 | std::pair<int, bool> key2 = std::make_pair(1, false); | |||
| 105 | MOZ_RELEASE_ASSERT(map.putNew(key2, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key2, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key2, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key2, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 105); do { } while (false); do { MOZ_CrashSequence(__null, 105); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 106 | std::pair<int, bool> key3 = std::make_pair(2, false); | |||
| 107 | MOZ_RELEASE_ASSERT(map.putNew(key3, 2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key3, 2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key3, 2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key3, 2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 107); do { } while (false); do { MOZ_CrashSequence(__null, 107); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 108 | MOZ_RELEASE_ASSERT(map.has(key3))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.has(key3))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.has(key3)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.has(key3)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 108); do { } while (false); do { MOZ_CrashSequence(__null, 108); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 109 | ||||
| 110 | MOZ_RELEASE_ASSERT(map.lookup(key1)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key1)->value() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key1)->value() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key1)->value() == 1", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 110); do { } while (false); do { MOZ_CrashSequence(__null, 110 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 111 | MOZ_RELEASE_ASSERT(map.lookup(key2)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key2)->value() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key2)->value() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key2)->value() == 1", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 111); do { } while (false); do { MOZ_CrashSequence(__null, 111 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 112 | MOZ_RELEASE_ASSERT(map.lookup(key3)->value() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key3)->value() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key3)->value() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key3)->value() == 2", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 112); do { } while (false); do { MOZ_CrashSequence(__null, 112 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 113 | } | |||
| 114 | // Test wtih compact pair | |||
| 115 | { | |||
| 116 | HashMap<mozilla::CompactPair<int, bool>, int, CompactPairHasher<int, bool>> | |||
| 117 | map; | |||
| 118 | mozilla::CompactPair<int, bool> key1 = mozilla::MakeCompactPair(1, true); | |||
| 119 | MOZ_RELEASE_ASSERT(map.putNew(key1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key1, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key1, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 119); do { } while (false); do { MOZ_CrashSequence(__null, 119); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 120 | MOZ_RELEASE_ASSERT(map.has(key1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.has(key1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.has(key1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.has(key1)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 120); do { } while (false); do { MOZ_CrashSequence(__null, 120); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 121 | mozilla::CompactPair<int, bool> key2 = mozilla::MakeCompactPair(1, false); | |||
| 122 | MOZ_RELEASE_ASSERT(map.putNew(key2, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key2, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key2, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key2, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 122); do { } while (false); do { MOZ_CrashSequence(__null, 122); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 123 | mozilla::CompactPair<int, bool> key3 = mozilla::MakeCompactPair(2, false); | |||
| 124 | MOZ_RELEASE_ASSERT(map.putNew(key3, 2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(key3, 2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(key3, 2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(key3, 2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 124); do { } while (false); do { MOZ_CrashSequence(__null, 124); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 125 | MOZ_RELEASE_ASSERT(map.has(key3))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.has(key3))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.has(key3)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.has(key3)", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 125); do { } while (false); do { MOZ_CrashSequence(__null, 125); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 126 | ||||
| 127 | MOZ_RELEASE_ASSERT(map.lookup(key1)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key1)->value() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key1)->value() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key1)->value() == 1", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 127); do { } while (false); do { MOZ_CrashSequence(__null, 127 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 128 | MOZ_RELEASE_ASSERT(map.lookup(key2)->value() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key2)->value() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key2)->value() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key2)->value() == 1", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 128); do { } while (false); do { MOZ_CrashSequence(__null, 128 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 129 | MOZ_RELEASE_ASSERT(map.lookup(key3)->value() == 2)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(key3)->value() == 2)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(key3)->value() == 2))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(key3)->value() == 2", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 129); do { } while (false); do { MOZ_CrashSequence(__null, 129 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 130 | } | |||
| 131 | } | |||
| 132 | ||||
| 133 | void TestRekey() { | |||
| 134 | using namespace mozilla; | |||
| 135 | ||||
| 136 | HashMap<int, int> map; | |||
| 137 | MOZ_RELEASE_ASSERT(map.putNew(1, 10))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 10))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 10)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 10)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 137); do { } while (false); do { MOZ_CrashSequence(__null, 137); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 138 | MOZ_RELEASE_ASSERT(map.putNew(2, 20))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(2, 20))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(2, 20)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(2, 20)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 138); do { } while (false); do { MOZ_CrashSequence(__null, 138); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 139 | MOZ_RELEASE_ASSERT(map.putNew(3, 30))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(3, 30))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(3, 30)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(3, 30)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 139); do { } while (false); do { MOZ_CrashSequence(__null, 139); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 140 | ||||
| 141 | // rekeyIfMoved: same key is a no-op. | |||
| 142 | map.rekeyIfMoved(1, 1); | |||
| 143 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 143); do { } while (false); do { MOZ_CrashSequence(__null, 143); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 144 | MOZ_RELEASE_ASSERT(map.lookup(1)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(1)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(1)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(1)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 144); do { } while (false); do { MOZ_CrashSequence(__null, 144 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 145 | ||||
| 146 | // rekeyIfMoved: replace an existing key. | |||
| 147 | map.rekeyIfMoved(1, 11); | |||
| 148 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 148); do { } while (false); do { MOZ_CrashSequence(__null, 148); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 149 | MOZ_RELEASE_ASSERT(!map.lookup(1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 149); do { } while (false); do { MOZ_CrashSequence(__null, 149); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 150 | MOZ_RELEASE_ASSERT(map.lookup(11)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(11)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(11)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(11)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 150); do { } while (false); do { MOZ_CrashSequence(__null, 150 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 151 | ||||
| 152 | // rekeyIfMoved on a missing key is a no-op. | |||
| 153 | map.rekeyIfMoved(99, 100); | |||
| 154 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 154); do { } while (false); do { MOZ_CrashSequence(__null, 154); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 155 | MOZ_RELEASE_ASSERT(!map.lookup(99))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(99))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(99)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(99)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 155); do { } while (false); do { MOZ_CrashSequence(__null, 155); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 156 | MOZ_RELEASE_ASSERT(!map.lookup(100))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(100))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(100)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(100)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 156); do { } while (false); do { MOZ_CrashSequence(__null, 156); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 157 | ||||
| 158 | // rekeyAs: returns true and replaces key when present. | |||
| 159 | MOZ_RELEASE_ASSERT(map.rekeyAs(2, 22, 22))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.rekeyAs(2, 22, 22))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.rekeyAs(2, 22, 22)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("map.rekeyAs(2, 22, 22)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 159); do { } while (false); do { MOZ_CrashSequence(__null, 159); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 160 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 160); do { } while (false); do { MOZ_CrashSequence(__null, 160); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 161 | MOZ_RELEASE_ASSERT(!map.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 161); do { } while (false); do { MOZ_CrashSequence(__null, 161); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 162 | MOZ_RELEASE_ASSERT(map.lookup(22)->value() == 20)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(22)->value() == 20)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(22)->value() == 20))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(22)->value() == 20", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 162); do { } while (false); do { MOZ_CrashSequence(__null, 162 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 163 | ||||
| 164 | // rekeyAs: returns false when the old key is absent. | |||
| 165 | MOZ_RELEASE_ASSERT(!map.rekeyAs(2, 23, 23))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.rekeyAs(2, 23, 23))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.rekeyAs(2, 23, 23)))), 0 ))) { do { } while (false); MOZ_ReportAssertionFailure("!map.rekeyAs(2, 23, 23)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 165); do { } while (false); do { MOZ_CrashSequence(__null, 165); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 166 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 166); do { } while (false); do { MOZ_CrashSequence(__null, 166); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 167 | MOZ_RELEASE_ASSERT(!map.lookup(23))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(23))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(23)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(23)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 167); do { } while (false); do { MOZ_CrashSequence(__null, 167); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 168 | ||||
| 169 | // Other entries are unaffected. | |||
| 170 | MOZ_RELEASE_ASSERT(map.lookup(3)->value() == 30)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(3)->value() == 30)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(3)->value() == 30))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(3)->value() == 30", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 170); do { } while (false); do { MOZ_CrashSequence(__null, 170 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 171 | } | |||
| 172 | ||||
| 173 | // A structure that holds an int and supports move semantics but not copy | |||
| 174 | // semantics. | |||
| 175 | struct WrappedInt { | |||
| 176 | int mValue; | |||
| 177 | ||||
| 178 | explicit WrappedInt(int v) : mValue(v) {} | |||
| 179 | ||||
| 180 | WrappedInt(const WrappedInt&) = delete; | |||
| 181 | WrappedInt& operator=(const WrappedInt&) = delete; | |||
| 182 | ||||
| 183 | WrappedInt(WrappedInt&& aOther) : mValue(aOther.mValue) { aOther.mValue = 0; } | |||
| 184 | WrappedInt& operator=(WrappedInt&& aOther) { | |||
| 185 | mValue = aOther.mValue; | |||
| 186 | aOther.mValue = 0; | |||
| 187 | return *this; | |||
| 188 | } | |||
| 189 | ||||
| 190 | struct HashPolicy { | |||
| 191 | using Key = WrappedInt; | |||
| 192 | using Lookup = int; | |||
| 193 | ||||
| 194 | static mozilla::HashNumber hash(Lookup aLookup) { return aLookup; } | |||
| 195 | ||||
| 196 | static bool match(const Key& aKey, Lookup aLookup) { | |||
| 197 | return aKey.mValue == aLookup; | |||
| 198 | } | |||
| 199 | ||||
| 200 | static void rekey(Key& aKey, Key&& aNewKey) { aKey = std::move(aNewKey); } | |||
| 201 | }; | |||
| 202 | }; | |||
| 203 | ||||
| 204 | void TestRekeyWithRValue() { | |||
| 205 | using namespace mozilla; | |||
| 206 | ||||
| 207 | HashMap<WrappedInt, int, WrappedInt::HashPolicy> map; | |||
| 208 | MOZ_RELEASE_ASSERT(map.putNew(1, 10))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 10))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 10)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 10)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 208); do { } while (false); do { MOZ_CrashSequence(__null, 208); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 209 | MOZ_RELEASE_ASSERT(map.putNew(2, 20))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(2, 20))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(2, 20)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(2, 20)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 209); do { } while (false); do { MOZ_CrashSequence(__null, 209); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 210 | MOZ_RELEASE_ASSERT(map.putNew(3, 30))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(3, 30))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(3, 30)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(3, 30)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 210); do { } while (false); do { MOZ_CrashSequence(__null, 210); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 211 | ||||
| 212 | // rekeyAs: replace an existing key. | |||
| 213 | map.rekeyAs(1, 11, WrappedInt(11)); | |||
| 214 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 214); do { } while (false); do { MOZ_CrashSequence(__null, 214); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 215 | MOZ_RELEASE_ASSERT(!map.lookup(1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 215); do { } while (false); do { MOZ_CrashSequence(__null, 215); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 216 | MOZ_RELEASE_ASSERT(map.lookup(11)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(11)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(11)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(11)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 216); do { } while (false); do { MOZ_CrashSequence(__null, 216 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 217 | ||||
| 218 | // rekeyAs on a missing key is a no-op. | |||
| 219 | MOZ_RELEASE_ASSERT(!map.rekeyAs(99, 100, WrappedInt(100)))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.rekeyAs(99, 100, WrappedInt(100)))>::isValid , "invalid assertion condition"); if ((__builtin_expect(!!(!( !!(!map.rekeyAs(99, 100, WrappedInt(100))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.rekeyAs(99, 100, WrappedInt(100))" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 219); do { } while (false); do { MOZ_CrashSequence(__null, 219); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 220 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 220); do { } while (false); do { MOZ_CrashSequence(__null, 220); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 221 | MOZ_RELEASE_ASSERT(!map.lookup(99))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(99))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(99)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(99)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 221); do { } while (false); do { MOZ_CrashSequence(__null, 221); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 222 | MOZ_RELEASE_ASSERT(!map.lookup(100))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(100))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(100)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(100)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 222); do { } while (false); do { MOZ_CrashSequence(__null, 222); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 223 | ||||
| 224 | // rekeyAs: returns true and replaces key when present. | |||
| 225 | MOZ_RELEASE_ASSERT(map.rekeyAs(2, 22, WrappedInt(22)))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.rekeyAs(2, 22, WrappedInt(22)))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.rekeyAs(2, 22, WrappedInt (22))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.rekeyAs(2, 22, WrappedInt(22))", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 225); do { } while (false); do { MOZ_CrashSequence(__null, 225 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 226 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 226); do { } while (false); do { MOZ_CrashSequence(__null, 226); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 227 | MOZ_RELEASE_ASSERT(!map.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 227); do { } while (false); do { MOZ_CrashSequence(__null, 227); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 228 | MOZ_RELEASE_ASSERT(map.lookup(22)->value() == 20)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(22)->value() == 20)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(22)->value() == 20))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(22)->value() == 20", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 228); do { } while (false); do { MOZ_CrashSequence(__null, 228 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 229 | ||||
| 230 | // rekeyAs: returns false when the old key is absent. | |||
| 231 | MOZ_RELEASE_ASSERT(!map.rekeyAs(2, 23, WrappedInt(23)))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.rekeyAs(2, 23, WrappedInt(23)))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.rekeyAs(2, 23, WrappedInt (23))))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("!map.rekeyAs(2, 23, WrappedInt(23))", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 231); do { } while (false); do { MOZ_CrashSequence(__null, 231 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 232 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 232); do { } while (false); do { MOZ_CrashSequence(__null, 232); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 233 | MOZ_RELEASE_ASSERT(!map.lookup(23))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(23))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(23)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(23)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 233); do { } while (false); do { MOZ_CrashSequence(__null, 233); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 234 | ||||
| 235 | // Other entries are unaffected. | |||
| 236 | MOZ_RELEASE_ASSERT(map.lookup(3)->value() == 30)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(3)->value() == 30)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(3)->value() == 30))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(3)->value() == 30", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 236); do { } while (false); do { MOZ_CrashSequence(__null, 236 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 237 | } | |||
| 238 | ||||
| 239 | void TestModIteratorRekey() { | |||
| 240 | using namespace mozilla; | |||
| 241 | ||||
| 242 | // Rekey one entry found during iteration. | |||
| 243 | { | |||
| 244 | HashMap<int, int> map; | |||
| 245 | MOZ_RELEASE_ASSERT(map.putNew(1, 10))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 10))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 10)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 10)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 245); do { } while (false); do { MOZ_CrashSequence(__null, 245); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 246 | MOZ_RELEASE_ASSERT(map.putNew(2, 20))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(2, 20))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(2, 20)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(2, 20)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 246); do { } while (false); do { MOZ_CrashSequence(__null, 246); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 247 | MOZ_RELEASE_ASSERT(map.putNew(3, 30))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(3, 30))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(3, 30)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(3, 30)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 247); do { } while (false); do { MOZ_CrashSequence(__null, 247); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 248 | ||||
| 249 | for (auto iter = map.modIter(); !iter.done(); iter.next()) { | |||
| 250 | if (iter.get().key() == 2) { | |||
| 251 | iter.rekey(22); | |||
| 252 | } | |||
| 253 | } | |||
| 254 | ||||
| 255 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 255); do { } while (false); do { MOZ_CrashSequence(__null, 255); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 256 | MOZ_RELEASE_ASSERT(!map.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 256); do { } while (false); do { MOZ_CrashSequence(__null, 256); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 257 | MOZ_RELEASE_ASSERT(map.lookup(22)->value() == 20)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(22)->value() == 20)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(22)->value() == 20))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(22)->value() == 20", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 257); do { } while (false); do { MOZ_CrashSequence(__null, 257 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 258 | MOZ_RELEASE_ASSERT(map.lookup(1)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(1)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(1)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(1)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 258); do { } while (false); do { MOZ_CrashSequence(__null, 258 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 259 | MOZ_RELEASE_ASSERT(map.lookup(3)->value() == 30)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(3)->value() == 30)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(3)->value() == 30))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(3)->value() == 30", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 259); do { } while (false); do { MOZ_CrashSequence(__null, 259 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 260 | } | |||
| 261 | ||||
| 262 | // Rekey multiple entries. | |||
| 263 | { | |||
| 264 | HashMap<int, int> map; | |||
| 265 | MOZ_RELEASE_ASSERT(map.putNew(1, 10))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 10))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 10)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 10)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 265); do { } while (false); do { MOZ_CrashSequence(__null, 265); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 266 | MOZ_RELEASE_ASSERT(map.putNew(2, 20))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(2, 20))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(2, 20)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(2, 20)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 266); do { } while (false); do { MOZ_CrashSequence(__null, 266); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 267 | MOZ_RELEASE_ASSERT(map.putNew(3, 30))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(3, 30))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(3, 30)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(3, 30)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 267); do { } while (false); do { MOZ_CrashSequence(__null, 267); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 268 | ||||
| 269 | for (auto iter = map.modIter(); !iter.done(); iter.next()) { | |||
| 270 | int key = iter.get().key(); | |||
| 271 | if (key > 0) { | |||
| 272 | iter.rekey(-key); | |||
| 273 | } | |||
| 274 | } | |||
| 275 | ||||
| 276 | MOZ_RELEASE_ASSERT(map.count() == 3)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 3)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 3))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 3" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 276); do { } while (false); do { MOZ_CrashSequence(__null, 276); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 277 | MOZ_RELEASE_ASSERT(!map.lookup(1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 277); do { } while (false); do { MOZ_CrashSequence(__null, 277); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 278 | MOZ_RELEASE_ASSERT(!map.lookup(2))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(2))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(2)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(2)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 278); do { } while (false); do { MOZ_CrashSequence(__null, 278); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 279 | MOZ_RELEASE_ASSERT(!map.lookup(3))do { static_assert( mozilla::detail::AssertionConditionType< decltype(!map.lookup(3))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!map.lookup(3)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!map.lookup(3)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 279); do { } while (false); do { MOZ_CrashSequence(__null, 279); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 280 | MOZ_RELEASE_ASSERT(map.lookup(-1)->value() == 10)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(-1)->value() == 10)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(-1)->value() == 10))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(-1)->value() == 10", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 280); do { } while (false); do { MOZ_CrashSequence(__null, 280 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 281 | MOZ_RELEASE_ASSERT(map.lookup(-2)->value() == 20)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(-2)->value() == 20)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(-2)->value() == 20))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(-2)->value() == 20", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 281); do { } while (false); do { MOZ_CrashSequence(__null, 281 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 282 | MOZ_RELEASE_ASSERT(map.lookup(-3)->value() == 30)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.lookup(-3)->value() == 30)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.lookup(-3)->value() == 30))), 0))) { do { } while (false); MOZ_ReportAssertionFailure ("map.lookup(-3)->value() == 30", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 282); do { } while (false); do { MOZ_CrashSequence(__null, 282 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 283 | } | |||
| 284 | } | |||
| 285 | ||||
| 286 | void TestCapacityAfterRemove() { | |||
| 287 | mozilla::HashMap<int, int> map; | |||
| 288 | MOZ_RELEASE_ASSERT(map.count() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 288); do { } while (false); do { MOZ_CrashSequence(__null, 288); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 289 | MOZ_RELEASE_ASSERT(map.capacity() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 289); do { } while (false); do { MOZ_CrashSequence(__null, 289); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 290 | ||||
| 291 | MOZ_RELEASE_ASSERT(map.putNew(1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 291); do { } while (false); do { MOZ_CrashSequence(__null, 291); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 292 | MOZ_RELEASE_ASSERT(map.count() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 1" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 292); do { } while (false); do { MOZ_CrashSequence(__null, 292); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 293 | MOZ_RELEASE_ASSERT(map.capacity() != 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() != 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() != 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() != 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 293); do { } while (false); do { MOZ_CrashSequence(__null, 293); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 294 | ||||
| 295 | map.remove(1); | |||
| 296 | MOZ_RELEASE_ASSERT(map.count() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 296); do { } while (false); do { MOZ_CrashSequence(__null, 296); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 297 | MOZ_RELEASE_ASSERT(map.capacity() != 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() != 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() != 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() != 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 297); do { } while (false); do { MOZ_CrashSequence(__null, 297); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 298 | ||||
| 299 | map.compact(); | |||
| 300 | MOZ_RELEASE_ASSERT(map.count() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 300); do { } while (false); do { MOZ_CrashSequence(__null, 300); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 301 | MOZ_RELEASE_ASSERT(map.capacity() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 301); do { } while (false); do { MOZ_CrashSequence(__null, 301); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 302 | ||||
| 303 | MOZ_RELEASE_ASSERT(map.putNew(1, 1))do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.putNew(1, 1))>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.putNew(1, 1)))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.putNew(1, 1)" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 303); do { } while (false); do { MOZ_CrashSequence(__null, 303); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 304 | MOZ_RELEASE_ASSERT(map.count() == 1)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 1)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 1))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 1" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 304); do { } while (false); do { MOZ_CrashSequence(__null, 304); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 305 | MOZ_RELEASE_ASSERT(map.capacity() != 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() != 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() != 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() != 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 305); do { } while (false); do { MOZ_CrashSequence(__null, 305); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 306 | ||||
| 307 | { | |||
| 308 | auto iter = map.modIter(); | |||
| 309 | MOZ_RELEASE_ASSERT(!iter.done())do { static_assert( mozilla::detail::AssertionConditionType< decltype(!iter.done())>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(!iter.done()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("!iter.done()", "/root/firefox-clang/mfbt/tests/TestHashTable.cpp" , 309); do { } while (false); do { MOZ_CrashSequence(__null, 309 ); __attribute__((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 310 | iter.remove(); | |||
| 311 | } | |||
| 312 | MOZ_RELEASE_ASSERT(map.count() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 312); do { } while (false); do { MOZ_CrashSequence(__null, 312); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 313 | MOZ_RELEASE_ASSERT(map.capacity() != 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() != 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() != 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() != 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 313); do { } while (false); do { MOZ_CrashSequence(__null, 313); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 314 | ||||
| 315 | map.compact(); | |||
| 316 | MOZ_RELEASE_ASSERT(map.count() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.count() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.count() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.count() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 316); do { } while (false); do { MOZ_CrashSequence(__null, 316); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 317 | MOZ_RELEASE_ASSERT(map.capacity() == 0)do { static_assert( mozilla::detail::AssertionConditionType< decltype(map.capacity() == 0)>::isValid, "invalid assertion condition" ); if ((__builtin_expect(!!(!(!!(map.capacity() == 0))), 0))) { do { } while (false); MOZ_ReportAssertionFailure("map.capacity() == 0" , "/root/firefox-clang/mfbt/tests/TestHashTable.cpp", 317); do { } while (false); do { MOZ_CrashSequence(__null, 317); __attribute__ ((nomerge)) ::abort(); } while (false); } } while (false); | |||
| 318 | } | |||
| 319 | ||||
| 320 | int main() { | |||
| 321 | TestMoveConstructor(); | |||
| 322 | TestEnumHash(); | |||
| 323 | TestHashPair(); | |||
| 324 | TestRekey(); | |||
| 325 | TestRekeyWithRValue(); | |||
| 326 | TestModIteratorRekey(); | |||
| 327 | TestCapacityAfterRemove(); | |||
| 328 | return 0; | |||
| 329 | } |