summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-06-14 16:41:50 +0000
committerZachary Turner <zturner@google.com>2017-06-14 16:41:50 +0000
commitcb30e705d8006b5bb7671ab2b364e8c38b6c0232 (patch)
tree6a8d9510060208e357745338b9d910d4329c6984 /llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
parentb6567b18c72b3a4370002d689fda50eeee827d5b (diff)
downloadbcm5719-llvm-cb30e705d8006b5bb7671ab2b364e8c38b6c0232.tar.gz
bcm5719-llvm-cb30e705d8006b5bb7671ab2b364e8c38b6c0232.zip
[gtest] Create a shared include directory for gtest utilities.
Many times unit tests for different libraries would like to use the same helper functions for checking common types of errors. This patch adds a common library with helpers for testing things in Support, and introduces helpers in here for integrating the llvm::Error and llvm::Expected<T> classes with gtest and gmock. Normally, we would just be able to write: EXPECT_THAT(someFunction(), succeeded()); but due to some quirks in llvm::Error's move semantics, gmock doesn't make this easy, so two macros EXPECT_THAT_ERROR() and EXPECT_THAT_EXPECTED() are introduced to gloss over the difficulties. Consider this an exception, and possibly only temporary as we look for ways to improve this. Differential Revision: https://reviews.llvm.org/D33059 llvm-svn: 305395
Diffstat (limited to 'llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp')
-rw-r--r--llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp b/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
index 249bc4a03b8..0efc2c6411b 100644
--- a/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
+++ b/llvm/unittests/DebugInfo/PDB/StringTableBuilderTest.cpp
@@ -7,13 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#include "ErrorChecking.h"
-
#include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h"
#include "llvm/Support/BinaryByteStream.h"
#include "llvm/Support/BinaryStreamReader.h"
#include "llvm/Support/BinaryStreamWriter.h"
+#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
@@ -36,21 +35,21 @@ TEST_F(StringTableBuilderTest, Simple) {
std::vector<uint8_t> Buffer(Builder.calculateSerializedSize());
MutableBinaryByteStream OutStream(Buffer, little);
BinaryStreamWriter Writer(OutStream);
- EXPECT_NO_ERROR(Builder.commit(Writer));
+ EXPECT_THAT_ERROR(Builder.commit(Writer), Succeeded());
// Reads the contents back.
BinaryByteStream InStream(Buffer, little);
BinaryStreamReader Reader(InStream);
PDBStringTable Table;
- EXPECT_NO_ERROR(Table.reload(Reader));
+ EXPECT_THAT_ERROR(Table.reload(Reader), Succeeded());
EXPECT_EQ(3U, Table.getNameCount());
EXPECT_EQ(1U, Table.getHashVersion());
- EXPECT_EXPECTED_EQ("foo", Table.getStringForID(1));
- EXPECT_EXPECTED_EQ("bar", Table.getStringForID(5));
- EXPECT_EXPECTED_EQ("baz", Table.getStringForID(9));
- EXPECT_EXPECTED_EQ(1U, Table.getIDForString("foo"));
- EXPECT_EXPECTED_EQ(5U, Table.getIDForString("bar"));
- EXPECT_EXPECTED_EQ(9U, Table.getIDForString("baz"));
+ EXPECT_THAT_EXPECTED(Table.getStringForID(1), HasValue("foo"));
+ EXPECT_THAT_EXPECTED(Table.getStringForID(5), HasValue("bar"));
+ EXPECT_THAT_EXPECTED(Table.getStringForID(9), HasValue("baz"));
+ EXPECT_THAT_EXPECTED(Table.getIDForString("foo"), HasValue(1U));
+ EXPECT_THAT_EXPECTED(Table.getIDForString("bar"), HasValue(5U));
+ EXPECT_THAT_EXPECTED(Table.getIDForString("baz"), HasValue(9U));
}
OpenPOWER on IntegriCloud