STL_MSFT created this revision.
STL_MSFT added reviewers: mclow.lists, EricWF.
STL_MSFT added a subscriber: cfe-commits.

Fix vector<bool> tests that were using ints copy-pasted from vector<int> tests.

I copied the bool a[] 0/1 pattern from another vector<bool> test.

Fixes MSVC warning C4305 "'argument': truncation from 'int' to 'const bool'".

http://reviews.llvm.org/D21092

Files:
  test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
  test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
  test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
  test/std/containers/sequences/vector.bool/copy.pass.cpp
  test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp

Index: test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
===================================================================
--- test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
+++ test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
@@ -32,30 +32,30 @@
 int main()
 {
     {
-        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
-        int* an = a + sizeof(a)/sizeof(a[0]);
+        bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+        bool* an = a + sizeof(a)/sizeof(a[0]);
         test(std::vector<bool>(a, an), std::allocator<bool>());
     }
     {
-        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
         std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
         assert(l2 == l);
         assert(l2.get_allocator() == test_allocator<bool>(3));
     }
     {
-        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5));
         std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
         assert(l2 == l);
         assert(l2.get_allocator() == other_allocator<bool>(3));
     }
 #if TEST_STD_VER >= 11
     {
-        int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
-        int* an = a + sizeof(a)/sizeof(a[0]);
+        bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+        bool* an = a + sizeof(a)/sizeof(a[0]);
         test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
     }
     {
-        std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>());
         std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
         assert(l2 == l);
         assert(l2.get_allocator() == min_allocator<bool>());
Index: test/std/containers/sequences/vector.bool/copy.pass.cpp
===================================================================
--- test/std/containers/sequences/vector.bool/copy.pass.cpp
+++ test/std/containers/sequences/vector.bool/copy.pass.cpp
@@ -38,14 +38,14 @@
         test(std::vector<bool>(a, an));
     }
     {
-        std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > v(3, true, test_allocator<bool>(5));
         std::vector<bool, test_allocator<bool> > v2 = v;
         assert(v2 == v);
         assert(v2.get_allocator() == v.get_allocator());
     }
 #if TEST_STD_VER >= 11
     {
-        std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > v(3, true, other_allocator<bool>(5));
         std::vector<bool, other_allocator<bool> > v2 = v;
         assert(v2 == v);
         assert(v2.get_allocator() == other_allocator<bool>(-2));
@@ -56,7 +56,7 @@
         test(std::vector<bool, min_allocator<bool>>(a, an));
     }
     {
-        std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > v(3, true, min_allocator<bool>());
         std::vector<bool, min_allocator<bool> > v2 = v;
         assert(v2 == v);
         assert(v2.get_allocator() == v.get_allocator());
Index: test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
===================================================================
--- test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
+++ test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -33,8 +33,8 @@
 
 int main()
 {
-    test<std::vector<bool> >(50, 3, std::allocator<bool>());
+    test<std::vector<bool> >(50, true, std::allocator<bool>());
 #if TEST_STD_VER >= 11
-    test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
+    test<std::vector<bool, min_allocator<bool>> >(50, true, min_allocator<bool>());
 #endif
 }
Index: test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
===================================================================
--- test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
+++ test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
@@ -31,8 +31,8 @@
 
 int main()
 {
-    test<std::vector<bool> >(50, 3);
+    test<std::vector<bool> >(50, true);
 #if TEST_STD_VER >= 11
-    test<std::vector<bool, min_allocator<bool>> >(50, 3);
+    test<std::vector<bool, min_allocator<bool>> >(50, true);
 #endif
 }
Index: test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
===================================================================
--- test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
+++ test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -19,22 +19,22 @@
 int main()
 {
     {
-        std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+        std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
         std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
         l2 = l;
         assert(l2 == l);
         assert(l2.get_allocator() == test_allocator<bool>(3));
     }
     {
-        std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+        std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5));
         std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
         l2 = l;
         assert(l2 == l);
         assert(l2.get_allocator() == other_allocator<bool>(5));
     }
 #if __cplusplus >= 201103L
     {
-        std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+        std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>());
         std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
         l2 = l;
         assert(l2 == l);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to