[PATCH] D140474: [YAML IO] Check that mapping doesn't contain duplicating keys

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 01:08:23 PST 2023


jhenderson added inline comments.


================
Comment at: llvm/unittests/Support/YAMLIOTest.cpp:108-110
+//
+// Test the reading of a map containing duplicated keys
+//
----------------
This comment doesn't really add anything that the test name can't capture.


================
Comment at: llvm/unittests/Support/YAMLIOTest.cpp:113-114
+  FooBar doc;
+  // YAML spec: "The content of a mapping node is an unordered set of key/value
+  // node pairs, with the restriction that each of the keys is unique."
+  Input yin("{foo: 3\n bar: 5\nfoo: 3}", nullptr, suppressErrorMessages);
----------------
There's no real need to explain this here, since the comment is by the actual code logic itself.


================
Comment at: llvm/unittests/Support/YAMLIOTest.cpp:115-117
+  Input yin("{foo: 3\n bar: 5\nfoo: 3}", nullptr, suppressErrorMessages);
+  yin >> doc;
+  EXPECT_TRUE(!!yin.error());
----------------
I see that this is the pattern used above, but is there any way of testing that the error message is correct? If not, we may well want the yaml2obj test (optionally in addition to the unit test).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140474



More information about the llvm-commits mailing list