1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-08 23:36:34 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

View File

View File

@@ -0,0 +1,281 @@
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
local library = "assert";
local triggers =
{
branch: [ "master", "develop", "feature/*" ]
};
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
local asan = { ASAN: '1' };
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "linux",
arch: arch
},
steps:
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'set -e',
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
] +
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "exec",
trigger: triggers,
platform: {
"os": "darwin",
"arch": arch
},
node: {
"os": osx_version
},
steps: [
{
name: "everything",
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
commands:
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local windows_pipeline(name, image, environment, arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "windows",
arch: arch
},
"steps":
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'cmd /C .drone\\\\drone.bat ' + library,
]
}
]
};
[
linux_pipeline(
"Linux 14.04 GCC 4.4",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
"g++-4.4",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.6",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x' },
"g++-4.6",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.7",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x' },
"g++-4.7",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.8*",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11' },
),
linux_pipeline(
"Linux 14.04 GCC 4.9",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
"g++-4.9",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 16.04 GCC 5*",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' },
),
linux_pipeline(
"Linux 18.04 GCC 6",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' },
"g++-6",
),
linux_pipeline(
"Linux 18.04 GCC 7* 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 18.04 GCC 8",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' },
"g++-8",
),
linux_pipeline(
"Linux 20.04 GCC 9* 32",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
),
linux_pipeline(
"Linux 20.04 GCC 9* 64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
),
linux_pipeline(
"Linux 20.04 GCC 9 ARM64 32/64",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
arch="arm64",
),
linux_pipeline(
"Linux 20.04 GCC 10 32 ASAN",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan,
"g++-10-multilib",
),
linux_pipeline(
"Linux 20.04 GCC 10 64 ASAN",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan,
"g++-10-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11,14' },
"clang-3.5",
),
linux_pipeline(
"Linux 16.04 Clang 3.6",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
"clang-3.6",
),
linux_pipeline(
"Linux 16.04 Clang 3.7",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
"clang-3.7",
),
linux_pipeline(
"Linux 16.04 Clang 3.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
"clang-3.8",
),
linux_pipeline(
"Linux 20.04 Clang 13",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
"clang-13",
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"],
),
linux_pipeline(
"Linux 20.04 Clang 14 UBSAN",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
"clang-14",
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
),
linux_pipeline(
"Linux 20.04 Clang 14 ASAN",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
"clang-14",
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
),
windows_pipeline(
"Windows VS2015 msvc-14.0",
"cppalliance/dronevs2015",
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' },
),
windows_pipeline(
"Windows VS2017 msvc-14.1",
"cppalliance/dronevs2017",
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
),
windows_pipeline(
"Windows VS2019 msvc-14.2",
"cppalliance/dronevs2019",
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2022 msvc-14.3",
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
]

View File

@@ -0,0 +1,23 @@
@REM Copyright 2022 Peter Dimov
@REM Distributed under the Boost Software License, Version 1.0.
@REM https://www.boost.org/LICENSE_1_0.txt
@ECHO ON
set LIBRARY=%1
set DRONE_BUILD_DIR=%CD%
set BOOST_BRANCH=develop
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
python tools/boostdep/depinst/depinst.py %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
set -ex
DRONE_BUILD_DIR=$(pwd)
BOOST_BRANCH=develop
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
python tools/boostdep/depinst/depinst.py $LIBRARY
./bootstrap.sh
./b2 -d0 headers
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}

View File

@@ -0,0 +1,96 @@
* text=auto !eol svneol=native#text/plain
*.gitattributes text svneol=native#text/plain
# Scriptish formats
*.bat text svneol=native#text/plain
*.bsh text svneol=native#text/x-beanshell
*.cgi text svneol=native#text/plain
*.cmd text svneol=native#text/plain
*.js text svneol=native#text/javascript
*.php text svneol=native#text/x-php
*.pl text svneol=native#text/x-perl
*.pm text svneol=native#text/x-perl
*.py text svneol=native#text/x-python
*.sh eol=lf svneol=LF#text/x-sh
configure eol=lf svneol=LF#text/x-sh
# Image formats
*.bmp binary svneol=unset#image/bmp
*.gif binary svneol=unset#image/gif
*.ico binary svneol=unset#image/ico
*.jpeg binary svneol=unset#image/jpeg
*.jpg binary svneol=unset#image/jpeg
*.png binary svneol=unset#image/png
*.tif binary svneol=unset#image/tiff
*.tiff binary svneol=unset#image/tiff
*.svg text svneol=native#image/svg%2Bxml
# Data formats
*.pdf binary svneol=unset#application/pdf
*.avi binary svneol=unset#video/avi
*.doc binary svneol=unset#application/msword
*.dsp text svneol=crlf#text/plain
*.dsw text svneol=crlf#text/plain
*.eps binary svneol=unset#application/postscript
*.gz binary svneol=unset#application/gzip
*.mov binary svneol=unset#video/quicktime
*.mp3 binary svneol=unset#audio/mpeg
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
*.ps binary svneol=unset#application/postscript
*.psd binary svneol=unset#application/photoshop
*.rdf binary svneol=unset#text/rdf
*.rss text svneol=unset#text/xml
*.rtf binary svneol=unset#text/rtf
*.sln text svneol=native#text/plain
*.swf binary svneol=unset#application/x-shockwave-flash
*.tgz binary svneol=unset#application/gzip
*.vcproj text svneol=native#text/xml
*.vcxproj text svneol=native#text/xml
*.vsprops text svneol=native#text/xml
*.wav binary svneol=unset#audio/wav
*.xls binary svneol=unset#application/vnd.ms-excel
*.zip binary svneol=unset#application/zip
# Text formats
.htaccess text svneol=native#text/plain
*.bbk text svneol=native#text/xml
*.cmake text svneol=native#text/plain
*.css text svneol=native#text/css
*.dtd text svneol=native#text/xml
*.htm text svneol=native#text/html
*.html text svneol=native#text/html
*.ini text svneol=native#text/plain
*.log text svneol=native#text/plain
*.mak text svneol=native#text/plain
*.qbk text svneol=native#text/plain
*.rst text svneol=native#text/plain
*.sql text svneol=native#text/x-sql
*.txt text svneol=native#text/plain
*.xhtml text svneol=native#text/xhtml%2Bxml
*.xml text svneol=native#text/xml
*.xsd text svneol=native#text/xml
*.xsl text svneol=native#text/xml
*.xslt text svneol=native#text/xml
*.xul text svneol=native#text/xul
*.yml text svneol=native#text/plain
boost-no-inspect text svneol=native#text/plain
CHANGES text svneol=native#text/plain
COPYING text svneol=native#text/plain
INSTALL text svneol=native#text/plain
Jamfile text svneol=native#text/plain
Jamroot text svneol=native#text/plain
Jamfile.v2 text svneol=native#text/plain
Jamrules text svneol=native#text/plain
Makefile* text svneol=native#text/plain
README text svneol=native#text/plain
TODO text svneol=native#text/plain
# Code formats
*.c text svneol=native#text/plain
*.cpp text svneol=native#text/plain
*.h text svneol=native#text/plain
*.hpp text svneol=native#text/plain
*.ipp text svneol=native#text/plain
*.tpp text svneol=native#text/plain
*.jam text svneol=native#text/plain
*.java text svneol=native#text/plain

View File

@@ -0,0 +1,362 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-11
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-12
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: "14"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error

View File

