rectangle-union-area/main.cpp

32 lines
No EOL
603 B
C++

#include <cstdlib>
#include <iostream>
#include <cassert>
#include "areas.h"
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);
}
int main() {
srand(987192345);
add_rect(0,0,5,4);
check_area(20);
add_rect(3,2,6,6);
check_area(28);
std::cout << "All checks passed" << std::endl;
return 0;
}