Add test/thread

This commit is contained in:
Peter Dimov
2018-10-05 18:29:13 +03:00
parent afbdd121d0
commit 3b941298df
2 changed files with 44 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# Copyright 2018 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
cmake_minimum_required(VERSION 3.5)
project(CmakeConfigThreadTest LANGUAGES CXX)
find_package(boost_thread 1.69.0 EXACT CONFIG)
add_executable(main quick.cpp)
target_link_libraries(main Boost::thread)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_test(main main)
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2017, 2018 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/thread.hpp>
#include <boost/core/lightweight_test.hpp>
void f( int & x, int y )
{
x = y;
}
int main()
{
int x = 0;
boost::thread th( f, boost::ref( x ), 12 );
th.join();
BOOST_TEST_EQ( x, 12 );
return boost::report_errors();
}