Skip to content

Commit

Permalink
lgtuple_test: add "tuple_sort" test
Browse files Browse the repository at this point in the history
  • Loading branch information
jesec committed Aug 8, 2021
1 parent b49917b commit f0ba484
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 0 additions & 1 deletion core/BUILD
Expand Up @@ -42,7 +42,6 @@ cc_test(
srcs = ["tests/lgtuple_test.cpp"],
copts = COPTS,
includes = ["."],
tags = ["fixme"],
deps = [
":core",
"@com_google_googletest//:gtest_main",
Expand Down
22 changes: 21 additions & 1 deletion core/tests/lgtuple_test.cpp
Expand Up @@ -17,7 +17,7 @@ class Lgtuple_test : public ::testing::Test {
std::set<std::string> name_set;

void SetUp() override {
auto *lg = Lgraph::create("lgdb_lgtest", "constants", "-");
auto* lg = Lgraph::create("lgdb_lgtest", "constants", "-");

for (int i = 0; i < 100; ++i) {
dpin.emplace_back(lg->create_node_const(i).get_driver_pin());
Expand Down Expand Up @@ -57,6 +57,8 @@ class Lgtuple_test : public ::testing::Test {
void TearDown() override {}
};

// FIXME
#if 0
TEST_F(Lgtuple_test, flat1) {
Lbench b("lgtuple_test.FLAT1");

Expand Down Expand Up @@ -266,3 +268,21 @@ TEST_F(Lgtuple_test, internal_test) {
EXPECT_EQ(top->get_dpin("foo.5.jojojo"), dpin[5]);
EXPECT_EQ(top->get_dpin("foo.xxx.jojojo"), dpin[5]);
}
#endif

TEST_F(Lgtuple_test, sort) {
auto top = std::make_shared<Lgtuple>("top");

const std::vector<std::string>& names = {":0:a", ":0:a.__sbits", ":1:b", ":2:c", ":2:c.__ubits", "3", "3.__sbits", "4"};

for (const auto& name : names) {
top->add(name, dpin[1]);
}

const auto& sorted_map = top->get_sort_map();
EXPECT_EQ(sorted_map.size(), names.size());

for (size_t i = 0; i < sorted_map.size(); ++i) {
EXPECT_EQ(sorted_map[i].first, names[i]);
}
}

0 comments on commit f0ba484

Please sign in to comment.