-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShortTest.cpp
More file actions
58 lines (46 loc) · 1.06 KB
/
ShortTest.cpp
File metadata and controls
58 lines (46 loc) · 1.06 KB
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
#include "ShortTest.h"
#include <assert.h>
#include "Map.h"
#include "MapIterator.h"
void test_new_ex(){
Map m;
m.add(5,5);
m.add(1,111);
m.add(10,110);
m.add(7,7);
m.add(-3,-3);
Map new_map;
//new_map = m.filter(1,7);
// assert(new_map.size() == 3);
}
void testAll() { //call each function to see if it is implemented
test_new_ex();
Map m;
assert(m.isEmpty() == true);
assert(m.size() == 0); //add elements
assert(m.add(5,5)==NULL_TVALUE);
assert(m.add(1,111)==NULL_TVALUE);
assert(m.add(10,110)==NULL_TVALUE);
assert(m.add(7,7)==NULL_TVALUE);
assert(m.add(1,1)==111);
assert(m.add(10,10)==110);
assert(m.add(-3,-3)==NULL_TVALUE);
assert(m.size() == 5);
assert(m.search(10) == 10);
assert(m.search(16) == NULL_TVALUE);
assert(m.remove(1) == 1);
assert(m.remove(6) == NULL_TVALUE);
assert(m.size() == 4);
TElem e;
MapIterator id = m.iterator();
id.first();
int s1 = 0, s2 = 0;
while (id.valid()) {
e = id.getCurrent();
s1 += e.first;
s2 += e.second;
id.next();
}
assert(s1 == 19);
assert(s2 == 19);
}