ready for testing automation

This commit is contained in:
mrexodia 2016-06-05 13:00:55 +02:00
parent d211bf56a5
commit 2206f556c3
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
2 changed files with 21 additions and 4 deletions

View File

@ -494,8 +494,7 @@ bool TestLexer(const string & filename)
actual += line; actual += line;
})) }))
{ {
printf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str()); actual += StringUtils::sprintf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str());
return false;
} }
actual = StringUtils::Trim(actual); actual = StringUtils::Trim(actual);
string expected; string expected;
@ -522,7 +521,6 @@ void RunLexerTests()
bool DebugLexer(const string & filename) bool DebugLexer(const string & filename)
{ {
printf("Debugging \"%s\"\n", filename.c_str());
Lexer lexer; Lexer lexer;
if (!lexer.ReadInputFile("tests\\" + filename)) if (!lexer.ReadInputFile("tests\\" + filename))
{ {
@ -537,9 +535,27 @@ bool DebugLexer(const string & filename)
return true; return true;
} }
void GenerateExpected(const string & filename)
{
Lexer lexer;
if (!lexer.ReadInputFile("tests\\" + filename))
{
printf("failed to read \"%s\"\n", filename.c_str());
return;
}
string actual;
if (!lexer.TestLex([&](const string & line)
{
actual += line;
}))
{
actual += StringUtils::sprintf("lex error in \"%s\": %s\n", filename.c_str(), lexer.Error.c_str());
}
FileHelper::WriteAllText("tests\\expected\\" + filename + ".lextest", actual);
}
int main() int main()
{ {
DebugLexer(testFiles[82]);
RunLexerTests(); RunLexerTests();
system("pause"); system("pause");
return 0; return 0;

View File

@ -0,0 +1 @@
string test = "this is a test