cypher_quries are moved to the tests folder and another part of CMakeLists file is written

This commit is contained in:
Marko Budiselic
2016-05-23 07:51:36 +02:00
parent 8aed81de38
commit 18838f5318
30 changed files with 89 additions and 13 deletions

View File

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

View File

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

View File

@@ -0,0 +1 @@
MATCH (n) DELETE n

View File

@@ -0,0 +1 @@
MATCH (n {surname:"Neville"}) SET n.surname="Neville", n.age=30 RETURN n

View File

@@ -0,0 +1 @@
MATCH (n {age: 30, role: "player"}) SET n.age=31

View File

@@ -0,0 +1 @@
MATCH (n:Person) WHERE n.name="Alice" DELETE n

View File

@@ -0,0 +1 @@
MATCH (user:User { name: 'Dominik', age: 8 + 4})-[has:HAS|IS|CAN { duration: 'PERMANENT'}]->(item:Item)--(shop) RETURN shop

View File

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

View File

@@ -0,0 +1 @@
MATCH (n)-->(m) RETURN n

View File

@@ -0,0 +1 @@
OPTIONAL MATCH (n)-[r]->(m) RETURN n

View File

@@ -0,0 +1 @@
MATCH p = (n:Person)-->(m:Dog {name: 'Bos'}) RETURN p

View File

@@ -0,0 +1 @@
MATCH (n {name:'Alice'})-->(m) RETURN m

View File

@@ -0,0 +1 @@
MATCH (n:Person)-[:KNOWS]->(m:Person) WHERE n.name="Alice" RETURN m

View File

@@ -0,0 +1 @@
MATCH (n) RETURN n AS columnName

View File

@@ -0,0 +1 @@
MATCH (n) RETURN n

View File

@@ -0,0 +1 @@
RETURN count(*)

View File

@@ -0,0 +1 @@
MATCH (n) RETURN DISTINCT n

View File

@@ -0,0 +1 @@
LIMIT 10

View File

@@ -0,0 +1 @@
ORDER BY n.property

View File

@@ -0,0 +1 @@
ORDER BY n.property DESC

View File

@@ -0,0 +1 @@
SKIP 2 LIMIT 3

View File

@@ -0,0 +1 @@
SKIP 10

View File

@@ -0,0 +1 @@
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION ALL MATCH (a)-[:LOVES]->(b) RETURN b.name

View File

@@ -0,0 +1 @@
MATCH (a)-[:KNOWS]->(b) RETURN b.name UNION MATCH (a)-[:LOVES]->(b) RETURN b.name

View File

@@ -0,0 +1 @@
MATCH n WHERE n.property <> "100"

View File

@@ -0,0 +1 @@
MATCH (user)-[:FRIEND]-(friend) WITH user, count(friend) AS friends ORDER BY friends DESC SKIP 1 LIMIT 3 RETURN user

View File

@@ -0,0 +1 @@
MATCH (user)-[:FRIEND]-(friend) WHERE user.name = {name} WITH user, count(friend) AS friends WHERE friends > 10 RETURN user

View File

@@ -0,0 +1 @@
CREATE (n {name: 'Domko', age: 26}) RETURN n

View File

@@ -0,0 +1 @@
CREATE (n {name: "Roy", surname: "Keane"})