Skip to content
Snippets Groups Projects
Commit 7af2a8f9 authored by Ben Langmuir's avatar Ben Langmuir
Browse files

Improve some gtest assertions

As requested during review, compare pointers to NULL explicitly to make what's
going on more clear.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202090 91177308-0d34-0410-b5e6-96231b3b80d8
parent 4fefab25
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment