about summary refs log tree commit diff
path: root/absl/types
diff options
context:
space:
mode:
Diffstat (limited to 'absl/types')
-rw-r--r--absl/types/BUILD.bazel2
-rw-r--r--absl/types/CMakeLists.txt2
-rw-r--r--absl/types/any_exception_safety_test.cc11
-rw-r--r--absl/types/any_test.cc5
-rw-r--r--absl/types/optional_exception_safety_test.cc8
-rw-r--r--absl/types/optional_test.cc5
-rw-r--r--absl/types/variant_exception_safety_test.cc9
-rw-r--r--absl/types/variant_test.cc5
8 files changed, 43 insertions, 4 deletions
diff --git a/absl/types/BUILD.bazel b/absl/types/BUILD.bazel
index 6dd4e142ce9d..037d499a604b 100644
--- a/absl/types/BUILD.bazel
+++ b/absl/types/BUILD.bazel
@@ -111,6 +111,7 @@ cc_test(
     linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
     deps = [
         ":any",
+        "//absl/base:config",
         "//absl/base:exception_safety_testing",
         "@com_google_googletest//:gtest_main",
     ],
@@ -240,6 +241,7 @@ cc_test(
     linkopts = ABSL_EXCEPTIONS_FLAG_LINKOPTS + ABSL_DEFAULT_LINKOPTS,
     deps = [
         ":optional",
+        "//absl/base:config",
         "//absl/base:exception_safety_testing",
         "@com_google_googletest//:gtest_main",
     ],
diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt
index ddae7f2a6859..1f7fde09694a 100644
--- a/absl/types/CMakeLists.txt
+++ b/absl/types/CMakeLists.txt
@@ -105,6 +105,7 @@ absl_cc_test(
     ${ABSL_EXCEPTIONS_FLAG_LINKOPTS}
   DEPS
     absl::any
+    absl::config
     absl::exception_safety_testing
     gmock_main
 )
@@ -256,6 +257,7 @@ absl_cc_test(
     ${ABSL_EXCEPTIONS_FLAG_LINKOPTS}
   DEPS
     absl::optional
+    absl::config
     absl::exception_safety_testing
     gmock_main
 )
diff --git a/absl/types/any_exception_safety_test.cc b/absl/types/any_exception_safety_test.cc
index 5d7d8a5cfd21..17d7f5d77813 100644
--- a/absl/types/any_exception_safety_test.cc
+++ b/absl/types/any_exception_safety_test.cc
@@ -14,6 +14,12 @@
 
 #include "absl/types/any.h"
 
+#include "absl/base/config.h"
+
+// This test is a no-op when absl::any is an alias for std::any and when
+// exceptions are not enabled.
+#if !defined(ABSL_HAVE_STD_ANY) && defined(ABSL_HAVE_EXCEPTIONS)
+
 #include <typeinfo>
 #include <vector>
 
@@ -136,8 +142,6 @@ TEST(AnyExceptionSafety, Assignment) {
   EXPECT_TRUE(strong_empty_any_tester.Test(move));
 }
 
-// libstdc++ std::any fails this test
-#if !defined(ABSL_HAVE_STD_ANY)
 TEST(AnyExceptionSafety, Emplace) {
   auto initial_val =
       absl::any{absl::in_place_type_t<Thrower>(), 1, testing::nothrow_ctor};
@@ -163,6 +167,7 @@ TEST(AnyExceptionSafety, Emplace) {
   EXPECT_TRUE(empty_tester.Test(emp_thrower));
   EXPECT_TRUE(empty_tester.Test(emp_throwervec));
 }
-#endif  // ABSL_HAVE_STD_ANY
 
 }  // namespace
+
+#endif  // #if !defined(ABSL_HAVE_STD_ANY) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/absl/types/any_test.cc b/absl/types/any_test.cc
index 8710472190e8..4a848ae4ae8f 100644
--- a/absl/types/any_test.cc
+++ b/absl/types/any_test.cc
@@ -14,6 +14,9 @@
 
 #include "absl/types/any.h"
 
+// This test is a no-op when absl::any is an alias for std::any.
+#if !defined(ABSL_HAVE_STD_ANY)
+
 #include <initializer_list>
 #include <type_traits>
 #include <utility>
@@ -774,3 +777,5 @@ TEST(AnyTest, FailedEmplace) {
 }
 
 }  // namespace
+
+#endif  // #if !defined(ABSL_HAVE_STD_ANY)
diff --git a/absl/types/optional_exception_safety_test.cc b/absl/types/optional_exception_safety_test.cc
index aaf8ebcd9886..f99e35c05447 100644
--- a/absl/types/optional_exception_safety_test.cc
+++ b/absl/types/optional_exception_safety_test.cc
@@ -14,6 +14,12 @@
 
 #include "absl/types/optional.h"
 
+#include "absl/base/config.h"
+
+// This test is a no-op when absl::optional is an alias for std::optional and
+// when exceptions are not enabled.
+#if !defined(ABSL_HAVE_STD_OPTIONAL) && defined(ABSL_HAVE_EXCEPTIONS)
+
 #include "gtest/gtest.h"
 #include "absl/base/internal/exception_safety_testing.h"
 
@@ -280,3 +286,5 @@ TEST(OptionalExceptionSafety, NothrowMoveAssign) {
 }  // namespace
 
 }  // namespace absl
