jeudi 28 juillet 2016

Good way to call overloaded const vs non-const method in C++ TDD?

All

wrote some fancy container with iterators. So I have

iterator begin() {
}

iterator end() {
}

const_iterator begin() const {
}

const_iterator end() const {
}

In test I instantiate container, fill it and testing it. What is an accepted/good way to call both const and non-const version? Say, simple test like

TEST( c.end() - c.begin() == c.size() );

should run for iterators as well as for const iterators. Const reference? Some ugly cast?

Aucun commentaire:

Enregistrer un commentaire