[PATCH] D81142: [MsgPack] Added a convenience operator

Dineshkumar Bhaskaran via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 01:36:27 PDT 2020


dineshkb-amd updated this revision to Diff 268699.
dineshkb-amd added a comment.

Added test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81142/new/

https://reviews.llvm.org/D81142

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: D81142.268699.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/6a95913f/attachment.bin>


More information about the llvm-commits mailing list