Resolves T46; CMake + CTest setup
This commit is contained in:
parent
75300ecebd
commit
8aed81de38
24
CMakeLists.txt
Normal file
24
CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
# set directory name as the project name
|
||||||
|
# get directory name
|
||||||
|
get_filename_component(ProjectId ${CMAKE_SOURCE_DIR} NAME)
|
||||||
|
# replace whitespaces with underscores
|
||||||
|
string(REPLACE " " "_" ProjectId ${ProjectId})
|
||||||
|
# set project name
|
||||||
|
project(${ProjectId})
|
||||||
|
|
||||||
|
INCLUDE(ExternalProject)
|
||||||
|
|
||||||
|
# compiler options
|
||||||
|
SET(COMPILE_OPTIONS "-O0 -g3 -Wall -Werror -fmessage-length=0")
|
||||||
|
|
||||||
|
# add all cpp file recursive into sourceFiles varibale
|
||||||
|
FILE(GLOB_RECURSE sourceFiles ${CMAKE_HOME_DIRECTORY}/src/*.cpp)
|
||||||
|
|
||||||
|
# print list of source files
|
||||||
|
# MESSAGE(STATUS "All source files are: ${sourceFiles}")
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_HOME_DIRECTORY}/src)
|
||||||
|
ENABLE_TESTING()
|
||||||
|
ADD_SUBDIRECTORY(tests)
|
2
libs/.gitignore
vendored
Normal file
2
libs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*
|
||||||
|
!.gitignore
|
@ -7,6 +7,5 @@ namespace config
|
|||||||
|
|
||||||
constexpr const char * COMPILE_CPU_PATH = "compile_cpu_path";
|
constexpr const char * COMPILE_CPU_PATH = "compile_cpu_path";
|
||||||
constexpr const char * TEMPLATE_CPU_CPP_PATH = "template_cpu_cpp_path";
|
constexpr const char * TEMPLATE_CPU_CPP_PATH = "template_cpu_cpp_path";
|
||||||
constexpr const char * TEMPLATE_CPU_HPP_PATH = "template_cpu_hpp_path";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
Entry(Printer& printer) : printer(printer), valid(true)
|
Entry(Printer& printer) : printer(printer), valid(true)
|
||||||
{
|
{
|
||||||
printer.level++;
|
printer.level++;
|
||||||
|
|
||||||
for(size_t i = 1; i < printer.level; ++i)
|
for(size_t i = 1; i < printer.level; ++i)
|
||||||
printer.stream << "| ";
|
printer.stream << "| ";
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entry(const Entry&) = delete;
|
Entry(const Entry&) = delete;
|
||||||
|
|
||||||
Entry(Entry&& other) : printer(other.printer), valid(true)
|
Entry(Entry&& other) : printer(other.printer), valid(true)
|
||||||
{
|
{
|
||||||
other.valid = false;
|
other.valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Entry()
|
~Entry()
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@ -87,7 +87,7 @@ public:
|
|||||||
auto entry = printer.advance("Start");
|
auto entry = printer.advance("Start");
|
||||||
Traverser::visit(start);
|
Traverser::visit(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void visit(ast::ReadQuery& read_query) override
|
void visit(ast::ReadQuery& read_query) override
|
||||||
{
|
{
|
||||||
auto entry = printer.advance("Read Query");
|
auto entry = printer.advance("Read Query");
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
@ -27,12 +28,14 @@ private:
|
|||||||
// 3. ENV var |
|
// 3. ENV var |
|
||||||
// 4. program argument \ /
|
// 4. program argument \ /
|
||||||
// _config = YAML::LoadFile("config.yaml");
|
// _config = YAML::LoadFile("config.yaml");
|
||||||
|
|
||||||
|
// env -> std::getenv("NAME")
|
||||||
|
// somehow inject (int argc, char* argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Config& instance()
|
static Config& instance()
|
||||||
{
|
{
|
||||||
// TODO resolve multithreading problems
|
|
||||||
static Config config;
|
static Config config;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
36
tests/CMakeLists.txt
Normal file
36
tests/CMakeLists.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
project(memgraph_tests)
|
||||||
|
|
||||||
|
# setup dependencies
|
||||||
|
|
||||||
|
# Catch (C++ Automated Test Cases in Headers) dependency
|
||||||
|
ExternalProject_Add(
|
||||||
|
Catch
|
||||||
|
GIT_REPOSITORY "https://github.com/philsquared/Catch.git"
|
||||||
|
GIT_TAG "master"
|
||||||
|
SOURCE_DIR "${CMAKE_SOURCE_DIR}/libs/Catch"
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
TEST_COMMAND ""
|
||||||
|
)
|
||||||
|
ExternalProject_Get_Property(Catch source_dir)
|
||||||
|
set(catch_source_dir ${source_dir})
|
||||||
|
include_directories(${catch_source_dir}/include)
|
||||||
|
|
||||||
|
# find tests
|
||||||
|
file(GLOB_RECURSE test_files ${CMAKE_HOME_DIRECTORY}/tests/*.cpp)
|
||||||
|
set(tests "")
|
||||||
|
foreach(test_file ${test_files})
|
||||||
|
get_filename_component(test_name ${test_file} NAME_WE)
|
||||||
|
list(APPEND tests ${test_name})
|
||||||
|
endforeach()
|
||||||
|
MESSAGE(STATUS "Available tests are: ${tests}")
|
||||||
|
|
||||||
|
# build tests
|
||||||
|
foreach(test ${tests})
|
||||||
|
add_executable(${test} ${test}.cpp)
|
||||||
|
add_test(NAME ${test} COMMAND ${test})
|
||||||
|
set_property(TARGET ${test} PROPERTY CXX_STANDARD 14)
|
||||||
|
endforeach()
|
30
tests/cypher_traversal.cpp
Normal file
30
tests/cypher_traversal.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "cypher/compiler.hpp"
|
||||||
|
#include "cypher/debug/tree_print.hpp"
|
||||||
|
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
|
int calc(int i)
|
||||||
|
{
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
// auto print_visitor = new PrintVisitor(cout);
|
||||||
|
|
||||||
|
// // 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);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
20
tests/dynamic_bitset.cpp
Normal file
20
tests/dynamic_bitset.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#include "data_structures/bitset/dynamic_bitset.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("Dynamic bitset basic functionality")
|
||||||
|
{
|
||||||
|
DynamicBitset<> db;
|
||||||
|
db.set(222555, 1);
|
||||||
|
bool value = db.at(222555, 1);
|
||||||
|
REQUIRE(value == true);
|
||||||
|
|
||||||
|
db.set(32, 1);
|
||||||
|
value = db.at(32, 1);
|
||||||
|
REQUIRE(value == true);
|
||||||
|
|
||||||
|
db.clear(32, 1);
|
||||||
|
value = db.at(32, 1);
|
||||||
|
REQUIRE(value == false);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user