@@ -0,0 +1,377 @@
# Copyright 2016-2020 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)
language: cpp
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: COMMENT=clang-3.3 TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: COMMENT=clang-3.4 TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
dist: xenial
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: xenial
compiler: clang++-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: xenial
compiler: clang++-11
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE=1
script:
- mkdir __build__ && cd __build__
- cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=assert ..
- cmake --build . --target tests
- ctest --output-on-failure
- os: linux
env: CMAKE_SUBDIR=1
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_INCLUDE_LIBRARIES=assert -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/assert/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init tools/boost_install
- git submodule update --init libs/config
- git submodule update --init libs/core
- git submodule update --init libs/headers
- git submodule update --init tools/cmake
- cp -r $TRAVIS_BUILD_DIR/* libs/assert
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 libs/assert/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

View File

@@ -0,0 +1,26 @@
# 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
# We support CMake 3.5, but prefer 3.16 policies and behavior
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_assert VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_assert INTERFACE)
add_library(Boost::assert ALIAS boost_assert)
target_include_directories(boost_assert INTERFACE include)
target_link_libraries(boost_assert
INTERFACE
Boost::config
)
# BUILD_TESTING is the standard CTest variable that enables testing
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -0,0 +1,13 @@
# Boost.Assert
The Boost.Assert library, part of the collection of [Boost C++ Libraries](http://github.com/boostorg),
provides several configurable diagnostic macros similar in behavior and purpose to the standard macro
`assert` from `<cassert>`.
## Documentation
See [the documentation](https://boost.org/libs/assert) for more information.
## License
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

View File

@@ -0,0 +1,86 @@
# Copyright 2016, 2018, 2019 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)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1,clang-win
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_SUBDIR: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_INSTALL: 1
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init tools/boost_install
- git submodule update --init tools/cmake
- git submodule update --init libs/headers
- git submodule update --init libs/config
- git submodule update --init libs/core
- git submodule update --init libs/static_assert
- git submodule update --init libs/throw_exception
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\assert\
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j 3 libs/assert/test toolset=%TOOLSET% %CXXSTD% %ADDRMD%
- if not "%CMAKE%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=assert ..
- if not "%CMAKE%" == "" cmake --build . --target tests --config Debug & ctest --output-on-failure -C Debug
- if not "%CMAKE%" == "" cmake --build . --target tests --config Release & ctest --output-on-failure -C Release
- if not "%CMAKE%" == "" cmake --build . --target tests --config MinSizeRel & ctest --output-on-failure -C MinSizeRel
- if not "%CMAKE%" == "" cmake --build . --target tests --config RelWithDebInfo & ctest --output-on-failure -C RelWithDebInfo
- if not "%CMAKE_SUBDIR%" == "" cd libs/assert/test/cmake_subdir_test && mkdir __build__ && cd __build__
- if not "%CMAKE_SUBDIR%" == "" cmake ..
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config MinSizeRel && cmake --build . --target check --config MinSizeRel
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config RelWithDebInfo && cmake --build . --target check --config RelWithDebInfo
- if not "%CMAKE_INSTALL%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DBOOST_INCLUDE_LIBRARIES=assert -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Release
- if not "%CMAKE_INSTALL%" == "" cd ../libs/assert/test/cmake_install_test && mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Release && cmake --build . --target check --config Release

View File

@@ -0,0 +1,2 @@
/html/
/pdf/

View File

@@ -0,0 +1,27 @@
# Copyright 2017 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)
import asciidoctor ;
# import boostbook ;
html assert.html : index.adoc ;
# docbook assert.docbook : index.adoc ;
# boostbook assert.html : assert.docbook : <format>onehtml ;
install html_ : assert.html : <location>html ;
pdf assert.pdf : index.adoc ;
explicit assert.pdf ;
install pdf_ : assert.pdf : <location>pdf ;
explicit pdf_ ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : html_ ;
explicit boostrelease ;

View File

@@ -0,0 +1,166 @@
////
Copyright 2002, 2007, 2014, 2017 Peter Dimov
Copyright 2011 Beman Dawes
Copyright 2015 Ion Gaztañaga
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
////
[#assertion_macros]
# Assertion Macros, <boost/assert.hpp>
:toc:
:toc-title:
:idprefix:
## BOOST_ASSERT
The header `<boost/assert.hpp>` defines the macro `BOOST_ASSERT`,
which is similar to the standard `assert` macro defined in `<cassert>`.
The macro is intended to be used in both Boost libraries and user
code.
* By default, `BOOST_ASSERT(expr)` expands to `assert(expr)`.
* If the macro `BOOST_DISABLE_ASSERTS` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT(expr)` expands to `((void)0)`, regardless of whether
the macro `NDEBUG` is defined. This allows users to selectively disable `BOOST_ASSERT` without
affecting the definition of the standard `assert`.
* If the macro `BOOST_ENABLE_ASSERT_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT(expr)` expands to
+
```none
(BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr,
BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
```
+
That is, it evaluates `expr` and if it's false, calls
`::boost::assertion_failed(#expr, <<current_function.adoc#boost_current_function,BOOST_CURRENT_FUNCTION>>, \\__FILE__, \\__LINE__)`.
This is true regardless of whether `NDEBUG` is defined.
+
`boost::assertion_failed` is declared in `<boost/assert.hpp>` as
+
```
namespace boost
{
void assertion_failed(char const * expr, char const * function,
char const * file, long line);
}
```
+
but it is never defined. The user is expected to supply an appropriate definition.
* If the macro `BOOST_ENABLE_ASSERT_DEBUG_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT(expr)` expands to `((void)0)` when `NDEBUG` is
defined. Otherwise the behavior is as if `BOOST_ENABLE_ASSERT_HANDLER` has been defined.
As is the case with `<cassert>`, `<boost/assert.hpp>`
can be included multiple times in a single translation unit. `BOOST_ASSERT`
will be redefined each time as specified above.
## BOOST_ASSERT_MSG
The macro `BOOST_ASSERT_MSG` is similar to `BOOST_ASSERT`, but it takes an additional argument,
a character literal, supplying an error message.
* By default, `BOOST_ASSERT_MSG(expr,msg)` expands to `assert\((expr)&&(msg))`.
* If the macro `BOOST_DISABLE_ASSERTS` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT_MSG(expr,msg)` expands to `((void)0)`, regardless of whether
the macro `NDEBUG` is defined.
* If the macro `BOOST_ENABLE_ASSERT_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT_MSG(expr,msg)` expands to
+
```none
(BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr,
msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
```
+
This is true regardless of whether `NDEBUG` is defined.
+
`boost::assertion_failed_msg` is declared in `<boost/assert.hpp>` as
+
```
namespace boost
{
void assertion_failed_msg(char const * expr, char const * msg,
char const * function, char const * file, long line);
}
```
+
but it is never defined. The user is expected to supply an appropriate definition.
* If the macro `BOOST_ENABLE_ASSERT_DEBUG_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_ASSERT_MSG(expr)` expands to `((void)0)` when `NDEBUG` is
defined. Otherwise the behavior is as if `BOOST_ENABLE_ASSERT_HANDLER` has been defined.
As is the case with `<cassert>`, `<boost/assert.hpp>`
can be included multiple times in a single translation unit. `BOOST_ASSERT_MSG`
will be redefined each time as specified above.
## BOOST_VERIFY
The macro `BOOST_VERIFY` has the same behavior as `BOOST_ASSERT`, except that
the expression that is passed to `BOOST_VERIFY` is always
evaluated. This is useful when the asserted expression has desirable side
effects; it can also help suppress warnings about unused variables when the
only use of the variable is inside an assertion.
* If the macro `BOOST_DISABLE_ASSERTS` is defined when `<boost/assert.hpp>`
is included, `BOOST_VERIFY(expr)` expands to `\((void)(expr))`.
* If the macro `BOOST_ENABLE_ASSERT_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_VERIFY(expr)` expands to `BOOST_ASSERT(expr)`.
* Otherwise, `BOOST_VERIFY(expr)` expands to `\((void)(expr))` when `NDEBUG` is
defined, to `BOOST_ASSERT(expr)` when it's not.
## BOOST_VERIFY_MSG
The macro `BOOST_VERIFY_MSG` is similar to `BOOST_VERIFY`, with an additional parameter, an error message.
* If the macro `BOOST_DISABLE_ASSERTS` is defined when `<boost/assert.hpp>`
is included, `BOOST_VERIFY_MSG(expr,msg)` expands to `\((void)(expr))`.
* If the macro `BOOST_ENABLE_ASSERT_HANDLER` is defined when `<boost/assert.hpp>`
is included, `BOOST_VERIFY_MSG(expr,msg)` expands to `BOOST_ASSERT_MSG(expr,msg)`.
* Otherwise, `BOOST_VERIFY_MSG(expr,msg)` expands to `\((void)(expr))` when `NDEBUG` is
defined, to `BOOST_ASSERT_MSG(expr,msg)` when it's not.
## BOOST_ASSERT_IS_VOID
The macro `BOOST_ASSERT_IS_VOID` is defined when `BOOST_ASSERT` and `BOOST_ASSERT_MSG` are expanded to `((void)0)`.
Its purpose is to avoid compiling and potentially running code that is only intended to prepare data to be used in the assertion.
```
void MyContainer::erase(iterator i)
{
// Some sanity checks, data must be ordered
#ifndef BOOST_ASSERT_IS_VOID
if(i != c.begin()) {
iterator prev = i;
--prev;
BOOST_ASSERT(*prev < *i);
}
else if(i != c.end()) {
iterator next = i;
++next;
BOOST_ASSERT(*i < *next);
}
#endif
this->erase_impl(i);
}
```
* By default, `BOOST_ASSERT_IS_VOID` is defined if `NDEBUG` is defined.
* If the macro `BOOST_DISABLE_ASSERTS` is defined, `BOOST_ASSERT_IS_VOID` is always defined.
* If the macro `BOOST_ENABLE_ASSERT_HANDLER` is defined, `BOOST_ASSERT_IS_VOID` is never defined.
* If the macro `BOOST_ENABLE_ASSERT_DEBUG_HANDLER` is defined, then `BOOST_ASSERT_IS_VOID` is defined when `NDEBUG` is defined.

View File

@@ -0,0 +1,28 @@
////
Copyright 2019, 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
////
[#changes]
# Revision History
:toc:
:toc-title:
:idprefix:
## Changes in 1.79.0
* `source_location().file_name()` and `source_location().function_name()`
now return `""` instead of `"(unknown)"`.
* Added a `source_location` constructor from `std::source_location`.
* Changed `BOOST_CURRENT_LOCATION` to more closely match the behavior of
`std::source_location::current()`, such as being usable at top level or
as a default function argument.
## Changes in 1.78.0
* Added `source_location::to_string`.
## Changes in 1.73.0
* Added `source_location`.

View File

@@ -0,0 +1,32 @@
////
Copyright 2002, 2017 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
////
[#current_function_macro]
# Current Function Macro, <boost/current_function.hpp>
:toc:
:toc-title:
:idprefix:
## BOOST_CURRENT_FUNCTION
The header `<boost/current_function.hpp>` defines a single macro, `BOOST_CURRENT_FUNCTION`,
similar to the C99 predefined identifier `\\__func__`.
`BOOST_CURRENT_FUNCTION` expands to either a string literal, or the name of a
character array local to the current function, containing the (fully qualified,
if possible) name of the enclosing function. If there is no enclosing function,
the behavior varies by compiler, but is usually a compile error.
Some compilers do not provide a way to obtain the name of the current enclosing
function. On such compilers, or when the macro `BOOST_DISABLE_CURRENT_FUNCTION`
is defined, `BOOST_CURRENT_FUNCTION` expands to `"(unknown)"`.
`BOOST_DISABLE_CURRENT_FUNCTION` addresses a use case in which the programmer
wishes to eliminate the string literals produced by `BOOST_CURRENT_FUNCTION` from
the final executable for security reasons.

View File

@@ -0,0 +1,6 @@
<style>
*:not(pre)>code { background: none; color: #600000; }
:not(pre):not([class^=L])>code { background: none; color: #600000; }
</style>

View File

@@ -0,0 +1,38 @@
////
Copyright 2017 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
////
# Boost.Assert
Peter Dimov
:toc: left
:idprefix:
:docinfo: private-footer
:source-highlighter: rouge
:source-language: c++
The Boost.Assert library provides several configurable diagnostic macros
similar in behavior and purpose to the standard macro `assert` from `<cassert>`.
:leveloffset: +1
include::assert.adoc[]
include::current_function.adoc[]
include::source_location.adoc[]
include::changes.adoc[]
:leveloffset: -1
[appendix]
## Copyright and License
This documentation is
* Copyright 2002, 2007, 2014, 2017, 2019-2022 Peter Dimov
* Copyright 2011 Beman Dawes
* Copyright 2015 Ion Gaztañaga
* Distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@@ -0,0 +1,182 @@
////
Copyright 2019, 2021, 2022 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
////
[#source_location_support]
# Source Location Support, <boost/assert/source_location.hpp>
:toc:
:toc-title:
:idprefix:
## Description
The header `<boost/assert/source_location.hpp>` defines `source_location`,
a class representing a source location and containing file, line, function
and column information. It's similar to `std::source_location` from {cpp}20,
but only requires {cpp}03.
The macro `BOOST_CURRENT_LOCATION` creates a `source_location` object
containing information about the current source location. It can be used
roughly in the same way `std::source_location::current()` can be used,
such as in the declaration of a function default argument:
```
#include <boost/assert/source_location.hpp>
#include <iostream>
void f( boost::source_location const& loc = BOOST_CURRENT_LOCATION )
{
std::cout << "f() called from: " << loc << std::endl;
}
int main()
{
f();
}
```
The output of this example varies by compiler and C++ standard level, but
it's generally one of
```none
f() called from: example.cpp:11:6 in function 'int main()'
```
```none
f() called from: example.cpp:11:5 in function 'main'
```
```none
f() called from: example.cpp:11 in function 'main'
```
```none
f() called from: example.cpp:4
```
This is useful if, for example, you want to declare a function that throws
an exception, such that the source location of the caller is attached to
the thrown exception:
```
BOOST_NORETURN BOOST_NOINLINE void throw_invalid_argument(
char const* message,
boost::source_location const& loc = BOOST_CURRENT_LOCATION )
{
boost::throw_exception( std::invalid_argument( message ), loc );
}
```
Now you could use this helper function in, say, the implementation of
`at` to signal an index that is out of range:
```
T& my_class::at( size_t i )
{
if( i >= size() ) throw_invalid_argument( "index out of range" );
return data()[ i ];
}
```
This would attach the source location of the line in `at` that calls
`throw_invalid_argument` to the thrown exception.
Note that if instead you use `BOOST_THROW_EXCEPTION` in
`throw_invalid_argument`, the location will be that of
`throw_invalid_argument` and not of its caller.
## Synopsis
```
namespace boost
{
struct source_location
{
constexpr source_location() noexcept;
constexpr source_location( char const* file, uint_least32_t line,
char const* function, uint_least32_t column = 0 ) noexcept;
constexpr source_location( std::source_location const& loc ) noexcept;
constexpr char const* file_name() const noexcept;
constexpr char const* function_name() const noexcept;
constexpr uint_least32_t line() const noexcept;
constexpr uint_least32_t column() const noexcept;
std::string to_string() const;
};
template<class E, class T>
std::basic_ostream<E, T> &
operator<<( std::basic_ostream<E, T> & os, source_location const & loc );
} // namespace boost
#define BOOST_CURRENT_LOCATION /* see below */
```
## source_location
```
constexpr source_location() noexcept;
```
Effects: :: Constructs a `source_location` object for which `file_name()`
and `function_name()` return `""`, and `line()` and `column()` return `0`.
```
constexpr source_location( char const* file, uint_least32_t line,
char const* function, uint_least32_t column = 0 ) noexcept;
```
Effects: :: Constructs a `source_location` object for which `file_name()`
returns `file`, `function_name()` returns `function`, `line()` returns the
`line` argument and `column()` returns the `column` argument.
```
constexpr source_location( std::source_location const& loc ) noexcept;
```
Effects: :: Constructs a `source_location` object for which `file_name()`
returns `loc.file_name()`, `function_name()` returns `loc.function_name()`,
`line()` returns `loc.line()` and `column()` returns `loc.column()`.
## to_string
```
std::string to_string() const;
```
Returns: ::
a string representation of `*this`.
## operator<<
```
template<class E, class T>
std::basic_ostream<E, T> &
operator<<( std::basic_ostream<E, T> & os, source_location const & loc );
```
Effects: :: `os << loc.to_string()`.
Returns: ::
`os`.
## BOOST_CURRENT_LOCATION
When `BOOST_DISABLE_CURRENT_LOCATION` is defined, the definition of
`BOOST_CURRENT_LOCATION` is:
```
#define BOOST_CURRENT_LOCATION ::boost::source_location()
```
This allows producing executables that contain no identifying information,
for security reasons.
Otherwise, `BOOST_CURRENT_LOCATION` is defined as the approximate equivalent
of
```
#define BOOST_CURRENT_LOCATION \
::boost::source_location(::std::source_location::current())
```

View File

@@ -0,0 +1,85 @@
//
// boost/assert.hpp - BOOST_ASSERT(expr)
// BOOST_ASSERT_MSG(expr, msg)
// BOOST_VERIFY(expr)
// BOOST_VERIFY_MSG(expr, msg)
// BOOST_ASSERT_IS_VOID
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2007, 2014 Peter Dimov
// Copyright (c) Beman Dawes 2011
// Copyright (c) 2015 Ion Gaztanaga
//
// 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
//
// Note: There are no include guards. This is intentional.
//
// See http://www.boost.org/libs/assert/assert.html for documentation.
//
//
// Stop inspect complaining about use of 'assert':
//
// boostinspect:naassert_macro
//
//
// BOOST_ASSERT, BOOST_ASSERT_MSG, BOOST_ASSERT_IS_VOID
//
#undef BOOST_ASSERT
#undef BOOST_ASSERT_MSG
#undef BOOST_ASSERT_IS_VOID
#if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
# define BOOST_ASSERT(expr) ((void)0)
# define BOOST_ASSERT_MSG(expr, msg) ((void)0)
# define BOOST_ASSERT_IS_VOID
#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
#include <boost/config.hpp> // for BOOST_LIKELY
#include <boost/current_function.hpp>
namespace boost
{
void assertion_failed(char const * expr, char const * function, char const * file, long line); // user defined
void assertion_failed_msg(char const * expr, char const * msg, char const * function, char const * file, long line); // user defined
} // namespace boost
#define BOOST_ASSERT(expr) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define BOOST_ASSERT_MSG(expr, msg) (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#else
# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
# define BOOST_ASSERT(expr) assert(expr)
# define BOOST_ASSERT_MSG(expr, msg) assert((expr)&&(msg))
#if defined(NDEBUG)
# define BOOST_ASSERT_IS_VOID
#endif
#endif
//
// BOOST_VERIFY, BOOST_VERIFY_MSG
//
#undef BOOST_VERIFY
#undef BOOST_VERIFY_MSG
#if defined(BOOST_DISABLE_ASSERTS) || ( !defined(BOOST_ENABLE_ASSERT_HANDLER) && defined(NDEBUG) )
# define BOOST_VERIFY(expr) ((void)(expr))
# define BOOST_VERIFY_MSG(expr, msg) ((void)(expr))
#else
# define BOOST_VERIFY(expr) BOOST_ASSERT(expr)
# define BOOST_VERIFY_MSG(expr, msg) BOOST_ASSERT_MSG(expr,msg)
#endif

View File

@@ -0,0 +1,163 @@
#ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED
#define BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED
// http://www.boost.org/libs/assert
//
// Copyright 2019, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/current_function.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/cstdint.hpp>
#include <iosfwd>
#include <string>
#include <cstdio>
#include <cstring>
#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
# include <source_location>
#endif
namespace boost
{
struct source_location
{
private:
char const * file_;
char const * function_;
boost::uint_least32_t line_;
boost::uint_least32_t column_;
public:
BOOST_CONSTEXPR source_location() BOOST_NOEXCEPT: file_( "" ), function_( "" ), line_( 0 ), column_( 0 )
{
}
BOOST_CONSTEXPR source_location( char const * file, boost::uint_least32_t ln, char const * function, boost::uint_least32_t col = 0 ) BOOST_NOEXCEPT: file_( file ), function_( function ), line_( ln ), column_( col )
{
}
#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
BOOST_CONSTEXPR source_location( std::source_location const& loc ) BOOST_NOEXCEPT: file_( loc.file_name() ), function_( loc.function_name() ), line_( loc.line() ), column_( loc.column() )
{
}
#endif
BOOST_CONSTEXPR char const * file_name() const BOOST_NOEXCEPT
{
return file_;
}
BOOST_CONSTEXPR char const * function_name() const BOOST_NOEXCEPT
{
return function_;
}
BOOST_CONSTEXPR boost::uint_least32_t line() const BOOST_NOEXCEPT
{
return line_;
}
BOOST_CONSTEXPR boost::uint_least32_t column() const BOOST_NOEXCEPT
{
return column_;
}
#if defined(BOOST_MSVC)
# pragma warning( push )
# pragma warning( disable: 4996 )
#endif
std::string to_string() const
{
unsigned long ln = line();
if( ln == 0 )
{
return "(unknown source location)";
}
std::string r = file_name();
char buffer[ 16 ];
std::sprintf( buffer, ":%lu", ln );
r += buffer;
unsigned long co = column();
if( co )
{
std::sprintf( buffer, ":%lu", co );
r += buffer;
}
char const* fn = function_name();
if( *fn != 0 )
{
r += " in function '";
r += fn;
r += '\'';
}
return r;
}
#if defined(BOOST_MSVC)
# pragma warning( pop )
#endif
};
template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ostream<E, T> & os, source_location const & loc )
{
os << loc.to_string();
return os;
}
} // namespace boost
#if defined(BOOST_DISABLE_CURRENT_LOCATION)
# define BOOST_CURRENT_LOCATION ::boost::source_location()
#elif defined(BOOST_MSVC) && BOOST_MSVC >= 1926
// std::source_location::current() is available in -std:c++20, but fails with consteval errors before 19.31, and doesn't produce
// the correct result under 19.31, so prefer the built-ins
# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN())
#elif defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
# define BOOST_CURRENT_LOCATION ::boost::source_location(::std::source_location::current())
#elif defined(BOOST_CLANG) && BOOST_CLANG_VERSION >= 90000
# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION(), __builtin_COLUMN())
#elif defined(BOOST_GCC) && BOOST_GCC >= 70000
// The built-ins are available in 4.8+, but are not constant expressions until 7
# define BOOST_CURRENT_LOCATION ::boost::source_location(__builtin_FILE(), __builtin_LINE(), __builtin_FUNCTION())
#elif defined(BOOST_GCC) && BOOST_GCC >= 50000
// __PRETTY_FUNCTION__ is allowed outside functions under GCC, but 4.x suffers from codegen bugs
# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
// __func__ macros aren't allowed outside functions, but BOOST_CURRENT_LOCATION is
# define BOOST_CURRENT_LOCATION ::boost::source_location(__FILE__, __LINE__, "")
#endif
#endif // #ifndef BOOST_ASSERT_SOURCE_LOCATION_HPP_INCLUDED

View File

@@ -0,0 +1,75 @@
#ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED
#define BOOST_CURRENT_FUNCTION_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
//
// boost/current_function.hpp - BOOST_CURRENT_FUNCTION
//
// Copyright 2002-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
//
// http://www.boost.org/libs/assert
//
namespace boost
{
namespace detail
{
inline void current_function_helper()
{
#if defined( BOOST_DISABLE_CURRENT_FUNCTION )
# define BOOST_CURRENT_FUNCTION "(unknown)"
#elif defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) || defined(__clang__)
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__DMC__) && (__DMC__ >= 0x810)
# define BOOST_CURRENT_FUNCTION __PRETTY_FUNCTION__
#elif defined(__FUNCSIG__)
# define BOOST_CURRENT_FUNCTION __FUNCSIG__
#elif (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)) || (defined(__IBMCPP__) && (__IBMCPP__ >= 500))
# define BOOST_CURRENT_FUNCTION __FUNCTION__
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x550)
# define BOOST_CURRENT_FUNCTION __FUNC__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
# define BOOST_CURRENT_FUNCTION __func__
#elif defined(__cplusplus) && (__cplusplus >= 201103)
# define BOOST_CURRENT_FUNCTION __func__
#else
# define BOOST_CURRENT_FUNCTION "(unknown)"
#endif
}
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_CURRENT_FUNCTION_HPP_INCLUDED

View File

@@ -0,0 +1,15 @@
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/html/assert.html">
</head>
<body>
Automatic redirection failed, please go to
<a href="doc/html/assert.html">doc/html/assert.html</a>.
</body>
</html>
<!--
<09> Copyright Beman Dawes, 2001
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
-->

View File

@@ -0,0 +1,16 @@
{
"key": "assert",
"name": "Assert",
"authors": [
"Peter Dimov"
],
"maintainers": [
"Peter Dimov <pdimov -at- gmail.com>"
],
"description": "Customizable assert macros.",
"category": [
"Correctness",
"Error-handling"
],
"cxxstd": "03"
}

View File

@@ -0,0 +1,15 @@
# 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
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::assert Boost::core)
if(BOOST_SUPERPROJECT_VERSION)
boost_test(SOURCES check_cmake_version.cpp ARGUMENTS ${PROJECT_VERSION} LINK_LIBRARIES Boost::core Boost::config)
endif()
endif()

View File

@@ -0,0 +1,44 @@
# Boost.Assert Library test Jamfile
#
# Copyright (c) 2014, 2017, 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
import testing ;
project : requirements
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>gcc:<cxxflags>-Wshadow
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare
;
run assert_test.cpp ;
run current_function_test.cpp
: : : <test-info>always_show_run_output ;
run verify_test.cpp ;
run assert_is_void_test.cpp ;
# expansion tests are in exp/ so that there is a backslash in the path on Windows
run exp/assert_exp_test.cpp ;
run exp/assert_msg_exp_test.cpp ;
run exp/verify_exp_test.cpp ;
run exp/verify_msg_exp_test.cpp ;
run assert_test2.cpp ;
run assert_msg_test2.cpp ;
# quick test (for CI)
run quick.cpp ;
run current_function_test2.cpp ;
run source_location_test.cpp ;
run source_location_test2.cpp ;
run source_location_test3.cpp ;
run source_location_test4.cpp ;
run source_location_test5.cpp ;

View File

@@ -0,0 +1,108 @@
//
// assert_is_void_test.cpp - tests BOOST_ASSERT_IS_VOID
//
// Copyright (c) 2015 Ion Gaztanaga
//
// 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/config.hpp>
// default case, !NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#undef NDEBUG
#include <boost/assert.hpp>
#ifdef BOOST_ASSERT_IS_VOID
#error "BOOST_ASSERT should NOT be void if NDEBUG is not defined"
#endif
// default case, NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#define NDEBUG
#include <boost/assert.hpp>
#ifndef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should be void in NDEBUG"
#endif
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
#ifndef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should be void with BOOST_DISABLE_ASSERTS"
#endif
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
#ifndef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should be void with BOOST_DISABLE_ASSERTS and NDEBUG"
#endif
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#ifdef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should NOT be void with BOOST_ENABLE_ASSERT_HANDLER"
#endif
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define NDEBUG
#include <boost/assert.hpp>
#ifdef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should NOT be void with BOOST_ENABLE_ASSERT_HANDLER"
#endif
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// same as BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#ifdef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should NOT be void with BOOST_ENABLE_ASSERT_DEBUG_HANDLER and !NDEBUG"
#endif
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
#ifndef BOOST_ASSERT_IS_VOID
#error "Error: BOOST_ASSERT should be void with BOOST_ENABLE_ASSERT_DEBUG_HANDLER and NDEBUG"
#endif
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
return 0;
}

View File

@@ -0,0 +1,118 @@
//
// assert_msg_test2.cpp - a test for BOOST_ASSERT_MSG and NDEBUG
//
// Copyright (c) 2014 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/detail/lightweight_test.hpp>
#include <stdio.h>
// default case, !NDEBUG
// BOOST_ASSERT_MSG(x) -> assert(x)
#undef NDEBUG
#include <boost/assert.hpp>
void test_default()
{
int x = 1;
BOOST_ASSERT_MSG( 1, "msg" );
BOOST_ASSERT_MSG( x, "msg" );
BOOST_ASSERT_MSG( x == 1, "msg" );
}
// default case, NDEBUG
// BOOST_ASSERT_MSG(x) -> assert(x)
#define NDEBUG
#include <boost/assert.hpp>
void test_default_ndebug()
{
int x = 1;
BOOST_ASSERT_MSG( 1, "msg" );
BOOST_ASSERT_MSG( x, "msg" );
BOOST_ASSERT_MSG( x == 1, "msg" );
BOOST_ASSERT_MSG( 0, "msg" );
BOOST_ASSERT_MSG( !x, "msg" );
BOOST_ASSERT_MSG( x == 0, "msg" );
(void)x;
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// same as BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
int handler_invoked = 0;
void boost::assertion_failed_msg( char const * expr, char const * msg, char const * function, char const * file, long line )
{
printf( "Expression: %s\nMessage: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, msg, function, file, line );
++handler_invoked;
}
void test_debug_handler()
{
handler_invoked = 0;
int x = 1;
BOOST_ASSERT_MSG( 1, "msg" );
BOOST_ASSERT_MSG( x, "msg" );
BOOST_ASSERT_MSG( x == 1, "msg" );
BOOST_ASSERT_MSG( 0, "msg" );
BOOST_ASSERT_MSG( !x, "msg" );
BOOST_ASSERT_MSG( x == 0, "msg" );
BOOST_TEST( handler_invoked == 3 );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_ASSERT_MSG(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
handler_invoked = 0;
int x = 1;
BOOST_ASSERT_MSG( 1, "msg" );
BOOST_ASSERT_MSG( x, "msg" );
BOOST_ASSERT_MSG( x == 1, "msg" );
BOOST_ASSERT_MSG( 0, "msg" );
BOOST_ASSERT_MSG( !x, "msg" );
BOOST_ASSERT_MSG( x == 0, "msg" );
BOOST_TEST( handler_invoked == 0 );
(void)x;
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,157 @@
//
// assert_test.cpp - a test for boost/assert.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) Beman Dawes 2011
//
// 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/core/lightweight_test.hpp>
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Waddress"
#endif
#include <boost/assert.hpp>
void test_default()
{
int x = 1; (void)x;
BOOST_ASSERT(1);
BOOST_ASSERT(x);
BOOST_ASSERT(x == 1);
BOOST_ASSERT(&x);
BOOST_ASSERT_MSG(1, "msg");
BOOST_ASSERT_MSG(x, "msg");
BOOST_ASSERT_MSG(x == 1, "msg");
BOOST_ASSERT_MSG(&x, "msg");
}
#define BOOST_DISABLE_ASSERTS
#include <boost/assert.hpp>
void test_disabled()
{
int x = 1;
BOOST_ASSERT(1);
BOOST_ASSERT(x);
BOOST_ASSERT(x == 1);
BOOST_ASSERT(&x);
BOOST_ASSERT_MSG(1, "msg");
BOOST_ASSERT_MSG(x, "msg");
BOOST_ASSERT_MSG(x == 1, "msg");
BOOST_ASSERT_MSG(&x, "msg");
BOOST_ASSERT(0);
BOOST_ASSERT(!x);
BOOST_ASSERT(x == 0);
BOOST_ASSERT_MSG(0, "msg");
BOOST_ASSERT_MSG(!x, "msg");
BOOST_ASSERT_MSG(x == 0, "msg");
void * p = 0;
BOOST_ASSERT(p);
BOOST_ASSERT_MSG(p, "msg");
// suppress warnings
p = &x;
p = &p;
}
#undef BOOST_DISABLE_ASSERTS
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <cstdio>
int handler_invoked = 0;
int msg_handler_invoked = 0;
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::printf;
#endif
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
++handler_invoked;
}
void boost::assertion_failed_msg(char const * expr, char const * msg, char const * function,
char const * file, long line)
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::printf;
#endif
printf("Expression: %s Message: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n",
expr, msg, function, file, line);
++msg_handler_invoked;
}
struct X
{
static void f()
{
BOOST_ASSERT(0);
BOOST_ASSERT_MSG(0, "msg f()");
}
};
void test_handler()
{
int x = 1;
BOOST_ASSERT(1);
BOOST_ASSERT(x);
BOOST_ASSERT(x == 1);
BOOST_ASSERT(&x);
BOOST_ASSERT_MSG(1, "msg2");
BOOST_ASSERT_MSG(x, "msg3");
BOOST_ASSERT_MSG(x == 1, "msg4");
BOOST_ASSERT_MSG(&x, "msg5");
BOOST_ASSERT(0);
BOOST_ASSERT(!x);
BOOST_ASSERT(x == 0);
BOOST_ASSERT_MSG(0,"msg 0");
BOOST_ASSERT_MSG(!x, "msg !x");
BOOST_ASSERT_MSG(x == 0, "msg x == 0");
void * p = 0;
BOOST_ASSERT(p);
BOOST_ASSERT_MSG(p, "msg p");
X::f();
BOOST_ASSERT(handler_invoked == 5);
BOOST_TEST(handler_invoked == 5);
BOOST_ASSERT_MSG(msg_handler_invoked == 5, "msg_handler_invoked count is wrong");
BOOST_TEST(msg_handler_invoked == 5);
}
#undef BOOST_ENABLE_ASSERT_HANDLER
#undef BOOST_ENABLE_ASSERT_MSG_HANDLER
int main()
{
test_default();
test_disabled();
test_handler();
return boost::report_errors();
}

View File

@@ -0,0 +1,118 @@
//
// assert_test2.cpp - a test for BOOST_ASSERT and NDEBUG
//
// Copyright (c) 2014 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/detail/lightweight_test.hpp>
#include <stdio.h>
// default case, !NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#undef NDEBUG
#include <boost/assert.hpp>
void test_default()
{
int x = 1;
BOOST_ASSERT( 1 );
BOOST_ASSERT( x );
BOOST_ASSERT( x == 1 );
}
// default case, NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#define NDEBUG
#include <boost/assert.hpp>
void test_default_ndebug()
{
int x = 1;
BOOST_ASSERT( 1 );
BOOST_ASSERT( x );
BOOST_ASSERT( x == 1 );
BOOST_ASSERT( 0 );
BOOST_ASSERT( !x );
BOOST_ASSERT( x == 0 );
(void)x;
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// same as BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
int handler_invoked = 0;
void boost::assertion_failed( char const * expr, char const * function, char const * file, long line )
{
printf( "Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line );
++handler_invoked;
}
void test_debug_handler()
{
handler_invoked = 0;
int x = 1;
BOOST_ASSERT( 1 );
BOOST_ASSERT( x );
BOOST_ASSERT( x == 1 );
BOOST_ASSERT( 0 );
BOOST_ASSERT( !x );
BOOST_ASSERT( x == 0 );
BOOST_TEST( handler_invoked == 3 );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
handler_invoked = 0;
int x = 1;
BOOST_ASSERT( 1 );
BOOST_ASSERT( x );
BOOST_ASSERT( x == 1 );
BOOST_ASSERT( 0 );
BOOST_ASSERT( !x );
BOOST_ASSERT( x == 0 );
BOOST_TEST( handler_invoked == 0 );
(void)x;
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,27 @@
// Check whether the version in CMakeLists.txt is up to date
//
// Copyright 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/core/lightweight_test.hpp>
#include <boost/version.hpp>
#include <cstdio>
int main( int ac, char const* av[] )
{
BOOST_TEST_EQ( ac, 2 );
if( ac >= 2 )
{
char version[ 64 ];
std::sprintf( version, "%d.%d.%d", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100 );
BOOST_TEST_CSTR_EQ( av[1], version );
}
return boost::report_errors();
}

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://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_assert REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Boost::assert)
enable_testing()
add_test(NAME main COMMAND main)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,11 @@
// Copyright 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
#include <boost/assert.hpp>
int main()
{
int x = 5;
BOOST_ASSERT( x > 4 );
}

View File

@@ -0,0 +1,18 @@
# Copyright 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_executable(main main.cpp)
target_link_libraries(main Boost::assert)
enable_testing()
add_test(NAME main COMMAND main)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,11 @@
// Copyright 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
#include <boost/assert.hpp>
int main()
{
int x = 5;
BOOST_ASSERT( x > 4 );
}

View File

@@ -0,0 +1,39 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// current_function_test.cpp - a test for boost/current_function.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
//
// 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/current_function.hpp>
#include <boost/config.hpp>
#include <cstdio>
void message(char const * file, long line, char const * func, char const * msg)
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::printf;
#endif
printf("%s(%ld): in function '%s': %s\n", file, line, func, msg);
}
#define MESSAGE(msg) message(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, msg)
int main()
{
MESSAGE("testing BOOST_CURRENT_FUNCTION");
return 0;
}

View File

@@ -0,0 +1,25 @@
//
// current_function_test2.cpp - a test for boost/current_function.hpp
//
// Copyright 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/current_function.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
int f()
{
BOOST_TEST_EQ( std::string( BOOST_CURRENT_FUNCTION ).substr( 0, 4 ), std::string( "int " ) );
return 0;
}
int main()
{
f();
return boost::report_errors();
}

View File

@@ -0,0 +1,164 @@
//
// assert_exp_test.cpp - tests BOOST_ASSERT expansion
//
// Copyright (c) 2014 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/config.hpp>
#include <boost/current_function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
static std::string quote( std::string const & s )
{
std::string r;
r.reserve( s.size() );
for( char const * p = s.c_str(); *p; ++p )
{
r += *p;
if( *p == '\\' ) r += *p;
}
return r;
}
// default case, !NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#undef NDEBUG
#include <boost/assert.hpp>
#undef assert
void test_default()
{
std::string v1 = BOOST_STRINGIZE(BOOST_ASSERT(x1));
BOOST_TEST_EQ( v1, "assert(x1)" );
}
// default case, NDEBUG
// BOOST_ASSERT(x) -> assert(x)
#define NDEBUG
#include <boost/assert.hpp>
#undef assert
void test_default_ndebug()
{
std::string v2 = BOOST_STRINGIZE(BOOST_ASSERT(x2));
BOOST_TEST_EQ( v2, "assert(x2)" );
}
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled()
{
std::string v3 = BOOST_STRINGIZE(BOOST_ASSERT(x3));
BOOST_TEST_EQ( v3, "((void)0)" );
}
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_disabled_ndebug()
{
std::string v4 = BOOST_STRINGIZE(BOOST_ASSERT(x4));
BOOST_TEST_EQ( v4, "((void)0)" );
}
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#undef BOOST_LIKELY
#undef BOOST_CURRENT_FUNCTION
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
void test_handler()
{
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT(x5)); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed(\"x5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
BOOST_TEST_EQ( v5, w5 );
}
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
// BOOST_ASSERT(expr) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed(#expr, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define NDEBUG
#include <boost/assert.hpp>
void test_handler_ndebug()
{
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT(x6)); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed(\"x6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
BOOST_TEST_EQ( v6, w6 );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// same as BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
void test_debug_handler()
{
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT(x7)); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed(\"x7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
BOOST_TEST_EQ( v7, w7 );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_ASSERT(x) -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
std::string v8 = BOOST_STRINGIZE(BOOST_ASSERT(x8));
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler_ndebug()";
BOOST_TEST_EQ( v8, "((void)0)" );
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_disabled();
test_disabled_ndebug();
test_handler();
test_handler_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,164 @@
//
// assert_msg_exp_test.cpp - tests BOOST_ASSERT_MSG expansion
//
// Copyright (c) 2014 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/config.hpp>
#include <boost/current_function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
// Each backslash in __FILE__ when passed through BOOST_STRINGIZE is doubled
static std::string quote( std::string const & s )
{
std::string r;
r.reserve( s.size() );
for( char const * p = s.c_str(); *p; ++p )
{
r += *p;
if( *p == '\\' ) r += *p;
}
return r;
}
// default case, !NDEBUG
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
#undef NDEBUG
#include <boost/assert.hpp>
#undef assert
void test_default()
{
std::string v1 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x1, "m1"));
BOOST_TEST_EQ( v1, "assert((x1)&&(\"m1\"))" );
}
// default case, NDEBUG
// BOOST_ASSERT_MSG(x,"m") -> assert((x)&&("m"))
#define NDEBUG
#include <boost/assert.hpp>
#undef assert
void test_default_ndebug()
{
std::string v2 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x2, "m2"));
BOOST_TEST_EQ( v2, "assert((x2)&&(\"m2\"))" );
}
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled()
{
std::string v3 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x3, "m3"));
BOOST_TEST_EQ( v3, "((void)0)" );
}
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_disabled_ndebug()
{
std::string v4 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x4, "m4"));
BOOST_TEST_EQ( v4, "((void)0)" );
}
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_ASSERT_MSG(expr, msg) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#undef BOOST_LIKELY
#undef BOOST_CURRENT_FUNCTION
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
void test_handler()
{
std::string v5 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x5, "m5")); std::string w5 = "(BOOST_LIKELY(!!(x5))? ((void)0): ::boost::assertion_failed_msg(\"x5\", \"m5\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_handler()";
BOOST_TEST_EQ( v5, w5 );
}
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
// BOOST_ASSERT_MSG(expr, msg) -> (BOOST_LIKELY(!!(expr))? ((void)0): ::boost::assertion_failed_msg(#expr, msg, BOOST_CURRENT_FUNCTION, __FILE__, __LINE__))
#define NDEBUG
#include <boost/assert.hpp>
void test_handler_ndebug()
{
std::string v6 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x6, "m6")); std::string w6 = "(BOOST_LIKELY(!!(x6))? ((void)0): ::boost::assertion_failed_msg(\"x6\", \"m6\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_handler_ndebug()";
BOOST_TEST_EQ( v6, w6 );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// same as BOOST_ENABLE_ASSERT_HANDLER
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
void test_debug_handler()
{
std::string v7 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x7, "m7")); std::string w7 = "(BOOST_LIKELY(!!(x7))? ((void)0): ::boost::assertion_failed_msg(\"x7\", \"m7\", BOOST_CURRENT_FUNCTION, \"" + quote( __FILE__ ) + "\", " BOOST_STRINGIZE(__LINE__) "))";
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler()";
BOOST_TEST_EQ( v7, w7 );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_ASSERT_MSG(x,"m") -> ((void)0)
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
std::string v8 = BOOST_STRINGIZE(BOOST_ASSERT_MSG(x8, "m8"));
char const * BOOST_CURRENT_FUNCTION = "void test_debug_handler_ndebug()";
BOOST_TEST_EQ( v8, "((void)0)" );
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_disabled();
test_disabled_ndebug();
test_handler();
test_handler_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,136 @@
//
// verify_exp_test.cpp - tests BOOST_ASSERT expansion
//
// Copyright (c) 2014 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/config.hpp>
#include <boost/current_function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
// default case, !NDEBUG
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT
void test_default()
{
std::string v1 = BOOST_STRINGIZE(BOOST_VERIFY(x1));
BOOST_TEST_EQ( v1, "BOOST_ASSERT(x1)" );
}
// default case, NDEBUG
// BOOST_VERIFY(x) -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_default_ndebug()
{
std::string v2 = BOOST_STRINGIZE(BOOST_VERIFY(x2));
BOOST_TEST_EQ( v2, "((void)(x2))" );
}
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_VERIFY(x) -> ((void)(x))
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled()
{
std::string v3 = BOOST_STRINGIZE(BOOST_VERIFY(x3));
BOOST_TEST_EQ( v3, "((void)(x3))" );
}
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_VERIFY(x) -> ((void)(x))
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled_ndebug()
{
std::string v4 = BOOST_STRINGIZE(BOOST_VERIFY(x4));
BOOST_TEST_EQ( v4, "((void)(x4))" );
}
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT
void test_handler()
{
std::string v5 = BOOST_STRINGIZE(BOOST_VERIFY(x5));
BOOST_TEST_EQ( v5, "BOOST_ASSERT(x5)" );
}
#define NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT
void test_handler_ndebug()
{
std::string v6 = BOOST_STRINGIZE(BOOST_VERIFY(x6));
BOOST_TEST_EQ( v6, "BOOST_ASSERT(x6)" );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// BOOST_VERIFY(x) -> BOOST_ASSERT(x)
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT
void test_debug_handler()
{
std::string v7 = BOOST_STRINGIZE(BOOST_VERIFY(x7));
BOOST_TEST_EQ( v7, "BOOST_ASSERT(x7)" );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_VERIFY(x) -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
std::string v8 = BOOST_STRINGIZE(BOOST_VERIFY(x8));
BOOST_TEST_EQ( v8, "((void)(x8))" );
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_disabled();
test_disabled_ndebug();
test_handler();
test_handler_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,140 @@
//
// verify_msg_exp_test.cpp - tests BOOST_VERIFY_MSG expansion
//
// Copyright (c) 2014 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/config.hpp>
#include <boost/current_function.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
// default case, !NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> BOOST_ASSERT_MSG(x,"m")
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_default()
{
std::string v1 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x1, m1));
BOOST_TEST_EQ( v1, "BOOST_ASSERT_MSG(x1,m1)" );
}
// default case, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_default_ndebug()
{
std::string v2 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x2, m2));
BOOST_TEST_EQ( v2, "((void)(x2))" );
}
// BOOST_DISABLE_ASSERTS, !NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define BOOST_DISABLE_ASSERTS
#undef NDEBUG
#include <boost/assert.hpp>
void test_disabled()
{
std::string v3 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x3, "m3"));
BOOST_TEST_EQ( v3, "((void)(x3))" );
}
// BOOST_DISABLE_ASSERTS, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_disabled_ndebug()
{
std::string v4 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x4, "m4"));
BOOST_TEST_EQ( v4, "((void)(x4))" );
}
#undef BOOST_DISABLE_ASSERTS
// BOOST_ENABLE_ASSERT_HANDLER, !NDEBUG
// BOOST_VERIFY_MSG(x,m) -> BOOST_ASSERT_MSG(x,m)
#define BOOST_ENABLE_ASSERT_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_handler()
{
std::string v5 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x5, m5));
BOOST_TEST_EQ( v5, "BOOST_ASSERT_MSG(x5,m5)" );
}
// BOOST_ENABLE_ASSERT_HANDLER, NDEBUG
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
#define NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_handler_ndebug()
{
std::string v6 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x6, m6));
BOOST_TEST_EQ( v6, "BOOST_ASSERT_MSG(x6,m6)" );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, !NDEBUG
// BOOST_VERIFY_MSG(x,n) -> BOOST_ASSERT_MSG(x,m)
#define BOOST_ENABLE_ASSERT_DEBUG_HANDLER
#undef NDEBUG
#include <boost/assert.hpp>
#undef BOOST_ASSERT_MSG
void test_debug_handler()
{
std::string v7 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x7, m7));
BOOST_TEST_EQ( v7, "BOOST_ASSERT_MSG(x7,m7)" );
}
// BOOST_ENABLE_ASSERT_DEBUG_HANDLER, NDEBUG
// BOOST_VERIFY_MSG(x,"m") -> ((void)(x))
#define NDEBUG
#include <boost/assert.hpp>
void test_debug_handler_ndebug()
{
std::string v8 = BOOST_STRINGIZE(BOOST_VERIFY_MSG(x8, "m8"));
BOOST_TEST_EQ( v8, "((void)(x8))" );
}
#undef BOOST_ENABLE_ASSERT_DEBUG_HANDLER
int main()
{
test_default();
test_default_ndebug();
test_disabled();
test_disabled_ndebug();
test_handler();
test_handler_ndebug();
test_debug_handler();
test_debug_handler_ndebug();
return boost::report_errors();
}

View File

@@ -0,0 +1,18 @@
//
// quick.cpp - a quick test for boost/assert.hpp
//
// Copyright 2017 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/assert.hpp>
int main()
{
int x = 1; (void)x;
BOOST_ASSERT( x == 1 );
}

View File

@@ -0,0 +1,66 @@
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
{
boost::source_location loc;
BOOST_TEST_CSTR_EQ( loc.file_name(), "" );
BOOST_TEST_CSTR_EQ( loc.function_name(), "" );
BOOST_TEST_EQ( loc.line(), 0 );
BOOST_TEST_EQ( loc.column(), 0 );
}
{
boost::source_location loc( __FILE__, __LINE__, "main()" );
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST_EQ( loc.line(), 20 );
BOOST_TEST_CSTR_EQ( loc.function_name(), "main()" );
BOOST_TEST_EQ( loc.column(), 0 );
}
{
boost::source_location loc( "file", 1, "main()", 2 );
BOOST_TEST_CSTR_EQ( loc.file_name(), "file" );
BOOST_TEST_EQ( loc.line(), 1 );
BOOST_TEST_CSTR_EQ( loc.function_name(), "main()" );
BOOST_TEST_EQ( loc.column(), 2 );
}
{
boost::source_location loc = BOOST_CURRENT_LOCATION;
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST_EQ( loc.line(), 38 );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST_EQ( loc.line(), 45 );
}
#if defined(__cpp_lib_source_location) && __cpp_lib_source_location >= 201907L
{
std::source_location loc = std::source_location::current();
boost::source_location loc2 = loc;
BOOST_TEST_CSTR_EQ( loc2.file_name(), loc.file_name() );
BOOST_TEST_CSTR_EQ( loc2.function_name(), loc.function_name() );
BOOST_TEST_EQ( loc2.line(), loc.line() );
BOOST_TEST_EQ( loc2.column(), loc.column() );
}
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,31 @@
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#define BOOST_DISABLE_CURRENT_LOCATION
#include <boost/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
{
boost::source_location loc;
BOOST_TEST_CSTR_EQ( loc.file_name(), "" );
BOOST_TEST_CSTR_EQ( loc.function_name(), "" );
BOOST_TEST_EQ( loc.line(), 0 );
BOOST_TEST_EQ( loc.column(), 0 );
}
{
boost::source_location loc = BOOST_CURRENT_LOCATION;
BOOST_TEST_CSTR_EQ( loc.file_name(), "" );
BOOST_TEST_CSTR_EQ( loc.function_name(), "" );
BOOST_TEST_EQ( loc.line(), 0 );
BOOST_TEST_EQ( loc.column(), 0 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,74 @@
// Copyright 2020, 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
int main()
{
{
boost::source_location loc;
BOOST_TEST_EQ( loc.to_string(), std::string( "(unknown source location)" ) );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
{
boost::source_location loc( "file", 5, "" );
BOOST_TEST_EQ( loc.to_string(), std::string( "file:5" ) );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
{
boost::source_location loc( "file", 7, "main()" );
BOOST_TEST_EQ( loc.to_string(), std::string( "file:7 in function 'main()'" ) );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
{
boost::source_location loc( "file", 11, "main()", 13 );
BOOST_TEST_EQ( loc.to_string(), std::string( "file:11:13 in function 'main()'" ) );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
{
boost::source_location loc( "file", 17, "", 19 );
BOOST_TEST_EQ( loc.to_string(), std::string( "file:17:19" ) );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
{
boost::source_location loc = BOOST_CURRENT_LOCATION;
std::string prefix = std::string( __FILE__ ) + ":62";
BOOST_TEST_EQ( loc.to_string().substr( 0, prefix.size() ), prefix );
std::ostringstream os;
os << loc;
BOOST_TEST_EQ( os.str(), loc.to_string() );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,44 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
boost::source_location s_loc = BOOST_CURRENT_LOCATION;
BOOST_STATIC_CONSTEXPR boost::source_location c_loc = BOOST_CURRENT_LOCATION;
boost::source_location f( boost::source_location const& loc = BOOST_CURRENT_LOCATION )
{
return loc;
}
int main()
{
{
BOOST_TEST_CSTR_EQ( s_loc.file_name(), __FILE__ );
BOOST_TEST_EQ( s_loc.line(), 9 );
#if defined(BOOST_GCC) && BOOST_GCC < 90000
// '__static_initialization_and_destruction_0'
#else
BOOST_TEST_CSTR_EQ( s_loc.function_name(), "" );
#endif
}
{
BOOST_TEST_CSTR_EQ( c_loc.file_name(), __FILE__ );
BOOST_TEST_EQ( c_loc.line(), 11 );
}
{
boost::source_location loc = f();
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST( loc.line() == 13 || loc.line() == 37 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,44 @@
// Copyright 2022 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// Reduced from a boost::system::result test; codegen bug
// in GCC < 5 which is somehow triggered by __PRETTY_FUNCTION__
// and throwing an exception
#include <boost/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
#include <exception>
template<class T> class result
{
private:
bool has_value_;
T value_;
public:
result(): has_value_( false ), value_()
{
}
T value( boost::source_location const& /*loc*/ = BOOST_CURRENT_LOCATION ) const
{
if( has_value_ )
{
return value_;
}
else
{
throw std::exception();
}
}
};
int main()
{
result<int> r;
BOOST_TEST_THROWS( r.value(), std::exception );
return boost::report_errors();
}

View File

@@ -0,0 +1,130 @@
//
// verify_test.cpp - a test for BOOST_VERIFY
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2007 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/core/lightweight_test.hpp>
#if defined(__GNUC__)
# pragma GCC diagnostic ignored "-Waddress"
#endif
#include <boost/assert.hpp>
int f( int & x )
{
return ++x;
}
void test_default()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
}
#define BOOST_DISABLE_ASSERTS
#include <boost/assert.hpp>
void test_disabled()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
BOOST_VERIFY( 0 );
BOOST_VERIFY( !x );
BOOST_VERIFY( x == 0 );
BOOST_VERIFY( !++x );
BOOST_VERIFY( !f(x) );
BOOST_TEST( x == 5 );
void * p = 0;
BOOST_VERIFY( p );
}
#undef BOOST_DISABLE_ASSERTS
#define BOOST_ENABLE_ASSERT_HANDLER
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <cstdio>
int handler_invoked = 0;
void boost::assertion_failed(char const * expr, char const * function, char const * file, long line)
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::printf;
#endif
printf("Expression: %s\nFunction: %s\nFile: %s\nLine: %ld\n\n", expr, function, file, line);
++handler_invoked;
}
struct X
{
static bool f()
{
BOOST_VERIFY( 0 );
return false;
}
};
void test_handler()
{
int x = 1;
BOOST_VERIFY( 1 );
BOOST_VERIFY( x == 1 );
BOOST_VERIFY( ++x );
BOOST_VERIFY( f(x) );
BOOST_VERIFY( &x );
BOOST_TEST( x == 3 );
BOOST_VERIFY( 0 );
BOOST_VERIFY( !x );
BOOST_VERIFY( x == 0 );
BOOST_VERIFY( !++x );
BOOST_VERIFY( !f(x) );
BOOST_TEST( x == 5 );
void * p = 0;
BOOST_VERIFY( p );
BOOST_VERIFY( X::f() );
BOOST_TEST( handler_invoked == 8 );
}
#undef BOOST_ENABLE_ASSERT_HANDLER
int main()
{
test_default();
test_disabled();
test_handler();
return boost::report_errors();
}

View File

@@ -0,0 +1,7 @@
-- Downloading https://github.com/boostorg/assert/archive/boost-1.79.0.tar.gz -> boostorg-assert-boost-1.79.0.tar.gz...
-- Extracting source D:/a/1/s/externals/vcpkg/downloads/boostorg-assert-boost-1.79.0.tar.gz
-- Using source at D:/a/1/s/externals/vcpkg/buildtrees/boost-assert/src/ost-1.79.0-2288a3bead.clean
-- Copying headers
-- Copying headers done
-- Installing: D:/a/1/s/externals/vcpkg/packages/boost-assert_x64-windows/share/boost-assert/usage
-- Installing: D:/a/1/s/externals/vcpkg/packages/boost-assert_x64-windows/share/boost-assert/copyright

View File

@@ -0,0 +1,13 @@
boost-config 797535e8975ed7cf5bbe11d9f7fe26caa5da8fe819888564758d82a21109fade
boost-vcpkg-helpers c81c7b003df356a1a120a7c0c2f5a2ac95f3c33b006a2a5b4c02dcf0c9f3deaa
cmake 3.23.2
features core
portfile.cmake f42197f9a27b171b9fb74d88fc2d61d044498681f9425159b8dd5ae960987652
ports.cmake 366c60b768113102408b32ac1d7c7b48ef7d30a477af2a220ecc222d9ffa3166
post_build_checks 2
powershell 7.2.5
triplet x64-windows
triplet_abi 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c-c0600b35e024ce0485ed253ef5419f3686f7257cfb58cb6a24febcb600fc4b4c-27ebd443f77a6c449168adfa6ce8def60cf46e88
vcpkg.json 02c3ec2e88c6a777ea94984231244322f874e95a66b28c86558cb0c94ef69c3e
vcpkg_from_git 0aab20e34e84d52ba4763f009e539bfa8f418c41c918c8cf700156f1a8551a10
vcpkg_from_github b743742296a114ea1b18ae99672e02f142c4eb2bef7f57d36c038bedbfb0502f