Commit 2d04ee39 authored by Bart van der Velden's avatar Bart van der Velden

Prepare for unit tests on main etc in the root source directory (#53)

parent 371ba541
......@@ -28,7 +28,6 @@ namespace po = boost::program_options;
static const char* DefaultLogFile = "mc";
static const char* DefaultConfigFile = "musiccollection.cfg";
static const char* CopyrightNotice = "Copyright 2012-2014 Bart van der Velden";
void AddErrorMessage(string& orgMessage, const string& newMessage)
{
......
if(test)
# Where Google Test's libraries can be found.
set(gtest_link_dir ${gtest_BINARY_DIR}/../lib/Debug)
link_directories(${gtest_link_dir})
if(CMAKE_DEBUG)
message(STATUS "include directories:")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
message(STATUS "link directories:")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LINK_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
message(STATUS "gtest_BINARY_DIR: " ${gtest_BINARY_DIR})
endif()
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
# As moc files are generated in the binary dir, tell CMake to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Widgets finds its own dependencies (QtGui and QtCore).
find_package(Qt5Core 5.0 REQUIRED)
include_directories(SYSTEM ${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${QtWidgets_DEFINITIONS})
set(INCLUDES
../HandleCommandLine.h
../version.h
)
set(SOURCES
HandleCommandLine_test.cpp ../HandleCommandLine.cpp
${PROJECT_BINARY_DIR}/src/version.cpp
)
add_executable(
runMusicCollectionTest
${SOURCES}
${INCLUDES}
${gtest_SOURCE_DIR}/src/gtest_main.cc)
target_link_libraries(runMusicCollectionTest gtest ${TAGLIB_LIBRARIES})
qt5_use_modules(runMusicCollectionTest Core)
add_test(NAME MusicCollectionTest COMMAND runMusicCollectionTest)
endif()
\ No newline at end of file
#include <gtest/gtest.h>
#include "../HandleCommandLine.h"
using namespace std;
namespace fs = boost::filesystem;
TEST(HandleCommandLineTest, EmptyPath)
{
vector<fs::path> directories;
fs::path logfile;
string message;
auto result = HandleCommandLine(0, 0, directories, logfile, message);
EXPECT_EQ(false, result);
}
TEST(HandleCommandLineTest, OneArg)
{
vector<fs::path> directories;
fs::path logfile;
string message;
vector<char*> args;
args.push_back("--directory");
args.push_back("c:\temp");
auto result = HandleCommandLine(2, &args[0], directories, logfile, message);
EXPECT_EQ(false, result);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment