forked from OSchip/llvm-project
Improve some gtest assertions
As requested during review, compare pointers to NULL explicitly to make what's going on more clear. llvm-svn: 202090
This commit is contained in:
parent
1d4db8f719
commit
509fe8fd63
|
@ -281,7 +281,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) {
|
|||
"]\n"
|
||||
"}",
|
||||
Lower);
|
||||
ASSERT_TRUE(FS.getPtr());
|
||||
ASSERT_TRUE(FS.getPtr() != NULL);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
|
@ -325,7 +325,7 @@ TEST_F(VFSFromYAMLTest, CaseInsensitive) {
|
|||
" ]\n"
|
||||
"}]}",
|
||||
Lower);
|
||||
ASSERT_TRUE(FS.getPtr());
|
||||
ASSERT_TRUE(FS.getPtr() != NULL);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
|
@ -361,7 +361,7 @@ TEST_F(VFSFromYAMLTest, CaseSensitive) {
|
|||
" ]\n"
|
||||
"}]}",
|
||||
Lower);
|
||||
ASSERT_TRUE(FS.getPtr());
|
||||
ASSERT_TRUE(FS.getPtr() != NULL);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
|
@ -381,88 +381,88 @@ TEST_F(VFSFromYAMLTest, IllegalVFSFile) {
|
|||
|
||||
// invalid YAML at top-level
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString("{]", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
// invalid YAML in roots
|
||||
FS = getFromYAMLString("{ 'roots':[}", Lower);
|
||||
// invalid YAML in directory
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'name': 'foo', 'type': 'directory', 'contents': [}",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// invalid configuration
|
||||
FS = getFromYAMLString("{ 'knobular': 'true', 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString("{ 'case-sensitive': 'maybe', 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// invalid roots
|
||||
FS = getFromYAMLString("{ 'roots':'' }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString("{ 'roots':{} }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// invalid entries
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'other', 'name': 'me', 'contents': '' }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString("{ 'roots':[ { 'type': 'file', 'name': [], "
|
||||
"'external-contents': 'other' }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': [] }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'file', 'name': 'me', 'external-contents': {} }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': {} }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'directory', 'name': 'me', 'contents': '' }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'thingy': 'directory', 'name': 'me', 'contents': [] }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// missing mandatory fields
|
||||
FS = getFromYAMLString("{ 'roots':[ { 'type': 'file', 'name': 'me' }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'roots':[ { 'type': 'file', 'external-contents': 'other' }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString("{ 'roots':[ { 'name': 'me', 'contents': [] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// duplicate keys
|
||||
FS = getFromYAMLString("{ 'roots':[], 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLString(
|
||||
"{ 'case-sensitive':'true', 'case-sensitive':'true', 'roots':[] }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS =
|
||||
getFromYAMLString("{ 'roots':[{'name':'me', 'name':'you', 'type':'file', "
|
||||
"'external-contents':'blah' } ] }",
|
||||
Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// missing version
|
||||
FS = getFromYAMLRawString("{ 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
|
||||
// bad version number
|
||||
FS = getFromYAMLRawString("{ 'version':'foo', 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLRawString("{ 'version':-1, 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
FS = getFromYAMLRawString("{ 'version':100000, 'roots':[] }", Lower);
|
||||
EXPECT_FALSE(FS.getPtr());
|
||||
EXPECT_EQ(NULL, FS.getPtr());
|
||||
EXPECT_EQ(24, NumDiagnostics);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue