[libcamera-devel] [RFC PATCH v2 05/14] test: yaml-parser: Test dictionary items ordering

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jun 4 20:59:30 CEST 2022


The order of items in a YAML dictionary may matter. Update the test to
ensure that it is preserved. The test currently fails at the YamlParser
doesn't correctly preserve the order, this will be fixed by the next
commit.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 test/yaml-parser.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp
index 5ff4c3236dbf..582c9caed836 100644
--- a/test/yaml-parser.cpp
+++ b/test/yaml-parser.cpp
@@ -29,8 +29,8 @@ static const string testYaml =
 	"  - Mary\n"
 	"dictionary:\n"
 	"  a: 1\n"
-	"  b: 2\n"
 	"  c: 3\n"
+	"  b: 2\n"
 	"level1:\n"
 	"  level2:\n"
 	"    - [1, 2]\n"
@@ -428,7 +428,6 @@ protected:
 		}
 
 		auto memeberNames = dictObj.memberNames();
-		sort(memeberNames.begin(), memeberNames.end());
 
 		if (memeberNames.size() != 3) {
 			cerr << "Dictionary object fail to extra member names" << std::endl;
@@ -436,8 +435,8 @@ protected:
 		}
 
 		if (memeberNames[0] != "a" ||
-		    memeberNames[1] != "b" ||
-		    memeberNames[2] != "c") {
+		    memeberNames[1] != "c" ||
+		    memeberNames[2] != "b") {
 			cerr << "Dictionary object fail to parse member names" << std::endl;
 			return TestFail;
 		}
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list