From 807268e6f48df3b81b306eee8922248d1c0fb7ef Mon Sep 17 00:00:00 2001 From: Kurt Degiorgio Date: Thu, 8 Feb 2018 10:50:26 +0000 Subject: [PATCH] Fixes the symbol_base_tablet iterator The iterator for symbol_base_tablet had a missing operator overload which prevented range-based loops from working Commit also adds a unit-test --- src/util/symbol_table_base.h | 5 +++++ unit/util/symbol_table.cpp | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) 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]") {