[cros] Don't succeed if user has default profile picturewq
[chromium-blink-merge.git] / base / template_util_unittest.cc
blobdaf83b6578fd0ae22c6a7d7a4d9f8117f4473667
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/template_util.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace base {
9 namespace {
11 struct AStruct {};
12 class AClass {};
13 enum AnEnum {};
15 class Parent {};
16 class Child : public Parent {};
18 TEST(TemplateUtilTest, IsPointer) {
19 EXPECT_FALSE(is_pointer<int>::value);
20 EXPECT_FALSE(is_pointer<int&>::value);
21 EXPECT_TRUE(is_pointer<int*>::value);
22 EXPECT_TRUE(is_pointer<const int*>::value);
25 TEST(TemplateUtilTest, IsArray) {
26 EXPECT_FALSE(is_array<int>::value);
27 EXPECT_FALSE(is_array<int*>::value);
28 EXPECT_FALSE(is_array<int(*)[3]>::value);
29 EXPECT_TRUE(is_array<int[]>::value);
30 EXPECT_TRUE(is_array<const int[]>::value);
31 EXPECT_TRUE(is_array<int[3]>::value);
34 TEST(TemplateUtilTest, IsNonConstReference) {
35 EXPECT_FALSE(is_non_const_reference<int>::value);
36 EXPECT_FALSE(is_non_const_reference<const int&>::value);
37 EXPECT_TRUE(is_non_const_reference<int&>::value);
40 TEST(TemplateUtilTest, IsConvertible) {
41 // Extra parens needed to make EXPECT_*'s parsing happy. Otherwise,
42 // it sees the equivalent of
44 // EXPECT_TRUE( (is_convertible < Child), (Parent > ::value));
46 // Silly C++.
47 EXPECT_TRUE( (is_convertible<Child, Parent>::value) );
48 EXPECT_FALSE( (is_convertible<Parent, Child>::value) );
49 EXPECT_FALSE( (is_convertible<Parent, AStruct>::value) );
51 EXPECT_TRUE( (is_convertible<int, double>::value) );
52 EXPECT_TRUE( (is_convertible<int*, void*>::value) );
53 EXPECT_FALSE( (is_convertible<void*, int*>::value) );
56 TEST(TemplateUtilTest, IsSame) {
57 EXPECT_FALSE( (is_same<Child, Parent>::value) );
58 EXPECT_FALSE( (is_same<Parent, Child>::value) );
59 EXPECT_TRUE( (is_same<Parent, Parent>::value) );
61 EXPECT_TRUE( (is_same<int*, int*>::value) );
62 EXPECT_TRUE( (is_same<int, int>::value) );
63 EXPECT_TRUE( (is_same<void, void>::value) );
64 EXPECT_FALSE( (is_same<int, double>::value) );
67 TEST(TemplateUtilTest, IsClass) {
68 EXPECT_TRUE(is_class<AStruct>::value);
69 EXPECT_TRUE(is_class<AClass>::value);
71 EXPECT_FALSE(is_class<AnEnum>::value);
72 EXPECT_FALSE(is_class<int>::value);
73 EXPECT_FALSE(is_class<char*>::value);
74 EXPECT_FALSE(is_class<int&>::value);
75 EXPECT_FALSE(is_class<char[3]>::value);
78 } // namespace
79 } // namespace base