0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 21:04:15 +08:00
sqlpp11/test_scripts/ddl2cpp.cpp

62 lines
1.4 KiB
C++
Raw Normal View History

2016-06-11 03:53:16 +08:00
#include <sqlpp11/sqlpp11.h>
2016-06-11 19:40:23 +08:00
#include <cassert>
2016-06-11 06:36:42 +08:00
//#include "MockDb.h" //todo 1
#include "ddl2cpp_test.h"
#include <iostream>
2016-06-11 07:10:14 +08:00
#include <string>
2016-06-11 19:40:23 +08:00
#include <fstream>
int testSqlFile(const std::string pathToSqlFile ){
2016-06-11 19:46:21 +08:00
#if defined _WIN64 || defined _WIN32
std::string nullOutput = " > nul 2>&1";
#else
std::string nullOutput = " > /dev/null 2>&1";
#endif
nullOutput = "";
std::string ddlHeaderPath = "../test_scripts/ddl2cpp_test_result_header";
2016-06-11 19:40:23 +08:00
std::string args =
" ../scripts/ddl2cpp -fail-on-parse " +
2016-06-11 19:46:21 +08:00
pathToSqlFile + " " +
ddlHeaderPath +
" ddlcpp2_test_namespace "+
nullOutput
;
2016-06-11 19:40:23 +08:00
auto python_args = test_scripts_pythonPath + args.c_str();
return system(python_args.c_str());
}
2016-06-11 03:53:16 +08:00
int ddl2cpp(int, char* [])
{
std::ifstream file("../scripts/ddl2cpp");
2016-06-11 19:40:23 +08:00
if (!file)
{
std::cout << "script tests should be started from the test_scripts directory.\n";
2016-06-11 19:40:23 +08:00
exit(1);
}
assert(0 == testSqlFile ("../test_scripts/ddl2cpp_sample_good.sql"));
assert(0 < testSqlFile ("../test_scripts/ddl2cpp_sample_bad.sql"));
2016-06-11 19:40:23 +08:00
/* maybe todo 1: test compile / use db_mock, for now we're just checking that ddl2cpp generates header without errors
2016-06-11 06:36:42 +08:00
*/
/*
MockDb db = {};
MockDb::_serializer_context_t printer = {};
const auto f = test::TabFoo{};
const auto t = test::TabBar{};
const auto tab_a = f.as(sqlpp::alias::a);
getColumn(db, t._epsilon); //underscore bug check
*/
2016-06-11 03:53:16 +08:00
return 0;
}
2016-06-11 06:36:42 +08:00