From af271ed3f65cf6cd9b38a467960d6ae9f2c2ad22 Mon Sep 17 00:00:00 2001 From: Zufu Liu Date: Mon, 30 Sep 2019 12:15:31 +1000 Subject: Feature [feature-requests:#1305] Optimize setting up keyword lists in lexers. Avoids splitting and sorting the input twice. --- test/unit/testWordList.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/unit/testWordList.cxx b/test/unit/testWordList.cxx index 4d7805d1e..3970d37d4 100644 --- a/test/unit/testWordList.cxx +++ b/test/unit/testWordList.cxx @@ -26,6 +26,21 @@ TEST_CASE("WordList") { REQUIRE(!wl.InList("class")); } + SECTION("Set") { + // Check whether Set returns whether it has changed correctly + const bool changed = wl.Set("else struct"); + REQUIRE(changed); + // Changing to same thing + const bool changed2 = wl.Set("else struct"); + REQUIRE(!changed2); + // Changed order shouldn't be seen as a change + const bool changed3 = wl.Set("struct else"); + REQUIRE(!changed3); + // Removing word is a change + const bool changed4 = wl.Set("struct"); + REQUIRE(changed4); + } + SECTION("WordAt") { wl.Set("else struct"); REQUIRE(0 == strcmp(wl.WordAt(0), "else")); -- cgit v1.2.3