diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp --- a/libcxx/src/debug.cpp +++ b/libcxx/src/debug.cpp @@ -438,7 +438,7 @@ __i_node* j = __find_iterator(__j); __c_node* ci = i != nullptr ? i->__c_ : nullptr; __c_node* cj = j != nullptr ? j->__c_ : nullptr; - return ci != nullptr && ci == cj; + return ci == cj; } void diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp --- a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp @@ -22,69 +22,46 @@ #include "test_macros.h" -int main(int, char**) +template +void test() { { // N3644 testing - typedef std::string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; + typename C::iterator ii1{}, ii2{}; + typename C::iterator ii4 = ii1; + typename C::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } - { // N3644 testing - typedef std::wstring C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); + assert (!(ii1 != ii2 )); + + assert ( (ii1 == cii )); + assert ( (cii == ii1 )); + assert (!(ii1 != cii )); + assert (!(cii != ii1 )); + assert (!(ii1 < cii )); + assert (!(cii < ii1 )); + assert ( (ii1 <= cii )); + assert ( (cii <= ii1 )); + assert (!(ii1 > cii )); + assert (!(cii > ii1 )); + assert ( (ii1 >= cii )); + assert ( (cii >= ii1 )); + assert (cii - ii1 == 0); + assert (ii1 - cii == 0); } +} + +int main(int, char**) +{ + test(); + test(); #if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L - { - typedef std::u8string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } + test(); #endif - { // N3644 testing - typedef std::u16string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } - - { // N3644 testing - typedef std::u32string C; - C::iterator ii1{}, ii2{}; - C::iterator ii4 = ii1; - C::const_iterator cii{}; - assert ( ii1 == ii2 ); - assert ( ii1 == ii4 ); - assert ( ii1 == cii ); - assert ( !(ii1 != ii2 )); - assert ( !(ii1 != cii )); - } + test(); + test(); - return 0; + return 0; }