pitrou commented on code in PR #330:
URL: https://github.com/apache/arrow-nanoarrow/pull/330#discussion_r1417079894
##########
src/nanoarrow/nanoarrow_testing_test.cc:
##########
@@ -1107,3 +1147,290 @@ TEST(NanoarrowTestingTest,
NanoarrowTestingTestFieldUnion) {
TestTypeError(R"({"name": "union", "mode": "NOT_A_MODE", "typeIds": []})",
"Type[name=='union'] mode must be 'DENSE' or 'SPARSE'");
}
+
+TEST(NanoarrowTestingTest, NanoarrowTestingTestSchemaComparison) {
+ nanoarrow::UniqueSchema actual;
+ nanoarrow::UniqueSchema expected;
+ TestingJSONComparison comparison;
+ std::stringstream msg;
+
+ // Start with two identical schemas and ensure there are no differences
+ ArrowSchemaInit(actual.get());
+ ASSERT_EQ(ArrowSchemaSetTypeStruct(actual.get(), 1), NANOARROW_OK);
+ ASSERT_EQ(ArrowSchemaSetType(actual->children[0], NANOARROW_TYPE_NA),
NANOARROW_OK);
+ ASSERT_EQ(ArrowSchemaDeepCopy(actual.get(), expected.get()), NANOARROW_OK);
+
+ ASSERT_EQ(comparison.CompareSchema(actual.get(), expected.get()),
NANOARROW_OK);
+ EXPECT_EQ(comparison.num_differences(), 0);
+ comparison.WriteDifferences(msg);
+ EXPECT_EQ(msg.str(), "");
+ msg.str("");
+ comparison.ClearDifferences();
+
+ // With different top-level flags
+ actual->flags = ARROW_FLAG_MAP_KEYS_SORTED;
+ ASSERT_EQ(comparison.CompareSchema(actual.get(), expected.get()),
NANOARROW_OK);
+ EXPECT_EQ(comparison.num_differences(), 1);
+ comparison.WriteDifferences(msg);
+ EXPECT_EQ(msg.str(), "Path: \n- .flags: 4\n+ .flags: 2\n\n");
+ msg.str("");
Review Comment:
You could factor this out in a helper function:
```suggestion
AssertSchemasCompareUnequal(actual.get(), expected.get(),
/*expected_num_differences=*/ 1,
/*expected_msg=*/ "Path: \n- .flags: 4\n+ .flags: 2\n\n");
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]