Skip to content

Commit 025503a

Browse files
committed
Add tests expected to fail and make sure errors are caught
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent 20a7d75 commit 025503a

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

llvm/lib/Support/SYCLPropertySetIO.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ SYCLPropertySetRegistry::read(const MemoryBuffer *Buf) {
7676
return createStringError(std::error_code{},
7777
"invalid property value: ", Val.data());
7878
Prop.set(static_cast<uint32_t>(ValV.getZExtValue()));
79-
llvm::errs() << "ARV: read int done\n";
8079
break;
8180
}
8281
case SYCLPropertyValue::Type::BYTE_ARRAY: {

llvm/unittests/Support/SYCLPropertySetIOTest.cpp

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,76 @@ using namespace llvm::util;
1818

1919
namespace {
2020

21+
TEST(SYCLPropertySet, IncorrectValuesIO) {
22+
auto Content = "Staff/Ages]\n";
23+
auto MemBuf = MemoryBuffer::getMemBuffer(Content);
24+
// Parse a property set registry
25+
auto PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
26+
if (PropSetsPtr)
27+
FAIL() << "SYCLPropertySetRegistry::Invalid line error not caught\n";
28+
29+
Content = "[Staff/Ages\n";
30+
MemBuf = MemoryBuffer::getMemBuffer(Content);
31+
// Parse a property set registry
32+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
33+
if (PropSetsPtr)
34+
FAIL() << "SYCLPropertySetRegistry::Invalid line error not caught\n";
35+
36+
Content = "[Staff/Ages]\n"
37+
"person1=\n";
38+
MemBuf = MemoryBuffer::getMemBuffer(Content);
39+
// Parse a property set registry
40+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
41+
if (PropSetsPtr)
42+
FAIL()
43+
<< "SYCLPropertySetRegistry::Invalid property line error not caught\n";
44+
45+
Content = "[Staff/Ages]\n"
46+
"person1=|10\n";
47+
MemBuf = MemoryBuffer::getMemBuffer(Content);
48+
// Parse a property set registry
49+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
50+
if (PropSetsPtr)
51+
FAIL()
52+
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
53+
54+
Content = "[Staff/Ages]\n"
55+
"person1=abc|10\n";
56+
MemBuf = MemoryBuffer::getMemBuffer(Content);
57+
// Parse a property set registry
58+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
59+
if (PropSetsPtr)
60+
FAIL()
61+
<< "SYCLPropertySetRegistry::Invalid property type error not caught\n";
62+
63+
Content = "[Staff/Ages]\n"
64+
"person1=2|10\n";
65+
MemBuf = MemoryBuffer::getMemBuffer(Content);
66+
// Parse a property set registry
67+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
68+
if (PropSetsPtr)
69+
FAIL()
70+
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
71+
72+
Content = "[Staff/Ages]\n"
73+
"person1=2|IAQ\n";
74+
MemBuf = MemoryBuffer::getMemBuffer(Content);
75+
// Parse a property set registry
76+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
77+
if (PropSetsPtr)
78+
FAIL()
79+
<< "SYCLPropertySetRegistry::Invalid property value error not caught\n";
80+
81+
Content = "[Staff/Ages]\n"
82+
"person1=100|10\n";
83+
MemBuf = MemoryBuffer::getMemBuffer(Content);
84+
// Parse a property set registry
85+
PropSetsPtr = SYCLPropertySetRegistry::read(MemBuf.get());
86+
if (PropSetsPtr)
87+
FAIL()
88+
<< "SYCLPropertySetRegistry::Invalid property type error not caught\n";
89+
}
90+
2191
TEST(SYCLPropertySet, IntValuesIO) {
2292
// '1' in '1|20' means 'integer property'
2393
auto Content = "[Staff/Ages]\n"

0 commit comments

Comments
 (0)