Skip to content

Commit e927765

Browse files
committed
Rebase
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent cbfe4d6 commit e927765

2 files changed

Lines changed: 80 additions & 19 deletions

File tree

test/documentation/documentation_2020_12_test.cc

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,56 @@ TEST(Documentation_2020_12, dependent_schemas_as_allof) {
231231

232232
const auto &applicator_branch{all_of.children.at(0)};
233233
EXPECT_TABLE_SIZE(applicator_branch, 2, 0, 1);
234-
EXPECT_EQ(applicator_branch.children.front().label, "All of");
235-
EXPECT_EQ(applicator_branch.children.front().children.size(), 1);
236-
const auto &dep_expansion{applicator_branch.children.front().children.at(0)};
237-
EXPECT_TABLE_SIZE(dep_expansion, 3, 0, 1);
238-
EXPECT_EQ(dep_expansion.children.front().label, "Any of");
239-
EXPECT_EQ(dep_expansion.children.front().children.size(), 2);
234+
EXPECT_EQ(applicator_branch.children.front().label, "Any of");
235+
EXPECT_EQ(applicator_branch.children.front().children.size(), 2);
236+
237+
const auto &not_sub{applicator_branch.children.front().children.at(0)};
238+
EXPECT_TABLE_SIZE(not_sub, 3, 1, 0);
239+
EXPECT_WILDCARD_ROW_OBJECT_WITH_CONSTRAINTS(4, not_sub, 0, PATH(),
240+
"must NOT match >= 1 properties");
241+
242+
const auto &allof_sub{applicator_branch.children.front().children.at(1)};
243+
EXPECT_TABLE_SIZE(allof_sub, 5, 0, 1);
244+
EXPECT_EQ(allof_sub.children.front().label, "All of");
245+
EXPECT_EQ(allof_sub.children.front().children.size(), 2);
246+
247+
const auto &name_req_table{allof_sub.children.front().children.at(0)};
248+
EXPECT_TABLE_SIZE(name_req_table, 6, 1, 0);
249+
EXPECT_ROW_ANY(7, name_req_table, 0, PATH(LITERAL("name")), true);
250+
251+
const auto &type_expansion{allof_sub.children.front().children.at(1)};
252+
EXPECT_TABLE_SIZE(type_expansion, 8, 0, 1);
253+
EXPECT_EQ(type_expansion.children.front().label, "Any of");
254+
EXPECT_EQ(type_expansion.children.front().children.size(), 6);
255+
256+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(0), 9, 1, 0);
257+
EXPECT_WILDCARD_ROW_ENUM(10, type_expansion.children.front().children.at(0),
258+
0, PATH(), 1, 0);
259+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(1), 11, 1, 0);
260+
EXPECT_WILDCARD_ROW_ENUM(12, type_expansion.children.front().children.at(1),
261+
0, PATH(), 2, 0);
262+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(2), 13, 1, 0);
263+
EXPECT_ROW_PRIMITIVE(
264+
14, type_expansion.children.front().children.at(2), 0,
265+
PATH(LITERAL("age")),
266+
sourcemeta::blaze::Documentation::Type::Expression::Primitive::Integer,
267+
false);
268+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(3), 15, 1, 0);
269+
EXPECT_WILDCARD_ROW_ARRAY(16, type_expansion.children.front().children.at(3),
270+
0, PATH());
271+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(4), 17, 1, 0);
272+
EXPECT_WILDCARD_ROW_PRIMITIVE(
273+
18, type_expansion.children.front().children.at(4), 0, PATH(),
274+
sourcemeta::blaze::Documentation::Type::Expression::Primitive::String);
275+
EXPECT_TABLE_SIZE(type_expansion.children.front().children.at(5), 19, 1, 0);
276+
EXPECT_WILDCARD_ROW_PRIMITIVE(
277+
20, type_expansion.children.front().children.at(5), 0, PATH(),
278+
sourcemeta::blaze::Documentation::Type::Expression::Primitive::Number);
240279

