Skip to content

Commit

Permalink
Merge pull request #111 from openvanilla/dev/sync-test
Browse files Browse the repository at this point in the history
Carry over a test case from the macOS version
  • Loading branch information
zonble authored Jan 31, 2024
2 parents 1ed4b7f + 17efa0a commit 54a3600
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions src/Engine/gramambular2/reading_grid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,81 @@ TEST(ReadingGridTest, LongGridDeletion) {
ASSERT_EQ(grid.spans()[8].nodeOf(5)->reading(), "jklmn");
}

TEST(ReadingGridTest, FindNodeInSpans) {
ReadingGrid grid(std::make_shared<MockLM>());
grid.setReadingSeparator(";");
grid.insertReading("a");
grid.insertReading("b");
grid.insertReading("c");

ASSERT_FALSE(
grid.findInSpan(0, [](const auto& n) { return n->spanningLength() == 4; })
.has_value());
ASSERT_FALSE(
grid.findInSpan(1, [](const auto& n) { return n->spanningLength() == 0; })
.has_value());
ASSERT_EQ(
grid.findInSpan(0, [](const auto& n) { return n->spanningLength() == 1; })
->get()
->reading(),
"a");
ASSERT_EQ(
grid.findInSpan(1, [](const auto& n) { return n->spanningLength() == 1; })
->get()
->reading(),
"b");
ASSERT_EQ(
grid.findInSpan(2, [](const auto& n) { return n->spanningLength() == 1; })
->get()
->reading(),
"c");
ASSERT_EQ(
grid.findInSpan(3, [](const auto& n) { return n->spanningLength() == 1; })
->get()
->reading(),
"c");
ASSERT_EQ(
grid.findInSpan(0, [](const auto& n) { return n->spanningLength() == 2; })
->get()
->reading(),
"a;b");
ASSERT_EQ(
grid.findInSpan(1, [](const auto& n) { return n->spanningLength() == 2; })
->get()
->reading(),
"b;c");
ASSERT_EQ(
grid.findInSpan(2, [](const auto& n) { return n->spanningLength() == 2; })
->get()
->reading(),
"b;c");
ASSERT_EQ(
grid.findInSpan(3, [](const auto& n) { return n->spanningLength() == 2; })
->get()
->reading(),
"b;c");
ASSERT_EQ(
grid.findInSpan(0, [](const auto& n) { return n->spanningLength() == 3; })
->get()
->reading(),
"a;b;c");
ASSERT_EQ(
grid.findInSpan(1, [](const auto& n) { return n->spanningLength() == 3; })
->get()
->reading(),
"a;b;c");
ASSERT_EQ(
grid.findInSpan(2, [](const auto& n) { return n->spanningLength() == 3; })
->get()
->reading(),
"a;b;c");
ASSERT_EQ(
grid.findInSpan(3, [](const auto& n) { return n->spanningLength() == 3; })
->get()
->reading(),
"a;b;c");
}

TEST(ReadingGridTest, StressTest) {
constexpr char kStressData[] = R"(
ㄧ 一 -2.08170692
Expand Down

0 comments on commit 54a3600

Please # to comment.