Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ project (ccsh)

option(WITH_LIB "Compile shared library." ON)
option(WITH_CLING "Compile cling front-end (interactive shell) as well, requires cling at /opt/cling." ON)
option(WITH_SAMPLE "Compile sample code as well, not required for release." ON)
option(WITH_TEST "Compile test code as well, not required for release." ON)

option(BOOST_FILESYSTEM "Use boost::filesystem instead of std::[experimental::]filesystem" OFF)
Expand All @@ -22,6 +23,10 @@ if(WITH_LIB)
add_subdirectory(lib)
endif()

if(WITH_SAMPLE)
add_subdirectory(sample)
endif()

if(WITH_TEST)
add_subdirectory(test)
endif()
Expand Down
12 changes: 12 additions & 0 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required (VERSION 2.6)

add_subdirectory(./../lib ccsh_lib)

include_directories(${SHARED_LIB_INCLUDE_DIR})
include_directories(${WRAPPERS_INCLUDE_DIR})

file(GLOB_RECURSE wrappers ../wrappers/*.hpp)

add_executable(ccsh_sample main.cpp ${wrappers})
target_link_libraries( ccsh_sample PUBLIC ccsh_lib ${filesystem_lib})
target_compile_options(ccsh_sample PUBLIC -std=c++11 -Wall -Wextra -pedantic -O0 -g -ggdb)
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ include_directories(${SHARED_LIB_INCLUDE_DIR})
include_directories(${WRAPPERS_INCLUDE_DIR})

file(GLOB_RECURSE wrappers ../wrappers/*.hpp)
file(GLOB_RECURSE tests test*.cpp)

add_executable(ccsh_test main.cpp ${wrappers})
target_link_libraries( ccsh_test PUBLIC ccsh_lib ${filesystem_lib})
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

add_executable(ccsh_test ${tests} ${wrappers})
target_link_libraries( ccsh_test PUBLIC ccsh_lib ${filesystem_lib} ${GTEST_BOTH_LIBRARIES})
target_compile_options(ccsh_test PUBLIC -std=c++11 -Wall -Wextra -pedantic -O0 -g -ggdb)
37 changes: 37 additions & 0 deletions test/test1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <ccsh/ccsh.hpp>
#include <cstdio>
#include <string>
#include <fstream>

#include <gtest/gtest.h>

using namespace ccsh;

std::string ReadAllText(fs::path filename)
{
std::ifstream t(filename.c_str());
return std::string(std::istreambuf_iterator<char>(t),
std::istreambuf_iterator<char>());
}

TEST(NativeTest, CopyRemoveFile)
{
fs::path example_path1{__FILE__};
fs::path example_path2 = example_path1.parent_path() / "example1.file";

std::string example_content1 = ReadAllText(example_path1);
EXPECT_NE(example_content1, "");

shell("rm", {example_path2.string()});
EXPECT_EQ(fs::exists(example_path2), false);

shell("cp", {example_path1.string(), example_path2.string()});
EXPECT_EQ(fs::exists(example_path2), true);

fs::path example_content2 = ReadAllText(example_path2);
EXPECT_EQ(example_content1, example_content2);

shell("rm", {example_path2.string()});
EXPECT_EQ(fs::exists(example_path2), false);
}

13 changes: 13 additions & 0 deletions test/test2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <ccsh/ccsh.hpp>
#include <cstdio>
#include <string>
#include <fstream>

#include <gtest/gtest.h>

using namespace ccsh;

TEST(DummyTest, Dummy)
{
EXPECT_EQ(true, true);
}