Avoids iterator_traits, as it's not available in libCStd when compiled with Sun C++.

This commit is contained in:
zhanyong.wan
2011-04-12 18:24:59 +00:00
parent e9adbcbb56
commit fc99b1ad51
6 changed files with 52 additions and 15 deletions

View File

@@ -39,7 +39,9 @@
# include <time.h>
#endif // GTEST_OS_MAC
#include <list>
#include <utility> // For std::pair and std::make_pair.
#include <vector>
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
@@ -172,6 +174,24 @@ TEST(ImplicitCastTest, CanUseImplicitConstructor) {
EXPECT_TRUE(converted);
}
TEST(IteratorTraitsTest, WorksForSTLContainerIterators) {
StaticAssertTypeEq<int,
IteratorTraits< ::std::vector<int>::const_iterator>::value_type>();
StaticAssertTypeEq<bool,
IteratorTraits< ::std::list<bool>::iterator>::value_type>();
}
TEST(IteratorTraitsTest, WorksForPointerToNonConst) {
StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>();
StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>();
}
TEST(IteratorTraitsTest, WorksForPointerToConst) {
StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>();
StaticAssertTypeEq<const void*,
IteratorTraits<const void* const*>::value_type>();
}
// Tests that the element_type typedef is available in scoped_ptr and refers
// to the parameter type.
TEST(ScopedPtrTest, DefinesElementType) {