William A. Kennington III | db1bdbc | 2023-01-09 16:02:13 -0800 | [diff] [blame] | 1 | #include <stdplus/variant.hpp> |
| 2 | |
| 3 | #include <gtest/gtest.h> |
| 4 | |
| 5 | namespace stdplus |
| 6 | { |
| 7 | |
| 8 | using namespace std::literals::string_literals; |
| 9 | using V = std::variant<int, float, std::string>; |
| 10 | |
| 11 | TEST(variantEqFuzzy, Basic) |
| 12 | { |
| 13 | EXPECT_TRUE(variantEqFuzzy(V{1}, 1)); |
| 14 | EXPECT_TRUE(variantEqFuzzy(V{1}, V{1})); |
| 15 | EXPECT_TRUE(variantEqFuzzy(V{1}, 1.)); |
| 16 | EXPECT_TRUE(variantEqFuzzy(V{1}, V{1.f})); |
| 17 | EXPECT_TRUE(variantEqFuzzy(V{1.f}, 1)); |
| 18 | EXPECT_TRUE(variantEqFuzzy(V{1.f}, 1.)); |
| 19 | EXPECT_TRUE(variantEqFuzzy(V{1.f}, 1.f)); |
| 20 | EXPECT_FALSE(variantEqFuzzy(V{"1"}, 1)); |
| 21 | EXPECT_FALSE(variantEqFuzzy(V{"1"}, 1.)); |
| 22 | EXPECT_TRUE(variantEqFuzzy(V{"1"}, "1")); |
| 23 | EXPECT_TRUE(variantEqFuzzy(V{"1"}, V{"1"})); |
| 24 | EXPECT_FALSE(variantEqFuzzy(V{"1"}, V{1})); |
| 25 | } |
| 26 | |
| 27 | TEST(variantEqStrict, Basic) |
| 28 | { |
| 29 | EXPECT_TRUE(variantEqStrict(V{1}, 1)); |
| 30 | EXPECT_TRUE(variantEqStrict(V{1}, V{1})); |
| 31 | EXPECT_FALSE(variantEqStrict(V{1}, 1.f)); |
| 32 | EXPECT_FALSE(variantEqStrict(V{1}, V{1.f})); |
| 33 | EXPECT_FALSE(variantEqStrict(V{1.f}, 1)); |
| 34 | EXPECT_TRUE(variantEqStrict(V{1.f}, 1.f)); |
| 35 | EXPECT_FALSE(variantEqStrict(V{"1"}, 1)); |
| 36 | EXPECT_FALSE(variantEqStrict(V{"1"}, 1.f)); |
| 37 | EXPECT_TRUE(variantEqStrict(V{"1"}, "1"s)); |
| 38 | EXPECT_TRUE(variantEqStrict(V{"1"}, V{"1"})); |
| 39 | } |
| 40 | |
| 41 | } // namespace stdplus |