Add tests for free-standing iterator and size functions

This commit is contained in:
Martijn Otto 2019-11-15 14:19:41 +01:00
parent b186b6cc68
commit fa8a8117a0
No known key found for this signature in database
GPG Key ID: D2E0D5D0B1D606F9

View File

@ -1084,6 +1084,45 @@ TEST(span_test, from_array_constructor)
EXPECT_TRUE(cit3 == s.cend());
}
TEST(span_test, iterator_free_functions)
{
int a[] = {1, 2, 3, 4};
span<int> s{a};
EXPECT_TRUE((std::is_same<decltype(s.begin()), decltype(begin(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.end()), decltype(end(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.cbegin()), decltype(cbegin(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.cend()), decltype(cend(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.rbegin()), decltype(rbegin(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.rend()), decltype(rend(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.crbegin()), decltype(crbegin(s))>::value));
EXPECT_TRUE((std::is_same<decltype(s.crend()), decltype(crend(s))>::value));
EXPECT_TRUE(s.begin() == begin(s));
EXPECT_TRUE(s.end() == end(s));
EXPECT_TRUE(s.cbegin() == cbegin(s));
EXPECT_TRUE(s.cend() == cend(s));
EXPECT_TRUE(s.rbegin() == rbegin(s));
EXPECT_TRUE(s.rend() == rend(s));
EXPECT_TRUE(s.crbegin() == crbegin(s));
EXPECT_TRUE(s.crend() == crend(s));
}
TEST(span_test, ssize_free_function)
{
int a[] = {1, 2, 3, 4};
span<int> s{a};
EXPECT_TRUE((std::is_same<decltype(s.size()), decltype(ssize(s))>::value));
EXPECT_TRUE(s.size() == ssize(s));
}
TEST(span_test, iterator_comparisons)
{
int a[] = {1, 2, 3, 4};