PAASS
Software suite to Acquire and Analyze Data from Pixie16
unittest-Identifier.cpp
Go to the documentation of this file.
1 #include <iostream>
6 
7 #include <cmath>
8 
9 #include <UnitTest++.h>
10 
11 #include "Identifier.hpp"
12 
13 using namespace std;
14 
16 TEST_FIXTURE(Identifier, Test_GetAndSetDammID) {
17  unsigned int dammid = 12;
18  SetDammID(dammid);
19  CHECK(GetDammID() == dammid);
20 }
21 
23 TEST_FIXTURE(Identifier, Test_GetAndSetLocation) {
24  unsigned int loc = 111;
25  SetLocation(loc);
26  CHECK(GetLocation() == loc);
27 }
28 
30 TEST_FIXTURE(Identifier, Test_GetAndSetType) {
31  string type = "unittest";
32  SetType(type);
33  CHECK(GetType() == type);
34 }
35 
37 TEST_FIXTURE(Identifier, Test_GetAndSetSubtype) {
38  string type = "unittest";
39  SetSubtype(type);
40  CHECK(GetSubtype() == type);
41 }
42 
44 TEST_FIXTURE(Identifier, Test_GetAndSetTag) {
45  string tag = "unittest";
46  AddTag(tag, 1234);
47  CHECK(GetTag(tag) == 1234);
48 }
49 
51 TEST_FIXTURE(Identifier, Test_GetTagMap) {
52  string tag = "unittest";
53  AddTag(tag, 1234);
54  map<string, int> testmap;
55  testmap.insert(make_pair(tag, 1234));
56  CHECK(GetTagMap() == testmap);
57 }
58 
60 TEST_FIXTURE(Identifier, Test_HasTag) {
61  string tag = "unittest";
62  AddTag(tag, 12345);
63  CHECK(HasTag(tag));
64 }
65 
67 TEST_FIXTURE(Identifier, Test_HasMissingTag) {
68  string tag = "unittest";
69  CHECK(! HasTag(tag));
70 }
71 
72 //Check the comparison operators
73 TEST_FIXTURE(Identifier, Test_Comparison) {
74  string type = "unit";
75  string subtype = "test";
76  unsigned int loc = 112;
77  SetSubtype(subtype);
78  SetType(type);
79  SetLocation(loc);
80 
81  Identifier id(type, subtype, loc);
82 
83  CHECK(*this == id);
84 
85  SetLocation(123);
86  CHECK(*this > id);
87 
88  SetLocation(4);
89  CHECK(*this < id);
90 }
91 
93 TEST_FIXTURE(Identifier, Test_PlaceName) {
94  string type = "unit";
95  string subtype = "test";
96  unsigned int loc = 112;
97  SetSubtype(subtype);
98  SetType(type);
99  SetLocation(loc);
100  CHECK(GetPlaceName() == "unit_test_112");
101 }
102 
105  Identifier id("unit", "test", 123);
106  id.Zero();
107  CHECK(*this == id);
108 }
109 
110 int main(int argv, char *argc[]) {
111  return (UnitTest::RunAllTests());
112 }
Channel identification.
Definition: Identifier.hpp:23
STL namespace.
int main(int argv, char *argc[])
TEST_FIXTURE(Identifier, Test_GetAndSetDammID)
Testing the set/get for the dammid.
Defines identifying information for channels.