Skip to content

Commit 6550bf5

Browse files
committed
Update test to pass when assertions are turned on
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent 025503a commit 6550bf5

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

llvm/unittests/Support/SYCLPropertySetIOTest.cpp

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "llvm/Support/SYCLPropertySetIO.h"
1111
#include "llvm/Support/MemoryBuffer.h"
1212
#include "llvm/Support/raw_ostream.h"
13+
#include "llvm/Testing/Support/Error.h"
1314

1415
#include "gtest/gtest.h"
1516

@@ -23,69 +24,63 @@ TEST(SYCLPropertySet, IncorrectValuesIO) {
2324
auto MemBuf = MemoryBuffer::getMemBuffer(Content);
2425
// Parse a property set registry
2526
auto PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
26-
if (PropSetsPtr)
27-
FAIL() << "SYCLPropertySetRegistry::Invalid line error not caught\n";
27+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
28+
<< "Invalid line";
2829

2930
Content = "[Staff/Ages\n";
3031
MemBuf = MemoryBuffer::getMemBuffer(Content);
3132
// Parse a property set registry
3233
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
33-
if (PropSetsPtr)
34-
FAIL() << "SYCLPropertySetRegistry::Invalid line error not caught\n";
34+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
35+
<< "Invalid line";
3536

3637
Content = "[Staff/Ages]\n"
3738
"person1=\n";
3839
MemBuf = MemoryBuffer::getMemBuffer(Content);
3940
// Parse a property set registry
4041
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
41-
if (PropSetsPtr)
42-
FAIL()
43-
<< "SYCLPropertySetRegistry::Invalid property line error not caught\n";
42+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
43+
<< "Invalid property line";
4444

4545
Content = "[Staff/Ages]\n"
4646
"person1=|10\n";
4747
MemBuf = MemoryBuffer::getMemBuffer(Content);
4848
// Parse a property set registry
4949
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
50-
if (PropSetsPtr)
51-
FAIL()
52-
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
50+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
51+
<< "Invalid property value";
5352

5453
Content = "[Staff/Ages]\n"
5554
"person1=abc|10\n";
5655
MemBuf = MemoryBuffer::getMemBuffer(Content);
5756
// Parse a property set registry
5857
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
59-
if (PropSetsPtr)
60-
FAIL()
61-
<< "SYCLPropertySetRegistry::Invalid property type error not caught\n";
58+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
59+
<< "Invalid property type";
6260

6361
Content = "[Staff/Ages]\n"
6462
"person1=2|10\n";
6563
MemBuf = MemoryBuffer::getMemBuffer(Content);
6664
// Parse a property set registry
6765
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
68-
if (PropSetsPtr)
69-
FAIL()
70-
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
66+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
67+
<< "Invalid property value";
7168

7269
Content = "[Staff/Ages]\n"
7370
"person1=2|IAQ\n";
7471
MemBuf = MemoryBuffer::getMemBuffer(Content);
7572
// Parse a property set registry
7673
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
77-
if (PropSetsPtr)
78-
FAIL()
79-
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
74+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
75+
<< "Invalid property value";
8076

8177
Content = "[Staff/Ages]\n"
8278
"person1=100|10\n";
8379
MemBuf = MemoryBuffer::getMemBuffer(Content);
8480
// Parse a property set registry
8581
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
86-
if (PropSetsPtr)
87-
FAIL()
88-
<< "SYCLPropertySetRegistry::Invalid property type error not caught\n";
82+
EXPECT_THAT_ERROR(std::move(PropSetsPtr.takeError()), Failed())
83+
<< "Invalid property type";
8984
}
9085

9186
TEST(SYCLPropertySet, IntValuesIO) {

0 commit comments

Comments
 (0)