MXS-1296: Test that lc statements are parsed correctly

The transaction boundary parser - TrxBoundaryParser - must handle
upper and lowercase statements correctly.
This commit is contained in:
Johan Wikman
2017-06-26 08:52:20 +03:00
parent b29cda10a2
commit 500f79a150

View File

@ -12,6 +12,7 @@
*/
#include <maxscale/cppdefs.hh>
#include <algorithm>
#include <iostream>
#include <maxscale/modutil.h>
#include <maxscale/paths.h>
@ -69,6 +70,7 @@ struct test_case
uint32_t type_mask;
} test_cases[] =
{
// Keep these all uppercase, lowercase are tested programmatically.
{ "BEGIN", QUERY_TYPE_BEGIN_TRX },
{ "BEGIN WORK", QUERY_TYPE_BEGIN_TRX },
@ -299,14 +301,23 @@ bool test(uint32_t (*getter)(GWBUF*), bool dont_bail_out)
string base(pTest->zStmt);
cout << base << endl;
string s;
s = base;
if (!test(getter, s.c_str(), pTest->type_mask))
if (!test(getter, base.c_str(), pTest->type_mask))
{
rc = false;
}
if (dont_bail_out || rc)
{
// Test all lowercase.
string lc(base);
transform(lc.begin(), lc.end(), lc.begin(), ::tolower);
if (!test(getter, lc.c_str(), pTest->type_mask))
{
rc = false;
}
}
if (dont_bail_out || rc)
{
if (!test_with_prefixes(getter, base, pTest->type_mask))