├── cevelop-workspace
├── .gitignore
├── scope17
│ ├── .gitignore
│ ├── .project
│ ├── src
│ │ ├── license.txt
│ │ └── Test.cpp
│ └── cute
│ │ ├── cute_version.h
│ │ ├── cute.h
│ │ ├── cute_listener.h
│ │ ├── cute_determine_version.h
│ │ ├── cute_suite.h
│ │ ├── cute_determine_traits.h
│ │ ├── cute_suite_test.h
│ │ ├── cute_determine_library.h
│ │ ├── cute_repeated_test.h
│ │ ├── cute_xml_file.h
│ │ ├── cute_deprecated.h
│ │ ├── cute_diff_values.h
│ │ ├── cute_test.h
│ │ ├── cute_throws.h
│ │ ├── cute_counting_listener.h
│ │ ├── cute_test_incarnate.h
│ │ ├── ostream_listener.h
│ │ ├── cute_range.h
│ │ ├── cute_base.h
│ │ ├── tap_listener.h
│ │ ├── cute_integer_sequence.h
│ │ ├── cute_relops.h
│ │ ├── ide_listener.h
│ │ ├── cute_testmember.h
│ │ ├── xml_listener.h
│ │ ├── cute_data_driven.h
│ │ ├── cute_demangle.h
│ │ ├── cute_runner.h
│ │ ├── cute_equals.h
│ │ └── cute_to_string.h
└── CMakeLists.txt
├── .clang-format
├── scopeConfig.cmake.in
├── examples
├── CMakeLists.txt
└── Demo.cpp
├── appveyor.yml
├── .gitignore
├── .github
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── .travis.yml
├── README.md
├── LICENSE_1_0.txt
├── CMakeLists.txt
└── scope.hpp
/cevelop-workspace/.gitignore:
--------------------------------------------------------------------------------
1 | /.metadata/
2 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/.gitignore:
--------------------------------------------------------------------------------
1 | /Debug/
2 | demo_hello.txt
3 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | ---
2 | BasedOnStyle: Google
3 | IndentWidth: 4
4 | # BraceWrapping:
5 |
--------------------------------------------------------------------------------
/scopeConfig.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/scopeTargets.cmake")
4 |
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required (VERSION 3.12...3.19 FATAL_ERROR)
2 |
3 | project(demo LANGUAGES CXX)
4 |
5 | if(NOT TARGET scope)
6 | find_package(scope CONFIG REQUIRED)
7 | endif()
8 |
9 | add_executable(Demo Demo.cpp)
10 | target_link_libraries(Demo PRIVATE std::scope)
11 |
12 | if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
13 | target_link_libraries(Demo PRIVATE "stdc++fs")
14 | endif()
15 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 |
2 | image:
3 | - Visual Studio 2017
4 | - Visual Studio 2019
5 |
6 | platform:
7 | - x64
8 | - Win32
9 |
10 | configuration:
11 | - Debug
12 | - Release
13 |
14 | matrix:
15 | fast_finish: true
16 |
17 | build_script:
18 | - cmd: >-
19 | mkdir build && cd build && cmake -A %platform% .. && cmake --build . --config %configuration%
20 |
21 | test_script:
22 | - cmd: >-
23 | ctest -C %configuration%
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.aux
2 | *.bbl
3 | *.blg
4 | *.dvi
5 | *.fdb_latexmk
6 | *.fls
7 | *.glg
8 | *.glo
9 | *.gls
10 | *.idx
11 | *.ilg
12 | *.ind
13 | *.ist
14 | *.lof
15 | *.log
16 | *.lot
17 | *.nav
18 | *.nlo
19 | *.out
20 | *.pdfsync
21 | *.ps
22 | *.snm
23 | *.synctex.gz
24 | *.toc
25 | *.vrb
26 | *.maf
27 | *.mtc
28 | *.mtc0
29 |
30 | .DS_Store
31 |
32 | Release
33 | Debug
34 | .metadata/
35 | .settings/
36 | .cproject
37 | *Test.xml
38 | .*.html
39 | scope17.xml
40 |
41 | build/
42 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 |
2 | language: cpp
3 |
4 | matrix:
5 | include:
6 | - os: linux
7 | dist: bionic
8 | addons:
9 | apt:
10 | sources:
11 | - ubuntu-toolchain-r-test
12 | packages:
13 | - g++-8
14 | env:
15 | - CC=gcc-8
16 | - CXX=g++-8
17 | - configuration=Debug
18 |
19 | - os: linux
20 | dist: bionic
21 | addons:
22 | apt:
23 | sources:
24 | - ubuntu-toolchain-r-test
25 | packages:
26 | - g++-8
27 | env:
28 | - CC=gcc-8
29 | - CXX=g++-8
30 | - configuration=Release
31 |
32 | script:
33 | mkdir build && cd build && cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE .. && cmake --build . --config $configuration && ctest -C $configuration
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # scope17
2 | C++17 version of `unique_resource` and `scope_guards` from LFTS3
3 |
4 | List of tested compilers:
5 | - OSX and AppleClang 12.0
6 | - Linux and gcc 8.3
7 | - Windows and msvc 2017
8 | - Windows and msvc 2019
9 |
10 | Status of tests in CI servers:
11 |
12 | | Branch | Travis | Appveyor |
13 | | ---- | -------- | -------- |
14 | | **Master** | [](https://travis-ci.org/menuet/scope17) | [](https://ci.appveyor.com/project/menuet/scope17/branch/master) |
15 |
16 | How to build and run the tests locally:
17 | ```
18 | mkdir build && cd build && cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE .. && cmake --build . --config Debug && ctest -C Debug
19 | ```
20 |
--------------------------------------------------------------------------------
/cevelop-workspace/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(scope_test scope17/src/Test.cpp ../scope.hpp)
2 | target_include_directories(scope_test PRIVATE scope17/cute)
3 | target_link_libraries(scope_test PRIVATE scope)
4 |
5 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR
6 | ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows"))
7 | target_compile_definitions(scope_test PRIVATE _CRT_SECURE_NO_WARNINGS)
8 | endif()
9 |
10 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
11 | add_compile_options(-Wall -Wextra -Wpedantic -Wshadow -Wold-style-cast)
12 | endif()
13 |
14 | if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
15 | target_link_libraries(scope_test PRIVATE "stdc++fs")
16 | endif()
17 |
18 | add_test(NAME scope_test COMMAND scope_test)
19 |
20 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | scope17
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | ch.hsr.ifs.cute.ui.cutenature
23 | org.eclipse.cdt.core.cnature
24 | org.eclipse.cdt.core.ccnature
25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/LICENSE_1_0.txt:
--------------------------------------------------------------------------------
1 | Boost Software License - Version 1.0 - August 17th, 2003
2 |
3 | Permission is hereby granted, free of charge, to any person or organization
4 | obtaining a copy of the software and accompanying documentation covered by
5 | this license (the "Software") to use, reproduce, display, distribute,
6 | execute, and transmit the Software, and to prepare derivative works of the
7 | Software, and to permit third-parties to whom the Software is furnished to
8 | do so, all subject to the following:
9 |
10 | The copyright notices in the Software and this entire statement, including
11 | the above license grant, this restriction and the following disclaimer,
12 | must be included in all copies of the Software, in whole or in part, and
13 | all derivative works of the Software, unless such copies or derivative
14 | works are solely in the form of machine-executable object code generated by
15 | a source language processor.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/src/license.txt:
--------------------------------------------------------------------------------
1 | Boost Software License - Version 1.0 - August 17th, 2003
2 |
3 | Copyright (c) 2016-2022 Eric Niebler and Peter Sommerlad
4 |
5 | Permission is hereby granted, free of charge, to any person or organization
6 | obtaining a copy of the software and accompanying documentation covered by
7 | this license (the "Software") to use, reproduce, display, distribute,
8 | execute, and transmit the Software, and to prepare derivative works of the
9 | Software, and to permit third-parties to whom the Software is furnished to
10 | do so, all subject to the following:
11 |
12 | The copyright notices in the Software and this entire statement, including
13 | the above license grant, this restriction and the following disclaimer,
14 | must be included in all copies of the Software, in whole or in part, and
15 | all derivative works of the Software, unless such copies or derivative
16 | works are solely in the form of machine-executable object code generated by
17 | a source language processor.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 | DEALINGS IN THE SOFTWARE.
26 |
27 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_version.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2008-2018 Peter Sommerlad, Emanuel Graf, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_VERSION_H_
27 | #define CUTE_VERSION_H_
28 |
29 | #define CUTE_LIB_VERSION "2.2.6"
30 |
31 | #endif /*CUTE_VERSION_H_*/
32 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_H_
27 | #define CUTE_H_
28 | // all CUTE includes for writing tests and suites
29 | #include "cute_base.h"
30 | #include "cute_equals.h"
31 | #include "cute_relops.h"
32 | #include "cute_data_driven.h"
33 | #include "cute_throws.h"
34 | #include "cute_suite.h"
35 | #include "cute_repeated_test.h"
36 | #include "cute_suite_test.h"
37 | #include "cute_test_incarnate.h"
38 | #include "cute_test.h"
39 | #include "cute_testmember.h"
40 | #include "cute_version.h"
41 | #endif /*CUTE_H_*/
42 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_LISTENER_H_
27 | #define CUTE_LISTENER_H_
28 | #include "cute_base.h"
29 | #include "cute_suite.h"
30 | namespace cute {
31 | struct null_listener{ // defines Contract of runner parameter
32 | void begin(suite const &, char const * /*info*/, size_t /*n_of_tests*/){}
33 | void end(suite const &, char const * /*info*/){}
34 | void start(test const &){}
35 | void success(test const &,char const * /*msg*/){}
36 | void failure(test const &,test_failure const &){}
37 | void error(test const &,char const * /*what*/){}
38 | };
39 | }
40 | #endif /* CUTE_LISTENER_H_ */
41 |
42 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_determine_version.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DETERMINE_VERSION_H_
27 | #define CUTE_DETERMINE_VERSION_H_
28 |
29 | #if __cplusplus >= 201103L && ! defined (USE_STD11)
30 | #define USE_STD11 1
31 | #endif
32 |
33 | #if defined(__GNUG__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && ! defined(USE_TR1) && ! defined(USE_STD11)
34 | #define USE_STD11 1
35 | #endif
36 |
37 | #ifdef _MSC_VER
38 | #if (_MSC_VER >= 1400)
39 | #define USE_STD11 1
40 | #endif
41 | #endif
42 |
43 | #if __cplusplus >= 201402L
44 | #define USE_STD14
45 | #endif
46 |
47 | #if __cplusplus >= 201703L
48 | #define USE_STD17
49 | #endif
50 | #endif /*CUTE_DETERMINE_VERSION_H_*/
51 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_suite.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_SUITE_H_
27 | #define CUTE_SUITE_H_
28 |
29 | #include "cute_test.h"
30 |
31 | #include
32 |
33 | namespace cute {
34 | typedef std::vector suite;
35 | // convenience operator for appending to suites, might not be right
36 | // deprecated, not supported by plug-in, not needed with Eclipse plug-in
37 | inline
38 | suite &operator+=(suite &left, suite const &right){
39 | left.insert(left.end(),right.begin(),right.end());
40 | return left;
41 | }
42 | inline
43 | suite &operator+=(suite &left, test const &right){
44 | left.push_back(right);
45 | return left;
46 | }
47 | }
48 |
49 | #endif /*CUTE_SUITE_H_*/
50 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_determine_traits.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2013-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DETERMINE_TRAITS_H_
27 | #define CUTE_DETERMINE_TRAITS_H_
28 | #include "cute_determine_version.h"
29 | #if defined(USE_STD11)
30 | #include
31 | #elif defined(USE_TR1)
32 | #include
33 | #else
34 | #include
35 | #include
36 | #include
37 | #endif
38 | #if defined(USE_STD11)
39 | namespace impl_place_for_traits = std;
40 | #elif defined(USE_TR1)
41 | namespace impl_place_for_traits = std::tr1;
42 | #else
43 | namespace impl_place_for_traits = boost;
44 | #endif
45 |
46 | #endif /* CUTE_DETERMINE_TRAITS_H_ */
47 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_suite_test.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_SUITE_TEST_H_
27 | #define CUTE_SUITE_TEST_H_
28 | #include "cute_suite.h"
29 | #include "cute_determine_library.h"
30 |
31 | #include
32 | namespace cute{
33 | // make a whole suite a test, failure stops the suite's execution
34 | struct suite_test {
35 | suite theSuite;
36 | suite_test(suite const &s):theSuite(s){}
37 | void operator()(){
38 | std::for_each(theSuite.begin(),theSuite.end(),boost_or_tr1::bind(&test::operator(),_1));
39 | }
40 | };
41 | }
42 | #define CUTE_SUITE_TEST(s) cute::test(cute::suite_test((s)),#s)
43 | #define CUTE_SUITE_TEST_NAME(s, name) cute::test(cute::suite_test((s)),name)
44 | #endif /*CUTE_SUITE_TEST_H_*/
45 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_determine_library.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DETERMINE_LIBRARY_H_
27 | #define CUTE_DETERMINE_LIBRARY_H_
28 | #include "cute_determine_version.h"
29 | #if defined(USE_TR1)
30 | #include
31 | // bind already given by in cute_test.h from cute_suite.h
32 | namespace boost_or_tr1 = std::tr1;
33 | namespace cute {
34 | using namespace boost_or_tr1::placeholders;
35 | }
36 | #elif defined(USE_STD11)
37 | #include
38 | namespace boost_or_tr1 = std;
39 | namespace cute {
40 | using namespace boost_or_tr1::placeholders;
41 | }
42 | #else
43 | #include
44 | #include
45 | namespace boost_or_tr1 = boost;
46 | #endif
47 |
48 | #endif /*CUTE_DETERMINE_LIBRARY_H_*/
49 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_repeated_test.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_REPEATED_TEST_H_
27 | #define CUTE_REPEATED_TEST_H_
28 |
29 | #include "cute_test.h"
30 |
31 | namespace cute{
32 | struct repeated_test {
33 | repeated_test(test const &t,unsigned int n):theTest(t),repetitions(n){}
34 | void operator()(){
35 | for (unsigned int i=0;i
30 | #include
31 |
32 | namespace cute {
33 | struct xml_file_opener {
34 | std::string filename;
35 | std::ofstream out;
36 | xml_file_opener(int argc, char const *const* argv)
37 | :filename(argc>0&&argv[0]?basename(argv[0]):"testresult.xml")
38 | ,out(filename.c_str()){}
39 | std::string basename(std::string path){
40 | #if defined( _MSC_VER ) || defined(__MINGW32__)
41 | char const sep='\\';
42 | #else
43 | char const sep='/';
44 | #endif
45 | std::string::size_type pos=path.find_last_of(sep,path.size()-1);
46 | if (pos != std::string::npos) path.erase(0,pos+1);
47 | path+=".xml";
48 | return path;
49 | }
50 | };
51 | }
52 |
53 | #endif /* CUTE_XML_FILE_H_ */
54 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_deprecated.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2016-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DEPRECATED_H_
27 | #define CUTE_DEPRECATED_H_
28 |
29 | #if __cplusplus >= 201402L
30 | #define DEPRECATE(orig, repl) [[deprecated ("Use "#repl" instead.")]] inline void orig() {}
31 | #elif defined(__GNUG__)
32 | #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
33 | #if GCC_VERSION >= 40500 || defined(__clang__)
34 | #define DEPRECATE(orig, repl) __attribute__((deprecated("Use "#repl" instead."))) inline void orig() {}
35 | #else
36 | #define DEPRECATE(orig, repl) __attribute__((deprecated)) inline void orig() {}
37 | #endif
38 | #elif defined(_MSC_VER)
39 | #define DEPRECATE(orig, repl) __declspec(deprecated(#orig" is deprecated, use "#repl" instead.")) inline void orig() {}
40 | #endif
41 |
42 | #ifdef DEPRECATE
43 | #define DEPRECATED(name) name()
44 | #endif
45 |
46 | #endif /*CUTE_DEPRECATED_H_*/
47 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required (VERSION 3.12...3.19 FATAL_ERROR)
2 |
3 | project(scope17 VERSION 0.9.0 LANGUAGES CXX)
4 |
5 | set(MASTER_PROJECT OFF)
6 | if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
7 | set(MASTER_PROJECT ON)
8 | message(STATUS "CMake version: ${CMAKE_VERSION}")
9 | endif()
10 |
11 | #----------------------------------------------------------
12 | # Compiler config
13 | #----------------------------------------------------------
14 | if(NOT DEFINED CMAKE_CXX_STANDARD)
15 | set(CMAKE_CXX_STANDARD 17)
16 | set(CMAKE_CXX_STANDARD_REQUIRED ON)
17 | set(CMAKE_CXX_EXTENSIONS OFF)
18 | endif()
19 |
20 | add_library(scope INTERFACE)
21 | add_library(std::scope ALIAS scope)
22 |
23 | ### target_sources(scope INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/scope.hpp)
24 | target_include_directories(scope INTERFACE
25 | $
26 | )
27 | target_include_directories(scope SYSTEM INTERFACE
28 | $/include/experimental>
29 | )
30 | target_compile_features(scope INTERFACE cxx_std_17)
31 |
32 | option(SCOPE_TEST "Generate the scope_test target" ${MASTER_PROJECT})
33 | if(SCOPE_TEST)
34 | enable_testing()
35 | add_subdirectory(cevelop-workspace)
36 | add_subdirectory(examples)
37 | endif()
38 |
39 | option(SCOPE_INSTALL "Generate the scope_test target" ${MASTER_PROJECT})
40 | if(SCOPE_INSTALL)
41 | install(TARGETS scope EXPORT scopeTargets
42 | INCLUDES DESTINATION include
43 | )
44 |
45 | install(EXPORT scopeTargets
46 | FILE scopeTargets.cmake
47 | NAMESPACE std::
48 | DESTINATION lib/cmake/scope
49 | )
50 |
51 | export(TARGETS scope
52 | NAMESPACE std::
53 | FILE scopeTargets.cmake
54 | )
55 |
56 | install(FILES scope.hpp DESTINATION include/experimental)
57 |
58 | include(CMakePackageConfigHelpers)
59 | configure_package_config_file(scopeConfig.cmake.in
60 | ${CMAKE_CURRENT_BINARY_DIR}/scopeConfig.cmake
61 | INSTALL_DESTINATION lib/cmake/scope
62 | )
63 | write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/scopeConfigVersion.cmake
64 | COMPATIBILITY SameMajorVersion
65 | )
66 |
67 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scopeConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/scopeConfigVersion.cmake
68 | DESTINATION lib/cmake/scope
69 | )
70 | endif()
71 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_diff_values.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2013-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DIFF_VALUES_H_
27 | #define CUTE_DIFF_VALUES_H_
28 | #include "cute_to_string.h"
29 | namespace cute {
30 | // you could provide your own overload for diff_values for your app-specific types
31 | // be sure to use tabs as given below, then the CUTE eclipse plug-in will parse correctly
32 | template
33 | std::string diff_values(ExpectedValue const &expected
34 | , ActualValue const & actual
35 | , char const *left="expected"
36 | , char const *right="but was"){
37 | // construct a simple message...to be parsed by IDE support
38 | std::string res;
39 | res += ' ';
40 | res += left;
41 | res+=":\t" + cute_to_string::backslashQuoteTabNewline(cute_to_string::to_string(expected))+'\t';
42 | res += right;
43 | res +=":\t"+cute_to_string::backslashQuoteTabNewline(cute_to_string::to_string(actual))+'\t';
44 | return res;
45 | }
46 | }
47 |
48 | #endif /* CUTE_DIFF_VALUES_H_ */
49 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_test.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, Emanuel Graf, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_TEST_H_
27 | #define CUTE_TEST_H_
28 |
29 | #include "cute_determine_library.h"
30 | #include "cute_demangle.h"
31 |
32 | // make plain functions as tests more 'cute':
33 | namespace cute {
34 |
35 | struct test{
36 | void operator()()const{ theTest(); }
37 | std::string name()const{ return name_;}
38 |
39 |
40 | // (real) functor types can (almost) spell their name
41 | // but a name can also be given explicitely, e.g. for CUTE() macro
42 | // for simple test functions
43 | template
44 | test(VoidFunctor const &t, std::string sname = demangle(typeid(VoidFunctor).name()))
45 | :name_(sname),theTest(t){}
46 | // separate overload to allow nicer C++11 initializers with {"name",lambda}
47 | template
48 | test(std::string sname,VoidFunctor const &t)
49 | :name_(sname),theTest(t){}
50 |
51 | private:
52 | std::string name_;
53 | boost_or_tr1::function theTest;
54 | };
55 |
56 | }
57 |
58 | #define CUTE(name) cute::test((&name),(#name))
59 |
60 | #endif /*CUTE_TEST_H_*/
61 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_throws.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_THROWS_H_
27 | #define CUTE_THROWS_H_
28 |
29 | #include "cute_base.h"
30 |
31 | // should we allow arbitrary code and remove the parentheses around the macro expansion?
32 | // not now, strange compilation side-effects might result.
33 | namespace cute {
34 | namespace do_not_use_this_namespace {
35 | struct assert_throws_failure_exception {
36 | struct cute::test_failure original;
37 | assert_throws_failure_exception(std::string const &r,char const *f, int line):
38 | original(r,f, line){}
39 | };
40 | }
41 | }
42 |
43 | #define ASSERT_THROWSM(anuncommonmessagetextparametername,code,exc) \
44 | do { \
45 | try { \
46 | { code ; } \
47 | throw cute::do_not_use_this_namespace::assert_throws_failure_exception((anuncommonmessagetextparametername),__FILE__,__LINE__); \
48 | } catch(exc const &){ \
49 | } catch(cute::do_not_use_this_namespace::assert_throws_failure_exception const &atf){throw atf.original;} \
50 | } while(0)
51 | #define ASSERT_THROWS(code,exc) ASSERT_THROWSM(" expecting " #code " to throw " #exc,code,exc)
52 |
53 | #endif /*CUTE_THROWS_H_*/
54 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_counting_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_COUNTING_LISTENER_H_
27 | #define CUTE_COUNTING_LISTENER_H_
28 | #include "cute_listener.h"
29 | namespace cute{
30 | template
31 | struct counting_listener:Listener{
32 | counting_listener()
33 | :Listener()
34 | ,numberOfTests(0),successfulTests(0),failedTests(0),errors(0),numberOfSuites(0),numberOfTestsInSuites(0){}
35 |
36 | counting_listener(Listener const &s)
37 | :Listener(s)
38 | ,numberOfTests(0),successfulTests(0),failedTests(0),errors(0),numberOfSuites(0),numberOfTestsInSuites(0){}
39 |
40 | void begin(suite const &s,char const *info, size_t n_of_tests){
41 | ++numberOfSuites;
42 | numberOfTestsInSuites+=n_of_tests;
43 | Listener::begin(s,info, n_of_tests);
44 | }
45 | void start(test const &t){
46 | ++numberOfTests;
47 | Listener::start(t);
48 | }
49 | void success(test const &t,char const *msg){
50 | ++successfulTests;
51 | Listener::success(t,msg);
52 | }
53 | void failure(test const &t,test_failure const &e){
54 | ++failedTests;
55 | Listener::failure(t,e);
56 | }
57 | void error(test const &t,char const *what){
58 | ++errors;
59 | Listener::error(t,what);
60 | }
61 | size_t numberOfTests;
62 | size_t successfulTests;
63 | size_t failedTests;
64 | size_t errors;
65 | size_t numberOfSuites;
66 | size_t numberOfTestsInSuites;
67 |
68 | };
69 | }
70 | #endif /*CUTE_COUNTING_LISTENER_H_*/
71 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_test_incarnate.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_TEST_INCARNATE_H_
27 | #define CUTE_TEST_INCARNATE_H_
28 |
29 | #include "cute_test.h"
30 |
31 | // idea blatantly stolen from Aeryn
32 | namespace cute {
33 | template
34 | struct test_incarnate {
35 | void operator()(){
36 | TestFunctor()();
37 | }
38 | };
39 | // TODO: check if there are problems with references.
40 | template
41 | struct test_incarnate_with_context {
42 | test_incarnate_with_context(ContextObject context):theContext(context)
43 | {}
44 | test_incarnate_with_context(test_incarnate_with_context const &other):theContext(other.theContext){} // provide copy-ctor in case compiler will define it deleted
45 | void operator()(){
46 | TestFunctor t(theContext);// wouldn't create temporary to call with ()()
47 | t();
48 | }
49 | ContextObject theContext;
50 | };
51 | template
52 | test make_incarnate_with_context(ContextObject obj){
53 | return test(test_incarnate_with_context(obj),demangle(typeid(TestFunctor).name()));
54 | }
55 | }
56 |
57 | #define CUTE_INCARNATE(TestFunctor) cute::test(cute::test_incarnate(),cute::demangle(typeid(TestFunctor).name()))
58 | #define CUTE_INCARNATE_WITH_CONTEXT(TestFunctor,contextObject) cute::make_incarnate_with_context(contextObject)
59 |
60 | #endif /*CUTE_TEST_INCARNATE_H_*/
61 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/ostream_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef OSTREAM_LISTENER_H_
27 | #define OSTREAM_LISTENER_H_
28 |
29 | #include "cute_listener.h"
30 |
31 | #include
32 |
33 | namespace cute {
34 | // a "root" listener displaying output, use it as an example on how to build your own, e.g., for XML output
35 | template
36 | struct ostream_listener:Listener
37 | {
38 | std::ostream &out;
39 | public:
40 | ostream_listener(std::ostream &os=std::cerr):out(os) {}
41 | void begin(suite const &t,char const *info, size_t n_of_tests){
42 | out << "beginning: " << info << std::endl;
43 | Listener::begin(t,info, n_of_tests);
44 | }
45 | void end(suite const &t, char const *info){
46 | out << "ending: " << info << std::endl;
47 | Listener::end(t,info);
48 | }
49 | void start(test const &t){
50 | out << "starting: " << t.name() << std::endl;
51 | Listener::start(t);
52 | }
53 | void success(test const &t, char const *msg){
54 | out << t.name() << " " << msg << std::endl;
55 | Listener::success(t,msg);
56 | }
57 | void failure(test const &t,test_failure const &e){
58 | out << std::dec << e.filename << ":" << e.lineno << ": testcase failed: " << e.reason << " in " << t.name() << std::endl;
59 | Listener::failure(t,e);
60 | }
61 | void error(test const &t, char const *what){
62 | out << what << " in " << t.name() << std::endl;
63 | Listener::error(t,what);
64 | }
65 | };
66 | }
67 |
68 | #endif /*OSTREAM_LISTENER_H_*/
69 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_range.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2015-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_RANGE_H_
27 | #define CUTE_RANGE_H_
28 |
29 | #include "cute_determine_version.h"
30 |
31 | #include
32 | #include
33 | #ifdef USE_STD11
34 | #include
35 | #endif
36 |
37 | namespace cute{
38 | template
39 | struct range {
40 | typedef ForwardIterator const_iterator; // for to_stream dispatch
41 | typedef typename std::iterator_traits::value_type value_type;
42 | const_iterator const b;
43 | const_iterator const e;
44 | range(ForwardIterator bb,ForwardIterator ee):b(bb),e(ee){}
45 | const_iterator begin() const { return b; }
46 | const_iterator end() const { return e; }
47 | template
48 | bool operator==(RangeOrContainer const &other) const{
49 | #ifdef USE_STD14
50 | return std::equal(begin(),end(),other.begin(),other.end());
51 | #else
52 | if (std::distance(begin(),end())==std::distance(other.begin(),other.end())){
53 | return std::equal(begin(),end(),other.begin());
54 | }
55 | return false;
56 | #endif
57 | }
58 | };
59 | template
60 | range make_range(ForwardIterator b, ForwardIterator e){
61 | return range(b,e);
62 | }
63 |
64 | #ifdef USE_STD11
65 | template
66 | range::iterator>
67 | make_range(std::initializer_list const &il){
68 | return range::iterator>(il.begin(),il.end());
69 | }
70 | #endif
71 | }
72 |
73 | #endif /* CUTE_RANGE_H_ */
74 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_base.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_BASE_H_
27 | #define CUTE_BASE_H_
28 |
29 | #include "cute_to_string.h"
30 | #include "cute_determine_version.h"
31 |
32 | #include
33 |
34 | namespace cute {
35 | struct test_failure {
36 | std::string reason;
37 | std::string filename;
38 | int lineno;
39 |
40 | test_failure(std::string const &r,char const *f, int line)
41 | :reason(r),filename(f),lineno(line)
42 | { }
43 | char const * what() const { return reason.c_str(); }
44 | };
45 | }
46 |
47 | #if defined(USE_STD11) && !defined(_MSC_VER)
48 | #define CUTE_FUNCNAME_PREFIX std::string(__func__)+": "
49 | #else
50 | #if defined( _MSC_VER ) || defined(__GNUG__)
51 | //#if defined(USE_STD11)
52 | //#define CUTE_FUNCNAME_PREFIX
53 | // workaround doesn't work namespace { char const __FUNCTION__ []="lambda";}
54 | // MSC can not use lambdas outside of function bodies for tests.
55 | //#endif
56 | // use -D CUTE_FUNCNAME_PREFIX if you want to use non-local lambdas with test macros
57 | #if !defined(CUTE_FUNCNAME_PREFIX)
58 | #define CUTE_FUNCNAME_PREFIX std::string(__FUNCTION__)+": "
59 | #endif
60 | #else // could provide #defines for other compiler-specific extensions... need to experiment, i.e., MS uses __FUNCTION__
61 | #define CUTE_FUNCNAME_PREFIX std::string("")
62 | #endif
63 | #endif
64 | #define ASSERTM(msg,cond) do { if (!(cond)) throw cute::test_failure(CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__);} while(false)
65 | #define ASSERT(cond) ASSERTM(#cond,cond)
66 | #define FAIL() ASSERTM("FAIL()",false)
67 | #define FAILM(msg) ASSERTM(msg,false)
68 | #endif /*CUTE_BASE_H_*/
69 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/tap_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2017-2018 Felix Morgner
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef TAP_LISTENER_H_
27 | #define TAP_LISTENER_H_
28 |
29 | #include
30 | #include
31 |
32 | #include "cute_listener.h"
33 |
34 | namespace cute {
35 |
36 | template
37 | struct tap_listener : Listener {
38 | tap_listener(std::ostream & out = std::cout) : out(out),nofTests(0) { }
39 |
40 | ~tap_listener() {
41 | if (nofTests) {
42 | out << "1.." << nofTests << '\n';
43 | }
44 | }
45 |
46 | void begin(suite const & suite, char const * info, size_t n_of_tests) {
47 | out << "# Starting suite '" << info << "' containing " << n_of_tests << " tests\n";
48 | Listener::begin(suite, info, n_of_tests);
49 | }
50 |
51 | void end(suite const & suite, char const * info) {
52 | out << "# Ending suite '" << info << "'\n";
53 | Listener::end(suite, info);
54 | }
55 |
56 | void start(test const & test) {
57 | ++nofTests;
58 | Listener::start(test);
59 | }
60 |
61 | void success(test const & test, char const * msg) {
62 | out << "ok " << nofTests << ' ' << test.name() << '\n';
63 | Listener::success(test, msg);
64 | }
65 |
66 | void failure(test const & test, test_failure const & reason) {
67 | out << "not ok " << nofTests << ' ' << test.name() << '\n';
68 | out << "# Assertion failed: " << reason.what() << '\n';
69 | Listener::failure(test, reason);
70 | }
71 |
72 | void error(test const & test, char const * what) {
73 | out << "not ok " << nofTests << ' ' << test.name() << '\n';
74 | out << "# Unexpected exception: " << what << '\n';
75 | Listener::error(test, what);
76 | }
77 |
78 | private:
79 | std::ostream & out;
80 | std::size_t nofTests;
81 | };
82 |
83 | }
84 |
85 | #endif /* TAP_LISTENER_H_ */
86 |
87 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_integer_sequence.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2016-2018 Felix Morgner
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_INTEGER_SEQUENCE_H_
27 | #define CUTE_INTEGER_SEQUENCE_H_
28 |
29 | #include "cute_determine_version.h"
30 |
31 | #ifdef USE_STD14
32 | #include
33 | namespace cute {
34 | using std::index_sequence;
35 | using std::index_sequence_for;
36 | }
37 | #else
38 | #include
39 | namespace cute {
40 | namespace do_not_use_this_namespace {
41 | template
42 | struct integer_sequence {
43 | using type = integer_sequence;
44 | using value_type = IntType;
45 | static constexpr std::size_t size() { return sizeof...(Ints); }
46 | };
47 |
48 | template
49 | struct flatten;
50 |
51 | template
52 | struct flatten, integer_sequence>
53 | : integer_sequence {};
54 |
55 | template
56 | struct make_integer_sequence;
57 |
58 | template
59 | struct make_integer_sequence
60 | : integer_sequence{};
61 |
62 | template
63 | struct make_integer_sequence
64 | : integer_sequence{};
65 |
66 | template
67 | struct make_integer_sequence
68 | : flatten::type,
69 | typename make_integer_sequence::type>::type {};
70 |
71 | template
72 | using make_index_sequence = make_integer_sequence;
73 | }
74 |
75 | template
76 | using index_sequence = do_not_use_this_namespace::integer_sequence;
77 |
78 | template
79 | using index_sequence_for = do_not_use_this_namespace::make_index_sequence;
80 | }
81 | #endif
82 |
83 | #endif //CUTE_INTEGER_SEQUENCE_H_
84 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_relops.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2013-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_RELOPS_H_
27 | #define CUTE_RELOPS_H_
28 |
29 | #include "cute_base.h"
30 | #include "cute_diff_values.h"
31 | #include
32 |
33 | namespace cute {
34 |
35 | namespace cute_relops_detail{
36 | template
37 | std::string compare_values(LeftValue const &left
38 | , RightValue const & right){
39 | return cute::diff_values(left,right,"left","right");
40 | }
41 | }
42 | template class RELOP,typename TL, typename TR>
43 | void assert_relop(TL const &left
44 | , TR const &right
45 | ,std::string const &msg
46 | ,char const *file
47 | ,int line) {
48 | if (RELOP()(left,right)) return;
49 | throw test_failure(msg + cute_relops_detail::compare_values(left,right),file,line);
50 | }
51 |
52 | }
53 | #define ASSERT_LESSM(msg,left,right) cute::assert_relop((left),(right),\
54 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
55 | #define ASSERT_LESS(left,right) ASSERT_LESSM(#left " < " #right, (left),(right))
56 | #define ASSERT_LESS_EQUALM(msg,left,right) cute::assert_relop((left),(right),\
57 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
58 | #define ASSERT_LESS_EQUAL(left,right) ASSERT_LESS_EQUALM(#left " <= " #right, (left),(right))
59 | #define ASSERT_GREATERM(msg,left,right) cute::assert_relop((left),(right),\
60 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
61 | #define ASSERT_GREATER(left,right) ASSERT_GREATERM(#left " > " #right, (left),(right))
62 | #define ASSERT_GREATER_EQUALM(msg,left,right) cute::assert_relop((left),(right),\
63 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
64 | #define ASSERT_GREATER_EQUAL(left,right) ASSERT_GREATER_EQUALM(#left " >= " #right, (left),(right))
65 | #define ASSERT_NOT_EQUAL_TOM(msg,left,right) cute::assert_relop((left),(right),\
66 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
67 | #define ASSERT_NOT_EQUAL_TO(left,right) ASSERT_NOT_EQUAL_TOM(#left " != " #right, (left),(right))
68 |
69 | #endif /* CUTE_RELOPS_H_ */
70 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/ide_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef IDE_LISTENER_H_
27 | #define IDE_LISTENER_H_
28 |
29 | #include "cute_listener.h"
30 |
31 | #include
32 | #include
33 | #ifdef _MSC_VER
34 | #define WIN32_LEAN_AND_MEAN
35 | #include
36 | #include
37 | #endif
38 |
39 | namespace cute {
40 | template
41 | struct ide_listener: Listener
42 | {
43 | ide_listener(std::ostream &os=std::cout):out(os) {}
44 | void begin(suite const &t,char const *info, size_t n_of_tests){
45 | out << std::dec << "\n#beginning " << info << " " << n_of_tests << '\n' << std::flush;
46 | Listener::begin(t,info,n_of_tests);
47 | }
48 | void end(suite const &t, char const *info){
49 | out << "\n#ending " << info << '\n' << std::flush;
50 | Listener::end(t,info);
51 | }
52 | void start(test const &t){
53 | out << "\n#starting " << t.name() << '\n' << std::flush;
54 | Listener::start(t);
55 | }
56 | void success(test const &t, char const *msg){
57 | out << "\n#success " << maskBlanks(t.name()) << " " << msg << '\n' << std::flush;
58 | Listener::success(t,msg);
59 | }
60 | void failure(test const &t,test_failure const &e){
61 | out << std::dec << "\n#failure " << maskBlanks(t.name()) << " " << e.filename << ":" << e.lineno << " " << (e.reason) << '\n' << std::flush;
62 | Listener::failure(t,e);
63 | #ifdef _MSC_VER
64 | std::ostringstream os;
65 | os << std::dec << e.filename << "(" << e.lineno << ") : failure: " <
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "scope.hpp"
10 |
11 | #ifndef _MSC_VER
12 | #include
13 | #include
14 | #else
15 | #include
16 | #define open _open
17 | #define close _close
18 | #define unlink _unlink
19 | #define write _write
20 | #endif
21 |
22 | namespace {
23 | using namespace std::experimental;
24 |
25 | using std::filesystem::path;
26 |
27 | void copy_file_transact(path const &from, path const &to) {
28 | path t{to};
29 | t += path{".deleteme"};
30 | auto guard = scope_fail{[t] { remove(t); }};
31 | copy_file(from, t);
32 | rename(t, to);
33 | }
34 |
35 | void DemonstrateTransactionFilecopy() {
36 | std::string name("hello.txt");
37 | path to("/tmp/scope_hello.txt");
38 | {
39 | std::ofstream ofs{name};
40 | ofs << "Hello world\n";
41 | }
42 |
43 | copy_file_transact(name, to);
44 | auto guard = scope_success{[to] { remove(to); }};
45 | assert(exists(to) == true);
46 | }
47 |
48 | void demonstrate_unique_resource_with_stdio() {
49 | const std::string filename = "hello.txt";
50 | auto fclose = [](auto file) {
51 | ::fclose(file);
52 | }; // not allowed to take address const std::string filename = "hello.txt";
53 | {
54 | auto file = make_unique_resource_checked(::fopen(filename.c_str(), "w"),
55 | nullptr, fclose);
56 | ::fputs("Hello World!\n", file.get());
57 | assert(file.get() != nullptr);
58 | }
59 | {
60 | std::ifstream input{filename};
61 | std::string line{};
62 | getline(input, line);
63 | assert("Hello World!" == line);
64 | getline(input, line);
65 | assert(input.eof());
66 | }
67 | ::unlink(filename.c_str());
68 | {
69 | auto file = make_unique_resource_checked(
70 | ::fopen("nonexistingfile.txt", "r"), nullptr, fclose);
71 | assert(nullptr == file.get());
72 | }
73 | }
74 |
75 | void demontrate_unique_resource_with_POSIX_IO() {
76 | const std::string filename = "hello1.txt";
77 | auto close = [](auto fd) { ::close(fd); };
78 | {
79 | auto file = make_unique_resource_checked(
80 | ::open(filename.c_str(), O_CREAT | O_RDWR | O_TRUNC, 0666), -1,
81 | close);
82 | ::write(file.get(), "Hello World!\n", 12u);
83 | assert(file.get() != -1);
84 | }
85 | {
86 | std::ifstream input{filename};
87 | std::string line{};
88 | getline(input, line);
89 | assert("Hello World!" == line);
90 | getline(input, line);
91 | assert(input.eof());
92 | }
93 | ::unlink(filename.c_str());
94 | {
95 | auto file = make_unique_resource_checked(
96 | ::open("nonexistingfile.txt", O_RDONLY), -1, close);
97 | assert(-1 == file.get());
98 | }
99 | }
100 |
101 | void demo_scope_exit_fail_success() {
102 | std::ostringstream out{};
103 | auto lam = [&] { out << "called "; };
104 | try {
105 | auto v = scope_exit([&] { out << "always "; });
106 | auto w = scope_success([&] { out << "not "; });
107 | auto x = scope_fail(lam); // called too
108 | throw 42;
109 | } catch (...) {
110 | auto y = scope_fail([&] { out << "not "; });
111 | auto z = scope_success([&] { out << "handled"; }); // called too
112 | }
113 | assert("called always handled" == out.str());
114 | }
115 | } // namespace
116 |
117 | int main() {
118 | DemonstrateTransactionFilecopy();
119 | demonstrate_unique_resource_with_stdio();
120 | demontrate_unique_resource_with_POSIX_IO();
121 | demo_scope_exit_fail_success();
122 | }
123 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_testmember.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_TESTMEMBER_H_
27 | #define CUTE_TESTMEMBER_H_
28 |
29 | #include "cute_test.h"
30 |
31 | namespace cute {
32 | template
33 | test makeMemberFunctionTest(TestClass &t,void (TestClass::*fun)(),char const *name){
34 | return test(boost_or_tr1::bind(fun,boost_or_tr1::ref(t)),demangle(typeid(TestClass).name())+"::"+name);
35 | }
36 | template
37 | test makeMemberFunctionTest(TestClass const &t,void (TestClass::*fun)()const,char const *name){
38 | return test(boost_or_tr1::bind(fun,boost_or_tr1::cref(t)),demangle(typeid(TestClass).name())+"::"+name);
39 | }
40 | template
41 | struct incarnate_for_member_function {
42 | MemFun memfun;
43 | incarnate_for_member_function(MemFun f):memfun(f){}
44 | void operator()(){
45 | TestClass t;
46 | (t.*memfun)();
47 | }
48 | };
49 | template
50 | test makeSimpleMemberFunctionTest(MemFun fun,char const *name){
51 | return test(incarnate_for_member_function(fun),demangle(typeid(TestClass).name())+"::"+name);
52 | }
53 | template
54 | struct incarnate_for_member_function_with_context_object {
55 | MemFun memfun;
56 | Context context;
57 | incarnate_for_member_function_with_context_object(MemFun f,Context c)
58 | :memfun(f),context(c){}
59 | incarnate_for_member_function_with_context_object(incarnate_for_member_function_with_context_object const &other)
60 | :memfun(other.memfun),context(other.context){} // provide copy-ctor for std::function ctor requirement should be =default on C++11
61 |
62 | void operator()(){
63 | TestClass t(context);
64 | (t.*memfun)();
65 | }
66 | };
67 | template
68 | test makeMemberFunctionTestWithContext(Context c,MemFun fun,char const *name){
69 | return test(incarnate_for_member_function_with_context_object(fun,c),demangle(typeid(TestClass).name())+"::"+name);
70 | }
71 | }
72 |
73 | #define CUTE_MEMFUN(testobject,TestClass,MemberFunctionName) \
74 | cute::makeMemberFunctionTest(testobject,\
75 | &TestClass::MemberFunctionName,\
76 | #MemberFunctionName)
77 | #define CUTE_SMEMFUN(TestClass,MemberFunctionName) \
78 | cute::makeSimpleMemberFunctionTest(\
79 | &TestClass::MemberFunctionName,\
80 | #MemberFunctionName)
81 | #define CUTE_CONTEXT_MEMFUN(context_object,TestClass,MemberFunctionName) \
82 | cute::makeMemberFunctionTestWithContext(\
83 | context_object,\
84 | &TestClass::MemberFunctionName,\
85 | #MemberFunctionName)
86 |
87 | #endif /*CUTE_TESTMEMBER_H_*/
88 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/xml_listener.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef XML_LISTENER_H_
27 | #define XML_LISTENER_H_
28 |
29 | #include "cute_listener.h"
30 | #include "cute_xml_file.h" // for convenience
31 |
32 | #include
33 |
34 | namespace cute {
35 | template
36 | class xml_listener:public Listener
37 | {
38 | protected:
39 | std::string mask_xml_chars(std::string in){
40 | std::string::size_type pos=0;
41 | while((pos=in.find_first_of("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\"&'<>", pos, 34))!=std::string::npos){
42 | switch(in[pos]){
43 | case '&': in.replace(pos,1,"&"); pos +=5; break;
44 | case '<': in.replace(pos,1,"<"); pos += 4; break;
45 | case '>': in.replace(pos,1,">"); pos += 4; break;
46 | case '"': in.replace(pos,1,"""); pos+=6; break;
47 | case '\'':in.replace(pos,1,"'"); pos+=6; break;
48 | default:
49 | char c = in[pos];
50 | std::string replacement = "0x" + cute_to_string::hexit(c);
51 | in.replace(pos, 1, replacement); pos += replacement.size(); break;
52 | break;
53 | }
54 | }
55 | return in;
56 | }
57 | std::ostream &out;
58 | std::string current_suite;
59 | public:
60 | xml_listener(std::ostream &os):out(os) {
61 | out << "\n";
62 | }
63 | ~xml_listener(){
64 | out << "\n"<< std::flush;
65 | }
66 |
67 | void begin(suite const &t,char const *info, size_t n_of_tests){
68 | current_suite=mask_xml_chars(info);
69 | out << std::dec << "\t\n";
70 | Listener::begin(t,info, n_of_tests);
71 | }
72 | void end(suite const &t, char const *info){
73 | out << "\t\n";
74 | current_suite.clear();
75 | Listener::end(t,info);
76 | }
77 | void start(test const &t){
78 | out << "\t\t\n";
83 | Listener::success(t,msg);
84 | }
85 | void failure(test const &t,test_failure const &e){
86 | out << std::dec << ">\n\t\t\t\n"<\n\t\t\n";
88 | Listener::failure(t,e);
89 | }
90 | void error(test const &t, char const *what){
91 | out << ">\n\t\t\t\n"<\n\t\t\n";
94 | Listener::error(t,what);
95 | }
96 | };
97 | }
98 |
99 | #endif /*IDE_LISTENER_H_*/
100 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_data_driven.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2013-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DATA_DRIVEN_H_
27 | #define CUTE_DATA_DRIVEN_H_
28 |
29 | #include "cute_base.h"
30 | #include "cute_equals.h"
31 | #include "cute_relops.h"
32 |
33 | #define DDTM(msg) (cute::test_failure(cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__))
34 | #define DDT() DDTM("")
35 |
36 | #define ASSERT_DDTM(cond,msg,failure) do{ \
37 | if (!(cond)) \
38 | throw cute::test_failure(CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)+(failure).reason,\
39 | (failure).filename.c_str(),(failure).lineno);\
40 | } while (false)
41 | #define ASSERT_DDT(cond,failure) ASSERT_DDTM(cond,#cond,(failure))
42 |
43 | #define ASSERT_EQUAL_DDTM(msg,expected,actual,failure) cute::assert_equal((expected),(actual),\
44 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
45 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
46 | #define ASSERT_EQUAL_DDT(expected,actual,failure) ASSERT_EQUAL_DDTM(#expected " == " #actual, (expected),(actual),(failure))
47 | #define ASSERT_EQUAL_DELTA_DDTM(msg,expected,actual,delta,failure) cute::assert_equal_delta((expected),(actual),(delta),\
48 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
49 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
50 | #define ASSERT_EQUAL_DELTA_DDT(expected,actual,delta,failure) ASSERT_EQUAL_DELTA_DDTM(#expected " == " #actual " with error " #delta ,(expected),(actual),(delta),(failure))
51 |
52 | #define ASSERT_LESS_DDTM(msg,left,right,failure) cute::assert_relop((left),(right),\
53 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
54 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
55 | #define ASSERT_LESS_DDT(left,right,failure) ASSERT_LESS_DDTM(#left " < " #right, (left),(right),(failure))
56 |
57 | #define ASSERT_LESS_EQUAL_DDTM(msg,left,right,failure) cute::assert_relop((left),(right),\
58 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
59 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
60 | #define ASSERT_LESS_EQUAL_DDT(left,right,failure) ASSERT_LESS_EQUAL_DDTM(#left " <= " #right, (left),(right),(failure))
61 |
62 | #define ASSERT_GREATER_DDTM(msg,left,right,failure) cute::assert_relop((left),(right),\
63 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
64 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
65 | #define ASSERT_GREATER_DDT(left,right,failure) ASSERT_GREATER_DDTM(#left " > " #right, (left),(right),(failure))
66 |
67 | #define ASSERT_GREATER_EQUAL_DDTM(msg,left,right,failure) cute::assert_relop((left),(right),\
68 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
69 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
70 | #define ASSERT_GREATER_EQUAL_DDT(left,right,failure) ASSERT_GREATER_EQUAL_DDTM(#left " >= " #right, (left),(right),(failure))
71 |
72 | #define ASSERT_NOT_EQUAL_TO_DDTM(msg,left,right,failure) cute::assert_relop((left),(right),\
73 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg)\
74 | +(failure).reason,(failure).filename.c_str(),(failure).lineno)
75 | #define ASSERT_NOT_EQUAL_TO_DDT(left,right,failure) ASSERT_NOT_EQUAL_TO_DDTM(#left " != " #right, (left),(right),(failure))
76 |
77 |
78 |
79 | #endif /* CUTE_DATA_DRIVEN_H_ */
80 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_demangle.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2009-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_DEMANGLE_H_
27 | #define CUTE_DEMANGLE_H_
28 | #include
29 | // needs adaptation for different compilers
30 | // dependency to demangle is a given,
31 | // otherwise we have to use macros everywhere
32 | #ifdef __GNUG__ // also for clang...
33 | #include // __cxa_demangle
34 | #include // ::free()
35 | namespace cute {
36 | extern inline std::string demangle(char const *name);
37 |
38 | namespace cute_impl_demangle {
39 | inline std::string plain_demangle(char const *name){
40 | if (!name) return "unknown";
41 | char const *toBeFreed = abi::__cxa_demangle(name,0,0,0);
42 | std::string result(toBeFreed?toBeFreed:name);
43 | ::free(const_cast(toBeFreed));
44 | return result;
45 | }
46 | #if defined(_LIBCPP_ABI_NAMESPACE) || defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
47 | inline void patch_library_namespace(std::string &mightcontaininlinenamespace) {
48 | // libc++ uses inline namespace std::_LIBCPP_NAMESPACE:: for its classes. This breaks the tests relying on meta information. re-normalize the names back to std::
49 | // libstdc++ (at least in version 6.3.1) puts some STL classes into the inline namespace std::_GLIBCXX_NAMESPACE_CXX11 if in C++11 mode
50 | std::string::size_type pos=std::string::npos;
51 | #define XNS(X) #X
52 | #define NS(X) XNS(X)
53 | #if defined( _LIBCPP_NAMESPACE)
54 | #define TOREPLACE "::" NS(_LIBCPP_NAMESPACE)
55 | #elif defined(_LIBCPP_ABI_NAMESPACE)
56 | #define TOREPLACE "::" NS(_LIBCPP_ABI_NAMESPACE)
57 | #else
58 | #define TOREPLACE "::" NS(_GLIBCXX_NAMESPACE_CXX11)
59 | #endif
60 | std::string const nothing;
61 | while (std::string::npos != (pos= mightcontaininlinenamespace.find(TOREPLACE)))
62 | mightcontaininlinenamespace.erase(pos,sizeof(TOREPLACE)-1);
63 | #undef NS
64 | #undef XNS
65 | #undef TOREPLACE
66 | }
67 | inline void patchresultforstring(std::string& result) {
68 | static const std::string stringid=plain_demangle(typeid(std::string).name());
69 | std::string::size_type pos=std::string::npos;
70 | while(std::string::npos != (pos=result.find(stringid))){
71 | if (!result.compare(pos+stringid.size(),2," >",2)) result.erase(pos+stringid.size(),1); // makes templates look nice
72 | result.replace(pos,stringid.size(),"std::string");
73 | }
74 | patch_library_namespace(result);
75 | }
76 | #endif
77 |
78 | }
79 | inline std::string demangle(char const *name){
80 | if (!name) return "unknown";
81 | std::string result(cute_impl_demangle::plain_demangle(name));
82 | #if defined(_LIBCPP_ABI_NAMESPACE) || defined(_LIBCPP_NAMESPACE) || defined(_GLIBCXX_USE_CXX11_ABI)
83 | cute_impl_demangle::patchresultforstring(result);
84 | #endif
85 | return result;
86 | }
87 | }
88 | #else
89 | namespace cute {
90 | #ifdef _MSC_VER
91 | namespace cute_demangle_impl {
92 |
93 | inline void removeMSKeyword(std::string &name,std::string const &kw){
94 | std::string::size_type pos=std::string::npos;
95 | while (std::string::npos != (pos= name.find(kw)))
96 | name.erase(pos,kw.size());
97 |
98 | }
99 | inline void patchresultforstring(std::string& result) {
100 | static const std::string stringid=(typeid(std::string).name());
101 | std::string::size_type pos=std::string::npos;
102 | while(std::string::npos != (pos=result.find(stringid))){
103 | if (!result.compare(pos+stringid.size(),2," >",2)) result.erase(pos+stringid.size(),1); // makes templates look nice
104 | result.replace(pos,stringid.size(),"std::string");
105 | }
106 | }
107 |
108 | inline void patchMSMangling(std::string &name){
109 | patchresultforstring(name);
110 | removeMSKeyword(name,"class ");
111 | removeMSKeyword(name,"struct ");
112 | for (std::string::iterator i=name.begin(); i != name.end(); ++i){
113 | if (*i==','){ i = name.insert(i+1,' ');}
114 | }
115 | std::string::size_type pos=0;
116 | while(std::string::npos !=(pos=name.find(" ,",pos))){
117 | name.erase(pos,1);
118 | ++pos;
119 | }
120 | }
121 | }
122 | inline std::string demangle(char const *name){
123 | std::string result(name?name:"unknown");
124 | cute_demangle_impl::patchMSMangling(result);
125 | return result;
126 | }
127 |
128 | #else
129 | // this default works reasonably with MSVC71 and 8, hopefully for others as well
130 | inline std::string demangle(char const *name){
131 | return std::string(name?name:"unknown");
132 | }
133 | #endif
134 | }
135 | #endif
136 |
137 | #endif /* CUTE_DEMANGLE_H_ */
138 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_runner.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2006-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_RUNNER_H_
27 | #define CUTE_RUNNER_H_
28 |
29 | #include "cute_test.h"
30 | #include "cute_suite.h"
31 | #include "cute_listener.h"
32 | #include "cute_determine_traits.h"
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | namespace cute {
40 | namespace runner_aux {
41 | struct prefixMatcher
42 | {
43 | prefixMatcher(std::string const &prefix):prefix(prefix){}
44 | bool operator()(std::string const &s) const {
45 | size_t found=s.find(prefix);
46 | return found==0 && (s.size()==prefix.size() || s[prefix.size()]=='#');
47 | }
48 | private:
49 | std::string const prefix;
50 | };
51 | struct prefixCutter
52 | {
53 | prefixCutter(std::string const &prefix):prefix(prefix){}
54 | std::string operator()(std::string s) const {
55 | size_t found=s.find(prefix);
56 | if ( found==0 && s.size()>prefix.size() && s[prefix.size()]=='#'){
57 | s = s.substr(prefix.size()+1);
58 | } else {
59 | s.clear(); // either no match, or no individual test
60 | }
61 | return s;
62 | }
63 | private:
64 | std::string const prefix;
65 | };
66 | class ArgvTestFilter
67 | {
68 | std::set match;
69 | bool shouldRunSuite(std::string const &info, std::vector const &args)
70 | {
71 | if(!args.size() || !info.size())
72 | return true;
73 | if(args.end() != find_if(args.begin(), args.end(), prefixMatcher(info))){
74 | std::transform(args.begin(), args.end(), std::inserter(match,match.begin()),prefixCutter(info));
75 | match.erase(std::string()); // get rid of empty string
76 | return true;
77 | }
78 | return false;
79 | }
80 | public:
81 | bool const shouldrunsuite;
82 | ArgvTestFilter(std::string const &info, std::vector const &args)
83 | :shouldrunsuite(shouldRunSuite(info,args)){}
84 | bool shouldRun(const std::string & name) const
85 | {
86 | return match.empty() || match.count(name);
87 | }
88 | };
89 | } // namespace runner_aux
90 | template
91 | struct runner{
92 | Listener &listener;
93 | std::vector args;
94 | runner(Listener &l, int argc = 0, const char *const *argv = 0):listener(l){
95 | if(needsFiltering(argc,argv)){
96 | std::remove_copy_if(argv + 1, argv + argc,back_inserter(args),std::logical_not());
97 | }
98 | }
99 | bool operator()(const test & t) const
100 | {
101 | return runit(t);
102 | }
103 |
104 | bool operator ()(suite const &s, const char *info = "") const
105 | {
106 | runner_aux::ArgvTestFilter filter(info,args);
107 |
108 | bool result = true;
109 | if(filter.shouldrunsuite){
110 | listener.begin(s, info, (size_t)
111 | count_if(s.begin(),s.end(),boost_or_tr1::bind(&runner_aux::ArgvTestFilter::shouldRun,filter,boost_or_tr1::bind(&test::name,_1))));
112 | for(suite::const_iterator it = s.begin();it != s.end();++it){
113 | if (filter.shouldRun(it->name())) result = this->runit(*it) && result;
114 | }
115 | listener.end(s, info);
116 | }
117 |
118 | return result;
119 | }
120 | private:
121 | bool needsFiltering(int argc, const char *const *argv) const
122 | {
123 | return argc > 1 && argv ;
124 | }
125 |
126 |
127 | bool runit(const test & t) const
128 | {
129 | try {
130 | listener.start(t);
131 | t();
132 | listener.success(t, "OK");
133 | return true;
134 | } catch(const cute::test_failure & e){
135 | listener.failure(t, e);
136 | } catch(const std::exception & exc){
137 | listener.error(t, demangle(exc.what()).c_str());
138 | } catch(std::string & s){
139 | listener.error(t, s.c_str());
140 | } catch(const char *&cs) {
141 | listener.error(t,cs);
142 | } catch(...) {
143 | listener.error(t,"unknown exception thrown");
144 | }
145 | return false;
146 | }
147 | };
148 | template
149 | runner makeRunner(Listener &s, int argc = 0, const char *const *argv = 0){
150 | return runner(s,argc,argv);
151 | }
152 | }
153 |
154 | #endif /*CUTE_RUNNER_H_*/
155 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_equals.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, Emanuel Graf, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_EQUALS_H_
27 | #define CUTE_EQUALS_H_
28 | #include "cute_base.h"
29 | #include "cute_diff_values.h"
30 | #include "cute_determine_traits.h"
31 | #include "cute_determine_version.h"
32 | #include "cute_deprecated.h"
33 | #include "cute_range.h"
34 | #include
35 | #include
36 | #include
37 | #ifdef USE_STD11
38 | #include
39 | #endif
40 |
41 |
42 | namespace cute {
43 |
44 |
45 | namespace cute_do_equals {
46 | // provide some template meta programming tricks to select "correct" comparison for floating point and integer types
47 | template
48 | bool do_equals_floating_with_delta(ExpectedValue const &expected
49 | ,ActualValue const &actual
50 | ,DeltaValue const &delta) {
51 | using std::abs; // allow for user-defined types with abs overload
52 | #pragma GCC diagnostic push
53 | #pragma GCC diagnostic ignored "-Wconversion"
54 | return bool(abs(delta) >= abs(expected-actual)); // Accommodate non-standard boolean type with explicit conversion
55 | #pragma GCC diagnostic pop
56 | }
57 | template
58 | bool do_equals_floating(ExpectedValue const &expected
59 | ,ActualValue const &actual,const impl_place_for_traits::integral_constant&){
60 | return bool(expected==actual); // normal case for most types uses operator==!, accommodate non bool operator ==
61 | }
62 | template
63 | bool do_equals_floating(ExpectedValue const &expected
64 | ,ActualValue const &actual,const impl_place_for_traits::true_type&){
65 | const ExpectedValue automatic_delta_masking_last_significant_digit=(10*std::numeric_limits::epsilon())*expected;
66 | return do_equals_floating_with_delta(expected,actual,automatic_delta_masking_last_significant_digit);
67 | }
68 | // TMP-overload dispatch for floating points 2 bool params --> 4 overloads
69 | template
70 | bool do_equals(ExpectedValue const &expected
71 | ,ActualValue const &actual
72 | ,const impl_place_for_traits::integral_constant&/*exp_is_integral*/
73 | ,const impl_place_for_traits::integral_constant&/*act_is_integral*/){
74 | return do_equals_floating(expected,actual,impl_place_for_traits::is_floating_point());
75 | }
76 | template
77 | bool do_equals(ExpectedValue const &expected
78 | ,ActualValue const &actual
79 | ,const impl_place_for_traits::false_type&,const impl_place_for_traits::false_type&){
80 | return do_equals_floating(expected,actual,impl_place_for_traits::is_floating_point());
81 | }
82 | template
83 | bool do_equals(ExpectedValue const &expected
84 | ,ActualValue const &actual
85 | ,const impl_place_for_traits::integral_constant&/*exp_is_integral*/
86 | ,const impl_place_for_traits::true_type&){
87 | return do_equals_floating(expected,actual,impl_place_for_traits::is_floating_point());
88 | }
89 | template
90 | bool do_equals(ExpectedValue const &expected
91 | ,ActualValue const &actual
92 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::integral_constant&/*act_is_integral*/){
93 | return do_equals_floating(expected,actual,impl_place_for_traits::is_floating_point());
94 | }
95 | #ifdef USE_STD11
96 | template
97 | bool do_equals(std::tuple const &expected
98 | ,std::tuple const &actual,const std::integral_constant&){
99 | return expected==actual;
100 | }
101 | #endif
102 | // can I get rid of the following complexity by doing a do_equals_integral
103 | // parameterized by is_signed==is_signed or nofBits < nofBits
104 |
105 |
106 | // this is an optimization for avoiding if and sign-extend overhead if both int types are the same as below
107 | template
108 | bool do_equals(IntType const &expected
109 | ,IntType const &actual
110 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
111 | return expected==actual;
112 | }
113 | // bool cannot be made signed, therefore we need the following three overloads, also to avoid ambiguity
114 | template
115 | bool do_equals(bool const &expected
116 | ,IntType const &actual
117 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
118 | return expected== !(!actual); // warning from VS
119 | }
120 | template
121 | bool do_equals(IntType const &expected
122 | ,bool const &actual
123 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
124 | return !(!expected)==actual; // warning from VS
125 | }
126 | // do not forget the inline on a non-template overload!
127 | // this overload is needed to actually avoid ambiguity for comparing bool==bool as a best match
128 | inline bool do_equals(bool const &expected
129 | ,bool const &actual
130 | , const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
131 | return expected==actual;
132 | }
133 | // overload for char const *, my test case failed because VC++ doesn't use string constant folding like g++/clang
134 | // a feature where we should do string comparison
135 | inline bool do_equals(char const *const &expected
136 | ,char const *const &actual
137 | , const impl_place_for_traits::false_type&,const impl_place_for_traits::false_type&){
138 | return std::string(expected) == actual;
139 | }
140 | template
141 | size_t nof_bits(IntegralType const &){
142 | return std::numeric_limits::digits;
143 | }
144 | #if defined(USE_STD11)||defined(USE_TR1)
145 | template
146 | bool do_equals_integral(ExpectedValue const &expected
147 | ,ActualValue const &actual
148 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
149 | if (nof_bits(expected) < nof_bits(actual))
150 | return static_cast(expected) == actual;
151 | else
152 | return expected == static_cast(actual);
153 | return false;
154 | }
155 | template
156 | bool do_equals_integral(ExpectedValue const &expected
157 | ,ActualValue const &actual
158 | ,const impl_place_for_traits::false_type&,const impl_place_for_traits::true_type&){
159 | //TODO complicated case, one signed one unsigned type. since it is about equality casting to the longer should work?
160 | if (sizeof(ExpectedValue) > sizeof(ActualValue))
161 | return expected==static_cast(actual);
162 | else
163 | return static_cast(expected) == actual;
164 | }
165 | template
166 | bool do_equals_integral(ExpectedValue const &expected
167 | ,ActualValue const &actual
168 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::false_type&){
169 | //TODO
170 | if (sizeof(ExpectedValue) < sizeof(ActualValue))
171 | return static_cast(expected)== actual;
172 | else
173 | return expected == static_cast(actual);
174 | }
175 | template
176 | bool do_equals_integral(ExpectedValue const &expected
177 | ,ActualValue const &actual
178 | ,const impl_place_for_traits::false_type&,const impl_place_for_traits::false_type&){
179 | if (nof_bits(expected) < nof_bits(actual))
180 | return static_cast(expected) == actual;
181 | else
182 | return expected == static_cast(actual);
183 | return false;
184 | }
185 | #endif
186 | // will not work if either type is bool, therefore the overloads above.
187 | template
188 | bool do_equals(ExpectedValue const &expected
189 | ,ActualValue const &actual
190 | ,const impl_place_for_traits::true_type&,const impl_place_for_traits::true_type&){
191 | #if defined(USE_STD11) || defined(USE_TR1)
192 | return do_equals_integral(expected,actual,
193 | impl_place_for_traits::is_signed()
194 | ,impl_place_for_traits::is_signed());
195 | #else
196 | //TODO: replace the following code with a dispatcher on signed/unsigned
197 | typedef typename impl_place_for_traits::make_signed::type ex_s;
198 | typedef typename impl_place_for_traits::make_signed::type ac_s;
199 | // need to sign extend with the longer type, should work...
200 | // might be done through more template meta prog tricks....but...
201 | if (nof_bits(expected) < nof_bits(actual))
202 | return static_cast(expected) == static_cast(actual);
203 | else
204 | return static_cast(expected) == static_cast(actual);
205 | #endif
206 | }
207 | } // namespace equals_impl
208 | template
209 | void assert_equal(ExpectedValue const &expected
210 | ,ActualValue const &actual
211 | ,std::string const &msg
212 | ,char const *file
213 | ,int line) {
214 | // unfortunately there is no is_integral_but_not_bool_or_enum
215 | typedef typename impl_place_for_traits::is_integral exp_integral;
216 | typedef typename impl_place_for_traits::is_integral act_integral;
217 | if (cute_do_equals::do_equals(expected,actual,exp_integral(),act_integral()))
218 | return;
219 | throw test_failure(msg + diff_values(expected,actual),file,line);
220 | }
221 |
222 | template
223 | void assert_equal_delta(ExpectedValue const &expected
224 | ,ActualValue const &actual
225 | ,DeltaValue const &delta
226 | ,std::string const &msg
227 | ,char const *file
228 | ,int line) {
229 | if (cute_do_equals::do_equals_floating_with_delta(expected,actual,delta)) return;
230 | throw test_failure(msg + diff_values(expected,actual),file,line);
231 | }
232 |
233 | }
234 |
235 | #define ASSERT_EQUALM(msg,expected,actual) cute::assert_equal((expected),(actual),\
236 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
237 | #define ASSERT_EQUAL(expected,actual) ASSERT_EQUALM(#expected " == " #actual, (expected),(actual))
238 | #define ASSERT_EQUAL_DELTAM(msg,expected,actual,delta) cute::assert_equal_delta((expected),(actual),(delta),\
239 | CUTE_FUNCNAME_PREFIX+cute::cute_to_string::backslashQuoteTabNewline(msg),__FILE__,__LINE__)
240 | #define ASSERT_EQUAL_DELTA(expected,actual,delta) ASSERT_EQUAL_DELTAM(#expected " == " #actual " with error " #delta ,(expected),(actual),(delta))
241 |
242 | DEPRECATE(ASSERT_EQUAL_RANGES_M, ASSERT_EQUAL_RANGESM)
243 | #define ASSERT_EQUAL_RANGES_M(msg,expbeg,expend,actbeg,actend) DEPRECATED(ASSERT_EQUAL_RANGES_M), ASSERT_EQUALM(msg,cute::make_range(expbeg,expend),cute::make_range(actbeg,actend))
244 | #define ASSERT_EQUAL_RANGESM(msg,expbeg,expend,actbeg,actend) ASSERT_EQUALM(msg,cute::make_range(expbeg,expend),cute::make_range(actbeg,actend))
245 | #define ASSERT_EQUAL_RANGES(expbeg,expend,actbeg,actend) ASSERT_EQUAL_RANGESM("range{" #expbeg "," #expend "} == range{" #actbeg "," #actend "}",expbeg,expend,actbeg,actend)
246 | #endif /*CUTE_EQUALS_H_*/
247 |
--------------------------------------------------------------------------------
/cevelop-workspace/scope17/cute/cute_to_string.h:
--------------------------------------------------------------------------------
1 | /*********************************************************************************
2 | * This file is part of CUTE.
3 | *
4 | * Copyright (c) 2007-2018 Peter Sommerlad, IFS
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | * SOFTWARE.
23 | *
24 | *********************************************************************************/
25 |
26 | #ifndef CUTE_TO_STRING_H_
27 | #define CUTE_TO_STRING_H_
28 |
29 | #include
30 | #include
31 | #ifdef USE_STD17
32 | #include
33 | #endif
34 |
35 | namespace cute {
36 | namespace cute_to_string {
37 | static inline std::string backslashQuoteTabNewline(std::string const &input){
38 | std::string result;
39 | result.reserve(input.size());
40 | for (std::string::size_type i=0; i < input.length() ; ++i){
41 | switch(input[i]) {
42 | case '\n': result += "\\n"; break;
43 | case '\t': result += "\\t"; break;
44 | case '\\': result += "\\\\"; break;
45 | case '\r': result += "\\r"; break;
46 | default: result += input[i];
47 | }
48 | }
49 | return result;
50 | }
51 | // common overloads of interface that work without an ostream
52 | static inline std::string to_string(char const *const &s){
53 | return s;
54 | }
55 | static inline std::string to_string(std::string const &s){
56 | return s;
57 | }
58 | template
59 | std::string hexit(T const &t){ // must be an unsigned type
60 | std::string hexed;
61 | if (t == 0) hexed+='0';
62 | for (T x=t;x>0;x /= 16){
63 | hexed += "0123456789ABCDEF"[x%16];
64 | }
65 | reverse(hexed.begin(),hexed.end());
66 | return hexed;
67 | }
68 | }
69 | }
70 | #ifndef DONT_USE_IOSTREAM
71 | #include
72 | #include
73 | #include
74 | #ifdef _MSC_VER
75 | #include