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,21 @@
#include "loops.hpp"
#include <gtest/gtest.h>
TEST(Loops, SumRange) {
EXPECT_EQ(control_flow::sum_range(1, 5), 15);
EXPECT_EQ(control_flow::sum_range(5, 5), 5);
}
TEST(Loops, Factorial) {
EXPECT_EQ(control_flow::factorial(0), 1);
EXPECT_EQ(control_flow::factorial(5), 120);
}
TEST(Loops, CountOccurrences) {
EXPECT_EQ(control_flow::count_occurrences({1, 2, 2, 3}, 2), 2);
}
TEST(Loops, FirstIndexOf) {
EXPECT_EQ(control_flow::first_index_of({4, 5, 6}, 5), 1);
EXPECT_EQ(control_flow::first_index_of({4, 5, 6}, 9), -1);
}