cypher_quries are moved to the tests folder and another part of CMakeLists file is written
This commit is contained in:
@@ -28,9 +28,13 @@ foreach(test_file ${test_files})
|
||||
endforeach()
|
||||
MESSAGE(STATUS "Available tests are: ${tests}")
|
||||
|
||||
# copy test data
|
||||
file(COPY ${CMAKE_SOURCE_DIR}/tests/data DESTINATION ${CMAKE_BINARY_DIR}/tests)
|
||||
|
||||
# build tests
|
||||
foreach(test ${tests})
|
||||
add_executable(${test} ${test}.cpp)
|
||||
target_link_libraries(${test} stdc++fs)
|
||||
add_test(NAME ${test} COMMAND ${test})
|
||||
set_property(TARGET ${test} PROPERTY CXX_STANDARD 14)
|
||||
endforeach()
|
||||
|
||||
@@ -4,27 +4,46 @@
|
||||
#include "cypher/compiler.hpp"
|
||||
#include "cypher/debug/tree_print.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
int calc(int i)
|
||||
std::vector<std::string> load_queries()
|
||||
{
|
||||
return i + 1;
|
||||
std::vector<std::string> queries;
|
||||
fs::path queries_path = "data/cypher_queries";
|
||||
for (auto& directory_entry :
|
||||
fs::recursive_directory_iterator(queries_path)) {
|
||||
if (!fs::is_regular_file(directory_entry))
|
||||
continue;
|
||||
std::ifstream infile(directory_entry.path().c_str());
|
||||
if (infile) {
|
||||
std::string file_text((std::istreambuf_iterator<char>(infile)),
|
||||
std::istreambuf_iterator<char>());
|
||||
queries.emplace_back(file_text);
|
||||
}
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
// TODO
|
||||
// auto print_visitor = new PrintVisitor(cout);
|
||||
auto queries = load_queries();
|
||||
|
||||
// // create AST
|
||||
// cypher::Compiler compiler;
|
||||
// auto tree = compiler.syntax_tree("MATCH (n) DELETE n");
|
||||
|
||||
// // traverser the tree
|
||||
// tree.root->accept(*print_visitor);
|
||||
//
|
||||
assert(calc(0) == 1);
|
||||
for (auto& query : queries) {
|
||||
auto print_visitor = new PrintVisitor(cout);
|
||||
cypher::Compiler compiler;
|
||||
auto tree = compiler.syntax_tree(query);
|
||||
tree.root->accept(*print_visitor);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1
tests/data/cypher_queries/read-write/match-delete.cypher
Normal file
1
tests/data/cypher_queries/read-write/match-delete.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (n) DELETE n
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (n {surname:"Neville"}) SET n.surname="Neville", n.age=30 RETURN n
|
||||
1
tests/data/cypher_queries/read-write/match-set.cypher
Normal file
1
tests/data/cypher_queries/read-write/match-set.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (n {age: 30, role: "player"}) SET n.age=31
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (n:Person) WHERE n.name="Alice" DELETE n
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (user:User { name: 'Dominik', age: 8 + 4})-[has:HAS|IS|CAN { duration: 'PERMANENT'}]->(item:Item)--(shop) RETURN shop
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (user:User { name: 'Dominik', age: 24})-[has:HAS]->(item:Item) WHERE item.name = 'XPS 13' AND item.price = 11999.99 RETURN user, has, item
|
||||
1
tests/data/cypher_queries/read/match/match-n-m.cypher
Normal file
1
tests/data/cypher_queries/read/match/match-n-m.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (n)-->(m) RETURN n
|
||||
@@ -0,0 +1 @@
|
||||
OPTIONAL MATCH (n)-[r]->(m) RETURN n
|
||||
1
tests/data/cypher_queries/read/match/match-path.cypher
Normal file
1
tests/data/cypher_queries/read/match/match-path.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH p = (n:Person)-->(m:Dog {name: 'Bos'}) RETURN p
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (n {name:'Alice'})-->(m) RETURN m
|
||||
1
tests/data/cypher_queries/read/match/match-where.cypher
Normal file
1
tests/data/cypher_queries/read/match/match-where.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (n:Person)-[:KNOWS]->(m:Person) WHERE n.name="Alice" RETURN m
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (n) RETURN n AS columnName
|
||||
1
tests/data/cypher_queries/read/return/return-all.cypher
Normal file
1
tests/data/cypher_queries/read/return/return-all.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (n) RETURN n
|
||||
@@ -0,0 +1 @@
|
||||
RETURN count(*)
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (n) RETURN DISTINCT n
|
||||
@@ -0,0 +1 @@
|
||||
LIMIT 10
|
||||
@@ -0,0 +1 @@
|
||||
ORDER BY n.property
|
||||
@@ -0,0 +1 @@
|
||||
ORDER BY n.property DESC
|
||||
@@ -0,0 +1 @@
|
||||
SKIP 2 LIMIT 3
|
||||
1
tests/data/cypher_queries/read/return/return-skip.cypher
Normal file
1
tests/data/cypher_queries/read/return/return-skip.cypher
Normal file
@@ -0,0 +1 @@
|
||||
SKIP 10
|
||||
1
tests/data/cypher_queries/read/union/union-all.cypher
Normal file
1
tests/data/cypher_queries/read/union/union-all.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION ALL MATCH (a)-[:LOVES]->(b) RETURN b.name
|
||||
1
tests/data/cypher_queries/read/union/union.cypher
Normal file
1
tests/data/cypher_queries/read/union/union.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION MATCH (a)-[:LOVES]->(b) RETURN b.name
|
||||
1
tests/data/cypher_queries/read/where/where.cypher
Normal file
1
tests/data/cypher_queries/read/where/where.cypher
Normal file
@@ -0,0 +1 @@
|
||||
MATCH n WHERE n.property <> "100"
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (user)-[:FRIEND]-(friend) WITH user, count(friend) AS friends ORDER BY friends DESC SKIP 1 LIMIT 3 RETURN user
|
||||
@@ -0,0 +1 @@
|
||||
MATCH (user)-[:FRIEND]-(friend) WHERE user.name = {name} WITH user, count(friend) AS friends WHERE friends > 10 RETURN user
|
||||
1
tests/data/cypher_queries/write/create-return.cypher
Normal file
1
tests/data/cypher_queries/write/create-return.cypher
Normal file
@@ -0,0 +1 @@
|
||||
CREATE (n {name: 'Domko', age: 26}) RETURN n
|
||||
1
tests/data/cypher_queries/write/create.cypher
Normal file
1
tests/data/cypher_queries/write/create.cypher
Normal file
@@ -0,0 +1 @@
|
||||
CREATE (n {name: "Roy", surname: "Keane"})
|
||||
Reference in New Issue
Block a user