Initial Course

This commit is contained in:
David Gil de Gómez Pérez
2026-08-11 17:40:36 +03:00
commit 9aed1d1d86
202 changed files with 3420 additions and 0 deletions
@@ -0,0 +1,15 @@
#include "algorithm_lambdas.hpp"
#include <gtest/gtest.h>
TEST(AlgorithmLambdas, FilterLength) {
EXPECT_EQ(stl_algorithms::filter_length({"a", "ab", "abc"}, 2),
(std::vector<std::string>{"ab", "abc"}));
}
TEST(AlgorithmLambdas, MapToLengths) {
EXPECT_EQ(stl_algorithms::map_to_lengths({"hi", "there"}), (std::vector<int>{2, 5}));
}
TEST(AlgorithmLambdas, FirstMatch) {
EXPECT_EQ(stl_algorithms::first_match({1, 5, 9}, 4), 5);
}
@@ -0,0 +1,15 @@
#include "iterators.hpp"
#include <gtest/gtest.h>
TEST(Iterators, ReverseCopy) {
EXPECT_EQ(stl_algorithms::reverse_copy({1, 2, 3}), (std::vector<int>{3, 2, 1}));
}
TEST(Iterators, CountGreaterThan) {
EXPECT_EQ(stl_algorithms::countGreaterThan({1, 5, 9}, 4), 2);
}
TEST(Iterators, EveryEven) {
EXPECT_TRUE(stl_algorithms::everyEven({2, 4, 6}));
EXPECT_FALSE(stl_algorithms::everyEven({2, 3}));
}
@@ -0,0 +1,14 @@
#include "sort_and_find.hpp"
#include <gtest/gtest.h>
TEST(SortAndFind, SortedCopy) {
EXPECT_EQ(stl_algorithms::sorted_copy({3, 1, 2}), (std::vector<int>{1, 2, 3}));
}
TEST(SortAndFind, Contains) {
EXPECT_TRUE(stl_algorithms::contains({1, 2, 3}, 2));
}
TEST(SortAndFind, LowerBoundIndex) {
EXPECT_EQ(stl_algorithms::lower_bound_index({1, 3, 5, 7}, 5), 2);
}
@@ -0,0 +1,14 @@
#include "transform_reduce.hpp"
#include <gtest/gtest.h>
TEST(TransformReduce, SquareAll) {
EXPECT_EQ(stl_algorithms::square_all({1, 2, 3}), (std::vector<int>{1, 4, 9}));
}
TEST(TransformReduce, SumAll) {
EXPECT_EQ(stl_algorithms::sum_all({1, 2, 3}), 6);
}
TEST(TransformReduce, ProductPositive) {
EXPECT_EQ(stl_algorithms::product_positive({-1, 2, 3, -4}), 6);
}