MCPcopy Create free account
hub / github.com/davidrmiller/biosim4 / unitTestBasicTypes

Function unitTestBasicTypes

src/unitTestBasicTypes.cpp:19–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19bool unitTestBasicTypes()
20{
21 // Dir
22
23 // ctor from Compass
24 // .asInt()
25 // copy assignment
26 Dir d1 = Dir(Compass::N);
27 Dir d2 = Dir(Compass::CENTER);
28 d1 = d2;
29 assert(d1.asInt() == (int)Compass::CENTER);
30 d1 = Dir(Compass::SW);
31 assert(d1.asInt() == 0);
32 d1 = Dir(Compass::S);
33 assert(d1.asInt() == 1);
34 d1 = Dir(Compass::SE);
35 assert(d1.asInt() == 2);
36 d1 = Dir(Compass::W);
37 assert(d1.asInt() == 3);
38 d1 = Dir(Compass::CENTER);
39 assert(d1.asInt() == 4);
40 d1 = Dir(Compass::E);
41 assert(d1.asInt() == 5);
42 d1 = Dir(Compass::NW);
43 assert(d1.asInt() == 6);
44 d1 = Dir(Compass::N);
45 assert(d1.asInt() == 7);
46 d1 = Dir(Compass::NE);
47 assert(d1.asInt() == 8);
48
49 assert(Dir(Compass::SW).asInt() == 0);
50 assert(Dir(Compass::S).asInt() == 1);
51 assert(Dir(Compass::SE).asInt() == 2);
52 assert(Dir(Compass::W).asInt() == 3);
53 assert(Dir(Compass::CENTER).asInt() == 4);
54 assert(Dir(Compass::E).asInt() == 5);
55 assert(Dir(Compass::NW).asInt() == 6);
56 assert(Dir(Compass::N).asInt() == 7);
57 assert(Dir(Compass::NE).asInt() == 8);
58 assert(Dir((Compass)8).asInt() == 8);
59 assert(Dir((Compass)((Dir((Compass)8)).asInt())).asInt() == 8);
60 assert(Dir((Compass)(Dir(Compass::NE).asInt())).asInt() == 8);
61 d2 = Compass::E;
62 d1 = d2;
63 assert(d1.asInt() == 5);
64 d2 = d1;
65 assert(d1.asInt() == 5);
66
67 // .operator=() from Compass
68 d1 = Compass::SW;
69 assert(d1.asInt() == 0);
70 d1 = Compass::SE;
71 assert(d1.asInt() == 2);
72
73 // [in]equality with Compass
74 d1 = Compass::CENTER;
75 assert(d1 == Compass::CENTER);
76 d1 = Compass::SE;

Callers 1

mainFunction · 0.85

Calls 15

DirClass · 0.85
CoordClass · 0.85
areClosefFunction · 0.85
PolarClass · 0.85
asIntMethod · 0.80
rotateMethod · 0.80
asNormalizedCoordMethod · 0.80
asNormalizedPolarMethod · 0.80
isNormalizedMethod · 0.80
normalizeMethod · 0.80
asDirMethod · 0.80
lengthMethod · 0.80

Tested by

no test coverage detected