Initial Course
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#include "default_parameters.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(DefaultParameters, Repeat) {
|
||||
EXPECT_EQ(functions::repeat('*'), "*");
|
||||
EXPECT_EQ(functions::repeat('-', 3), "---");
|
||||
}
|
||||
|
||||
TEST(DefaultParameters, Power) {
|
||||
EXPECT_EQ(functions::power(5), 25);
|
||||
EXPECT_EQ(functions::power(2, 10), 1024);
|
||||
}
|
||||
|
||||
TEST(DefaultParameters, Clamp) {
|
||||
EXPECT_EQ(functions::clamp(150), 100);
|
||||
EXPECT_EQ(functions::clamp(-5), 0);
|
||||
EXPECT_EQ(functions::clamp(42, 10, 50), 42);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "function_basics.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(FunctionBasics, Square) { EXPECT_EQ(functions::square(7), 49); }
|
||||
|
||||
TEST(FunctionBasics, SwapIntegers) {
|
||||
int a = 1, b = 2;
|
||||
functions::swap_integers(a, b);
|
||||
EXPECT_EQ(a, 2);
|
||||
EXPECT_EQ(b, 1);
|
||||
}
|
||||
|
||||
TEST(FunctionBasics, Concatenate) {
|
||||
EXPECT_EQ(functions::concatenate({"C", "++"}), "C++");
|
||||
}
|
||||
|
||||
TEST(FunctionBasics, AppendSuffix) {
|
||||
std::string text = "modern";
|
||||
functions::append_suffix(text, "_cpp");
|
||||
EXPECT_EQ(text, "modern_cpp");
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "overloading.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Overloading, MaxInt) { EXPECT_EQ(functions::max_value(3, 9), 9); }
|
||||
TEST(Overloading, MaxDouble) { EXPECT_DOUBLE_EQ(functions::max_value(3.1, 2.9), 3.1); }
|
||||
TEST(Overloading, MaxString) { EXPECT_EQ(functions::max_value("abc", "abd"), "abd"); }
|
||||
TEST(Overloading, Area) {
|
||||
EXPECT_EQ(functions::area(4), 16);
|
||||
EXPECT_EQ(functions::area(3, 5), 15);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "recursion.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(Recursion, Fibonacci) {
|
||||
EXPECT_EQ(functions::fibonacci(0), 0);
|
||||
EXPECT_EQ(functions::fibonacci(1), 1);
|
||||
EXPECT_EQ(functions::fibonacci(10), 55);
|
||||
}
|
||||
|
||||
TEST(Recursion, SumDigits) {
|
||||
EXPECT_EQ(functions::sum_digits(12345), 15);
|
||||
}
|
||||
|
||||
TEST(Recursion, IsPalindrome) {
|
||||
EXPECT_TRUE(functions::is_palindrome(121));
|
||||
EXPECT_FALSE(functions::is_palindrome(123));
|
||||
}
|
||||
Reference in New Issue
Block a user