2022-04-16 11:49:45 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cassert>
|
2022-04-16 09:24:00 +02:00
|
|
|
|
2022-04-16 11:49:45 +02:00
|
|
|
#include "areas.h"
|
2022-04-16 09:24:00 +02:00
|
|
|
|
2022-04-16 12:47:39 +02:00
|
|
|
|
|
|
|
static std::vector<Rectangle> rects;
|
|
|
|
|
|
|
|
void add_rect(Coordinate x1, Coordinate y1, Coordinate x2, Coordinate y2) {
|
|
|
|
rects.push_back({{x1,y1}, {x2,y2}, 0, 0});
|
|
|
|
}
|
|
|
|
|
|
|
|
void check_area(Unit area) {
|
|
|
|
Unit computed = get_area_union(rects);
|
|
|
|
std::cout << "Computed area is " << computed << std::endl;
|
|
|
|
assert(computed == area);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-16 11:41:48 +02:00
|
|
|
int main() {
|
2022-04-16 11:49:45 +02:00
|
|
|
srand(987192345);
|
2022-04-16 12:22:49 +02:00
|
|
|
|
2022-04-16 12:47:39 +02:00
|
|
|
add_rect(0,0,5,4);
|
|
|
|
check_area(20);
|
2022-04-16 12:22:49 +02:00
|
|
|
|
2022-04-16 12:47:39 +02:00
|
|
|
add_rect(3,2,6,6);
|
|
|
|
check_area(28);
|
2022-04-16 12:22:49 +02:00
|
|
|
|
2022-04-16 13:16:34 +02:00
|
|
|
add_rect(1,-2,8,4);
|
|
|
|
check_area(52);
|
|
|
|
|
|
|
|
add_rect(2,2,7,3);
|
|
|
|
check_area(52);
|
|
|
|
|
2022-04-16 12:47:39 +02:00
|
|
|
std::cout << "All checks passed" << std::endl;
|
2022-04-16 11:41:48 +02:00
|
|
|
return 0;
|
|
|
|
}
|