-
Notifications
You must be signed in to change notification settings - Fork 285
Util changes needed for VSD #5375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c87b32e
736b397
4307ce3
6196338
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,16 @@ void symbol_table_baset::show(std::ostream &out) const | |
| out << symbols.at(name); | ||
| } | ||
|
|
||
| symbol_table_baset::const_iteratort symbol_table_baset::end() const | ||
| { | ||
| return symbols.end(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 96bd3ae Also this commit should be removed; Current develop already has begin/end for |
||
| } | ||
|
|
||
| symbol_table_baset::const_iteratort symbol_table_baset::begin() const | ||
| { | ||
| return symbols.begin(); | ||
| } | ||
|
|
||
| /// Print the contents of the symbol table. | ||
| /// \param out: The ostream to direct output to | ||
| /// \param symbol_table: The symbol table to print out | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ SCENARIO("irept_memory", "[core][utils][irept]") | |
| const std::size_t ref_count_size = 0; | ||
| #endif | ||
|
|
||
| #ifndef USE_STRING | ||
| #ifndef USE_STD_STRING | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Side note: I’d really love if we could just get rid of
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the only use case for it is / was debugging problems in the |
||
| const std::size_t data_size = sizeof(dstringt); | ||
| REQUIRE(sizeof(dstringt) == sizeof(unsigned)); | ||
| #else | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,14 +17,53 @@ TEST_CASE("Iterating through a symbol table", "[core][utils][symbol_tablet]") | |
|
|
||
| symbol_table.insert(symbol); | ||
|
|
||
| int counter = 0; | ||
| for(auto &entry : symbol_table) | ||
| SECTION("Non const iterator") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commit (a9afb9a) can also be removed; symbol table iterators are tested in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see a single class to |
||
| { | ||
| (void)entry; // we are just testing iteration here | ||
| ++counter; | ||
| int counter = 0; | ||
| for(auto &entry : symbol_table) | ||
| { | ||
| (void)entry; // we are just testing iteration here | ||
| ++counter; | ||
| } | ||
| REQUIRE(counter == 1); | ||
| } | ||
| SECTION("Const iterator") | ||
| { | ||
| int counter = 0; | ||
| for(const auto &entry : symbol_table) | ||
| { | ||
| (void)entry; // we are just testing iteration here | ||
| ++counter; | ||
| } | ||
| REQUIRE(counter == 1); | ||
| } | ||
| SECTION("Polymorphic access") | ||
| { | ||
| SECTION("Non-const iterator") | ||
| { | ||
| symbol_table_baset &base_st = symbol_table; | ||
| REQUIRE(std::distance(base_st.begin(), base_st.end()) == 1); | ||
| int counter = 0; | ||
| for(auto &entry : base_st) | ||
| { | ||
| (void)entry; // we are just testing iteration here | ||
| ++counter; | ||
| } | ||
| REQUIRE(counter == 1); | ||
| } | ||
| SECTION("Const iterator") | ||
| { | ||
| const symbol_table_baset &base_st = symbol_table; | ||
| REQUIRE(std::distance(base_st.begin(), base_st.end()) == 1); | ||
| int counter = 0; | ||
| for(const auto &entry : base_st) | ||
| { | ||
| (void)entry; // we are just testing iteration here | ||
| ++counter; | ||
| } | ||
| REQUIRE(counter == 1); | ||
| } | ||
| } | ||
|
|
||
| REQUIRE(counter == 1); | ||
| } | ||
|
|
||
| SCENARIO( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
develop
symbol_table_baset::begin/endare both purely virtual, so can not be used in this way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed out of band: more consistent to have both const and non-const iterators be virtual and defined in the base class.