0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-16 04:47:18 +08:00
sqlpp11/test_scripts/ddl2cpp.cpp
2016-06-12 22:34:26 +03:00

64 lines
1.5 KiB
C++

#include <sqlpp11/sqlpp11.h>
#include <cassert>
//#include "MockDb.h" //todo 1
#include "ddl2cpp_test.h"
#include <iostream>
#include <string>
#include <fstream>
int testSqlFile(const std::string pathToSqlFile ){
#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";
std::string args =
" ../scripts/ddl2cpp -fail-on-parse " +
pathToSqlFile + " " +
ddlHeaderPath +
" ddlcpp2_test_namespace "+
nullOutput
;
auto python_args = test_scripts_pythonPath + args.c_str();
return system(python_args.c_str());
}
int ddl2cpp(int, char* [])
{
#ifndef __MACH__
std::ifstream file("../scripts/ddl2cpp");
if (!file)
{
std::cout << "script tests should be started from the top level sqlpp11 directory. Where scripts/ dir is found\n";
exit(1);
}
assert(testSqlFile ("../test_scripts/ddl2cpp_sample_good.sql") == 0);
assert(testSqlFile ("../test_scripts/ddl2cpp_sample_bad.sql") > 0);
/* maybe todo 1: test compile / use db_mock, for now we're just checking that ddl2cpp generates header without errors
*/
/*
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
*/
#endif
return 0;
}