libStatGen Software 1
TestPosList Class Reference
Inheritance diagram for TestPosList:
Collaboration diagram for TestPosList:

Public Member Functions

void testPosList ()
 
- Public Member Functions inherited from PosList
 PosList ()
 Constructor. More...
 
 PosList (int numRefs, int numPositions)
 Reserves space for numRefs reference ids and numPositions for each id. More...
 
virtual ~PosList ()
 Destructor. More...
 
void addPosition (int refID, int refPosition)
 Add the specified reference id/position (negative values will not be added). More...
 
bool hasPosition (int refID, int refPosition)
 Return whether or not this list contains the specified reference ID and position (negative values will automatically return false). More...
 

Additional Inherited Members

- Protected Member Functions inherited from PosList
 PosList (const PosList &p)
 
void initVars ()
 
- Protected Attributes inherited from PosList
std::vector< std::vector< bool > > myPosList
 
int myNumRefs
 
int myNumPos
 

Detailed Description

Definition at line 22 of file TestPosList.h.

Constructor & Destructor Documentation

◆ TestPosList()

TestPosList::TestPosList ( )

Definition at line 28 of file TestPosList.cpp.

29{
30}

◆ ~TestPosList()

TestPosList::~TestPosList ( )

Definition at line 33 of file TestPosList.cpp.

34{
35}

Member Function Documentation

◆ testPosList()

void TestPosList::testPosList ( )

Definition at line 38 of file TestPosList.cpp.

39{
40 assert(myPosList.size() == 24);
41
42 for(int i = 0; i < 24; i++)
43 {
44 assert(myPosList.at(i).size() == 100);
45 }
46
47 bool caught = false;
48 try
49 {
50 myPosList.at(24);
51 }
52 catch(std::out_of_range& oor)
53 {
54 caught = true;
55 }
56
57 assert(caught == true);
58
59 //////////////////////////////
60 // Test accessing
61 for(int i = 0; i < 24; i++)
62 {
63 for(int j = 0; j < 100; j++)
64 {
65 assert(!hasPosition(i, j));
66 }
67 }
68
69 //////////////////////////////
70 // Test setting all
71 for(int i = 0; i < 24; i++)
72 {
73 for(int j = 0; j < 100; j++)
74 {
75 addPosition(i, j);
76 }
77 }
78 for(int i = 0; i < 24; i++)
79 {
80 for(int j = 0; j < 100; j++)
81 {
82 assert(hasPosition(i, j));
83 }
84 }
85
86
87
88
89 //////////////////////////////
90 // Test accessing out of range
91 assert(!hasPosition(-1, 0));
92 assert(!hasPosition(0, -1));
93 assert(!hasPosition(100, 0));
94 assert(!hasPosition(0, 1000));
95
96 //////////////////////////////
97 // Test adding more to ref 4,
98 // but skipping positions.
99 for(int j = 300; j < 350; j++)
100 {
101 addPosition(4, j);
102 }
103 for(int j = 0; j < 100; j++)
104 {
105 assert(hasPosition(4, j));
106 }
107 for(int j = 100; j < 300; j++)
108 {
109 assert(!hasPosition(4, j));
110 }
111 for(int j = 300; j < 350; j++)
112 {
113 assert(hasPosition(4, j));
114 }
115
116 // Test adding a new reference, 30,
117 // position 16.
118 addPosition(30, 16);
119
120 // Check the size now.
121 assert(myPosList.size() == 31);
122
123 for(int i = 0; i < 24; i++)
124 {
125 if(i != 4)
126 {
127 assert(myPosList.at(i).size() == 100);
128 }
129 else
130 {
131 assert(myPosList.at(i).size() == 350);
132 }
133 }
134
135 for(int i = 24; i < 31; i++)
136 {
137 assert(myPosList.at(i).size() == 350);
138 }
139
140 //////////////////////////////
141 // Test accessing
142 for(int i = 24; i < 30; i++)
143 {
144 for(int j = 0; j < 350; j++)
145 {
146 assert(!hasPosition(i, j));
147 }
148 }
149 for(int j = 0; j < 350; j++)
150 {
151 if(j != 16)
152 {
153 assert(!hasPosition(30, j));
154 }
155 else
156 {
157 assert(hasPosition(30, 16));
158 }
159 }
160}
bool hasPosition(int refID, int refPosition)
Return whether or not this list contains the specified reference ID and position (negative values wil...
Definition: PosList.cpp:81
void addPosition(int refID, int refPosition)
Add the specified reference id/position (negative values will not be added).
Definition: PosList.cpp:42

The documentation for this class was generated from the following files: