-
Notifications
You must be signed in to change notification settings - Fork 280
/
mapgen_function_test.cpp
90 lines (75 loc) · 3.64 KB
/
mapgen_function_test.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "catch/catch.hpp"
#include "mapgen.h"
#include "type_id.h"
TEST_CASE( "connects_to", "[mapgen][connects]" )
{
// connects_to returns true if a given oter connects to a given cardinal
// compass direction, identified by an integer, clockwise from 0:North
int north = 0;
int east = 1;
int south = 2;
int west = 3;
// oter suffixes must be one of the following (order matters):
// ne, ns, es, nes, wn, ew, new, sw, nsw, esw, nesw
SECTION( "two-way connections" ) {
// North/South
CHECK( connects_to( oter_id( "sewer_ns" ), north ) );
CHECK_FALSE( connects_to( oter_id( "sewer_ns" ), east ) );
CHECK( connects_to( oter_id( "sewer_ns" ), south ) );
CHECK_FALSE( connects_to( oter_id( "sewer_ns" ), west ) );
// East/West
CHECK_FALSE( connects_to( oter_id( "sewer_ew" ), north ) );
CHECK( connects_to( oter_id( "sewer_ew" ), east ) );
CHECK_FALSE( connects_to( oter_id( "sewer_ew" ), south ) );
CHECK( connects_to( oter_id( "sewer_ew" ), west ) );
// North/East
CHECK( connects_to( oter_id( "sewer_ne" ), north ) );
CHECK( connects_to( oter_id( "sewer_ne" ), east ) );
CHECK_FALSE( connects_to( oter_id( "sewer_ne" ), south ) );
CHECK_FALSE( connects_to( oter_id( "sewer_ne" ), west ) );
// East/South
CHECK_FALSE( connects_to( oter_id( "sewer_es" ), north ) );
CHECK( connects_to( oter_id( "sewer_es" ), east ) );
CHECK( connects_to( oter_id( "sewer_es" ), south ) );
CHECK_FALSE( connects_to( oter_id( "sewer_es" ), west ) );
// South/West
CHECK_FALSE( connects_to( oter_id( "sewer_sw" ), north ) );
CHECK_FALSE( connects_to( oter_id( "sewer_sw" ), east ) );
CHECK( connects_to( oter_id( "sewer_sw" ), south ) );
CHECK( connects_to( oter_id( "sewer_sw" ), west ) );
// West/North
CHECK( connects_to( oter_id( "sewer_wn" ), north ) );
CHECK_FALSE( connects_to( oter_id( "sewer_wn" ), east ) );
CHECK_FALSE( connects_to( oter_id( "sewer_wn" ), south ) );
CHECK( connects_to( oter_id( "sewer_wn" ), west ) );
}
SECTION( "three-way connections" ) {
// North/East/South
CHECK( connects_to( oter_id( "sewer_nes" ), north ) );
CHECK( connects_to( oter_id( "sewer_nes" ), east ) );
CHECK( connects_to( oter_id( "sewer_nes" ), south ) );
CHECK_FALSE( connects_to( oter_id( "sewer_nes" ), west ) );
// East/South/West
CHECK_FALSE( connects_to( oter_id( "sewer_esw" ), north ) );
CHECK( connects_to( oter_id( "sewer_esw" ), east ) );
CHECK( connects_to( oter_id( "sewer_esw" ), south ) );
CHECK( connects_to( oter_id( "sewer_esw" ), west ) );
// South/West/North
CHECK( connects_to( oter_id( "sewer_nsw" ), north ) );
CHECK_FALSE( connects_to( oter_id( "sewer_nsw" ), east ) );
CHECK( connects_to( oter_id( "sewer_nsw" ), south ) );
CHECK( connects_to( oter_id( "sewer_nsw" ), west ) );
// West/North/East
CHECK( connects_to( oter_id( "sewer_new" ), north ) );
CHECK( connects_to( oter_id( "sewer_new" ), east ) );
CHECK_FALSE( connects_to( oter_id( "sewer_new" ), south ) );
CHECK( connects_to( oter_id( "sewer_new" ), west ) );
}
SECTION( "four-way connections" ) {
// North/East/South/West
CHECK( connects_to( oter_id( "sewer_nesw" ), north ) );
CHECK( connects_to( oter_id( "sewer_nesw" ), east ) );
CHECK( connects_to( oter_id( "sewer_nesw" ), south ) );
CHECK( connects_to( oter_id( "sewer_nesw" ), west ) );
}
}