Commit 3e67a994 authored by Danil Chapovalov's avatar Danil Chapovalov Committed by Commit Bot

Enable absl variant and optional tests

To be more sure it is safe to use absl::variant in chromium

Abseil already uses EXPECT_DEATH_IF_SUPPORTED instead of EXPECT_DEATH
thus the only blocker for these test was already resolved.

Bug: 1073011
Change-Id: I3103fd558253aa80d6e770bd2cbf29840a5f768c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2332439Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793649}
parent 8bae1eec
......@@ -173,12 +173,8 @@ if (!is_component_build) {
"absl/strings:match_test",
"absl/strings:str_replace_test",
"absl/strings:string_view_test",
# TODO(mbonadei): On iOS, gtest doesn't support death tests. Fix upstream
# Abseil to use EXPECT_DEATH_IF_SUPPORTED instead of EXPECT_DEATH.
# "absl/types:optional_test",
# "absl/types:variant_test",
"absl/types:optional_test",
"absl/types:variant_test",
"//third_party/googletest:gtest_main",
]
}
......@@ -195,6 +191,7 @@ test("absl_hardening_tests") {
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
"//third_party/abseil-cpp/absl/types:span",
"//third_party/abseil-cpp/absl/types:variant",
"//third_party/googletest:gtest",
]
}
......@@ -98,36 +98,34 @@ absl_source_set("compare") {
"//third_party/abseil-cpp/absl/meta:type_traits",
]
}
# TODO(mbonadei): On iOS, gtest doesn't support death tests. Fix upstream
# Abseil to use EXPECT_DEATH_IF_SUPPORTED instead of EXPECT_DEATH.
# absl_source_set("optional_test") {
# testonly = true
# sources = [ "optional_test.cc" ]
# deps = [
# ":optional",
# "//third_party/abseil-cpp/absl/base:config",
# "//third_party/abseil-cpp/absl/base:raw_logging_internal",
# "//third_party/abseil-cpp/absl/meta:type_traits",
# "//third_party/abseil-cpp/absl/strings",
# "//third_party/googletest:gtest",
# ]
# visibility = [ "*" ]
# }
#
# absl_source_set("variant_test") {
# testonly = true
# sources = [ "variant_test.cc" ]
# if (is_clang) {
# cflags_cc = [ "-Wno-unused-function" ]
# }
# deps = [
# ":variant",
# "//third_party/abseil-cpp/absl/base:config",
# "//third_party/abseil-cpp/absl/base:core_headers",
# "//third_party/abseil-cpp/absl/memory",
# "//third_party/abseil-cpp/absl/meta:type_traits",
# "//third_party/abseil-cpp/absl/strings",
# "//third_party/googletest:gtest",
# "//third_party/googletest:gmock",
# ]
# }
absl_source_set("optional_test") {
testonly = true
sources = [ "optional_test.cc" ]
deps = [
":optional",
"//third_party/abseil-cpp/absl/base:config",
"//third_party/abseil-cpp/absl/base:raw_logging_internal",
"//third_party/abseil-cpp/absl/meta:type_traits",
"//third_party/abseil-cpp/absl/strings",
"//third_party/googletest:gtest",
]
}
absl_source_set("variant_test") {
testonly = true
sources = [ "variant_test.cc" ]
if (is_clang) {
cflags_cc = [ "-Wno-unused-function" ]
}
deps = [
":variant",
"//third_party/abseil-cpp/absl/base:config",
"//third_party/abseil-cpp/absl/base:core_headers",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/meta:type_traits",
"//third_party/abseil-cpp/absl/strings",
"//third_party/googletest:gtest",
"//third_party/googletest:gmock",
]
}
......@@ -12,6 +12,7 @@
#include "third_party/abseil-cpp/absl/strings/string_view.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/abseil-cpp/absl/types/span.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace {
......@@ -70,4 +71,10 @@ TEST(AbslHardeningTest, Span) {
EXPECT_DEATH_IF_SUPPORTED(absl::MakeConstSpan(&v1[2], &v[0]), "");
}
TEST(AbslHardeningTest, Variant) {
absl::variant<int, std::string> variant = 5;
EXPECT_DEATH_IF_SUPPORTED(absl::get<std::string>(variant), "");
EXPECT_DEATH_IF_SUPPORTED(absl::get<1>(variant), "");
}
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment