38 lines
No EOL
692 B
C++
38 lines
No EOL
692 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);
|
|
|
|
add_rect(1,-2,8,4);
|
|
check_area(52);
|
|
|
|
add_rect(2,2,7,3);
|
|
check_area(52);
|
|
|
|
std::cout << "All checks passed" << std::endl;
|
|
return 0;
|
|
} |