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,16 @@
#include "polymorphism.hpp"
#include <gtest/gtest.h>
TEST(Polymorphism, TotalArea) {
std::vector<std::unique_ptr<oop::Shape>> shapes;
shapes.push_back(std::make_unique<oop::Rectangle>(2.0, 3.0));
shapes.push_back(std::make_unique<oop::Circle>(1.0));
EXPECT_NEAR(oop::total_area(shapes), 6.0 + 3.141592653589793, 1e-9);
}
TEST(Polymorphism, ShapeNames) {
std::vector<std::unique_ptr<oop::Shape>> shapes;
shapes.push_back(std::make_unique<oop::Circle>(1.0));
shapes.push_back(std::make_unique<oop::Rectangle>(1.0, 2.0));
EXPECT_EQ(oop::shape_names(shapes), (std::vector<std::string>{"Circle", "Rectangle"}));
}