Initial Course
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
#include "variant.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Variant, VariantToString) {
|
||||
EXPECT_EQ(cpp17::variant_to_string(42), "int:42");
|
||||
EXPECT_EQ(cpp17::variant_to_string(std::string{"hi"}), "string:hi");
|
||||
}
|
||||
|
||||
TEST(Variant, SumNumericVariants) {
|
||||
const std::vector<cpp17::Value> values{1, 2.5, std::string{"x"}, 3.5};
|
||||
EXPECT_DOUBLE_EQ(cpp17::sum_numeric_variants(values), 7.0);
|
||||
}
|
||||
|
||||
TEST(Variant, IsString) {
|
||||
EXPECT_TRUE(cpp17::is_string(std::string{"ok"}));
|
||||
EXPECT_FALSE(cpp17::is_string(1));
|
||||
}
|
||||
Reference in New Issue
Block a user