-
Notifications
You must be signed in to change notification settings - Fork 0
/
lcmp.cpp
54 lines (39 loc) · 1.13 KB
/
lcmp.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
// https://github.com/MikeMirzayanov/testlib/blob/master/checkers/lcmp.cpp
#include "testlib.h"
#include <string>
#include <vector>
#include <sstream>
using namespace std;
bool compareWords(const string& a, const string& b) {
vector<string> va, vb;
stringstream sa;
sa << a;
string cur;
while (sa >> cur)
va.push_back(cur);
stringstream sb;
sb << b;
while (sb >> cur)
vb.push_back(cur);
return (va == vb);
}
int main(int argc, char *argv[]) {
setName("compare files as sequence of tokens in lines");
registerTestlibCmd(argc, argv);
string strAnswer;
int n = 0;
while (!ans.eof()) {
std::string j = ans.readString();
if (j.empty() && ans.eof())
break;
string p = ouf.readString();
strAnswer = p;
n++;
if (!compareWords(j, p))
quitf(_wa, "%d%s lines differ - expected: '%s', found: '%s'", n, englishEnding(n).c_str(),
compress(j).c_str(), compress(p).c_str());
}
if (n == 1)
quitf(_ok, "single line: '%s'", compress(strAnswer).c_str());
quitf(_ok, "%d lines", n);
}