diff options
author | Jordan Rose <jordan_rose@apple.com> | 2016-01-06 05:17:12 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2016-01-06 05:17:12 +0000 |
commit | 2110f9b13571f21ad5f3a7ea4c153f8a83a0c14d (patch) | |
tree | 120fd3f272607bc39a48d11288367c2deb69a472 /llvm/unittests/Support/YAMLParserTest.cpp | |
parent | b70e23c3909ca9a848a7ba963ee6580f48c57c5f (diff) | |
download | bcm5719-llvm-2110f9b13571f21ad5f3a7ea4c153f8a83a0c14d.tar.gz bcm5719-llvm-2110f9b13571f21ad5f3a7ea4c153f8a83a0c14d.zip |
Add != to YAMLParser's basic_collection_iterator.
...and mark it as merely an input_iterator rather than a forward_iterator,
since it is destructive. And then rewrite == to take advantage of that.
Patch by Alex Denisov!
llvm-svn: 256913
Diffstat (limited to 'llvm/unittests/Support/YAMLParserTest.cpp')
-rw-r--r-- | llvm/unittests/Support/YAMLParserTest.cpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/llvm/unittests/Support/YAMLParserTest.cpp b/llvm/unittests/Support/YAMLParserTest.cpp index 69b354a91d1..41ad649699c 100644 --- a/llvm/unittests/Support/YAMLParserTest.cpp +++ b/llvm/unittests/Support/YAMLParserTest.cpp @@ -260,4 +260,76 @@ TEST(YAMLParser, DiagnosticFilenameFromBufferID) { EXPECT_EQ("buffername.yaml", GeneratedDiag.getFilename()); } +TEST(YAMLParser, SameNodeIteratorOperatorNotEquals) { + SourceMgr SM; + yaml::Stream Stream("[\"1\", \"2\"]", SM); + + yaml::SequenceNode *Node = dyn_cast<yaml::SequenceNode>( + Stream.begin()->getRoot()); + + auto Begin = Node->begin(); + auto End = Node->end(); + + EXPECT_TRUE(Begin != End); + EXPECT_FALSE(Begin != Begin); + EXPECT_FALSE(End != End); +} + +TEST(YAMLParser, SameNodeIteratorOperatorEquals) { + SourceMgr SM; + yaml::Stream Stream("[\"1\", \"2\"]", SM); + + yaml::SequenceNode *Node = dyn_cast<yaml::SequenceNode>( + Stream.begin()->getRoot()); + + auto Begin = Node->begin(); + auto End = Node->end(); + + EXPECT_FALSE(Begin == End); + EXPECT_TRUE(Begin == Begin); + EXPECT_TRUE(End == End); +} + +TEST(YAMLParser, DifferentNodesIteratorOperatorNotEquals) { + SourceMgr SM; + yaml::Stream Stream("[\"1\", \"2\"]", SM); + yaml::Stream AnotherStream("[\"1\", \"2\"]", SM); + + yaml::SequenceNode *Node = dyn_cast<yaml::SequenceNode>( + Stream.begin()->getRoot()); + yaml::SequenceNode *AnotherNode = dyn_cast<yaml::SequenceNode>( + AnotherStream.begin()->getRoot()); + + auto Begin = Node->begin(); + auto End = Node->end(); + + auto AnotherBegin = AnotherNode->begin(); + auto AnotherEnd = AnotherNode->end(); + + EXPECT_TRUE(Begin != AnotherBegin); + EXPECT_TRUE(Begin != AnotherEnd); + EXPECT_FALSE(End != AnotherEnd); +} + +TEST(YAMLParser, DifferentNodesIteratorOperatorEquals) { + SourceMgr SM; + yaml::Stream Stream("[\"1\", \"2\"]", SM); + yaml::Stream AnotherStream("[\"1\", \"2\"]", SM); + + yaml::SequenceNode *Node = dyn_cast<yaml::SequenceNode>( + Stream.begin()->getRoot()); + yaml::SequenceNode *AnotherNode = dyn_cast<yaml::SequenceNode>( + AnotherStream.begin()->getRoot()); + + auto Begin = Node->begin(); + auto End = Node->end(); + + auto AnotherBegin = AnotherNode->begin(); + auto AnotherEnd = AnotherNode->end(); + + EXPECT_FALSE(Begin == AnotherBegin); + EXPECT_FALSE(Begin == AnotherEnd); + EXPECT_TRUE(End == AnotherEnd); +} + } // end namespace llvm |