From 5d64b4c23942c7c91792efa617bf67f7faac3488 Mon Sep 17 00:00:00 2001 From: karl Date: Sat, 20 Mar 2021 15:50:02 +0100 Subject: [PATCH] Add test application; fix linking issues with it --- SConstruct | 18 ++++++++++++------ include/Gedeng/Application.h | 1 + test/test-app/main.cpp | 16 ++++++++++++++++ test/{ => vector}/vector-test.cpp | 0 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 test/test-app/main.cpp rename test/{ => vector}/vector-test.cpp (100%) diff --git a/SConstruct b/SConstruct index b64ad3d..f03673c 100644 --- a/SConstruct +++ b/SConstruct @@ -8,19 +8,25 @@ env.Append(CCFLAGS=["-Wall", "-Wextra", "-Werror", "-pedantic"]) env.Append(CPPPATH=['cpp/', 'include/']) # Build the library -env.SharedLibrary('lib/ged', Glob('cpp/*.cpp')) +gedeng = env.SharedLibrary('lib/gedeng', Glob('cpp/*.cpp')) +env.Install('test/bin/lib/', gedeng) -# Build the test libraries +# Test environment setup testEnv = Environment(tools=['default', 'compilation_db']) testEnv.CompilationDatabase() testEnv.Append(CCFLAGS=["-Wall", "-Wextra", "-Werror", "-pedantic"]) -testEnv.Append(CPPPATH=['test/', 'include/']) +testEnv.Append(CPPPATH=['include/', 'test/']) testEnv.Append(LIBPATH=['lib/']) -testEnv.Append(LIBS=['ged']) +testEnv.Append(LIBS=['gedeng']) -testEnv.Append(CCFLAGS=["-Wall", "-Wextra", "-Werror", "-pedantic"]) +# Make the test executables search for the gedeng lib in their ./lib folder +testEnv.Append(LINKFLAGS=[ + '-Wl,--disable-new-dtags,-rpath,\'$$ORIGIN/lib/\'' +]) # Build the test programs catch_cpp = "test/catch_amalgamated.cpp" -testEnv.Program('test/bin/vector-test.out', [catch_cpp, 'test/vector-test.cpp']) +testEnv.Program('test/bin/vector-test.out', [catch_cpp, 'test/vector/vector-test.cpp']) + +testEnv.Program('test/bin/test-app.out', Glob('test/test-app/*.cpp')) diff --git a/include/Gedeng/Application.h b/include/Gedeng/Application.h index e1d5d45..da21645 100644 --- a/include/Gedeng/Application.h +++ b/include/Gedeng/Application.h @@ -3,6 +3,7 @@ namespace Gedeng { class Application { + public: Application() = default; // Virtual since this class will be inherited by user-created applications diff --git a/test/test-app/main.cpp b/test/test-app/main.cpp new file mode 100644 index 0000000..da731b1 --- /dev/null +++ b/test/test-app/main.cpp @@ -0,0 +1,16 @@ +#include + +class TestApp : public Gedeng::Application { + public: + TestApp() = default; + + ~TestApp() = default; +}; + +int main() { + TestApp *app = new TestApp(); + + app->run(); + + delete app; +} \ No newline at end of file diff --git a/test/vector-test.cpp b/test/vector/vector-test.cpp similarity index 100% rename from test/vector-test.cpp rename to test/vector/vector-test.cpp