This repository was archived by the owner on Oct 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.h
More file actions
84 lines (73 loc) · 2.08 KB
/
testing.h
File metadata and controls
84 lines (73 loc) · 2.08 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
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
#ifndef Testing_H
#define Testing_H
#include <iostream>
#include <string>
#include "array.h"
using namespace std;
#define RED "\033[31m"
#define YELLOW "\033[33m"
#define RESET "\033[0m"
#define GREEN "\033[32m"
/*
All classes put into T and J must have overloads of
==
copy constructor
string to_string(T obj)
*/
template <class T, class J>
class Suite;
string to_string(string obj)
{
return obj;
}
template <class T, class J>
class Testing
{
private:
T *testObject; // used for the start of all tests as a base
// make a new test object copy
J *correctObject; // used for the start of all tests as a base
// make a new test object copy
Array<Suite<T, J>> *testSuites;
// T must have the == operator overloaded with itself to check validity.
// there will also be single value checks made as static functions for specific unit checks
public:
Testing(T testObject, J correctObject);
~Testing();
T *getTestObj();
J *getCorrectObj();
Suite<T, J> *getSuite(int i);
void createTestSuite(Array<string> testsToRun, string suiteName = "Test");
};
template <class T, class J>
class Suite
{
private:
int passes, fails;
string suiteName;
T *testObj;
J *correctObj;
// copy of the pointers made initially
public:
Suite(Array<string> &testsToRun, T *testObj, J *correctObj, string suiteName = "Test");
Suite(Array<string> &testsToRun, T testObj, J correctObj, string suiteName = "Test");
Suite(Suite<T, J> ©);
~Suite();
// prints the states upon deletion
void runTests(Array<string>& testsToRun);
void textCompare();
template <class X, class Y>
void textCompare(X &lhs, Y &rhs);
void equalsTest();
template <class X, class Y>
void equalsTest(X &lhs, Y &rhs);
T *getTestObj();
J *getCorrectObj();
void setTest(T *testObj);
void setCorrect(J *corrObj);
Suite<T, J> &operator=(Suite<T, J> ©);
static string printGreen(int &index, string tstString, string corString);
static string printRed(int &index, string tstString, string corString);
};
#include "testing.cpp"
#endif