241280
const auto &typed_branch{all_of.children.at(1)};
242-
EXPECT_TABLE_SIZE(typed_branch, 22, 1, 0);
281+
EXPECT_TABLE_SIZE(typed_branch, 21, 1, 0);
243282
EXPECT_ROW_PRIMITIVE(
244-
23, typed_branch, 0, PATH(LITERAL("name")),
283+
22, typed_branch, 0, PATH(LITERAL("name")),
245284
sourcemeta::blaze::Documentation::Type::Expression::Primitive::String,
246285
false);
247286
}
@@ -271,21 +310,27 @@ TEST(Documentation_2020_12, dependent_required_as_allof) {
271310

272311
const auto &applicator_branch{all_of.children.at(0)};
273312
EXPECT_TABLE_SIZE(applicator_branch, 2, 0, 1);
274-
EXPECT_EQ(applicator_branch.children.front().label, "All of");
275-
EXPECT_EQ(applicator_branch.children.front().children.size(), 1);
276-
const auto &dep_expansion{applicator_branch.children.front().children.at(0)};
277-
EXPECT_TABLE_SIZE(dep_expansion, 3, 0, 1);
278-
EXPECT_EQ(dep_expansion.children.front().label, "Any of");
279-
EXPECT_EQ(dep_expansion.children.front().children.size(), 2);
313+
EXPECT_EQ(applicator_branch.children.front().label, "Any of");
314+
EXPECT_EQ(applicator_branch.children.front().children.size(), 2);
315+
316+
const auto &not_sub{applicator_branch.children.front().children.at(0)};
317+
EXPECT_TABLE_SIZE(not_sub, 3, 1, 0);
318+
EXPECT_WILDCARD_ROW_OBJECT_WITH_CONSTRAINTS(4, not_sub, 0, PATH(),
319+
"must NOT match >= 1 properties");
320+
321+
const auto &dep_sub{applicator_branch.children.front().children.at(1)};
322+
EXPECT_TABLE_SIZE(dep_sub, 5, 2, 0);
323+
EXPECT_ROW_ANY(6, dep_sub, 0, PATH(LITERAL("name")), true);
324+
EXPECT_ROW_ANY(7, dep_sub, 1, PATH(LITERAL("age")), true);
280325

281326
const auto &typed_branch{all_of.children.at(1)};
282-
EXPECT_TABLE_SIZE(typed_branch, 9, 2, 0);
327+
EXPECT_TABLE_SIZE(typed_branch, 8, 2, 0);
283328
EXPECT_ROW_PRIMITIVE(
284-
10, typed_branch, 0, PATH(LITERAL("name")),
329+
9, typed_branch, 0, PATH(LITERAL("name")),
285330
sourcemeta::blaze::Documentation::Type::Expression::Primitive::String,
286331
false);
287332
EXPECT_ROW_PRIMITIVE(
288-
11, typed_branch, 1, PATH(LITERAL("age")),
333+
10, typed_branch, 1, PATH(LITERAL("age")),
289334
sourcemeta::blaze::Documentation::Type::Expression::Primitive::Integer,
290335
false);
291336
}
@@ -1857,8 +1902,8 @@ TEST(Documentation_2020_12, dynamic_ref_with_anchor) {
18571902
sourcemeta::blaze::Documentation::Type::Expression::Primitive::String,
18581903
false);
18591904

1860-
EXPECT_ROW_ARRAY_OF_DYNAMIC_REF(3, documentation, 2,
1861-
PATH(LITERAL("children")), false, "node");
1905+
EXPECT_ROW_ARRAY_OF_RECURSIVE_REF(3, documentation, 2,
1906+
PATH(LITERAL("children")), false, 1);
18621907
}
18631908

18641909
TEST(Documentation_2020_12, dynamic_ref_standalone) {

test/documentation/documentation_test_utils.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,22 @@
930930
_EXPECT_ROW_NOTES_NONE(_row); \
931931
}
932932

933+
#define EXPECT_WILDCARD_ROW_OBJECT_WITH_CONSTRAINTS( \
934+
expected_identifier, documentation, index, expected_path, ...) \
935+
{ \
936+
const auto &_row{(documentation).rows.at((index))}; \
937+
_EXPECT_PATH(_row, expected_path); \
938+
EXPECT_EQ(_row.identifier, (expected_identifier)); \
939+
_EXPECT_ROW_BASE(_row); \
940+
EXPECT_FALSE(_row.required.has_value()); \
941+
EXPECT_TRUE(_row.type.badges.empty()); \
942+
EXPECT_TRUE(std::holds_alternative< \
943+
sourcemeta::blaze::Documentation::Type::Expression::Object>( \
944+
_row.type.expression.value)); \
945+
_EXPECT_CONSTRAINTS(_row, __VA_ARGS__); \
946+
_EXPECT_ROW_NOTES_NONE(_row); \
947+
}
948+
933949
#define _EXPECT_BADGE(row, badge_index, expected_kind, expected_value) \
934950
EXPECT_EQ((row).type.badges.at((badge_index)).kind, (expected_kind)); \
935951
EXPECT_EQ((row).type.badges.at((badge_index)).value, (expected_value));

0 commit comments

Comments
 (0)