File: tile_coordinates_set.test.cpp

package info (click to toggle)
tilemaker 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 83,488 kB
  • sloc: cpp: 29,461; ansic: 12,510; makefile: 229; ruby: 77; sh: 43
file content (58 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <iostream>
#include "external/minunit.h"
#include "tile_coordinates_set.h"

MU_TEST(test_tile_coordinates_set) {
	{
		PreciseTileCoordinatesSet z0(0);
		mu_check(z0.test(0, 0) == false);
		mu_check(z0.size() == 0);
		mu_check(z0.zoom() == 0);

		z0.set(0, 0);
		mu_check(z0.test(0, 0) == true);
		mu_check(z0.size() == 1);
	}

	{
		PreciseTileCoordinatesSet z6(6);
		mu_check(z6.test(0, 0) == false);

		z6.set(0, 0);
		mu_check(z6.test(0, 0) == true);
		mu_check(z6.test(1, 0) == false);
		mu_check(z6.test(0, 1) == false);
		mu_check(z6.size() == 1);
		mu_check(z6.zoom() == 6);
	}

	// Wrapped sets should extrapolate from lower zooms
	{
		PreciseTileCoordinatesSet z1(1);
		LossyTileCoordinatesSet z2(2, z1);

		mu_check(z2.size() == 0);
		for (int x = 0; x < 4; x++) {
			for (int y = 0; y < 4; y++) {
				mu_check(z2.test(x, y) == false);
			}
		}
		z1.set(0, 0);
		mu_check(z2.size() == 4);
		mu_check(z2.test(0, 0) == true);
		mu_check(z2.test(0, 1) == true);
		mu_check(z2.test(1, 0) == true);
		mu_check(z2.test(1, 1) == true);
		mu_check(z2.test(2, 2) == false);
	}
}

MU_TEST_SUITE(test_suite_tile_coordinates_set) {
	MU_RUN_TEST(test_tile_coordinates_set);
}

int main() {
	MU_RUN_SUITE(test_suite_tile_coordinates_set);
	MU_REPORT();
	return MU_EXIT_CODE;
}