46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/// @file
|
|
/// @brief Task3: tests
|
|
|
|
#include "task3.hpp"
|
|
#include "task2.aliases.hpp"
|
|
|
|
#include <cassert> // assert
|
|
#include <filesystem> // std::filesystem::exists
|
|
#include <iostream> // std::cout, sts::endl
|
|
#include <string> // std::string
|
|
#include <thread> // std::this_thread::sleep_for, std::chrono_literals
|
|
|
|
int main() {
|
|
|
|
std::string filepath = "task3.test.svg";
|
|
|
|
auto hori1 = task2::Line{{-50, 0}, {50, 0}};
|
|
auto vert1 = task2::Line{{0, -50}, {0, 50}};
|
|
auto hori2 = task2::Line{{-50 + 110, 0}, {50 + 110, 0}};
|
|
auto vert2 = task2::Line{{0 + 110, -50}, {0 + 110, 50}};
|
|
std::vector<task2::Line> lines = {hori1, vert1, hori2, vert2};
|
|
|
|
auto cline = task2::Polyline{{-60, 50}, {-90, 30}, {-110, 0}, {-90, -30}, {-60, -50}};
|
|
std::vector<task2::Polyline> polylines = {cline};
|
|
|
|
auto circle = task2::Circle{{20, 0}, 200};
|
|
std::vector<task2::Circle> circles = {circle};
|
|
|
|
std::filesystem::remove(filepath);
|
|
auto bbox = task3::plot_image(filepath, lines, polylines, circles);
|
|
using namespace std::chrono_literals;
|
|
std::this_thread::sleep_for(100ms);
|
|
assert(std::filesystem::exists(filepath));
|
|
|
|
const auto& [bbmin, bbmax] = bbox;
|
|
|
|
assert(bbmin[0] == -180);
|
|
assert(bbmax[0] == 220);
|
|
assert(bbmin[1] == -200);
|
|
assert(bbmax[1] == 200);
|
|
|
|
std::cout << "task3.test.cpp: all asserts passed" << std::endl;
|
|
|
|
return 0;
|
|
}
|