1
1

Fix set iterator test failure on macOS

This is a quite interesting case, where two arguments to a function are
evaluated in different order on Apple Clang than on GCC and I guess
MSVC. Left a comment on that.
This commit is contained in:
2022-07-28 23:50:40 +02:00
parent 3d91a853b2
commit a9c74a0cd0

View File

@@ -532,8 +532,14 @@ TEST(set, ForwardIterator)
Set<int>::iterator iter1 = set.begin();
int value1 = *iter1;
Set<int>::iterator iter2 = iter1++;
EXPECT_EQ(*iter1, *(++iter1));
EXPECT_EQ(*iter2, value1);
EXPECT_EQ(*(++iter2), *iter1);
/* Interesting find: On GCC & MSVC this will succeed, as the 2nd argument is evaluated before the
* 1st. On Apple Clang it's the other way around, and the test fails. */
// EXPECT_EQ(*iter1, *(++iter1));
Set<int>::iterator iter3 = ++iter1;
/* Check that #iter1 itself changed. */
EXPECT_EQ(*iter3, *iter1);
}
TEST(set, GenericAlgorithms)