-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestProgram.cpp
More file actions
130 lines (106 loc) · 4.29 KB
/
testProgram.cpp
File metadata and controls
130 lines (106 loc) · 4.29 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "video.h"
#include "videoFunction.h"
#include <iostream>
#include <filesystem>
#include <cassert>
#include <string>
#include <vector>
using namespace std;
// Function to compare two video files byte by byte
bool compareFiles(const string& filePath1, const string& filePath2) {
ifstream file1(filePath1, ios::binary);
ifstream file2(filePath2, ios::binary);
if (!file1.is_open() || !file2.is_open()) {
cerr << "Error opening files for comparison: "
<< filePath1 << " and " << filePath2 << endl;
return false;
}
istreambuf_iterator<char> it1(file1), it2(file2);
istreambuf_iterator<char> end;
return equal(it1, end, it2);
}
int main() {
string executable = "./runme ";
string testData = "data/test.bin ";
string outputPath = "data/TestOutput";
vector<string> commands = {
executable + testData + outputPath + "1.bin -M reverse",
executable + testData + outputPath + "2.bin -S reverse",
executable + testData + " " + outputPath + "3.bin reverse",
executable + testData + outputPath + "4.bin -M swap_channel 1,2",
executable + testData + outputPath + "5.bin -S swap_channel 1,2",
executable + testData + outputPath + "6.bin swap_channel 1,2",
executable + testData + outputPath + "7.bin -M clip_channel 1 [10,200]",
executable + testData + outputPath + "8.bin -S clip_channel 1 [10,200]",
executable + testData + outputPath + "9.bin clip_channel 1 [10,200]",
executable + testData + outputPath + "10.bin -M scale_channel 1 1.5",
executable + testData + outputPath + "11.bin -S scale_channel 1 1.5",
executable + testData + outputPath + "12.bin scale_channel 1 1.5",
executable + testData + outputPath + "13.bin -M invert_channel 1",
executable + testData + outputPath + "14.bin -S invert_channel 1",
executable + testData + outputPath + "15.bin invert_channel 1",
};
vector<string> errors;
for (const auto& command : commands) {
cout << "Executing: " << command << endl;
if (system(command.c_str()) != 0) {
string errorMessage = "Command failed: " + command;
cerr << errorMessage << endl;
errors.push_back(errorMessage);
}
}
vector<string> outputs = {
"data/TestOutput1.bin",
"data/TestOutput2.bin",
"data/TestOutput3.bin",
"data/TestOutput4.bin",
"data/TestOutput5.bin",
"data/TestOutput6.bin",
"data/TestOutput7.bin",
"data/TestOutput8.bin",
"data/TestOutput9.bin",
"data/TestOutput10.bin",
"data/TestOutput11.bin",
"data/TestOutput12.bin",
"data/TestOutput13.bin",
"data/TestOutput14.bin",
"data/TestOutput15.bin",
};
// Compare output files
for (size_t fileIndex = 0; fileIndex < outputs.size() - 1; fileIndex += 3) {
if (!compareFiles(outputs[fileIndex], outputs[fileIndex + 1])) {
string errorMessage = "Mismatch between "
+ outputs[fileIndex] + " and " + outputs[fileIndex + 1];
cerr << errorMessage << endl;
errors.push_back(errorMessage);
}
if (!compareFiles(outputs[fileIndex], outputs[fileIndex + 2])) {
string errorMessage = "Mismatch between "
+ outputs[fileIndex] + " and " + outputs[fileIndex + 2];
cerr << errorMessage << endl;
errors.push_back(errorMessage);
}
if (!compareFiles(outputs[fileIndex + 1], outputs[fileIndex + 2])) {
string errorMessage = "Mismatch between "
+ outputs[fileIndex + 1] + " and " + outputs[fileIndex + 2];
cerr << errorMessage << endl;
errors.push_back(errorMessage);
}
}
// Default test case
if (!compareFiles("data/test.bin", "data/test.bin")) {
string errorMessage = "Error: file is not equal to itself.";
cerr << errorMessage << endl;
errors.push_back(errorMessage);
}
// Report final results
if (!errors.empty()) {
cout << "\nTest completed with errors:" << endl;
for (const auto& error : errors) {
cout << " - " << error << endl;
}
return 1;
}
cout << "All tests passed! All outputs match." << endl;
return 0;
}