-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.cpp
115 lines (88 loc) · 4.03 KB
/
main.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* CrissCross
* A multi-purpose cross-platform library.
*
* A product of Uplink Laboratories.
*
* (c) 2006-2022 Steven Noonan.
* Licensed under the New BSD License.
*
*/
#include "header.h"
#include "testutils.h"
#include "backtrace.h"
#include "compare.h"
#include "darray.h"
#include "dstack.h"
#include "llist.h"
#include "splaytree.h"
#include "stltree.h"
#include "avltree.h"
#include "rbtree.h"
#include "hashtable.h"
#include "stopwatch.h"
#include "stree.h"
#include "sort.h"
using namespace CrissCross;
CrissCross::IO::Console *g_console;
int main(int argc, char * *argv)
{
g_console = new IO::Console();
g_console->SetColour(IO::Console::FG_RED | IO::Console::FG_INTENSITY);
g_console->WriteLine("CrissCross Test Suite");
g_console->SetColour();
g_console->WriteLine();
int retval = 0;
System::SeedRandom();
g_console->WriteLine("Testing PrintStackTrace()");
TestBacktrace();
WritePrefix("Stopwatch"); retval |= WriteResult(TestStopwatch());
WritePrefix("char* Compare"); retval |= WriteResult(TestComparison_CString());
WritePrefix("std::string Compare"); retval |= WriteResult(TestComparison_String());
WritePrefix("Integer Compare"); retval |= WriteResult(TestComparison_Integer());
WritePrefix("LList"); retval |= WriteResult(TestLList());
WritePrefix("DArray"); retval |= WriteResult(TestDArray());
WritePrefix("DStack"); retval |= WriteResult(TestDStack());
WritePrefix("SplayTree<const char *, const char *>"); retval |= WriteResult(TestSplayTree_CString());
WritePrefix("SplayTree<std::string, std::string>"); retval |= WriteResult(TestSplayTree_String());
WritePrefix("SplayTree<int, int>"); retval |= WriteResult(TestSplayTree_Int());
#ifdef ENABLE_STLTREE
WritePrefix("STLTree<const char *, const char *>"); retval |= WriteResult(TestSTLTree_CString());
WritePrefix("STLTree<std::string, std::string>"); retval |= WriteResult(TestSTLTree_String());
WritePrefix("STLTree<int, int>"); retval |= WriteResult(TestSTLTree_Int());
#endif
WritePrefix("AVLTree<const char *, const char *>"); retval |= WriteResult(TestAVLTree_CString());
WritePrefix("AVLTree<std::string, std::string>"); retval |= WriteResult(TestAVLTree_String());
WritePrefix("AVLTree<int, int>"); retval |= WriteResult(TestAVLTree_Int());
WritePrefix("RedBlackTree<const char *, const char *>"); retval |= WriteResult(TestRedBlackTree_CString());
WritePrefix("RedBlackTree<std::string, std::string>"); retval |= WriteResult(TestRedBlackTree_String());
WritePrefix("RedBlackTree<int, int>"); retval |= WriteResult(TestRedBlackTree_Int());
WritePrefix("STree<const char *, const char *>"); retval |= WriteResult(TestSTree_CString());
WritePrefix("STree<std::string, std::string>"); retval |= WriteResult(TestSTree_String());
WritePrefix("STree<int, int>"); retval |= WriteResult(TestSTree_Int());
WritePrefix("HashTable<const char *, const char *>"); retval |= WriteResult(TestHashTable_CString());
WritePrefix("LList std::sort"); retval |= WriteResult(TestSort_LList());
CrissCross::Data::CombSort<int> cs;
WritePrefix("CombSort (integer array)"); retval |= WriteResult(TestSort_IntArray(&cs));
WritePrefix("CombSort (integer DArray)"); retval |= WriteResult(TestSort_DArray(&cs));
CrissCross::Data::HeapSort<int> hs;
WritePrefix("HeapSort (integer array)"); retval |= WriteResult(TestSort_IntArray(&hs));
WritePrefix("HeapSort (integer DArray)"); retval |= WriteResult(TestSort_DArray(&hs));
CrissCross::Data::ShellSort<int> ss;
WritePrefix("ShellSort (integer array)"); retval |= WriteResult(TestSort_IntArray(&ss));
WritePrefix("ShellSort (integer DArray)"); retval |= WriteResult(TestSort_DArray(&ss));
CrissCross::Data::QuickSort<int> qs;
WritePrefix("QuickSort (integer array)"); retval |= WriteResult(TestSort_IntArray(&qs));
WritePrefix("QuickSort (integer DArray)"); retval |= WriteResult(TestSort_DArray(&qs));
if (retval == 0) {
g_console->WriteLine();
g_console->WriteLine("All tests passed.");
g_console->WriteLine();
}
g_console->Flush();
#ifdef TARGET_OS_WINDOWS
system("pause");
#endif
delete g_console;
return retval;
}