Initial Course
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#include "constexpr_frontier.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(ConstexprFrontier, Factorial) {
|
||||
EXPECT_EQ(cpp26::compile_time_factorial(5), 120);
|
||||
}
|
||||
|
||||
TEST(ConstexprFrontier, CompileTimeSum) {
|
||||
EXPECT_EQ(cpp26::compile_time_sum({1, 2, 3, 4, 5}), 15);
|
||||
}
|
||||
|
||||
TEST(ConstexprFrontier, IsSorted) {
|
||||
EXPECT_TRUE(cpp26::is_sorted({1, 2, 3, 4, 5}));
|
||||
EXPECT_FALSE(cpp26::is_sorted({1, 3, 2, 4, 5}));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "custom_formatter.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(CustomFormatter, FormatPoint) {
|
||||
EXPECT_EQ(cpp26::format_point({3, 4}), "(3, 4)");
|
||||
}
|
||||
|
||||
TEST(CustomFormatter, FormatPoints) {
|
||||
EXPECT_EQ(cpp26::format_points({1, 2}, {3, 4}), "(1, 2) -> (3, 4)");
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "monadic_expected.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(MonadicExpected, LoadUserName) {
|
||||
EXPECT_EQ(*cpp26::load_user_name("42"), "User-42");
|
||||
EXPECT_EQ(cpp26::load_user_name("x"), std::unexpected(cpp26::ErrorCode::Invalid));
|
||||
EXPECT_EQ(cpp26::load_user_name("999"), std::unexpected(cpp26::ErrorCode::NotFound));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "pipeline_ranges.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(PipelineRanges, TopValuesByCategory) {
|
||||
const std::vector<cpp26::Record> records{
|
||||
{"math", 10}, {"math", 50}, {"code", 30}, {"code", 5}};
|
||||
const auto result = cpp26::top_values_by_category(records, 20);
|
||||
ASSERT_EQ(result.size(), 2U);
|
||||
EXPECT_EQ(result[0].category, "math");
|
||||
EXPECT_EQ(result[0].value, 50);
|
||||
}
|
||||
|
||||
TEST(PipelineRanges, TotalByCategory) {
|
||||
const std::vector<cpp26::Record> records{{"math", 10}, {"math", 5}, {"code", 7}};
|
||||
const auto totals = cpp26::total_by_category(records);
|
||||
ASSERT_EQ(totals.size(), 2U);
|
||||
EXPECT_EQ(totals[0].first, "code");
|
||||
EXPECT_EQ(totals[0].second, 7);
|
||||
}
|
||||
Reference in New Issue
Block a user