Initial Course
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
#include "auto_return.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(AutoReturn, Identity) {
|
||||
EXPECT_EQ(cpp14::identity(42), 42);
|
||||
}
|
||||
|
||||
TEST(AutoReturn, CopyOrReference) {
|
||||
std::vector<int> data = {1, 2, 3};
|
||||
const auto& ref = cpp14::copy_or_reference(data);
|
||||
EXPECT_EQ(ref, data);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "digit_separators.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(DigitSeparators, Million) { EXPECT_EQ(cpp14::million(), 1'000'000); }
|
||||
TEST(DigitSeparators, Mask) { EXPECT_EQ(cpp14::mask(), 0xFF00'00FFU); }
|
||||
TEST(DigitSeparators, BitsSet) { EXPECT_EQ(cpp14::bits_set(), 16); }
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "generic_lambdas.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(GenericLambdas, ApplyTwice) {
|
||||
EXPECT_EQ(cpp14::apply_twice({1, 2, 3}), (std::vector<int>{2, 4, 6}));
|
||||
}
|
||||
|
||||
TEST(GenericLambdas, ConcatAny) {
|
||||
EXPECT_EQ(cpp14::concat_any({"a"}, {"b", "c"}), (std::vector<std::string>{"a", "b", "c"}));
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "make_unique.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(MakeUnique, MakeTask) {
|
||||
auto task = cpp14::make_task("build", 10);
|
||||
ASSERT_NE(task, nullptr);
|
||||
EXPECT_EQ(task->name, "build");
|
||||
EXPECT_EQ(task->priority, 10);
|
||||
}
|
||||
|
||||
TEST(MakeUnique, TotalPriority) {
|
||||
std::vector<std::unique_ptr<cpp14::Task>> tasks;
|
||||
tasks.push_back(cpp14::make_task("a", 1));
|
||||
tasks.push_back(cpp14::make_task("b", 2));
|
||||
EXPECT_EQ(cpp14::total_priority(tasks), 3);
|
||||
}
|
||||
Reference in New Issue
Block a user