Skip to content

Commit

Permalink
Add basic test cases for `Type::GetConfigTypesSortedByLoadDependencie…
Browse files Browse the repository at this point in the history
…s()`
  • Loading branch information
yhabteab committed Sep 10, 2024
1 parent 41427bb commit f78108d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ add_boost_test(base
base_type/assign
base_type/byname
base_type/instantiate
base_type/sort_by_load_after
base_utility/parse_version
base_utility/compare_version
base_utility/comparepasswords_works
Expand Down
20 changes: 20 additions & 0 deletions test/base-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,24 @@ BOOST_AUTO_TEST_CASE(instantiate)
BOOST_CHECK(p);
}

BOOST_AUTO_TEST_CASE(sort_by_load_after)
{
auto types (Type::GetConfigTypesSortedByLoadDependencies());

std::unordered_set<Type*> previousTypes;
for (auto type : types) {
BOOST_CHECK_EQUAL(true, ConfigObject::TypeInstance->IsAssignableFrom(type));

if (previousTypes.size() == 0) {
BOOST_CHECK_EQUAL(0, type->GetLoadDependencies().size());
} else {
for (Type* dependency : type->GetLoadDependencies()) {
BOOST_CHECK_EQUAL(true, previousTypes.find(dependency) != previousTypes.end());
}
}

previousTypes.emplace(type.get());
}
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit f78108d

Please sign in to comment.