diff options
author | Zachary Turner <zturner@google.com> | 2017-06-14 16:41:50 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-06-14 16:41:50 +0000 |
commit | cb30e705d8006b5bb7671ab2b364e8c38b6c0232 (patch) | |
tree | 6a8d9510060208e357745338b9d910d4329c6984 /llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp | |
parent | b6567b18c72b3a4370002d689fda50eeee827d5b (diff) | |
download | bcm5719-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/CodeView/RandomAccessVisitorTest.cpp')
-rw-r--r-- | llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp index 0ca24c716d1..4fa172a37ef 100644 --- a/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp +++ b/llvm/unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "ErrorChecking.h" - #include "llvm/ADT/SmallBitVector.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" @@ -22,6 +20,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryItemStream.h" #include "llvm/Support/Error.h" +#include "llvm/Testing/Support/Error.h" #include "gtest/gtest.h" @@ -219,7 +218,8 @@ TEST_F(RandomAccessVisitorTest, MultipleVisits) { for (uint32_t I : IndicesToVisit) { TypeIndex TI = TypeIndex::fromArrayIndex(I); CVType T = Types.getType(TI); - EXPECT_NO_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks)); + EXPECT_THAT_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks), + Succeeded()); } // [0,8) should be present @@ -247,7 +247,8 @@ TEST_F(RandomAccessVisitorTest, DescendingWithinChunk) { for (uint32_t I : IndicesToVisit) { TypeIndex TI = TypeIndex::fromArrayIndex(I); CVType T = Types.getType(TI); - EXPECT_NO_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks)); + EXPECT_THAT_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks), + Succeeded()); } // [0, 7] @@ -275,7 +276,8 @@ TEST_F(RandomAccessVisitorTest, AscendingWithinChunk) { for (uint32_t I : IndicesToVisit) { TypeIndex TI = TypeIndex::fromArrayIndex(I); CVType T = Types.getType(TI); - EXPECT_NO_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks)); + EXPECT_THAT_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks), + Succeeded()); } // [0, 7] @@ -305,7 +307,8 @@ TEST_F(RandomAccessVisitorTest, StopPrematurelyInChunk) { for (uint32_t I : IndicesToVisit) { TypeIndex TI = TypeIndex::fromArrayIndex(I); CVType T = Types.getType(TI); - EXPECT_NO_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks)); + EXPECT_THAT_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks), + Succeeded()); } // [0, 8) should be visited. @@ -334,7 +337,8 @@ TEST_F(RandomAccessVisitorTest, InnerChunk) { for (uint32_t I : IndicesToVisit) { TypeIndex TI = TypeIndex::fromArrayIndex(I); CVType T = Types.getType(TI); - EXPECT_NO_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks)); + EXPECT_THAT_ERROR(codeview::visitTypeRecord(T, TI, TestState->Callbacks), + Succeeded()); } // [4, 9) |