diff --git a/.travis.yml b/.travis.yml index fe4a470..d69e00d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ +language: cpp + install: - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo apt-get -qq update @@ -9,12 +11,9 @@ install: - which g++ - g++ -v -language: cpp - compiler: - gcc script: - make - - sudo make install - - make test \ No newline at end of file + - make test diff --git a/Makefile b/Makefile index 8bb3149..7b55b72 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,11 @@ format: test: $(BIN)/sql_tests $(BIN)/sql_grammar_test bash test/test.sh +# test whete +test_install: + make -C example/ + ./example/example "SELECT * FROM students WHERE name = 'Max Mustermann';" + $(BIN)/sql_tests: library @mkdir -p $(BIN)/ $(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser diff --git a/example/example.cpp b/example/example.cpp index f5c1ab2..008c92e 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -16,20 +16,21 @@ int main(int argc, char *argv[]) { std::string query = argv[1]; // parse a given query - hsql::SQLStatementList* result = hsql::SQLParser::parseSQLString(query); + hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query); // check whether the parsing was successful if (result->isValid) { printf("Parsed successfully!\n"); - printf("Number of statements: %lu\n", result->numStatements()); + printf("Number of statements: %lu\n", result->size()); for (hsql::SQLStatement* stmt : result->statements) { // process the statements... hsql::printStatementInfo(stmt); } + + return 0; } else { printf("Invalid SQL!\n"); + return -1; } - - return 0; } \ No newline at end of file diff --git a/test/test.sh b/test/test.sh index edf80fd..3df2e42 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,3 +1,4 @@ +#!/bin/bash # has to be executed from the root of the repository export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./