add test for installed library
This commit is contained in:
parent
ad072dd79d
commit
ef7c3cf349
|
@ -1,4 +1,6 @@
|
||||||
|
|
||||||
|
language: cpp
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||||
- sudo apt-get -qq update
|
- sudo apt-get -qq update
|
||||||
|
@ -9,12 +11,9 @@ install:
|
||||||
- which g++
|
- which g++
|
||||||
- g++ -v
|
- g++ -v
|
||||||
|
|
||||||
language: cpp
|
|
||||||
|
|
||||||
compiler:
|
compiler:
|
||||||
- gcc
|
- gcc
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make
|
- make
|
||||||
- sudo make install
|
- make test
|
||||||
- make test
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -62,6 +62,11 @@ format:
|
||||||
test: $(BIN)/sql_tests $(BIN)/sql_grammar_test
|
test: $(BIN)/sql_tests $(BIN)/sql_grammar_test
|
||||||
bash test/test.sh
|
bash test/test.sh
|
||||||
|
|
||||||
|
# test whete
|
||||||
|
test_install:
|
||||||
|
make -C example/
|
||||||
|
./example/example "SELECT * FROM students WHERE name = 'Max Mustermann';"
|
||||||
|
|
||||||
$(BIN)/sql_tests: library
|
$(BIN)/sql_tests: library
|
||||||
@mkdir -p $(BIN)/
|
@mkdir -p $(BIN)/
|
||||||
$(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser
|
$(CC) $(CTESTFLAGS) $(TESTCPP) test/sql_tests.cpp -o $(BIN)/sql_tests -lsqlparser
|
||||||
|
|
|
@ -16,20 +16,21 @@ int main(int argc, char *argv[]) {
|
||||||
std::string query = argv[1];
|
std::string query = argv[1];
|
||||||
|
|
||||||
// parse a given query
|
// parse a given query
|
||||||
hsql::SQLStatementList* result = hsql::SQLParser::parseSQLString(query);
|
hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query);
|
||||||
|
|
||||||
// check whether the parsing was successful
|
// check whether the parsing was successful
|
||||||
if (result->isValid) {
|
if (result->isValid) {
|
||||||
printf("Parsed successfully!\n");
|
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) {
|
for (hsql::SQLStatement* stmt : result->statements) {
|
||||||
// process the statements...
|
// process the statements...
|
||||||
hsql::printStatementInfo(stmt);
|
hsql::printStatementInfo(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
printf("Invalid SQL!\n");
|
printf("Invalid SQL!\n");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
# has to be executed from the root of the repository
|
# has to be executed from the root of the repository
|
||||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
|
||||||
|
|
Loading…
Reference in New Issue