[libcxx] r288157 - Protect std::{, unordered_}map tests under noexceptions

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 08:37:48 PST 2016


Author: rogfer01
Date: Tue Nov 29 10:37:48 2016
New Revision: 288157

URL: http://llvm.org/viewvc/llvm-project?rev=288157&view=rev
Log:
Protect std::{,unordered_}map tests under noexceptions

Skip tests that use exceptions

Differential Revision: https://reviews.llvm.org/D27093


Modified:
    libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp
    libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp

Modified: libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp?rev=288157&r1=288156&r2=288157&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp Tue Nov 29 10:37:48 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <map>
 
 // class map
@@ -19,6 +18,7 @@
 #include <cassert>
 
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -43,6 +43,7 @@ int main()
         assert(m.at(3) == 3.5);
         assert(m.at(4) == 4.5);
         assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             m.at(6);
@@ -51,6 +52,7 @@ int main()
         catch (std::out_of_range&)
         {
         }
+#endif
         assert(m.at(7) == 7.5);
         assert(m.at(8) == 8.5);
         assert(m.size() == 7);
@@ -74,6 +76,7 @@ int main()
         assert(m.at(3) == 3.5);
         assert(m.at(4) == 4.5);
         assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             m.at(6);
@@ -82,6 +85,7 @@ int main()
         catch (std::out_of_range&)
         {
         }
+#endif
         assert(m.at(7) == 7.5);
         assert(m.at(8) == 8.5);
         assert(m.size() == 7);
@@ -108,6 +112,7 @@ int main()
         assert(m.at(3) == 3.5);
         assert(m.at(4) == 4.5);
         assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             m.at(6);
@@ -116,6 +121,7 @@ int main()
         catch (std::out_of_range&)
         {
         }
+#endif
         assert(m.at(7) == 7.5);
         assert(m.at(8) == 8.5);
         assert(m.size() == 7);
@@ -139,6 +145,7 @@ int main()
         assert(m.at(3) == 3.5);
         assert(m.at(4) == 4.5);
         assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             m.at(6);
@@ -147,6 +154,7 @@ int main()
         catch (std::out_of_range&)
         {
         }
+#endif
         assert(m.at(7) == 7.5);
         assert(m.at(8) == 8.5);
         assert(m.size() == 7);

Modified: libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp?rev=288157&r1=288156&r2=288157&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp Tue Nov 29 10:37:48 2016
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // <unordered_map>
 
 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
@@ -23,6 +22,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -42,6 +42,7 @@ int main()
         assert(c.size() == 4);
         c.at(1) = "ONE";
         assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             c.at(11) = "eleven";
@@ -51,6 +52,7 @@ int main()
         {
         }
         assert(c.size() == 4);
+#endif
     }
     {
         typedef std::unordered_map<int, std::string> C;
@@ -67,6 +69,7 @@ int main()
         const C c(a, a + sizeof(a)/sizeof(a[0]));
         assert(c.size() == 4);
         assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             c.at(11);
@@ -76,6 +79,7 @@ int main()
         {
         }
         assert(c.size() == 4);
+#endif
     }
 #if TEST_STD_VER >= 11
     {
@@ -95,6 +99,7 @@ int main()
         assert(c.size() == 4);
         c.at(1) = "ONE";
         assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             c.at(11) = "eleven";
@@ -104,6 +109,7 @@ int main()
         {
         }
         assert(c.size() == 4);
+#endif
     }
     {
         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
@@ -121,6 +127,7 @@ int main()
         const C c(a, a + sizeof(a)/sizeof(a[0]));
         assert(c.size() == 4);
         assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
         try
         {
             c.at(11);
@@ -130,6 +137,7 @@ int main()
         {
         }
         assert(c.size() == 4);
+#endif
     }
 #endif
 }




More information about the cfe-commits mailing list