blob: 48b48439321244c67a8f4a4a86be9ac21c80af03 [file] [log] [blame]
William A. Kennington IIIdb1bdbc2023-01-09 16:02:13 -08001#include <stdplus/variant.hpp>
2
3#include <gtest/gtest.h>
4
5namespace stdplus
6{
7
8using namespace std::literals::string_literals;
9using V = std::variant<int, float, std::string>;
10
11TEST(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
27TEST(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