mirror of
https://github.com/boostorg/boost_install.git
synced 2026-07-21 13:13:30 +00:00
Add test/thread
This commit is contained in:
@@ -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)
|
||||
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user