diff --git a/src/util/symbol_table_base.h b/src/util/symbol_table_base.h index 46ec91a061b..b0a369c0736 100644 --- a/src/util/symbol_table_base.h +++ b/src/util/symbol_table_base.h @@ -144,6 +144,11 @@ class symbol_table_baset typedef symbolst::const_iterator::reference reference; // NOLINT typedef symbolst::iterator::iterator_category iterator_category; // NOLINT + bool operator!=(const iteratort &other) const + { + return it != other.it; + } + bool operator==(const iteratort &other) const { return it == other.it; diff --git a/unit/util/symbol_table.cpp b/unit/util/symbol_table.cpp index e16b93e3507..b81e47a219b 100644 --- a/unit/util/symbol_table.cpp +++ b/unit/util/symbol_table.cpp @@ -5,6 +5,25 @@ #include #include +TEST_CASE("Iterating through a symbol table", "[core][utils][symbol_tablet]") +{ + symbol_tablet symbol_table; + + symbolt symbol; + irep_idt symbol_name = "Test"; + symbol.name = symbol_name; + + symbol_table.insert(symbol); + + int counter = 0; + for(auto &entry : symbol_table) + { + ++counter; + } + + REQUIRE(counter == 1); +} + SCENARIO("journalling_symbol_table_writer", "[core][utils][journalling_symbol_table_writer]") {