Add test/cmake_install_test

This commit is contained in:
Peter Dimov
2026-02-05 17:56:15 +02:00
parent 084d1ddcb0
commit 40a194c511
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
# Copyright 2018, 2019 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
cmake_minimum_required(VERSION 3.5...3.31)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_xpressive REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Boost::xpressive)
enable_testing()
add_test(main main)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,25 @@
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/xpressive/xpressive.hpp>
#include <string>
using namespace boost::xpressive;
int main()
{
std::string hello( "hello world!" );
sregex rex = sregex::compile( "(\\w+) (\\w+)!" );
smatch what;
if( regex_match( hello, what, rex ) )
{
return what.size() == 3? 0: 1;
}
else
{
return 2;
}
}