mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-12 12:41:28 +00:00
Fix const_iterator postincrement behavior
This commit is contained in:
parent
c5d096b7b8
commit
4657768506
2 changed files with 26 additions and 2 deletions
|
@ -805,8 +805,8 @@ public:
|
|||
|
||||
const_iterator& operator++() { ++idx; return *this; }
|
||||
const_iterator& operator--() { --idx; return *this; }
|
||||
const_iterator& operator++(int) { ++idx; return *this; }
|
||||
const_iterator& operator--(int) { --idx; return *this; }
|
||||
const_iterator operator++(int) { const_iterator result(*this); ++idx; return result; }
|
||||
const_iterator operator--(int) { const_iterator result(*this); --idx; return result; }
|
||||
const_iterator& operator+=(int i) { idx += i; return *this; }
|
||||
|
||||
const_iterator operator+(int add) {
|
||||
|
|
|
@ -90,6 +90,30 @@ namespace RTLIL {
|
|||
|
||||
}
|
||||
|
||||
TEST_F(KernelRtlilTest, ConstConstIteratorWorks) {
|
||||
const Const c(0x2, 2);
|
||||
Const::const_iterator it = c.begin();
|
||||
ASSERT_NE(it, c.end());
|
||||
EXPECT_EQ(*it, State::S0);
|
||||
++it;
|
||||
ASSERT_NE(it, c.end());
|
||||
EXPECT_EQ(*it, State::S1);
|
||||
++it;
|
||||
EXPECT_EQ(it, c.end());
|
||||
}
|
||||
|
||||
TEST_F(KernelRtlilTest, ConstConstIteratorPreincrement) {
|
||||
const Const c(0x2, 2);
|
||||
Const::const_iterator it = c.begin();
|
||||
EXPECT_EQ(*++it, State::S1);
|
||||
}
|
||||
|
||||
TEST_F(KernelRtlilTest, ConstConstIteratorPostincrement) {
|
||||
const Const c(0x2, 2);
|
||||
Const::const_iterator it = c.begin();
|
||||
EXPECT_EQ(*it++, State::S0);
|
||||
}
|
||||
|
||||
class WireRtlVsHdlIndexConversionTest :
|
||||
public KernelRtlilTest,
|
||||
public testing::WithParamInterface<std::tuple<bool, int, int>>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue