Added negative test to runtests.pl
git-svn-id: http://svn.code.sf.net/p/utfcpp/code@36 a809a056-fc17-0410-9590-b4f493f8b08e
This commit is contained in:
parent
aad7fc0fef
commit
0ac74b9a49
2 changed files with 16 additions and 2 deletions
|
@ -4,9 +4,12 @@ using namespace utf8;
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const char* TEST_FILE_PATH = "../../test_data/negative/utf8_invalid.txt";
|
const char* TEST_FILE_PATH = "../../test_data/negative/utf8_invalid.txt";
|
||||||
|
const unsigned INVALID_LINES[] = { 75, 76, 82, 83, 84, 85, 93, 102, 103, 105, 106, 107, 108, 109, 110, 114, 115, 116, 117, 124, 125, 130, 135, 140, 145, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 169, 175, 176, 177, 207, 208, 209, 210, 211, 220, 221, 222, 223, 224, 232, 233, 234, 235, 236, 247, 248, 249, 250, 251, 252, 253, 257, 258, 259, 260, 261, 262, 263, 264, 268, 269};
|
||||||
|
const unsigned* INVALID_LINES_END = INVALID_LINES + sizeof(INVALID_LINES)/sizeof(unsigned);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +30,10 @@ int main()
|
||||||
|
|
||||||
line_count++;
|
line_count++;
|
||||||
// Print out lines that contain invalid UTF-8
|
// Print out lines that contain invalid UTF-8
|
||||||
if (!is_valid(line.begin(), line.end()))
|
if (!is_valid(line.begin(), line.end())) {
|
||||||
cout << line_count << ": " << line << '\n';
|
const unsigned* u = find(INVALID_LINES, INVALID_LINES_END, line_count);
|
||||||
|
if (u == INVALID_LINES_END)
|
||||||
|
cout << "Unexpected invalid utf-8 at line " << line_count << '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,3 +30,11 @@ chdir '..';
|
||||||
die if !open(REPORT, ">>$report_name");
|
die if !open(REPORT, ">>$report_name");
|
||||||
print REPORT "==================End of regression test==================\n";
|
print REPORT "==================End of regression test==================\n";
|
||||||
print REPORT "\n";
|
print REPORT "\n";
|
||||||
|
print REPORT "==================Negative Test ==================\n";
|
||||||
|
close($report_name);
|
||||||
|
chdir 'negative';
|
||||||
|
`./negative >> ../$report_name`;
|
||||||
|
chdir '..';
|
||||||
|
die if !open(REPORT, ">>$report_name");
|
||||||
|
print REPORT "==================End of negative test==================\n";
|
||||||
|
print REPORT "\n";
|
||||||
|
|
Loading…
Reference in a new issue