[PATCH] D81250: [MsgPack] Added a convenience operator
DineshKumar Bhaskaran via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 04:22:45 PDT 2020
dbhaskaran created this revision.
dbhaskaran added reviewers: arsenm, scott.linder, saiislam.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
dbhaskaran added a comment.
dbhaskaran edited the summary of this revision.
Moved from https://reviews.llvm.org/D81142 to use a different username.
Added "not equal to" operator for DocNode comparison
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D81250
Files:
llvm/include/llvm/BinaryFormat/MsgPackDocument.h
llvm/unittests/BinaryFormat/MsgPackDocumentTest.cpp
Index: llvm/unittests/BinaryFormat/MsgPackDocumentTest.cpp
===================================================================
--- llvm/unittests/BinaryFormat/MsgPackDocumentTest.cpp
+++ llvm/unittests/BinaryFormat/MsgPackDocumentTest.cpp
@@ -13,6 +13,16 @@
using namespace llvm;
using namespace msgpack;
+TEST(MsgPackDocument, DocNodeTest) {
+ Document Doc;
+
+ DocNode Int1 = Doc.getNode(1), Int2 = Doc.getNode(2);
+ DocNode Str1 = Doc.getNode("ab"), Str2 = Doc.getNode("ab");
+
+ ASSERT_TRUE(Int1 != Int2);
+ ASSERT_TRUE(Str1 == Str2);
+}
+
TEST(MsgPackDocument, TestReadInt) {
Document Doc;
bool Ok = Doc.readFromBlob(StringRef("\xd0\x00", 2), /*Multi=*/false);
Index: llvm/include/llvm/BinaryFormat/MsgPackDocument.h
===================================================================
--- llvm/include/llvm/BinaryFormat/MsgPackDocument.h
+++ llvm/include/llvm/BinaryFormat/MsgPackDocument.h
@@ -181,6 +181,11 @@
return !(Lhs < Rhs) && !(Rhs < Lhs);
}
+ /// Inequality operator
+ friend bool operator!=(const DocNode &Lhs, const DocNode &Rhs) {
+ return !(Lhs == Rhs);
+ }
+
/// Convert this node to a string, assuming it is scalar.
std::string toString() const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81250.268735.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/2e65a540/attachment.bin>
More information about the llvm-commits
mailing list