From 4cd3a9cdf65a8f0b96de21420b98b8e02181e4f4 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 30 Mar 2026 11:49:10 +0200 Subject: move testing-only things into test/ --- test/examples/boost/CMakeLists.txt | 12 ++++++++++++ test/examples/boost/foo.cpp | 13 +++++++++++++ test/examples/boost/run.ps1 | 24 ++++++++++++++++++++++++ test/examples/simple/CMakeLists.txt | 11 +++++++++++ test/examples/simple/baz.cpp | 7 +++++++ test/examples/simple/baz.hpp | 9 +++++++++ test/examples/simple/foo.cpp | 9 +++++++++ 7 files changed, 85 insertions(+) create mode 100644 test/examples/boost/CMakeLists.txt create mode 100644 test/examples/boost/foo.cpp create mode 100644 test/examples/boost/run.ps1 create mode 100644 test/examples/simple/CMakeLists.txt create mode 100644 test/examples/simple/baz.cpp create mode 100644 test/examples/simple/baz.hpp create mode 100644 test/examples/simple/foo.cpp (limited to 'test/examples') diff --git a/test/examples/boost/CMakeLists.txt b/test/examples/boost/CMakeLists.txt new file mode 100644 index 0000000..0e92e38 --- /dev/null +++ b/test/examples/boost/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) + +project(example_boost) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(Boost REQUIRED COMPONENTS filesystem) +add_executable(foo foo.cpp) +target_link_libraries(foo PRIVATE Boost::disable_autolinking Boost::filesystem) + +install(TARGETS foo RUNTIME DESTINATION bin) diff --git a/test/examples/boost/foo.cpp b/test/examples/boost/foo.cpp new file mode 100644 index 0000000..6219e68 --- /dev/null +++ b/test/examples/boost/foo.cpp @@ -0,0 +1,13 @@ +#include + +#include + +int main(int argc, char* argv[]) { + namespace fs = boost::filesystem; + std::cout << argv[0] << '\n'; + for (int i = 1; i < argc; ++i) { + std::cout << fs::absolute(boost::filesystem::path{argv[i]}).string() + << '\n'; + } + return 0; +} diff --git a/test/examples/boost/run.ps1 b/test/examples/boost/run.ps1 new file mode 100644 index 0000000..578911f --- /dev/null +++ b/test/examples/boost/run.ps1 @@ -0,0 +1,24 @@ +param( + [Parameter(Mandatory=$true)] + [string] $FooPath +) + +$foo_path = [System.IO.Path]::GetFullPath($FooPath) +if ($IsWindows) { + $foo_path += '.exe' +} + +$relative = 'test.txt' +$absolute = Join-Path (Get-Location).Path $relative + +$actual = & $foo_path $relative +echo 'Actual output:' +echo $actual + +$expected = $foo_path,$absolute +echo 'Expected output:' +echo $expected + +if (Compare-Object $actual $expected -CaseSensitive) { + throw 'Unexpected output' +} diff --git a/test/examples/simple/CMakeLists.txt b/test/examples/simple/CMakeLists.txt new file mode 100644 index 0000000..50a588b --- /dev/null +++ b/test/examples/simple/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) + +project(example_simple) + +add_library(baz SHARED baz.cpp) +target_include_directories(baz PUBLIC .) + +add_executable(foo foo.cpp) +target_link_libraries(foo PRIVATE baz) + +install(TARGETS foo baz RUNTIME DESTINATION bin LIBRARY DESTINATION lib) diff --git a/test/examples/simple/baz.cpp b/test/examples/simple/baz.cpp new file mode 100644 index 0000000..d108ae3 --- /dev/null +++ b/test/examples/simple/baz.cpp @@ -0,0 +1,7 @@ +#include "baz.hpp" + +#include + +void baz() { + std::cout << "baz\n"; +} diff --git a/test/examples/simple/baz.hpp b/test/examples/simple/baz.hpp new file mode 100644 index 0000000..2fc9b2a --- /dev/null +++ b/test/examples/simple/baz.hpp @@ -0,0 +1,9 @@ +#pragma once + +#ifdef _MSC_VER +#define DLLEXPORT __declspec(dllexport) +#else +#define DLLEXPORT +#endif + +DLLEXPORT void baz(); diff --git a/test/examples/simple/foo.cpp b/test/examples/simple/foo.cpp new file mode 100644 index 0000000..7e928e1 --- /dev/null +++ b/test/examples/simple/foo.cpp @@ -0,0 +1,9 @@ +#include + +#include + +int main() { + std::cout << "foo\n"; + baz(); + return 0; +} -- cgit v1.3