/// @file /// @brief Task2: tests #include "task2.Circle.hpp" #include "task2.Line.hpp" #include "task2.Polyline.hpp" #include "task2.aliases.hpp" #include // assert #include // std::cout, sts::endl #include // std::string bool contains(const std::string& str, const std::string& pattern) { return str.find(pattern) != std::string::npos; } bool check_defaults(const std::string& str) { if (!contains(str, "stroke-width='1'")) return false; if (!contains(str, "fill='none'")) return false; if (!contains(str, "stroke='black'")) return false; return true; } int main() { { // LineElement auto line = task2::Line{{0, 0}, {11, 12}}; auto elem = task2::LineElement(line); auto openstr = elem.open(); assert(check_defaults(openstr)); assert(openstr.starts_with("")); assert(elem.text().empty() && elem.close().empty()); } { // CircleElement auto circle = task2::Circle{{5, 6}, 5}; auto elem = task2::CircleElement(circle); auto openstr = elem.open(); assert(check_defaults(openstr)); assert(openstr.starts_with("")); assert(elem.text().empty() && elem.close().empty()); } { // PolylineElement auto polyline = task2::Polyline{{1, 2}, {3, 4}, {5, 6}}; auto elem = task2::PolylineElement(polyline); auto openstr = elem.open(); assert(check_defaults(openstr)); assert(openstr.starts_with("")); assert(elem.text().empty() && elem.close().empty()); } std::cout << "task2.test.cpp: all asserts passed" << std::endl; return 0; }