Files
M5Utility/test/optional/nullopt.cpp
T

18 lines
459 B
C++
Raw Permalink Normal View History

2024-08-08 14:30:50 +09:00
#include <gtest/gtest.h>
#include <m5_utility/stl/optional.hpp>
2024-09-25 18:24:01 +09:00
TEST(Optional, Nullopt)
{
2024-08-08 14:44:12 +09:00
m5::stl::optional<int> o1 = m5::stl::nullopt;
m5::stl::optional<int> o2{m5::stl::nullopt};
m5::stl::optional<int> o3(m5::stl::nullopt);
m5::stl::optional<int> o4 = {m5::stl::nullopt};
2024-08-08 14:30:50 +09:00
2024-08-08 14:44:12 +09:00
EXPECT_TRUE(!o1);
EXPECT_TRUE(!o2);
EXPECT_TRUE(!o3);
EXPECT_TRUE(!o4);
2024-08-08 14:30:50 +09:00
2024-08-08 14:44:12 +09:00
EXPECT_TRUE(!std::is_default_constructible<m5::stl::nullopt_t>::value);
2024-08-08 14:30:50 +09:00
}