Skip to content

Commit 807268e

Browse files
committed
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
1 parent 0df054c commit 807268e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/util/symbol_table_base.h

+5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ class symbol_table_baset
144144
typedef symbolst::const_iterator::reference reference; // NOLINT
145145
typedef symbolst::iterator::iterator_category iterator_category; // NOLINT
146146

147+
bool operator!=(const iteratort &other) const
148+
{
149+
return it != other.it;
150+
}
151+
147152
bool operator==(const iteratort &other) const
148153
{
149154
return it == other.it;

unit/util/symbol_table.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@
55
#include <testing-utils/catch.hpp>
66
#include <util/journalling_symbol_table.h>
77

8+
TEST_CASE("Iterating through a symbol table", "[core][utils][symbol_tablet]")
9+
{
10+
symbol_tablet symbol_table;
11+
12+
symbolt symbol;
13+
irep_idt symbol_name = "Test";
14+
symbol.name = symbol_name;
15+
16+
symbol_table.insert(symbol);
17+
18+
int counter = 0;
19+
for(auto &entry : symbol_table)
20+
{
21+
++counter;
22+
}
23+
24+
REQUIRE(counter == 1);
25+
}
26+
827
SCENARIO("journalling_symbol_table_writer",
928
"[core][utils][journalling_symbol_table_writer]")
1029
{

0 commit comments

Comments
 (0)