add test for installed library

This commit is contained in:
Pedro 2016-02-27 16:40:24 +01:00
parent ad072dd79d
commit ef7c3cf349
4 changed files with 14 additions and 8 deletions

View File

@ -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
- make test

View File

@ -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

View File

@ -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;
}

View File

@ -1,3 +1,4 @@
#!/bin/bash
# has to be executed from the root of the repository
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./