diff options
author | Ryan Guo <ryanguo@modular.com> | 2023-02-17 09:07:35 -0800 |
---|---|---|
committer | Ryan Guo <ryanguo@modular.com> | 2023-02-17 10:07:01 -0800 |
commit | be83a4b257c8f0dfd74a659261a544483c5df9af (patch) | |
tree | eea7f8a14e5b82a23663b436cec9ac3d87056dd8 /llvm/unittests/ADT/DenseMapTest.cpp | |
parent | 42944abf8583fc6efae5bbc39f092bf884f6d17c (diff) | |
download | llvm-be83a4b257c8f0dfd74a659261a544483c5df9af.zip llvm-be83a4b257c8f0dfd74a659261a544483c5df9af.tar.gz llvm-be83a4b257c8f0dfd74a659261a544483c5df9af.tar.bz2 |
[ADT] Fix tests for `StringMap::at` and `DenseMap::at`
These methods won't assert for release build.
Diffstat (limited to 'llvm/unittests/ADT/DenseMapTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/DenseMapTest.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp index ba4e764..69bf4e1 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -125,10 +125,6 @@ TYPED_TEST(DenseMapTest, EmptyIntMapTest) { EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.end()); EXPECT_EQ(typename TypeParam::mapped_type(), this->Map.lookup(this->getKey())); - - // LookupOrTrap tests - EXPECT_DEATH({ this->Map.at(this->getKey()); }, - "DenseMap::at failed due to a missing key"); } // Constant map tests @@ -160,10 +156,15 @@ TYPED_TEST(DenseMapTest, SingleEntryMapTest) { EXPECT_TRUE(this->Map.find(this->getKey()) == this->Map.begin()); EXPECT_EQ(this->getValue(), this->Map.lookup(this->getKey())); EXPECT_EQ(this->getValue(), this->Map[this->getKey()]); +} - // LookupOrTrap tests - EXPECT_DEATH({ this->Map.at(this->getKey(1)); }, - "DenseMap::at failed due to a missing key"); +TYPED_TEST(DenseMapTest, AtTest) { + this->Map[this->getKey(0)] = this->getValue(0); + this->Map[this->getKey(1)] = this->getValue(1); + this->Map[this->getKey(2)] = this->getValue(2); + EXPECT_EQ(this->getValue(0), this->Map.at(this->getKey(0))); + EXPECT_EQ(this->getValue(1), this->Map.at(this->getKey(1))); + EXPECT_EQ(this->getValue(2), this->Map.at(this->getKey(2))); } // Test clear() method |