Skip to content

Commit

Permalink
[CodegenC] Updated unit test for sorted CodegenC output
Browse files Browse the repository at this point in the history
Previously, this unit test generated a `Map<tvm::Target, IRModule>`
whose default iteration order was not sorted by function name, built
the `Map` of modules, then validated whether the resulting C code was
a sorted list of 4 elements.  However, this condition was stricter
than necessary, as it depended on the number of items added to the
`Map` until it was unsorted.

This commit updates the test to instead validate that `std::is_sorted`
returns true.
  • Loading branch information
Lunderberg committed May 25, 2023
1 parent 94f4e25 commit 0364887
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/cpp/c_codegen_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ TEST(CCodegen, FunctionOrder) {
auto module = build(inputs, Target());
Array<String> func_array = module->GetFunction("get_func_names", false)();
std::vector<std::string> functions{func_array.begin(), func_array.end()};
EXPECT_THAT(functions, ElementsAre(StrEq("op_1"), _, StrEq("op_2"), _));
EXPECT_TRUE(std::is_sorted(functions.begin(), functions.end()));
}

0 comments on commit 0364887

Please sign in to comment.