+
+#endif  // #if !defined(ABSL_HAVE_STD_OPTIONAL) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/absl/types/optional_test.cc b/absl/types/optional_test.cc
index e6a36eb8e26f..e005affb4ce6 100644
--- a/absl/types/optional_test.cc
+++ b/absl/types/optional_test.cc
@@ -14,6 +14,9 @@
 
 #include "absl/types/optional.h"
 
+// This test is a no-op when absl::optional is an alias for std::optional.
+#if !defined(ABSL_HAVE_STD_OPTIONAL)
+
 #include <string>
 #include <type_traits>
 #include <utility>
@@ -1654,3 +1657,5 @@ TEST(optionalTest, InPlaceTSFINAEBug) {
 #endif  // !defined(__EMSCRIPTEN__)
 
 }  // namespace
+
+#endif  // #if !defined(ABSL_HAVE_STD_OPTIONAL)
diff --git a/absl/types/variant_exception_safety_test.cc b/absl/types/variant_exception_safety_test.cc
index 76beb595925d..fd7e6c7fe802 100644
--- a/absl/types/variant_exception_safety_test.cc
+++ b/absl/types/variant_exception_safety_test.cc
@@ -14,6 +14,12 @@
 
 #include "absl/types/variant.h"
 
+#include "absl/base/config.h"
+
+// This test is a no-op when absl::variant is an alias for std::variant and when
+// exceptions are not enabled.
+#if !defined(ABSL_HAVE_STD_VARIANT) && defined(ABSL_HAVE_EXCEPTIONS)
+
 #include <iostream>
 #include <memory>
 #include <utility>
@@ -21,7 +27,6 @@
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include "absl/base/config.h"
 #include "absl/base/internal/exception_safety_testing.h"
 #include "absl/memory/memory.h"
 
@@ -521,3 +526,5 @@ TEST(VariantExceptionSafetyTest, Swap) {
 }  // namespace absl
 
 #endif  // !defined(ABSL_INTERNAL_MSVC_2017_DBG_MODE)
+
+#endif  // #if !defined(ABSL_HAVE_STD_VARIANT) && defined(ABSL_HAVE_EXCEPTIONS)
diff --git a/absl/types/variant_test.cc b/absl/types/variant_test.cc
index 85201b3ea659..56a6e01c6100 100644
--- a/absl/types/variant_test.cc
+++ b/absl/types/variant_test.cc
@@ -19,6 +19,9 @@
 
 #include "absl/types/variant.h"
 
+// This test is a no-op when absl::variant is an alias for std::variant.
+#if !defined(ABSL_HAVE_STD_VARIANT)
+
 #include <algorithm>
 #include <cstddef>
 #include <functional>
@@ -2705,3 +2708,5 @@ TEST(VariantTest, MoveCtorBug) {
 
 }  // namespace
 }  // namespace absl
+
+#endif  // #if !defined(ABSL_HAVE_STD_VARIANT)