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
+16
View File
@@ -0,0 +1,16 @@
#include "optional.hpp"
#include <gtest/gtest.h>
TEST(Optional, SafeDivide) {
EXPECT_DOUBLE_EQ(*cpp17::safe_divide(10, 2), 5.0);
EXPECT_FALSE(cpp17::safe_divide(1, 0).has_value());
}
TEST(Optional, FindUser) {
EXPECT_EQ(*cpp17::find_user({"Ada", "Grace"}, "Grace"), 1U);
}
TEST(Optional, FirstPositive) {
EXPECT_EQ(*cpp17::first_positive({-1, 0, 3, 4}), 3);
EXPECT_FALSE(cpp17::first_positive({-1, -2}).has_value());
}