From 18bff53c997f5bfac0435b8a03ee967eed8c9e20 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 29 Jun 2020 14:29:05 +0200 Subject: BLI: remove blender::Optional in favor of std::optional `std::optional` can be used now, because we switched to C++17. --- tests/gtests/blenlib/BLI_map_test.cc | 2 +- tests/gtests/blenlib/BLI_optional_test.cc | 61 ------------------------------- tests/gtests/blenlib/CMakeLists.txt | 1 - 3 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 tests/gtests/blenlib/BLI_optional_test.cc (limited to 'tests') diff --git a/tests/gtests/blenlib/BLI_map_test.cc b/tests/gtests/blenlib/BLI_map_test.cc index 79a8786def9..7a67255d8d3 100644 --- a/tests/gtests/blenlib/BLI_map_test.cc +++ b/tests/gtests/blenlib/BLI_map_test.cc @@ -88,7 +88,7 @@ TEST(map, PopTry) map.add(1, 5); map.add(2, 7); EXPECT_EQ(map.size(), 2u); - Optional value = map.pop_try(4); + std::optional value = map.pop_try(4); EXPECT_EQ(map.size(), 2u); EXPECT_FALSE(value.has_value()); value = map.pop_try(2); diff --git a/tests/gtests/blenlib/BLI_optional_test.cc b/tests/gtests/blenlib/BLI_optional_test.cc deleted file mode 100644 index 2fc2188563e..00000000000 --- a/tests/gtests/blenlib/BLI_optional_test.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include "BLI_optional.hh" -#include "BLI_strict_flags.h" -#include "testing/testing.h" -#include - -using namespace blender; - -TEST(optional, DefaultConstructor) -{ - Optional a; - EXPECT_FALSE(a.has_value()); -} - -TEST(optional, ValueConstructor) -{ - Optional a(5); - EXPECT_TRUE(a.has_value()); - EXPECT_EQ(a.value(), 5); -} - -TEST(optional, CopyConstructor) -{ - Optional a("Hello"); - Optional b = a; - EXPECT_TRUE(a.has_value()); - EXPECT_TRUE(b.has_value()); - b.value()[0] = 'T'; - EXPECT_EQ(a.value(), "Hello"); - EXPECT_EQ(b.value(), "Tello"); -} - -TEST(optional, Reset) -{ - Optional a(4); - EXPECT_TRUE(a.has_value()); - a.reset(); - EXPECT_FALSE(a.has_value()); -} - -TEST(optional, Extract) -{ - Optional a(32); - EXPECT_TRUE(a.has_value()); - EXPECT_EQ(a.extract(), 32); - EXPECT_FALSE(a.has_value()); -} - -TEST(optional, ArrowOperator) -{ - Optional value = std::string("Hello"); - EXPECT_TRUE(value.has_value()); - EXPECT_EQ(value->size(), 5); -} - -TEST(optional, StarOperator) -{ - Optional value = std::string("Hello"); - EXPECT_TRUE(value.has_value()); - std::string &s = *value; - EXPECT_EQ(s.size(), 5); -} diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt index 31c8e983292..ba493b22b42 100644 --- a/tests/gtests/blenlib/CMakeLists.txt +++ b/tests/gtests/blenlib/CMakeLists.txt @@ -63,7 +63,6 @@ BLENDER_TEST(BLI_math_geom "bf_blenlib") BLENDER_TEST(BLI_math_matrix "bf_blenlib") BLENDER_TEST(BLI_math_vector "bf_blenlib") BLENDER_TEST(BLI_memiter "bf_blenlib") -BLENDER_TEST(BLI_optional "bf_blenlib") BLENDER_TEST(BLI_path_util "${BLI_path_util_extra_libs}") BLENDER_TEST(BLI_polyfill_2d "bf_blenlib") BLENDER_TEST(BLI_set "bf_blenlib") -- cgit v1.2.3