Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: testing/gmock/test/gmock-internal-utils_test.cc

Issue 521012: Update gmock and gtest. (Closed)
Patch Set: update readme Created 10 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 int c[2][3]; 812 int c[2][3];
813 CopyArray(a, 2, c); 813 CopyArray(a, 2, c);
814 EXPECT_TRUE(ArrayEq(a, c)); 814 EXPECT_TRUE(ArrayEq(a, c));
815 } 815 }
816 816
817 // Tests NativeArray. 817 // Tests NativeArray.
818 818
819 TEST(NativeArrayTest, ConstructorFromArrayWorks) { 819 TEST(NativeArrayTest, ConstructorFromArrayWorks) {
820 const int a[3] = { 0, 1, 2 }; 820 const int a[3] = { 0, 1, 2 };
821 NativeArray<int> na(a, 3, kReference); 821 NativeArray<int> na(a, 3, kReference);
822 EXPECT_EQ(3, na.size()); 822 EXPECT_EQ(3U, na.size());
823 EXPECT_EQ(a, na.begin()); 823 EXPECT_EQ(a, na.begin());
824 } 824 }
825 825
826 TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) { 826 TEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {
827 typedef int Array[2]; 827 typedef int Array[2];
828 Array* a = new Array[1]; 828 Array* a = new Array[1];
829 (*a)[0] = 0; 829 (*a)[0] = 0;
830 (*a)[1] = 1; 830 (*a)[1] = 1;
831 NativeArray<int> na(*a, 2, kCopy); 831 NativeArray<int> na(*a, 2, kCopy);
832 EXPECT_NE(*a, na.begin()); 832 EXPECT_NE(*a, na.begin());
833 delete[] a; 833 delete[] a;
834 EXPECT_EQ(0, na.begin()[0]); 834 EXPECT_EQ(0, na.begin()[0]);
835 EXPECT_EQ(1, na.begin()[1]); 835 EXPECT_EQ(1, na.begin()[1]);
836 836
837 // We rely on the heap checker to verify that na deletes the copy of 837 // We rely on the heap checker to verify that na deletes the copy of
838 // array. 838 // array.
839 } 839 }
840 840
841 TEST(NativeArrayTest, TypeMembersAreCorrect) { 841 TEST(NativeArrayTest, TypeMembersAreCorrect) {
842 StaticAssertTypeEq<char, NativeArray<char>::value_type>(); 842 StaticAssertTypeEq<char, NativeArray<char>::value_type>();
843 StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>(); 843 StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>();
844 844
845 StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>(); 845 StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>();
846 StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>(); 846 StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>();
847 } 847 }
848 848
849 TEST(NativeArrayTest, MethodsWork) { 849 TEST(NativeArrayTest, MethodsWork) {
850 const int a[3] = { 0, 1, 2 }; 850 const int a[3] = { 0, 1, 2 };
851 NativeArray<int> na(a, 3, kCopy); 851 NativeArray<int> na(a, 3, kCopy);
852 ASSERT_EQ(3, na.size()); 852 ASSERT_EQ(3U, na.size());
853 EXPECT_EQ(3, na.end() - na.begin()); 853 EXPECT_EQ(3, na.end() - na.begin());
854 854
855 NativeArray<int>::const_iterator it = na.begin(); 855 NativeArray<int>::const_iterator it = na.begin();
856 EXPECT_EQ(0, *it); 856 EXPECT_EQ(0, *it);
857 ++it; 857 ++it;
858 EXPECT_EQ(1, *it); 858 EXPECT_EQ(1, *it);
859 it++; 859 it++;
860 EXPECT_EQ(2, *it); 860 EXPECT_EQ(2, *it);
861 ++it; 861 ++it;
862 EXPECT_EQ(na.end(), it); 862 EXPECT_EQ(na.end(), it);
863 863
864 EXPECT_THAT(na, Eq(na)); 864 EXPECT_THAT(na, Eq(na));
865 865
866 NativeArray<int> na2(a, 3, kReference); 866 NativeArray<int> na2(a, 3, kReference);
867 EXPECT_THAT(na, Eq(na2)); 867 EXPECT_THAT(na, Eq(na2));
868 868
869 const int b1[3] = { 0, 1, 1 }; 869 const int b1[3] = { 0, 1, 1 };
870 const int b2[4] = { 0, 1, 2, 3 }; 870 const int b2[4] = { 0, 1, 2, 3 };
871 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b1, 3, kReference)))); 871 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b1, 3, kReference))));
872 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b2, 4, kCopy)))); 872 EXPECT_THAT(na, Not(Eq(NativeArray<int>(b2, 4, kCopy))));
873 } 873 }
874 874
875 TEST(NativeArrayTest, WorksForTwoDimensionalArray) { 875 TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
876 const char a[2][3] = { "hi", "lo" }; 876 const char a[2][3] = { "hi", "lo" };
877 NativeArray<char[3]> na(a, 2, kReference); 877 NativeArray<char[3]> na(a, 2, kReference);
878 ASSERT_EQ(2, na.size()); 878 ASSERT_EQ(2U, na.size());
879 EXPECT_EQ(a, na.begin()); 879 EXPECT_EQ(a, na.begin());
880 } 880 }
881 881
882 // Tests StlContainerView. 882 // Tests StlContainerView.
883 883
884 TEST(StlContainerViewTest, WorksForStlContainer) { 884 TEST(StlContainerViewTest, WorksForStlContainer) {
885 StaticAssertTypeEq<std::vector<int>, 885 StaticAssertTypeEq<std::vector<int>,
886 StlContainerView<std::vector<int> >::type>(); 886 StlContainerView<std::vector<int> >::type>();
887 StaticAssertTypeEq<const std::vector<double>&, 887 StaticAssertTypeEq<const std::vector<double>&,
888 StlContainerView<std::vector<double> >::const_reference>(); 888 StlContainerView<std::vector<double> >::const_reference>();
(...skipping 14 matching lines...) Expand all
903 StaticAssertTypeEq<NativeArray<double>, 903 StaticAssertTypeEq<NativeArray<double>,
904 StlContainerView<const double[4]>::type>(); 904 StlContainerView<const double[4]>::type>();
905 StaticAssertTypeEq<NativeArray<char[3]>, 905 StaticAssertTypeEq<NativeArray<char[3]>,
906 StlContainerView<const char[2][3]>::type>(); 906 StlContainerView<const char[2][3]>::type>();
907 907
908 StaticAssertTypeEq<const NativeArray<int>, 908 StaticAssertTypeEq<const NativeArray<int>,
909 StlContainerView<int[2]>::const_reference>(); 909 StlContainerView<int[2]>::const_reference>();
910 910
911 int a1[3] = { 0, 1, 2 }; 911 int a1[3] = { 0, 1, 2 };
912 NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1); 912 NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1);
913 EXPECT_EQ(3, a2.size()); 913 EXPECT_EQ(3U, a2.size());
914 EXPECT_EQ(a1, a2.begin()); 914 EXPECT_EQ(a1, a2.begin());
915 915
916 const NativeArray<int> a3 = StlContainerView<int[3]>::Copy(a1); 916 const NativeArray<int> a3 = StlContainerView<int[3]>::Copy(a1);
917 ASSERT_EQ(3, a3.size()); 917 ASSERT_EQ(3U, a3.size());
918 EXPECT_EQ(0, a3.begin()[0]); 918 EXPECT_EQ(0, a3.begin()[0]);
919 EXPECT_EQ(1, a3.begin()[1]); 919 EXPECT_EQ(1, a3.begin()[1]);
920 EXPECT_EQ(2, a3.begin()[2]); 920 EXPECT_EQ(2, a3.begin()[2]);
921 921
922 // Makes sure a1 and a3 aren't aliases. 922 // Makes sure a1 and a3 aren't aliases.
923 a1[0] = 3; 923 a1[0] = 3;
924 EXPECT_EQ(0, a3.begin()[0]); 924 EXPECT_EQ(0, a3.begin()[0]);
925 } 925 }
926 926
927 TEST(StlContainerViewTest, WorksForDynamicNativeArray) { 927 TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
928 StaticAssertTypeEq<NativeArray<int>, 928 StaticAssertTypeEq<NativeArray<int>,
929 StlContainerView<tuple<const int*, size_t> >::type>(); 929 StlContainerView<tuple<const int*, size_t> >::type>();
930 StaticAssertTypeEq<NativeArray<double>, 930 StaticAssertTypeEq<NativeArray<double>,
931 StlContainerView<tuple<linked_ptr<double>, int> >::type>(); 931 StlContainerView<tuple<linked_ptr<double>, int> >::type>();
932 932
933 StaticAssertTypeEq<const NativeArray<int>, 933 StaticAssertTypeEq<const NativeArray<int>,
934 StlContainerView<tuple<const int*, int> >::const_reference>(); 934 StlContainerView<tuple<const int*, int> >::const_reference>();
935 935
936 int a1[3] = { 0, 1, 2 }; 936 int a1[3] = { 0, 1, 2 };
937 const int* const p1 = a1; 937 const int* const p1 = a1;
938 NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >:: 938 NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >::
939 ConstReference(make_tuple(p1, 3)); 939 ConstReference(make_tuple(p1, 3));
940 EXPECT_EQ(3, a2.size()); 940 EXPECT_EQ(3U, a2.size());
941 EXPECT_EQ(a1, a2.begin()); 941 EXPECT_EQ(a1, a2.begin());
942 942
943 const NativeArray<int> a3 = StlContainerView<tuple<int*, size_t> >:: 943 const NativeArray<int> a3 = StlContainerView<tuple<int*, size_t> >::
944 Copy(make_tuple(static_cast<int*>(a1), 3)); 944 Copy(make_tuple(static_cast<int*>(a1), 3));
945 ASSERT_EQ(3, a3.size()); 945 ASSERT_EQ(3U, a3.size());
946 EXPECT_EQ(0, a3.begin()[0]); 946 EXPECT_EQ(0, a3.begin()[0]);
947 EXPECT_EQ(1, a3.begin()[1]); 947 EXPECT_EQ(1, a3.begin()[1]);
948 EXPECT_EQ(2, a3.begin()[2]); 948 EXPECT_EQ(2, a3.begin()[2]);
949 949
950 // Makes sure a1 and a3 aren't aliases. 950 // Makes sure a1 and a3 aren't aliases.
951 a1[0] = 3; 951 a1[0] = 3;
952 EXPECT_EQ(0, a3.begin()[0]); 952 EXPECT_EQ(0, a3.begin()[0]);
953 } 953 }
954 954
955 } // namespace 955 } // namespace
956 } // namespace internal 956 } // namespace internal
957 } // namespace testing 957 } // namespace testing
OLDNEW
« no previous file with comments | « testing/gmock/test/gmock-generated-matchers_test.cc ('k') | testing/gmock/test/gmock-matchers_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698