diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 000000000..0e447d44b
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,18 @@
+version: 2.1
+
+jobs:
+ latest-clang-autotools:
+ docker:
+ - image: silkeh/clang:latest
+ environment:
+ BUILD: autotools
+ CXX: clang
+ CPPUTEST_BUILD_DIR: ./cpputest_build
+ steps:
+ - checkout
+# - run: mkdir -p $CPPUTEST_BUILD_DIR && cd $CPPUTEST_BUILD_DIR && ../scripts/travis_ci_build.sh
+
+workflows:
+ basic-build-and-test:
+ jobs:
+ - latest-clang-autotools
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..a586a94d3
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,41 @@
+---
+Language: Cpp
+Standard: Cpp03
+AccessModifierOffset: -4
+AlignAfterOpenBracket: BlockIndent
+AllowShortBlocksOnASingleLine: Empty
+AllowShortEnumsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AlwaysBreakBeforeMultilineStrings: true
+BinPackParameters: false
+BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: Never
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterStruct: true
+ AfterUnion: true
+ AfterExternBlock: false
+ BeforeCatch: true
+ BeforeElse: false
+ BeforeWhile: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit: 120
+NamespaceIndentation: All
+NamespaceMacros:
+ - TEST_GROUP
+FixNamespaceComments: false
+IndentPPDirectives: BeforeHash
+IndentWidth: 4
+IndentExternBlock: NoIndent
+PackConstructorInitializers: CurrentLine
+PointerAlignment: Left
+SortIncludes: Never
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+ AfterForeachMacros: false
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 000000000..6a48af4f9
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,11 @@
+---
+Checks:
+ - clang-diagnostic-*
+ - clang-analyzer-*
+ - bugprone-*
+ - -bugprone-easily-swappable-parameters
+ - -bugprone-casting-through-void # No C++ casts allowed
+WarningsAsErrors: "*"
+FormatStyle: file
+UseColor: true
+HeaderFilterRegex: .*
diff --git a/.cproject b/.cproject
deleted file mode 100644
index 1249a9da3..000000000
--- a/.cproject
+++ /dev/null
@@ -1,141 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- make
- extensions
- true
- true
- true
-
-
- make
-
- examples
- true
- true
- true
-
-
- make
-
- cleanExamples
- true
- true
- true
-
-
-
-
-
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 000000000..30c51b94f
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,7 @@
+# Enable via `git config blame.ignoreRevsFile .git-blame-ignore-revs`
+
+# Fix line endings
+e674cfe759b20c6b78becbc50d8f9f644d32ea8a
+
+# clang-format
+2a4942eb93b823c9723d4797222d6d3315f3bef2
diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml
new file mode 100644
index 000000000..47c3161ab
--- /dev/null
+++ b/.github/workflows/basic.yml
@@ -0,0 +1,445 @@
+---
+name: Basic builds
+
+"on":
+ push:
+ pull_request:
+
+jobs:
+ clang-format:
+ name: Clang Format
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@main
+ - uses: DoozyX/clang-format-lint-action@v0.14
+ with:
+ clangFormatVersion: 14
+ source: examples
+
+ codeql:
+ runs-on: ubuntu-latest
+ name: "CodeQL"
+ steps:
+ - name: Checkout
+ uses: actions/checkout@main
+ - name: CodeQL Initialization
+ uses: github/codeql-action/init@v2
+ with:
+ languages: cpp
+ queries: +security-and-quality
+ - name: Build
+ run: |
+ mkdir _build && cd _build
+ cmake -DCMAKE_CXX_STANDARD=17 ..
+ make -j2
+ - name: CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
+
+ autotools:
+ strategy:
+ matrix:
+ include:
+ - name: Mac GNU
+ os: macos-latest
+ cc: gcc
+ cxx: g++
+ make_args: tdd
+ - name: Mac Clang
+ os: macos-latest
+ cc: clang
+ cxx: clang++
+ make_args: tdd
+ - name: Linux GNU
+ os: ubuntu-latest
+ cc: gcc
+ cxx: g++
+ make_args: tdd
+ - name: Linux Clang
+ os: ubuntu-latest
+ cc: clang
+ cxx: clang++
+ make_args: tdd
+ - name: Disable long long
+ os: ubuntu-latest
+ configure_args: --disable-longlong
+ make_args: tdd
+ - name: Distribution
+ os: ubuntu-latest
+ make_args: dist dist-zip VERSION=latest
+ - name: Install
+ os: ubuntu-latest
+ make_args: DESTDIR=install_autotools install
+ runs-on: ${{ matrix.os }}
+ name: Autotools ${{ matrix.name }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@main
+ - run: brew install automake libtool
+ if: ${{ startswith(matrix.os, 'macos') }}
+ - if: ${{ matrix.cxx }}
+ run: echo "CXX=${{ matrix.cxx }}" >> $GITHUB_ENV
+ - if: ${{ matrix.cc }}
+ run: echo "CC=${{ matrix.cc }}" >> $GITHUB_ENV
+ - name: Configure
+ run: |
+ autoreconf -i .
+ ./configure ${{ matrix.configure_args }}
+ - name: Build and test
+ run: make ${{ matrix.make_args }}
+
+ cmake:
+ strategy:
+ matrix:
+ include:
+ - name: MSVC install
+ os: windows-latest
+ preset: MSVC
+ install: true
+ ctest_args: -C Debug
+ - name: MSVC 20
+ os: windows-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=20
+ preset: MSVC
+ ctest_args: -C Debug
+ - name: ClangCL
+ os: windows-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=17
+ preset: ClangCL
+ ctest_args: -C Debug
+ - name: Clang-Tidy
+ os: ubuntu-latest
+ preset: clang-tidy
+ - name: Linux Clang 98
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=98
+ preset: Clang
+ - name: Linux Clang 11
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=11
+ preset: Clang
+ - name: Linux Clang 14
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=14
+ preset: Clang
+ - name: Linux Clang 17
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=17
+ preset: Clang
+ - name: Linux Clang 20
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=20
+ preset: Clang
+ - name: Linux GNU 98
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=98
+ preset: GNU
+ - name: No long long
+ os: ubuntu-latest
+ preset: no-long-long
+ - name: Detailed
+ os: ubuntu-latest
+ preset: detailed
+ - name: Linux GNU Install
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=11
+ preset: GNU
+ install: true
+ - name: Linux GNU 14
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=14
+ preset: GNU
+ - name: Linux GNU 17
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=17
+ preset: GNU
+ - name: Linux GNU 20
+ os: ubuntu-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=20
+ preset: GNU
+ - name: MinGW
+ os: ubuntu-latest
+ preset: MinGW
+ apt_packages: mingw-w64 wine64
+ - name: No C++ Standard Library
+ os: ubuntu-latest
+ preset: no-std-cpp
+ - name: No RTTI
+ os: ubuntu-latest
+ preset: no-rtti
+ - name: No Exceptions
+ os: ubuntu-latest
+ preset: no-exceptions
+ - name: No C Standard Library
+ os: ubuntu-latest
+ preset: no-std-c
+ - name: Coverage
+ os: ubuntu-latest
+ preset: coverage
+ apt_packages: lcov
+ - name: Address Sanitizer
+ os: ubuntu-latest
+ preset: asan
+ - name: GCC ARM embedded
+ os: ubuntu-latest
+ preset: arm-embedded
+ - name: Mac install
+ os: macos-latest
+ preset: defaults
+ install: true
+ - name: Apple Clang 14
+ os: macos-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=14
+ preset: Clang
+ - name: Apple Clang 17
+ os: macos-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=17
+ preset: Clang
+ - name: Apple Clang 20
+ os: macos-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=20
+ preset: Clang
+ - name: Mac GNU 14
+ os: macos-latest
+ cmake_args: -DCMAKE_CXX_STANDARD=14
+ preset: GNU
+ - name: OpenWatcom DOS
+ os: ubuntu-latest
+ preset: DOS
+ apt_packages: dosbox
+ - name: Cygwin
+ os: windows-latest
+ preset: GNU
+ name: CMake ${{ matrix.name }}
+ runs-on: ${{ matrix.os }}
+ steps:
+ ### SETUP
+
+ - name: Install packages
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y ${{ matrix.apt_packages }}
+ if: ${{ matrix.apt_packages }}
+
+ - uses: carlosperate/arm-none-eabi-gcc-action@v1
+ if: ${{ matrix.name == 'GCC ARM embedded' }}
+
+ - name: Install OpenWatcom
+ uses: open-watcom/setup-watcom@v0
+ with:
+ version: "2.0"
+ if: ${{ matrix.name == 'OpenWatcom DOS' }}
+
+ - run: git config --global core.autocrlf input
+ if: ${{ matrix.name == 'Cygwin' }}
+ - name: Checkout
+ uses: actions/checkout@main
+
+ - name: Install Cygwin
+ uses: cygwin/cygwin-install-action@master
+ with:
+ platform: x86
+ packages: >
+ cmake
+ gcc-core
+ gcc-g++
+ make
+ if: ${{ matrix.name == 'Cygwin' }}
+
+ ## BUILD AND TEST
+
+ - name: Configure
+ run: cmake --preset ${{ matrix.preset }} ${{ matrix.cmake_args }}
+ - name: Build
+ run: cmake --build cpputest_build --verbose -j
+ - name: Save map files
+ uses: actions/upload-artifact@v4
+ with:
+ name: "${{ matrix.name }} map files"
+ path: cpputest_build/**/*.map
+ - name: Test
+ run: >
+ ctest
+ --test-dir cpputest_build
+ ${{ matrix.ctest_args }}
+ --output-on-failure
+
+ # POST PROCESSING
+
+ - name: Install (*nix)
+ run: |
+ sudo cmake --install cpputest_build/
+ pkg-config --print-provides cpputest
+ if: ${{ matrix.install && !startswith(matrix.os, 'windows')}}
+ - name: Install (Windows)
+ run: cmake --install cpputest_build/ --config=Debug
+ if: ${{ matrix.install && startswith(matrix.os, 'windows')}}
+ - name: Use install
+ run: |
+ cmake -B build -S examples
+ cmake --build build -j
+ ctest --test-dir build
+ if: ${{ matrix.install }}
+
+ - name: Coverage
+ run: |
+ lcov --ignore-errors mismatch --capture --directory . --no-external --output-file lcov.info
+ lcov --remove lcov.info --output-file lcov.info '*/tests/*'
+ if: ${{ matrix.name == 'Coverage' }}
+ - name: Coveralls
+ uses: coverallsapp/github-action@master
+ with:
+ path-to-lcov: lcov.info
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ if: ${{ matrix.name == 'Coverage' }}
+
+ test_report:
+ name: JUnit Test Report
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@main
+ - run: cmake --preset=defaults -DCPPUTEST_JUNIT_REPORT=TRUE
+ - run: cmake --build cpputest_build -j
+ - run: ctest --test-dir cpputest_build
+ - uses: actions/upload-artifact@v4
+ if: success() || failure()
+ with:
+ name: test-results
+ path: "cpputest_build/**/cpputest_*.xml"
+
+ make:
+ strategy:
+ matrix:
+ include:
+ - name: Defaults
+ make_target: test_defaults
+ - name: STDC++ disabled
+ make_target: test_disable_std_cpp
+ - name: Memory Leak Detection disabled
+ make_target: test_disable_memory_leak_detection
+ - name: Disable Leak Detection and STD C++
+ make_target: test_disable_std_cpp_and_leak_detection
+ - name: debug disabled
+ make_target: test_disable_debug
+ - name: overridden CXXFLAGS and CFLAGS and CPPFLAGS
+ make_target: test_override_flags
+ - name: without Standard C library includes
+ make_target: test_disable_std_c
+ - name: different TARGET_PLATFORM
+ make_target: test_target_platform
+ - name: override flags and disable memory leak and STDC++
+ make_target: test_override_and_disable
+ - name: Examples
+ make_target: test_examples
+ - name: JUnit Output
+ make_target: test_junit_output
+ # - name: gcov
+ # make_target: test_gcov
+ - name: VPATH usage
+ make_target: test_vpath
+ - name: VPATH Install
+ make_target: test_vpath_install
+ name: Make ${{ matrix.name }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@main
+ - name: Build
+ run: make -f Makefile_using_MakefileWorker ${{ matrix.make_target }}
+
+ make_dos:
+ name: Make OpenWatcom DOS
+ runs-on: ubuntu-latest
+ env:
+ WATCOM: "./watcom"
+ TERM: linux
+ steps:
+ - name: Checkout
+ uses: actions/checkout@main
+ - name: Install tools
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y dosbox
+ git clone https://github.com/cpputest/watcom-compiler.git $WATCOM
+ echo "$WATCOM/binl" >> $GITHUB_PATH
+ - name: Build
+ run: make -f platforms/Dos/Makefile
+ - name: Test
+ run: make -f platforms/Dos/Makefile test
+
+ cmake_msys:
+ name: CMake MSYS
+ runs-on: windows-latest
+ defaults:
+ run:
+ shell: msys2 {0}
+ env:
+ LDFLAGS: -static
+ steps:
+ - name: Checkout
+ uses: actions/checkout@main
+ - uses: msys2/setup-msys2@v2
+ with:
+ msystem: MINGW64
+ update: true
+ install: >
+ git
+ mingw-w64-x86_64-cc
+ mingw-w64-x86_64-cmake
+ mingw-w64-x86_64-make
+ - name: Configure
+ run: cmake --preset=GNU
+ - name: Build
+ run: cmake --build cpputest_build -j
+ - name: Test
+ run: ctest --test-dir cpputest_build --output-on-failure
+
+ autotools_msys:
+ name: Autotools MSYS
+ runs-on: windows-latest
+ defaults:
+ run:
+ shell: msys2 {0}
+ env:
+ LDFLAGS: -static
+ steps:
+ - uses: actions/checkout@v3
+ - uses: msys2/setup-msys2@v2
+ with:
+ msystem: MINGW64
+ update: true
+ install: >
+ git
+ mingw-w64-x86_64-autotools
+ mingw-w64-x86_64-cc
+ mingw-w64-x86_64-make
+ - name: Configure
+ run: |
+ autoreconf -i .
+ ./configure
+ - name: Build and test
+ run: make tdd
+
+ Docker:
+ strategy:
+ matrix:
+ image: ["ubuntu", "dos"]
+ runs-on: ubuntu-latest
+ name: Docker ${{ matrix.image }}
+ steps:
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v2
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v2
+ - name: Login to Docker Hub
+ uses: docker/login-action@v2
+ with:
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
+ env:
+ TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
+ if: ${{ env.TOKEN != '' }}
+ - name: Build
+ uses: docker/build-push-action@v3
+ with:
+ file: docker/Dockerfile.${{ matrix.image }}
+ tags: cpputest/${{ matrix.image }}
diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml
new file mode 100644
index 000000000..d44746601
--- /dev/null
+++ b/.github/workflows/test-report.yml
@@ -0,0 +1,17 @@
+---
+name: 'Test Report'
+"on":
+ workflow_run:
+ workflows: ['Basic builds']
+ types:
+ - completed
+jobs:
+ report:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: dorny/test-reporter@v1
+ with:
+ artifact: test-results
+ name: JUnit Tests
+ path: "**/cpputest_*.xml"
+ reporter: java-junit
diff --git a/.gitignore b/.gitignore
index eda2a9d57..fa41116a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -88,7 +88,19 @@ generated/
*.deps/
*.dirstamp
*.trs
+lcov.info
#IAR automatically generated files
*.dep
*.ewt
+
+# Watcom
+*.LIB
+*.LST
+*.EXE
+*.LOG
+/console_output
+/exit
+
+# Builds
+/cpputest_build/
diff --git a/.project b/.project
deleted file mode 100644
index 978d661d1..000000000
--- a/.project
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
- CppUTest
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
-
-
- ?name?
-
-
-
- org.eclipse.cdt.make.core.append_environment
- true
-
-
- org.eclipse.cdt.make.core.autoBuildTarget
- all
-
-
- org.eclipse.cdt.make.core.buildArguments
-
-
-
- org.eclipse.cdt.make.core.buildCommand
- make
-
-
- org.eclipse.cdt.make.core.cleanBuildTarget
- clean
-
-
- org.eclipse.cdt.make.core.contents
- org.eclipse.cdt.make.core.activeConfigSettings
-
-
- org.eclipse.cdt.make.core.enableAutoBuild
- true
-
-
- org.eclipse.cdt.make.core.enableCleanBuild
- true
-
-
- org.eclipse.cdt.make.core.enableFullBuild
- true
-
-
- org.eclipse.cdt.make.core.fullBuildTarget
- all
-
-
- org.eclipse.cdt.make.core.stopOnError
- true
-
-
- org.eclipse.cdt.make.core.useDefaultBuildCmd
- true
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.core.ccnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
diff --git a/.settings/org.eclipse.cdt.core.prefs b/.settings/org.eclipse.cdt.core.prefs
deleted file mode 100644
index 7bc75596d..000000000
--- a/.settings/org.eclipse.cdt.core.prefs
+++ /dev/null
@@ -1,152 +0,0 @@
-#Mon Jun 07 17:30:05 SGT 2010
-eclipse.preferences.version=1
-org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16
-org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80
-org.eclipse.cdt.core.formatter.alignment_for_compact_if=0
-org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=80
-org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16
-org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48
-org.eclipse.cdt.core.formatter.alignment_for_expression_list=0
-org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16
-org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16
-org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
-org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.cdt.core.formatter.brace_position_for_block=end_of_line
-org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=end_of_line
-org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=next_line
-org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=next_line
-org.eclipse.cdt.core.formatter.brace_position_for_switch=end_of_line
-org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=next_line
-org.eclipse.cdt.core.formatter.compact_else_if=true
-org.eclipse.cdt.core.formatter.continuation_indentation=2
-org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2
-org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false
-org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true
-org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false
-org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true
-org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false
-org.eclipse.cdt.core.formatter.indent_empty_lines=false
-org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true
-org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true
-org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true
-org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false
-org.eclipse.cdt.core.formatter.indentation.size=4
-org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
-org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert
-org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert
-org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert
-org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert
-org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert
-org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert
-org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
-org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert
-org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert
-org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert
-org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert
-org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert
-org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert
-org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert
-org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert
-org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
-org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert
-org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert
-org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
-org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert
-org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
-org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert
-org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert
-org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
-org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
-org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=true
-org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false
-org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false
-org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=true
-org.eclipse.cdt.core.formatter.lineSplit=200
-org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1
-org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.cdt.core.formatter.tabulation.char=tab
-org.eclipse.cdt.core.formatter.tabulation.size=4
-org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false
diff --git a/.settings/org.eclipse.cdt.ui.prefs b/.settings/org.eclipse.cdt.ui.prefs
deleted file mode 100644
index b684b38df..000000000
--- a/.settings/org.eclipse.cdt.ui.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Tue Dec 29 09:23:19 SGT 2009
-eclipse.preferences.version=1
-formatter_profile=_CppUTest Coding Style
-formatter_settings_version=1
diff --git a/.travis.yml b/.travis.yml
index e7b1e3145..1ce211e3e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -93,14 +93,14 @@ jobs:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
- compiler: clang
env: BUILD=cmake CPP_STD=17
- - CC=clang-10
- - CXX=clang++-10
+ - CC=clang-11
+ - CXX=clang++-11
addons:
apt:
sources:
- - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
+ - sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- packages: ['clang-10', 'libc++-10-dev', 'libc++abi-10-dev']
+ packages: ['clang-11', 'libc++-11-dev', 'libc++abi-11-dev']
# Specific other tests
- compiler: gcc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88e0cfb5f..0b6a4eeaf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,19 @@
-project(CppUTest)
-
-set(CppUTest_version_major 4)
-set(CppUTest_version_minor 0)
-
# 2.6.3 is needed for ctest support
# 3.1 is needed for target_sources
-cmake_minimum_required(VERSION 3.1)
+# 3.8 is needed for try_compile improvements (CMP0067)
+cmake_minimum_required(VERSION 3.8...3.31)
+
+project(CppUTest
+ VERSION 4.0
+)
+
+if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.21")
+ # PROJECT_IS_TOP_LEVEL is defined automatically
+elseif (CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
+ set(PROJECT_IS_TOP_LEVEL TRUE)
+else()
+ set(PROJECT_IS_TOP_LEVEL FALSE)
+endif()
###############
# Conan support
@@ -16,206 +24,131 @@ if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup()
endif()
-# Check for functions before setting a lot of stuff
-include(CheckFunctionExists)
-set (CMAKE_REQUIRED_INCLUDES "unistd.h")
-check_function_exists(fork HAVE_FORK)
-if(HAVE_FORK)
- add_definitions(-DCPPUTEST_HAVE_FORK)
-endif(HAVE_FORK)
-
-check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
-if(HAVE_GETTIMEOFDAY)
- add_definitions(-DCPPUTEST_HAVE_GETTIMEOFDAY=1)
-endif(HAVE_GETTIMEOFDAY)
-
-check_function_exists(pthread_mutex_lock HAVE_PTHREAD_MUTEX_LOCK)
-if(HAVE_PTHREAD_MUTEX_LOCK)
- add_definitions(-DCPPUTEST_HAVE_PTHREAD_MUTEX_LOCK=1)
-endif(HAVE_PTHREAD_MUTEX_LOCK)
-
-check_function_exists(strdup HAVE_STRDUP)
-if(HAVE_STRDUP)
- add_definitions(-DCPPUTEST_HAVE_STRDUP=1)
-endif(HAVE_STRDUP)
-
-if (MINGW)
- # Apply workaround for MinGW timespec redefinition (pthread.h / time.h)
- include(CheckStructHasMember)
- check_struct_has_member("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC)
- if (HAVE_STRUCT_TIMESPEC)
- add_definitions(-D_TIMESPEC_DEFINED=1)
- endif()
+include(CTest)
- if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
- # Apply workaround for static/shared libraries on MinGW C/C++ compiler
- # Issue occurs with CMake >= 3.9.0, it doesn't filter out gcc,gcc_s,gcc_eh from
- # the implicit library list anymore, so the C++ linker is getting passed the static
- # gcc_eh library since that's what the C linker uses by default. Only solution appears
- # to be to force static linkage.
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
+include(CMakeDependentOption)
+option(CPPUTEST_STD_C_LIB_DISABLED "Disable the standard C library")
+
+cmake_dependent_option(CPPUTEST_STD_CPP_LIB_DISABLED "Use the standard C++ library"
+ OFF "NOT CPPUTEST_STD_C_LIB_DISABLED" ON)
+cmake_dependent_option(CPPUTEST_MEM_LEAK_DETECTION_DISABLED "Enable memory leak detection"
+ OFF "NOT BORLAND;NOT CPPUTEST_STD_C_LIB_DISABLED" ON)
+option(CPPUTEST_EXTENSIONS "Use the CppUTest extension library" ON)
+include(CheckTypeSize)
+check_type_size("long long" SIZEOF_LONGLONG)
+cmake_dependent_option(CPPUTEST_USE_LONG_LONG "Support long long"
+ YES "HAVE_SIZEOF_LONGLONG" OFF)
+
+cmake_dependent_option(CPPUTEST_BUILD_TESTING "Compile and make tests for CppUTest"
+ ${PROJECT_IS_TOP_LEVEL} "BUILD_TESTING" OFF)
+cmake_dependent_option(CPPUTEST_SPLIT_TESTS "Split tests into small executables"
+ OFF "CPPUTEST_BUILD_TESTING" OFF)
+cmake_dependent_option(CPPUTEST_TEST_GTEST "Test GoogleTest integration"
+ OFF "CPPUTEST_BUILD_TESTING" OFF)
+cmake_dependent_option(CPPUTEST_EXAMPLES "Compile and make examples?"
+ ${PROJECT_IS_TOP_LEVEL} "CPPUTEST_EXTENSIONS;NOT CPPUTEST_STD_CPP_LIB_DISABLED" OFF)
+
+if(NOT DEFINED CPPUTEST_PLATFORM)
+ if(DEFINED CPP_PLATFORM)
+ message(DEPRECATION
+ "The CPP_PLATFORM variable has been deprecated. "
+ "Use CPPUTEST_PLATFORM instead."
+ )
+ set(CPPUTEST_PLATFORM ${CPP_PLATFORM})
+ else()
+ if(CPPUTEST_STD_C_LIB_DISABLED)
+ set(CPPUTEST_PLATFORM OFF)
+ elseif(MSVC)
+ set(CPPUTEST_PLATFORM VisualCpp)
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IAR")
+ set(CPPUTEST_PLATFORM Iar)
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "ARMCC")
+ set(CPPUTEST_PLATFORM armcc)
+ elseif(DOS)
+ set(CPPUTEST_PLATFORM Dos)
+ elseif(BORLAND)
+ set(CPPUTEST_PLATFORM Borland)
+ else()
+ set(CPPUTEST_PLATFORM Gcc)
endif()
+ endif()
+ message(STATUS "Setting CPPUTEST_PLATFORM: ${CPPUTEST_PLATFORM}")
+endif()
+set(CPPUTEST_PLATFORM "${CPPUTEST_PLATFORM}" CACHE STRING "Platform implementation")
+set_property(
+ CACHE CPPUTEST_PLATFORM
+ PROPERTY STRINGS
+ armcc Borland C2000 Dos Gcc Iar Keil Symbian VisualCpp OFF
+)
+
+include(CheckCXXSymbolExists)
+check_cxx_symbol_exists(fopen_s "stdio.h" CPPUTEST_HAVE_SECURE_STDLIB)
+cmake_dependent_option(CPPUTEST_USE_SECURE_STDLIB "Use MSVC safe functions"
+ ON "WIN32;CPPUTEST_HAVE_SECURE_STDLIB" OFF)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
+if(NOT PROJECT_IS_TOP_LEVEL)
+ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
endif()
-option(STD_C "Use the standard C library" ON)
-option(STD_CPP "Use the standard C++ library" ON)
-option(CPPUTEST_FLAGS "Use the CFLAGS/CXXFLAGS/LDFLAGS set by CppUTest" ON)
-option(MEMORY_LEAK_DETECTION "Enable memory leak detection" ON)
-option(EXTENSIONS "Use the CppUTest extension library" ON)
-option(LONGLONG "Support long long" OFF)
-option(MAP_FILE "Enable the creation of a map file" OFF)
-option(COVERAGE "Enable running with coverage" OFF)
-option(C++11 "Compile with C++11 support" OFF)
-option(WERROR "Compile with warnings as errors" OFF)
-
-option(TESTS "Compile and make tests for the code?" ON)
-option(TESTS_DETAILED "Run each test separately instead of grouped?" OFF)
-option(TESTS_BUILD_DISCOVER "Build time test discover" ON)
-
-option(EXAMPLES "Compile and make exaples?" OFF)
-
-option(VERBOSE_CONFIG "Print configuration to stdout during generation" ON)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "What kind of build this is" FORCE)
-endif(NOT CMAKE_BUILD_TYPE)
-
-# Pkg-config file
-include(FindPkgConfig)
-set(CppUTest_PKGCONFIG_FILE cpputest.pc)
-
-set(CppUTestRootDirectory ${PROJECT_SOURCE_DIR})
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CppUTestRootDirectory}/cmake/Modules)
+if(
+ (NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
+ AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "15.1")
+)
+ # Leak detection macros are not sane.
+ message(NOTICE "Disabling -fassume-sane-operators-new-delete which breaks leak detection")
+ add_compile_options($<$:-fno-assume-sane-operators-new-delete>)
+endif()
-include("${CppUTestRootDirectory}/cmake/Modules/CppUTestConfigurationOptions.cmake")
-include(CTest)
-#include("${CppUTestRootDirectory}/cmake/Modules/CheckFunctionExists.cmake")
-include("${CppUTestRootDirectory}/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake")
-include("${CppUTestRootDirectory}/cmake/Modules/CppUTestNormalizeTestOutputLocation.cmake")
+if(PROJECT_IS_TOP_LEVEL)
+ include(cmake/warnings.cmake)
+endif()
include(GNUInstallDirs)
-enable_testing()
+# Check for symbols before setting a lot of stuff
+include(CheckTypeSize)
+include(CheckStructHasMember)
+set(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS})
+check_cxx_symbol_exists(kill "signal.h" CPPUTEST_HAVE_KILL)
+check_cxx_symbol_exists(fork "unistd.h" CPPUTEST_HAVE_FORK)
+check_cxx_symbol_exists(waitpid "sys/wait.h" CPPUTEST_HAVE_WAITPID)
+check_cxx_symbol_exists(gettimeofday "sys/time.h" CPPUTEST_HAVE_GETTIMEOFDAY)
+check_cxx_symbol_exists(pthread_mutex_lock "pthread.h" CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK)
+
+if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "IAR")
+ check_cxx_symbol_exists(strdup "string.h" CPPUTEST_HAVE_STRDUP)
+endif()
+check_type_size("long long" SIZEOF_LONGLONG LANGUAGE CXX)
+if(HAVE_SIZEOF_LONGLONG)
+ set(CPPUTEST_HAVE_LONG_LONG_INT ON)
+endif()
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.cmake"
"${PROJECT_BINARY_DIR}/generated/CppUTestGeneratedConfig.h"
- )
-include_directories(${PROJECT_BINARY_DIR})
-add_definitions(-DHAVE_CONFIG_H)
+)
-include_directories(${CppUTestRootDirectory}/include)
-add_subdirectory(src/CppUTest)
+add_subdirectory(src)
-if (EXTENSIONS)
- add_subdirectory(src/CppUTestExt)
-endif (EXTENSIONS)
+target_include_directories(CppUTest
+ PUBLIC
+ $
+)
+target_compile_definitions(CppUTest
+ PUBLIC
+ HAVE_CONFIG_H
+)
-if (TESTS)
- add_subdirectory(tests/CppUTest)
- if (EXTENSIONS)
- add_subdirectory(tests/CppUTestExt)
- endif (EXTENSIONS)
-endif (TESTS)
+if (CPPUTEST_BUILD_TESTING)
+ add_subdirectory(tests)
+endif ()
-if (EXAMPLES)
+if (CPPUTEST_EXAMPLES)
add_subdirectory(examples)
-endif(EXAMPLES)
-
-set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
-set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
-set (INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
-
-# Pkg-config file.
-set (prefix "${CMAKE_INSTALL_PREFIX}")
-set (exec_prefix "\${prefix}")
-set (libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
-set (includedir "\${prefix}/${INCLUDE_INSTALL_DIR}")
-set (PACKAGE_VERSION "${CppUTest_version_major}.${CppUTest_version_minor}")
-
-configure_file (cpputest.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/${CppUTest_PKGCONFIG_FILE} @ONLY)
-
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CppUTest_PKGCONFIG_FILE}
- DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
- )
-
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/CppUTestGeneratedConfig.h"
- DESTINATION "${INCLUDE_INSTALL_DIR}/CppUTest"
- )
-
-# Try to include helper module
-include(CMakePackageConfigHelpers OPTIONAL
- RESULT_VARIABLE PkgHelpers_AVAILABLE)
-# guard against older versions of cmake which do not provide it
-if(PkgHelpers_AVAILABLE)
- configure_package_config_file(CppUTestConfig.cmake.install.in
- ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
- INSTALL_DESTINATION ${LIB_INSTALL_DIR}/CppUTest/cmake
- PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
- write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
- VERSION ${CppUTest_version_major}.${CppUTest_version_minor}
- COMPATIBILITY SameMajorVersion )
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
- DESTINATION ${LIB_INSTALL_DIR}/CppUTest/cmake )
- install(EXPORT CppUTestTargets
- DESTINATION ${LIB_INSTALL_DIR}/CppUTest/cmake)
- install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
- DESTINATION ${LIB_INSTALL_DIR}/CppUTest/cmake/Scripts)
- install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
- DESTINATION ${LIB_INSTALL_DIR}/CppUTest/cmake/Modules)
- configure_package_config_file(CppUTestConfig.cmake.build.in
- ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfig.cmake
- INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
- PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR)
- if (EXTENSIONS)
- export(TARGETS CppUTest CppUTestExt
- FILE "${CMAKE_CURRENT_BINARY_DIR}/CppUTestTargets.cmake")
- else()
- export(TARGETS CppUTest
- FILE "${CMAKE_CURRENT_BINARY_DIR}/CppUTestTargets.cmake")
- endif()
- write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfigVersion.cmake
- VERSION ${CppUTest_version_major}.${CppUTest_version_minor}
- COMPATIBILITY SameMajorVersion )
- set(CppUTest_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE PATH "The directory containing a CMake configuration file for CppUTest.")
-else()
- message("If you wish to use find_package(CppUTest) in your own project to find CppUTest library"
- " please update cmake to version which provides CMakePackageConfighelpers module"
- " or write generators for CppUTestConfig.cmake by yourself.")
endif()
-if(VERBOSE_CONFIG)
- message("
--------------------------------------------------------
-CppUTest Version ${CppUTest_version_major}.${CppUTest_version_minor}
-
-Current compiler options:
- CC: ${CMAKE_C_COMPILER}
- CXX: ${CMAKE_CXX_COMPILER}
- CppUTest CFLAGS: ${CPPUTEST_C_FLAGS}
- CppUTest CXXFLAGS: ${CPPUTEST_CXX_FLAGS}
- CppUTest LDFLAGS: ${CPPUTEST_LD_FLAGS}
-
-Features configured in CppUTest:
- Memory Leak Detection: ${MEMORY_LEAK_DETECTION}
- Compiling Extensions: ${EXTENSIONS}
- Support Long Long: ${LONGLONG}
- Use CppUTest flags: ${CPPUTEST_FLAGS}
-
- Using Standard C library: ${STD_C}
- Using Standard C++ library: ${STD_CPP}
- Using C++11 library: ${C++11}
-
- Generating map file: ${MAP_FILE}
- Compiling with coverage: ${COVERAGE}
-
- Compile and run self-tests ${TESTS}
- Run self-tests separately ${TESTS_DETAILED}
-
--------------------------------------------------------
-")
+if(PROJECT_IS_TOP_LEVEL)
+ include(cmake/install.cmake)
endif()
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 000000000..a4a3f8327
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,183 @@
+{
+ "version": 3,
+ "configurePresets": [
+ {
+ "name": "defaults",
+ "binaryDir": "cpputest_build",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo",
+ "CMAKE_CXX_EXTENSIONS": false
+ }
+ },
+ {
+ "name": "GNU",
+ "inherits": ["defaults"],
+ "environment": {
+ "CFLAGS": "-Werror",
+ "CXXFLAGS": "-Werror"
+ },
+ "cacheVariables": {
+ "CMAKE_C_COMPILER": "gcc",
+ "CMAKE_CXX_COMPILER": "g++"
+ }
+ },
+ {
+ "name": "Clang",
+ "inherits": ["GNU"],
+ "cacheVariables": {
+ "CMAKE_C_COMPILER": "clang",
+ "CMAKE_CXX_COMPILER": "clang++"
+ }
+ },
+ {
+ "name": "clang-tidy",
+ "inherits": ["Clang"],
+ "cacheVariables": {
+ "CMAKE_CXX_CLANG_TIDY": "clang-tidy;-header-filter=.*",
+ "CMAKE_C_CLANG_TIDY": "clang-tidy;-header-filter=.*"
+ }
+ },
+ {
+ "name": "MSVC",
+ "inherits": ["defaults"],
+ "environment": {
+ "CFLAGS": "/WX",
+ "CXXFLAGS": "/WX"
+ }
+ },
+ {
+ "name": "ClangCL",
+ "inherits": ["MSVC"],
+ "generator": "Visual Studio 17 2022",
+ "toolset": "ClangCL"
+ },
+ {
+ "name": "MinGW",
+ "inherits": ["GNU"],
+ "environment": {
+ "LDFLAGS": "-static"
+ },
+ "cacheVariables": {
+ "CMAKE_C_COMPILER": "x86_64-w64-mingw32-gcc",
+ "CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++",
+ "CMAKE_SYSTEM_NAME": "Windows",
+ "CMAKE_CROSSCOMPILING_EMULATOR": "wine"
+ }
+ },
+ {
+ "name": "arm-embedded",
+ "inherits": ["defaults"],
+ "toolchainFile": "${sourceDir}/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake",
+ "cacheVariables": {
+ "CMAKE_CROSSCOMPILING_EMULATOR": "docker;run;--rm;-v=${sourceDir}:${sourceDir};multiarch/qemu-user-static:arm-7.1.0-2;qemu-arm-static;-cpu;cortex-m4"
+ }
+ },
+ {
+ "name": "coverage",
+ "inherits": ["GNU"],
+ "environment": {
+ "CFLAGS": "--coverage",
+ "CXXFLAGS": "--coverage"
+ },
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug",
+ "CMAKE_CXX_STANDARD": "11",
+ "CPPUTEST_EXAMPLES": false
+ }
+ },
+ {
+ "name": "no-std-cpp",
+ "inherits": ["GNU"],
+ "environment": {
+ "CXXFLAGS": "-Werror -nostdinc++"
+ },
+ "cacheVariables": {
+ "CPPUTEST_STD_CPP_LIB_DISABLED": true
+ }
+ },
+ {
+ "name": "no-rtti",
+ "inherits": ["GNU"],
+ "environment": {
+ "CXXFLAGS": "-Werror -fno-rtti"
+ }
+ },
+ {
+ "name": "no-exceptions",
+ "inherits": ["GNU"],
+ "environment": {
+ "CXXFLAGS": "-Werror -fno-exceptions"
+ }
+ },
+ {
+ "name": "no-std-c",
+ "inherits": ["GNU"],
+ "environment": {
+ "CXXFLAGS": "-DCPPUTEST_CHAR_BIT=8 -Werror -nostdinc",
+ "CFLAGS": "-DCPPUTEST_CHAR_BIT=8 -Werror -nostdinc"
+ },
+ "cacheVariables": {
+ "CPPUTEST_STD_C_LIB_DISABLED": true
+ }
+ },
+ {
+ "name": "no-long-long",
+ "inherits": ["GNU"],
+ "cacheVariables": {
+ "CPPUTEST_USE_LONG_LONG": false
+ }
+ },
+ {
+ "name": "asan",
+ "inherits": ["Clang"],
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug"
+ },
+ "environment": {
+ "CFLAGS": "-fsanitize=address -fno-omit-frame-pointer",
+ "CXXFLAGS": "-fsanitize=address -fno-omit-frame-pointer",
+ "LDFLAGS": "-fsanitize=address"
+ }
+ },
+ {
+ "name": "detailed",
+ "inherits": ["defaults"],
+ "cacheVariables": {
+ "CPPUTEST_TESTS_DETAILED": true
+ }
+ },
+ {
+ "name": "gtest",
+ "inherits": ["defaults"],
+ "generator": "Ninja Multi-Config",
+ "cacheVariables": {
+ "CPPUTEST_TEST_GTEST": true,
+ "gtest_build_tests": true
+ }
+ },
+ {
+ "name": "IAR",
+ "inherits": ["defaults"],
+ "cacheVariables": {
+ "CMAKE_SYSTEM_NAME": "Generic",
+ "CMAKE_C_COMPILER": "iccarm",
+ "CMAKE_C_FLAGS_INIT": "--cpu Cortex-M4F --dlib_config normal",
+ "CMAKE_CXX_COMPILER": "iccarm",
+ "CMAKE_CXX_FLAGS_INIT": "--cpu Cortex-M4F --dlib_config normal",
+ "CMAKE_EXE_LINKER_FLAGS": "--semihosting --config ${sourceDir}/platforms/iar/CppUTestTest.icf"
+ }
+ },
+ {
+ "name": "DOS",
+ "inherits": ["defaults"],
+ "generator": "Watcom WMake",
+ "cacheVariables": {
+ "CMAKE_SYSTEM_NAME": "DOS",
+ "CMAKE_BUILD_TYPE": "MinRelSize",
+ "CMAKE_CXX_STANDARD": "98",
+ "CPPUTEST_MEM_LEAK_DETECTION_DISABLED": true,
+ "CPPUTEST_STD_CPP_LIB_DISABLED": true
+ }
+ }
+ ]
+}
diff --git a/CppUTest.vcproj b/CppUTest.vcproj
index 99a32833e..9a8bfdcc2 100644
--- a/CppUTest.vcproj
+++ b/CppUTest.vcproj
@@ -41,7 +41,7 @@
+
+
diff --git a/CppUTest.vcxproj b/CppUTest.vcxproj
index e39220c90..4a2f18e61 100644
--- a/CppUTest.vcxproj
+++ b/CppUTest.vcxproj
@@ -60,21 +60,21 @@
<_ProjectFileVersion>10.0.30319.1
- lib\
- lib\
- cpputest_build\Debug\$(ProjectName)\
- cpputest_build\Debug\$(ProjectName)\
- lib\
- lib\
- cpputest_build\Release\$(ProjectName)\
- cpputest_build\Release\$(ProjectName)\
+ lib\x86\
+ lib\x64\
+ cpputest_build\Debug\x86\$(ProjectName)\
+ cpputest_build\Debug\x64\$(ProjectName)\
+ lib\x86\
+ lib\x64\
+ cpputest_build\Release\x86\$(ProjectName)\
+ cpputest_build\Release\x64\$(ProjectName)\
$(ProjectName)d
$(ProjectName)d
Disabled
- .\include;.\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ .\include;%(AdditionalIncludeDirectories)
_LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
@@ -106,7 +106,7 @@
Disabled
- .\include;.\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ .\include;%(AdditionalIncludeDirectories)
_LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
@@ -138,7 +138,7 @@
Disabled
- .\include;.\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ .\include;%(AdditionalIncludeDirectories)
OnlyExplicitInline
WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)
true
@@ -173,7 +173,7 @@
Disabled
- .\include;.\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ .\include;%(AdditionalIncludeDirectories)
OnlyExplicitInline
WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)
true
@@ -271,6 +271,7 @@
+
@@ -295,4 +296,4 @@
-
+
\ No newline at end of file
diff --git a/CppUTestConfig.cmake.install.in b/CppUTestConfig.cmake.install.in
index 3e6b91e00..3c79ea3aa 100644
--- a/CppUTestConfig.cmake.install.in
+++ b/CppUTestConfig.cmake.install.in
@@ -1,6 +1,7 @@
@PACKAGE_INIT@
set_and_check(CppUTest_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")
include("${CMAKE_CURRENT_LIST_DIR}/CppUTestTargets.cmake")
set(CppUTest_LIBRARIES CppUTest CppUTestExt)
include("${CMAKE_CURRENT_LIST_DIR}/Modules/CppUTestBuildTimeDiscoverTests.cmake")
diff --git a/Makefile.am b/Makefile.am
index a770a68b8..3406079c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -77,6 +77,7 @@ include_cpputest_HEADERS = \
include/CppUTest/CppUTestConfig.h \
include/CppUTest/JUnitTestOutput.h \
include/CppUTest/MemoryLeakDetector.h \
+ include/CppUTest/MemoryLeakDetectorForceInclude.h \
include/CppUTest/MemoryLeakDetectorMallocMacros.h \
include/CppUTest/MemoryLeakDetectorNewMacros.h \
include/CppUTest/MemoryLeakWarningPlugin.h \
@@ -260,6 +261,25 @@ if INCLUDE_CPPUTEST_EXT
./$(CPPUTESTEXT_TESTS)
endif
+
+cpputest_build_gtest112:
+ mkdir -p cpputest_build_gtest112
+ cd cpputest_build_gtest112; \
+ wget https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip -O gtest-1.12.1.zip && unzip gtest-1.12.1.zip; \
+ cd googletest-release-1.12.1; cmake .; make
+
+cpputest_build_gtest111:
+ mkdir -p cpputest_build_gtest111
+ cd cpputest_build_gtest111; \
+ wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip -O gtest-1.11.0.zip && unzip gtest-1.11.0.zip; \
+ cd googletest-release-1.11.0; cmake .; make
+
+cpputest_build_gtest110:
+ mkdir -p cpputest_build_gtest110
+ cd cpputest_build_gtest110; \
+ wget https://github.com/google/googletest/archive/refs/tags/release-1.10.0.zip -O gtest-1.10.0.zip && unzip gtest-1.10.0.zip; \
+ cd googletest-release-1.10.0; cmake .; make
+
cpputest_build_gtest18:
mkdir -p cpputest_build_gtest18
cd cpputest_build_gtest18; \
@@ -311,13 +331,34 @@ check_gtest18: cpputest_build_gtest18
export GTEST_HOME=`pwd`/cpputest_build_gtest18/googletest-release-1.8.0/googletest; \
make distclean; $(srcdir)/configure --enable-std-cpp98; make check
+check_gtest110: cpputest_build_gtest110
+ @echo "Build using gmock 1.10"
+ export GMOCK_MOCK=`pwd`/cpputest_build_gtest110/googletest-release-1.10.0; \
+ export GTEST_HOME=`pwd`/cpputest_build_gtest110/googletest-release-1.10.0; \
+ make distclean; $(srcdir)/configure --enable-std-cpp11; make check
+
+check_gtest111: cpputest_build_gtest111
+ @echo "Build using gmock 1.11"
+ export GMOCK_MOCK=`pwd`/cpputest_build_gtest111/googletest-release-1.11.0; \
+ export GTEST_HOME=`pwd`/cpputest_build_gtest111/googletest-release-1.11.0; \
+ make distclean; $(srcdir)/configure --enable-std-cpp11; make check
+
+check_gtest112: cpputest_build_gtest112
+ @echo "Build using gmock 1.12"
+ export GMOCK_MOCK=`pwd`/cpputest_build_gtest121/googletest-release-1.12.1; \
+ export GTEST_HOME=`pwd`/cpputest_build_gtest121/googletest-release-1.12.1; \
+ make distclean; $(srcdir)/configure --enable-std-cpp11; make check
+
remove_gtest_directories:
rm -rf cpputest_build_gtest15
rm -rf cpputest_build_gtest16
rm -rf cpputest_build_gtest17
rm -rf cpputest_build_gtest18
+ rm -rf cpputest_build_gtest110
+ rm -rf cpputest_build_gtest111
+ rm -rf cpputest_build_gtest112
-check_gtest: remove_gtest_directories check_gtest15 check_gtest16 check_gtest17 check_gtest18
+check_gtest: remove_gtest_directories check_gtest15 check_gtest16 check_gtest17 check_gtest18 check_gtest110 check_gtest111 check_gtest112
check_basic:
@echo "If dash is available, run the configure with dash to find bash-isms and increase portability"
diff --git a/Makefile_using_MakefileWorker b/Makefile_using_MakefileWorker
index 0aa7395b8..66ec53932 100644
--- a/Makefile_using_MakefileWorker
+++ b/Makefile_using_MakefileWorker
@@ -29,38 +29,85 @@ include $(CPPUTEST_HOME)/build/MakefileWorker.mk
#these are a sample of the other alternative flag settings
.PHONY: test_all
test_all: start
+ $(MAKE_CMD) test_defaults
+ $(MAKE_CMD) test_disable_std_cpp
+ $(MAKE_CMD) test_disable_memory_leak_detection
+ $(MAKE_CMD) test_disable_std_cpp_and_leak_detection
+ $(MAKE_CMD) test_disable_debug
+ $(MAKE_CMD) test_override_flags
+ $(MAKE_CMD) test_disable_std_c
+ $(MAKE_CMD) test_target_platform
+ $(MAKE_CMD) test_override_and_disable
+ $(MAKE_CMD) test_examples
+ $(MAKE_CMD) test_junit_output
+ $(MAKE_CMD) test_gcov
+ $(MAKE_CMD) test_vpath
+ $(MAKE_CMD) test_vpath_install
+
+.PHONY: test_defaults
+test_defaults: start
@echo Building with the default flags.
$(MAKE_CMD) clean
$(TIME) $(MAKE_CMD)
./$(TEST_TARGET) -r
$(MAKE_CMD) clean
+
+.PHONY: test_disable_std_cpp
+test_disable_std_cpp: start
@echo Building with the STDC++ new disabled.
- $(TIME) $(MAKE_CMD) CPPUTEST_USE_STD_CPP_LIB=Y extensions
- $(MAKE_CMD) CPPUTEST_USE_STD_CPP_LIB=Y cleanExtensions
+ $(TIME) $(MAKE_CMD) CPPUTEST_USE_STD_CPP_LIB=N extensions
+ $(MAKE_CMD) CPPUTEST_USE_STD_CPP_LIB=N cleanExtensions
+
+.PHONY: test_disable_memory_leak_detection
+test_disable_memory_leak_detection: start
@echo Building with Memory Leak Detection disabled
$(TIME) $(MAKE_CMD) CPPUTEST_USE_MEM_LEAK_DETECTION=N extensions
$(MAKE_CMD) CPPUTEST_USE_MEM_LEAK_DETECTION=N cleanExtensions
+
+.PHONY: test_disable_std_cpp_and_leak_detection
+test_disable_std_cpp_and_leak_detection: start
@echo Building with Memory Leak Detection disabled and STD C++ disabled
$(TIME) $(MAKE_CMD) CPPUTEST_USE_MEM_LEAK_DETECTION=N CPPUTEST_USE_STD_CPP_LIB=Y extensions
$(MAKE_CMD) CPPUTEST_USE_MEM_LEAK_DETECTION=N CPPUTEST_USE_STD_CPP_LIB=Y cleanExtensions
+
+.PHONY: test_disable_debug
+test_disable_debug: start
@echo Building with debug disabled
$(TIME) $(MAKE_CMD) CPPUTEST_ENABLE_DEBUG=N extensions
$(MAKE_CMD) CPPUTEST_ENABLE_DEBUG=N cleanExtensions
+
+.PHONY: test_override_flags
+test_override_flags: start
@echo Building with overridden CXXFLAGS and CFLAGS and CPPFLAGS
- $(TIME) $(MAKE_CMD) CLFAGS="" CXXFLAGS="" CPPFLAGS="-Iinclude"
+ $(TIME) $(MAKE_CMD) CFLAGS="" CXXFLAGS="" CPPFLAGS="-Iinclude"
$(MAKE_CMD) CFLAGS="" CXXFLAGS="" clean
+
+.PHONY: test_disable_std_c
+test_disable_std_c: start
@echo Building without Standard C library includes
- $(TIME) $(MAKE_CMD) CPPUTEST_USE_STD_C_LIB=N all_no_tests
+ $(TIME) $(MAKE_CMD) CPPUTEST_USE_STD_C_LIB=N CPPUTEST_ADDITIONAL_CPPFLAGS="-DCPPUTEST_CHAR_BIT=8" all_no_tests
$(MAKE_CMD) CPPUTEST_USE_STD_C_LIB=N clean
+
+.PHONY: test_target_platform
+test_target_platform: start
@echo Building with a different TARGET_PLATFORM
$(MAKE_CMD) TARGET_PLATFORM=real_platform
+
+.PHONY: test_override_and_disable
+test_override_and_disable: start
@echo Building with overridden CXXFLAGS and CFLAGS and memory leak and STDC++ disabled
- $(TIME) $(MAKE_CMD) CLFAGS="" CXXFLAGS="" CPPFLAGS="-Iinclude -DCPPUTEST_STD_CPP_LIB_DISABLED -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED"
+ $(TIME) $(MAKE_CMD) CFLAGS="" CXXFLAGS="" CPPFLAGS="-Iinclude -DCPPUTEST_STD_CPP_LIB_DISABLED -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED"
$(MAKE_CMD) CFLAGS="" CXXFLAGS="" CPPFLAGS="-DCPPUTEST_STD_CPP_LIB_DISABLED -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED" clean
+
+.PHONY: test_examples
+test_examples: start
@echo Building examples
$(MAKE_CMD) cleanExamples
$(TIME) $(MAKE_CMD) examples
$(MAKE_CMD) cleanExamples
+
+.PHONY: test_junit_output
+test_junit_output: start
@echo Testing JUnit output
$(TIME) $(MAKE_CMD)
$(SILENCE)./$(TEST_TARGET) -ojunit > junit_run_output
@@ -68,18 +115,27 @@ test_all: start
$(MAKE_CMD) clean
$(MAKE_CMD) CPPUTEST_MAP_FILE=map.txt
$(MAKE_CMD) clean
+
+.PHONY: test_gcov
+test_gcov: start
@echo Testing GCOV usage
$(TIME) $(MAKE_CMD) CPPUTEST_USE_GCOV=Y everythingInstall
$(MAKE_CMD) gcov
$(MAKE) -f Makefile_CppUTestExt gcov
$(MAKE) -C examples gcov
$(MAKE_CMD) cleanEverythingInstall
+
+.PHONY: test_vpath
+test_vpath: start
@echo Testing VPATH usage
$(TIME) $(MAKE_CMD) CPPUTEST_USE_GCOV=Y CPPUTEST_USE_VPATH=Y everythingInstall
$(MAKE_CMD) CPPUTEST_USE_VPATH=Y gcov
$(MAKE) CPPUTEST_USE_VPATH=Y -f Makefile_CppUTestExt gcov
$(MAKE) CPPUTEST_USE_VPATH=Y -C examples gcov
$(MAKE_CMD) clean cleanExamples
+
+.PHONY: test_vpath_install
+test_vpath_install: start
@echo Testing VPATH usage
$(TIME) $(MAKE_CMD) CPPUTEST_USE_VPATH=Y everythingInstall
$(MAKE_CMD) CPPUTEST_USE_VPATH=Y cleanEverythingInstall
diff --git a/README.md b/README.md
index c3c6af2be..8d6ae3727 100644
--- a/README.md
+++ b/README.md
@@ -1,54 +1,58 @@
-CppUTest
-========
-
-CppUTest unit testing and mocking framework for C/C++
-
-[More information on the project page](http://cpputest.github.com)
+# CppUTest
-Travis Linux build status:
-[](https://travis-ci.org/cpputest/cpputest)
+[](https://github.com/cpputest/cpputest/actions/workflows/basic.yml)
+[](https://ci.appveyor.com/project/basvodde/cpputest)
+[](https://coveralls.io/github/cpputest/cpputest?branch=master)
+[](https://conan.io/center/cpputest)
-AppVeyor Windows build status:
-[](https://ci.appveyor.com/project/basvodde/cpputest)
+CppUTest unit testing and mocking framework for C/C++
-Coverage:
-[](https://coveralls.io/github/cpputest/cpputest?branch=master)
+[More information on the project page](https://cpputest.github.io)
Slack channel:
-[Join if link not expired](https://join.slack.com/t/cpputest/shared_invite/zt-dvhne8z8-i_sOcxMF3oYvjoN~qpwiDw)
+[Join if link not expired](https://join.slack.com/t/cpputest/shared_invite/zt-epq97u9h-6yBQHHl2cvUADjEENtdASw)
## Getting Started
You'll need to do the following to get started:
-Building from source (unix-based, cygwin, MacOSX):
+Building from source (Unix-based, Cygwin, MacOS):
-* git clone git://github.com/cpputest/cpputest.git
-* cd cpputest_build
-* autoreconf .. -i
-* ../configure
-* make
+```bash
+git clone https://github.com/cpputest/cpputest.git
+cd cpputest
+mkdir cpputest_build
+cd cpputest_build
+autoreconf .. -i
+../configure
+make
+```
-You can use `make install` if you want to install CppUTest system-wide
+You can use `make install` if you want to install CppUTest system-wide.
You can also use CMake, which also works for Windows Visual Studio.
-* Download latest version
-* cmake CMakeList.txt
-* make
+```bash
+git clone https://github.com/cpputest/cpputest.git
+cd cpputest
+mkdir cpputest_build
+cmake -B cpputest_build
+cmake --build cpputest_build
+```
Then to get started, you'll need to do the following:
+
* Add the include path to the Makefile. Something like:
- * CPPFLAGS += -I$(CPPUTEST_HOME)/include
+ * `CPPFLAGS += -I$(CPPUTEST_HOME)/include`
* Add the memory leak macros to your Makefile (needed for additional debug info!). Something like:
- * CXXFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h
- * CFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h
+ * `CXXFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h`
+ * `CFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h`
* Add the library linking to your Makefile. Something like:
- * LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
+ * `LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt`
After this, you can write your first test:
-```C++
+```cpp
TEST_GROUP(FirstTestGroup)
{
};
@@ -59,52 +63,58 @@ TEST(FirstTestGroup, FirstTest)
}
```
+You can build and install cpputest using [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
+
+```console
+$ vcpkg install cpputest (More information: https://github.com/microsoft/vcpkg)
+```
+
## Command line switches
-* -h help, shows the latest help, including the parameters we've implemented after updating this README page.
-* -v verbose, print each test name as it runs
-* -r# repeat the tests some number of times, default is one, default if # is not specified is 2. This is handy if you are experiencing memory leaks related to statics and caches.
-* -s# random shuffle the test execution order. # is an integer used for seeding the random number generator. # is optional, and if omitted, the seed value is chosen automatically, which results in a different order every time. The seed value is printed to console to make it possible to reproduce a previously generated execution order. Handy for detecting problems related to dependencies between tests.
-* -g group only run test whose group contains the substring group
-* -n name only run test whose name contains the substring name
+* `-h` help, shows the latest help, including the parameters we've implemented after updating this README page.
+* `-v` verbose, print each test name as it runs
+* `-r#` repeat the tests some number of times, default is one, default if # is not specified is 2. This is handy if you are experiencing memory leaks related to statics and caches.
+* `-s#` random shuffle the test execution order. # is an integer used for seeding the random number generator. # is optional, and if omitted, the seed value is chosen automatically, which results in a different order every time. The seed value is printed to console to make it possible to reproduce a previously generated execution order. Handy for detecting problems related to dependencies between tests.
+* `-g` group only run test whose group contains the substring group
+* `-n` name only run test whose name contains the substring name
+* `-f` crash on fail, run the tests as normal but, when a test fails, crash rather than report the failure in the normal way
## Test Macros
-* TEST(group, name) - define a test
-* IGNORE_TEST(group, name) - turn off the execution of a test
-* TEST_GROUP(group) - Declare a test group to which certain tests belong. This will also create the link needed from another library.
-* TEST_GROUP_BASE(group, base) - Same as TEST_GROUP, just use a different base class than Utest
-* TEST_SETUP() - Declare a void setup method in a TEST_GROUP - this is the same as declaring void setup()
-* TEST_TEARDOWN() - Declare a void setup method in a TEST_GROUP
-* IMPORT_TEST_GROUP(group) - Export the name of a test group so it can be linked in from a library. Needs to be done in main.
+* `TEST(group, name)` - define a test
+* `IGNORE_TEST(group, name)` - turn off the execution of a test
+* `TEST_GROUP(group)` - Declare a test group to which certain tests belong. This will also create the link needed from another library.
+* `TEST_GROUP_BASE(group, base)` - Same as `TEST_GROUP`, just use a different base class than Utest
+* `TEST_SETUP()` - Declare a void setup method in a `TEST_GROUP` - this is the same as declaring void `setup()`
+* `TEST_TEARDOWN()` - Declare a void setup method in a `TEST_GROUP`
+* `IMPORT_TEST_GROUP(group)` - Export the name of a test group so it can be linked in from a library. Needs to be done in `main`.
## Set up and tear down support
-* Each TEST_GROUP may contain a setup and/or a teardown method.
-* setup() is called prior to each TEST body and teardown() is called after the test body.
+* Each `TEST_GROUP` may contain a `setup` and/or a `teardown` method.
+* `setup()` is called prior to each `TEST` body and `teardown()` is called after the test body.
## Assertion Macros
The failure of one of these macros causes the current test to immediately exit
-* CHECK(boolean condition) - checks any boolean result
-* CHECK_TRUE(boolean condition) - checks for true
-* CHECK_FALSE(boolean condition) - checks for false
-* CHECK_EQUAL(expected, actual) - checks for equality between entities using ==. So if you have a class that supports operator==() you can use this macro to compare two instances.
-* STRCMP_EQUAL(expected, actual) - check const char* strings for equality using strcmp
-* LONGS_EQUAL(expected, actual) - Compares two numbers
-* BYTES_EQUAL(expected, actual) - Compares two numbers, eight bits wide
-* POINTERS_EQUAL(expected, actual) - Compares two const void *
-* DOUBLES_EQUAL(expected, actual, tolerance) - Compares two doubles within some tolerance
-* ENUMS_EQUAL_INT(excepted, actual) - Compares two enums which their underlying type is int
-* ENUMS_EQUAL_TYPE(underlying_type, excepted, actual) - Compares two enums which they have the same underlying type
-* FAIL(text) - always fails
-* TEST_EXIT - Exit the test without failure - useful for contract testing (implementing an assert fake)
-
+* `CHECK(boolean condition)` - checks any boolean result
+* `CHECK_TRUE(boolean condition)` - checks for true
+* `CHECK_FALSE(boolean condition)` - checks for false
+* `CHECK_EQUAL(expected, actual)` - checks for equality between entities using `==`. So if you have a class that supports `operator==()` you can use this macro to compare two instances.
+* `STRCMP_EQUAL(expected, actual)` - check const `char*` strings for equality using `strcmp`
+* `LONGS_EQUAL(expected, actual)` - Compares two numbers
+* `BYTES_EQUAL(expected, actual)` - Compares two numbers, eight bits wide
+* `POINTERS_EQUAL(expected, actual)` - Compares two `const void *`
+* `DOUBLES_EQUAL(expected, actual, tolerance)` - Compares two doubles within some tolerance
+* `ENUMS_EQUAL_INT(excepted, actual)` - Compares two enums which their underlying type is `int`
+* `ENUMS_EQUAL_TYPE(underlying_type, excepted, actual)` - Compares two enums which they have the same underlying type
+* `FAIL(text)` - always fails
+* `TEST_EXIT` - Exit the test without failure - useful for contract testing (implementing an assert fake)
-Customize CHECK_EQUAL to work with your types that support operator==()
+Customize `CHECK_EQUAL` to work with your types that support `operator==()`
-* Create the function: `SimpleString StringFrom(const yourType&)`
+- Create the function: `SimpleString StringFrom(const yourType&)`
The Extensions directory has a few of these.
@@ -117,7 +127,7 @@ The Extensions directory has a few of these.
Example of a main with a TestPlugin:
-```C++
+```cpp
int main(int ac, char** av)
{
LogPlugin logPlugin;
@@ -133,19 +143,19 @@ Memory leak detection
* A platform specific memory leak detection mechanism is provided.
* If a test fails and has allocated memory prior to the fail and that memory is not cleaned up by TearDown, a memory leak is reported.
It is best to only chase memory leaks when other errors have been eliminated.
-* Some code uses lazy initialization and appears to leak when it really does not (for example: gcc stringstream used to in an earlier release). One cause is that some standard library calls allocate something and do not free it until after main (or never).
- To find out if a memory leak is due to lazy initialization set the -r switch to run tests twice. The signature of this situation is that the first run shows leaks and the second run shows no leaks. When both runs show leaks, you have a leak to find.
+* Some code uses lazy initialization and appears to leak when it really does not (for example: gcc stringstream used to in an earlier release). One cause is that some standard library calls allocate something and do not free it until after `main` (or never).
+ To find out if a memory leak is due to lazy initialization set the `-r` switch to run tests twice. The signature of this situation is that the first run shows leaks and the second run shows no leaks. When both runs show leaks, you have a leak to find.
## How is memory leak detection implemented?
-* Before setup() a memory usage checkpoint is recorded
-* After teardown() another checkpoint is taken and compared to the original checkpoint
+* Before `setup()` a memory usage checkpoint is recorded
+* After `teardown()` another checkpoint is taken and compared to the original checkpoint
* In Visual Studio the MS debug heap capabilities are used
-* For GCC a simple new/delete count is used in overridden operators new, new[], delete and delete[]
+* For GCC a simple new/delete count is used in overridden operators `new`, `new[]`, `delete` and `delete[]`
If you use some leaky code that you can't or won't fix you can tell a TEST to ignore a certain number of leaks as in this example:
-```C++
+```cpp
TEST(MemoryLeakWarningTest, Ignore1)
{
EXPECT_N_LEAKS(1);
@@ -155,7 +165,7 @@ TEST(MemoryLeakWarningTest, Ignore1)
## Example Main
-```C++
+```cpp
#include "CppUTest/CommandLineTestRunner.h"
int main(int ac, char** av)
@@ -166,7 +176,7 @@ int main(int ac, char** av)
## Example Test
-```C++
+```cpp
#include "CppUTest/TestHarness.h"
#include "ClassName.h"
@@ -197,12 +207,38 @@ TEST(ClassName, Create)
```
There are some scripts that are helpful in creating your initial h, cpp, and
-Test files. See scripts/README.TXT
+Test files. See scripts/README.TXT
+## Conan
+
+CppUTest is available through [conan-center][conan-center].
+
+##### conanfile.txt
+
+```ini
+[requires]
+cpputest/4.0
+
+[generators]
+cmake_find_package
+cmake_paths
+```
+
+##### CMake
+
+```cmake
+find_package(CppUTest REQUIRED)
+
+add_executable(example_test ExampleTest.cpp)
+
+target_link_libraries(example_test PRIVATE
+ CppUTest::CppUTest
+ CppUTest::CppUTestExt)
+```
## Integration as external CMake project
-Sometimes you want to use CppUTest in your project without installing it to your system or for having control over the version you are using. This little snippet get the wanted version from Github and builds it as a library.
+Sometimes you want to use CppUTest in your project without installing it to your system or for having control over the version you are using. This little snippet get the wanted version from GitHub and builds it as a library.
```cmake
# CppUTest
@@ -210,10 +246,8 @@ include(FetchContent)
FetchContent_Declare(
CppUTest
GIT_REPOSITORY https://github.com/cpputest/cpputest.git
- GIT_TAG latest-passing-build # or use release tag, eg. v3.8
+ GIT_TAG master # or use release tag, eg. v4.0
)
-# Set this to ON if you want to have the CppUTests in your project as well.
-set(TESTS OFF CACHE BOOL "Switch off CppUTest Test build")
FetchContent_MakeAvailable(CppUTest)
```
@@ -221,5 +255,10 @@ It can be used then like so:
```cmake
add_executable(run_tests UnitTest1.cpp UnitTest2.cpp)
-target_link_libraries(run_tests PRIVATE CppUTest CppUTestExt)
+
+target_link_libraries(example_test PRIVATE
+ CppUTest::CppUTest
+ CppUTest::CppUTestExt)
```
+
+[conan-center]: https://conan.io/center/cpputest
diff --git a/README_CppUTest_for_C.txt b/README_CppUTest_for_C.txt
index 578c348e8..8674364ce 100644
--- a/README_CppUTest_for_C.txt
+++ b/README_CppUTest_for_C.txt
@@ -7,10 +7,9 @@ common problems to solve.
---++ Using extern "C"
When including C-header files or when declaring C-variables and routines
-in a .cpp file, you'll have to surround them with an extern "C". This is
-because the C++ linker works different than the C linker and you need to
-instruct the compiler about this. If you do NOT do this, you will probably
-get a linker error, like unresolved symbols, for a routine that you did
+in a .cpp file, you'll need to enclose them within an extern "C". This is
+because the C++ linker works differently than the C linker and you need to
+instruct the compiler about this else you may encounter a linker error. Like unresolved symbols for a routine that you did
implement.
An example:
@@ -25,10 +24,10 @@ extern "C" {
CppUTest comes with a file called TestHarness_c.h which contains a couple
of routines that can be used in C code, like C-versions of the CHECK-macro's.
-The file also contains malloc and free routines that can be used for using
+The file also contains malloc and free routines that can be used for accessing
the CppUTest memory leak detector. These routines should be used instead of
the normal malloc/free. This can be achieved by #defining them somewhere, for
-examples as a compiler option: -Dmalloc=cpputest_malloc.
+example as a compiler option: -Dmalloc=cpputest_malloc.
It's important to remember that TestHarness_c.h is a C-header file. It can be
used in C code, but when using in C++ code, you need to use extern "C" before
diff --git a/build/MakefileWorker.mk b/build/MakefileWorker.mk
index 6c7c90ab6..46852df8d 100644
--- a/build/MakefileWorker.mk
+++ b/build/MakefileWorker.mk
@@ -24,6 +24,8 @@
# These do not go in a library. They are explicitly included in the test runner
# MOCKS_SRC_DIRS - Directories containing mock source files to build into the test runner
# These do not go in a library. They are explicitly included in the test runner
+# MOCKS_SRC_FILES - Specific mock source files to build into the unit test runner
+# These do not go in a library. They are explicitly included in the test runner
#----------
# You can adjust these variables to influence how to build the test target
# and where to put and name outputs
@@ -46,6 +48,7 @@
# of the test harness
# CPPUTEST_USE_GCOV - Turn on coverage analysis
# Clean then build with this flag set to Y, then 'make gcov'
+# CPPUTEST_USE_GCOV_NO_GCNO_FILES - Disable gcov's .gcno files from being generated
# CPPUTEST_MAPFILE - generate a map file
# CPPUTEST_WARNINGFLAGS - overly picky by default
# OTHER_MAKEFILE_TO_INCLUDE - a hook to use this makefile to make
@@ -62,6 +65,8 @@
# CPPUTEST_CPPFLAGS - flags for the C++ AND C preprocessor
# CPPUTEST_CFLAGS - flags for the C complier
# CPPUTEST_LDFLAGS - Linker flags
+# CPPUTEST_CXX_PREFIX - prefix for the C++ compiler
+# CPPUTEST_CC_PREFIX - prefix for the C compiler
#----------
# Some behavior is weird on some platforms. Need to discover the platform.
@@ -73,14 +78,14 @@ MINGW_STR = MINGW
CYGWIN_STR = CYGWIN
LINUX_STR = Linux
SUNOS_STR = SunOS
-UNKNWOWN_OS_STR = Unknown
+UNKNOWN_OS_STR = Unknown
# Compilers
CC_VERSION_OUTPUT ="$(shell $(CXX) -v 2>&1)"
CLANG_STR = clang
SUNSTUDIO_CXX_STR = SunStudio
-UNAME_OS = $(UNKNWOWN_OS_STR)
+UNAME_OS = $(UNKNOWN_OS_STR)
ifeq ($(findstring $(MINGW_STR),$(UNAME_OUTPUT)),$(MINGW_STR))
UNAME_OS = $(MINGW_STR)
@@ -170,6 +175,11 @@ ifndef CPPUTEST_USE_GCOV
CPPUTEST_USE_GCOV = N
endif
+# Skip generating gcov's .gcno files, off by default
+ifndef CPPUTEST_USE_GCOV_NO_GCNO_FILES
+ CPPUTEST_USE_GCOV_NO_GCNO_FILES = N
+endif
+
ifndef CPPUTEST_PEDANTIC_ERRORS
CPPUTEST_PEDANTIC_ERRORS = Y
endif
@@ -192,25 +202,38 @@ ifeq ($(COMPILER_NAME),$(CLANG_STR))
# -Wno-disabled-macro-expansion -> Have to disable the macro expansion warning as the operator new overload warns on that.
# -Wno-padded -> I sort-of like this warning but if there is a bool at the end of the class, it seems impossible to remove it! (except by making padding explicit)
# -Wno-global-constructors Wno-exit-time-destructors -> Great warnings, but in CppUTest it is impossible to avoid as the automatic test registration depends on the global ctor and dtor
-# -Wno-weak-vtables -> The TEST_GROUP macro declares a class and will automatically inline its methods. Thats ok as they are only in one translation unit. Unfortunately, the warning can't detect that, so it must be disabled.
+# -Wno-weak-vtables -> The TEST_GROUP macro declares a class and will automatically inline its methods. That's ok as they are only in one translation unit. Unfortunately, the warning can't detect that, so it must be disabled.
# -Wno-old-style-casts -> We only use old style casts by decision
# -Wno-c++11-long-long -> When it detects long long, then we can use it and no need for a warning about that
# -Wno-c++98-compat-pedantic -> Incompatibilities with C++98, these are happening through #define.
-# -Wno-reserved-id-macro -> Macro uses __ in MINGW... can't change that.
-# -Wno-keyword-macro -> new overload
- CPPUTEST_CXX_WARNINGFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-old-style-cast -Wno-c++11-long-long -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-keyword-macro
- CPPUTEST_C_WARNINGFLAGS += -Weverything -Wno-padded
+ CPPUTEST_CXX_WARNINGFLAGS += -Wno-disabled-macro-expansion -Wno-padded -Wno-global-constructors -Wno-exit-time-destructors -Wno-weak-vtables -Wno-old-style-cast -Wno-c++11-long-long -Wno-c++98-compat-pedantic -Wreserved-id-macro
+ CPPUTEST_C_WARNINGFLAGS += -Wno-padded -Wreserved-id-macro
-# Clang "7" or newer (Xcode 7 or newer command-line tools) introduced new warnings by default that don't exist on previous versions of clang and cause errors when present.
-CLANG_VERSION := $(shell echo $(CC_VERSION_OUTPUT) | grep -o 'clang-[0-9][0-9][0-9]*.')
-CLANG_VERSION_NUM := $(subst .,,$(subst clang-,,$(CLANG_VERSION)))
-CLANG_VERSION_NUM_GT_700 := $(shell [[ $(CLANG_VERSION_NUM) -ge 700 ]] && echo Y)
+# Clang 7 and 12 introduced new warnings by default that don't exist on previous versions of clang and cause errors when present.
+CLANG_VERSION := $(shell echo $(CC_VERSION_OUTPUT) | sed -n 's/.* \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p')
+CLANG_VERSION_NUM := $(subst .,,$(CLANG_VERSION))
+CLANG_VERSION_NUM_GT_700 := $(shell [ "$(CLANG_VERSION_NUM)" -ge 700 ] && echo Y || echo N)
+CLANG_VERSION_NUM_GT_1200 := $(shell [ "$(CLANG_VERSION_NUM)" -ge 1200 ] && echo Y || echo N)
+CLANG_VERSION_NUM_GT_1205 := $(shell [ "$(CLANG_VERSION_NUM)" -ge 1205 ] && echo Y || echo N)
ifeq ($(CLANG_VERSION_NUM_GT_700), Y)
-# -Wno-reserved-id-macro -> Many CppUTest macros start with __, which is a reserved namespace
-# -Wno-keyword-macro -> CppUTest redefines the 'new' keyword for memory leak tracking
- CPPUTEST_CXX_WARNINGFLAGS += -Wno-reserved-id-macro -Wno-keyword-macro
- CPPUTEST_C_WARNINGFLAGS += -Wno-reserved-id-macro -Wno-keyword-macro
+ CPPUTEST_CXX_WARNINGFLAGS += -Wkeyword-macro
+ CPPUTEST_C_WARNINGFLAGS += -Wkeyword-macro
+endif
+
+ifeq ($(UNAME_OS),$(MACOSX_STR))
+#apple clang has some special behavior
+ifeq ($(CLANG_VERSION_NUM_GT_1200), Y)
+# -Wno-poison-system-directories -> Apparently apple clang thinks everything is a cross compile, making this useless
+ CPPUTEST_CXX_WARNINGFLAGS += -Wno-poison-system-directories
+ CPPUTEST_C_WARNINGFLAGS += -Wno-poison-system-directories
+endif # clang 1200
+
+ifeq ($(CLANG_VERSION_NUM_GT_1205), Y)
+# Not sure why apple clang throws these warnings on cpputest code when clang doesn't
+ CPPUTEST_CXX_WARNINGFLAGS += -Wno-suggest-override -Wno-suggest-destructor-override
+ CPPUTEST_C_WARNINGFLAGS += -Wno-suggest-override -Wno-suggest-destructor-override
+endif
endif
endif
@@ -229,7 +252,7 @@ else
endif
endif
-# Default dir for the outout library
+# Default dir for the output library
ifndef CPPUTEST_LIB_DIR
ifndef TARGET_PLATFORM
CPPUTEST_LIB_DIR = lib
@@ -243,7 +266,7 @@ ifndef CPPUTEST_MAP_FILE
CPPUTEST_MAP_FILE = N
endif
-# No extentions is default
+# No extensions is default
ifndef CPPUTEST_USE_EXTENSIONS
CPPUTEST_USE_EXTENSIONS = N
endif
@@ -317,8 +340,12 @@ endif
ifeq ($(CPPUTEST_USE_GCOV), Y)
- CPPUTEST_CXXFLAGS += -fprofile-arcs -ftest-coverage
- CPPUTEST_CFLAGS += -fprofile-arcs -ftest-coverage
+ CPPUTEST_CXXFLAGS += -fprofile-arcs
+ CPPUTEST_CFLAGS += -fprofile-arcs
+ ifneq ($(CPPUTEST_USE_GCOV_NO_GCNO_FILES), Y)
+ CPPUTEST_CXXFLAGS += -ftest-coverage
+ CPPUTEST_CFLAGS += -ftest-coverage
+ endif
endif
CPPUTEST_CXXFLAGS += $(CPPUTEST_WARNINGFLAGS) $(CPPUTEST_CXX_WARNINGFLAGS)
@@ -381,7 +408,7 @@ TEST_OBJS = $(call src_to_o,$(TEST_SRC))
STUFF_TO_CLEAN += $(TEST_OBJS)
-MOCKS_SRC += $(call get_src_from_dir_list, $(MOCKS_SRC_DIRS))
+MOCKS_SRC += $(call get_src_from_dir_list, $(MOCKS_SRC_DIRS)) $(MOCKS_SRC_FILES)
MOCKS_OBJS = $(call src_to_o,$(MOCKS_SRC))
STUFF_TO_CLEAN += $(MOCKS_OBJS)
@@ -485,35 +512,53 @@ TEST_DEPS = $(TEST_OBJS) $(MOCKS_OBJS) $(PRODUCTION_CODE_START) $(TARGET_LIB) $(
test-deps: $(TEST_DEPS)
$(TEST_TARGET): $(TEST_DEPS)
+ifndef MORE_SILENCE
@echo Linking $@
+endif
$(SILENCE)$(CXX) -o $@ $^ $(LD_LIBRARIES) $(LDFLAGS)
$(TARGET_LIB): $(OBJ)
+ifndef MORE_SILENCE
@echo Building archive $@
+endif
$(SILENCE)mkdir -p $(dir $@)
+ifndef MORE_SILENCE
$(SILENCE)$(AR) $(ARFLAGS) $@ $^
+else
+ $(SILENCE)$(AR) $(ARFLAGS) $@ $^ >/dev/null
+endif
$(SILENCE)$(RANLIB) $@
test: $(TEST_TARGET)
- $(RUN_TEST_TARGET) | tee $(TEST_OUTPUT)
+ @$(eval TEST_RUN_RETURN_CODE_FILE=$(shell mktemp /tmp/cpputestResult.XXX))
+ @($(RUN_TEST_TARGET); echo $$? > $(TEST_RUN_RETURN_CODE_FILE)) | tee $(TEST_OUTPUT)
+ @ret=$$(cat $(TEST_RUN_RETURN_CODE_FILE)); rm $(TEST_RUN_RETURN_CODE_FILE); if [ "$$ret" -ne 0 ]; then echo "$$(tput setaf 1)$(TEST_TARGET) returned $${ret}$$(tput sgr0)"; fi; exit $$ret
vtest: $(TEST_TARGET)
- $(RUN_TEST_TARGET) -v | tee $(TEST_OUTPUT)
+ @$(eval TEST_RUN_RETURN_CODE_FILE=$(shell mktemp /tmp/cpputestResult.XXX))
+ @($(RUN_TEST_TARGET) -v; echo $$? > $(TEST_RUN_RETURN_CODE_FILE)) | tee $(TEST_OUTPUT)
+ @ret=$$(cat $(TEST_RUN_RETURN_CODE_FILE)); rm $(TEST_RUN_RETURN_CODE_FILE); if [ "$$ret" -ne 0 ]; then echo "$$(tput setaf 1)$(TEST_TARGET) returned $${ret}$$(tput sgr0)"; fi; exit $$ret
$(CPPUTEST_OBJS_DIR)/%.o: %.cc
+ifndef MORE_SILENCE
@echo compiling $(notdir $<)
+endif
$(SILENCE)mkdir -p $(dir $@)
- $(SILENCE)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
+ $(SILENCE)$(CPPUTEST_CXX_PREFIX)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
$(CPPUTEST_OBJS_DIR)/%.o: %.cpp
+ifndef MORE_SILENCE
@echo compiling $(notdir $<)
+endif
$(SILENCE)mkdir -p $(dir $@)
- $(SILENCE)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
+ $(SILENCE)$(CPPUTEST_CXX_PREFIX)$(COMPILE.cpp) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
$(CPPUTEST_OBJS_DIR)/%.o: %.c
+ifndef MORE_SILENCE
@echo compiling $(notdir $<)
+endif
$(SILENCE)mkdir -p $(dir $@)
- $(SILENCE)$(COMPILE.c) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
+ $(SILENCE)$(CPPUTEST_CC_PREFIX)$(COMPILE.c) $(DEP_FLAGS) $(OUTPUT_OPTION) $<
ifneq "$(MAKECMDGOALS)" "clean"
-include $(DEP_FILES)
@@ -521,7 +566,9 @@ endif
.PHONY: clean
clean:
+ifndef MORE_SILENCE
@echo Making clean
+endif
$(SILENCE)$(RM) $(STUFF_TO_CLEAN)
$(SILENCE)rm -rf gcov $(CPPUTEST_OBJS_DIR) $(CPPUTEST_LIB_DIR)
$(SILENCE)find . -name "*.gcno" | xargs rm -f
diff --git a/build/alltests.mmp b/build/alltests.mmp
index 8eaaf5b13..40c1dc86a 100644
--- a/build/alltests.mmp
+++ b/build/alltests.mmp
@@ -29,7 +29,7 @@ TARGET cpputest.exe
TARGETTYPE exe
UID 0x00000000 0x03A6305A
-USERINCLUDE ..\include ..\include\CppUTest ..\include\Platforms\Symbian ..\tests
+USERINCLUDE ..\include ..\include\CppUTest ..\tests
SYSTEMINCLUDE \epoc32\include \epoc32\include\stdapis
STATICLIBRARY libcrt0.lib
diff --git a/build/cpputest.mmp b/build/cpputest.mmp
index 8093f8c59..103063507 100644
--- a/build/cpputest.mmp
+++ b/build/cpputest.mmp
@@ -29,7 +29,7 @@ TARGET cpputest.lib
TARGETTYPE LIB
UID 0x00000000 0x03A6305A
-USERINCLUDE ..\include ..\include\CppUTest ..\include\Platforms\Symbian
+USERINCLUDE ..\include ..\include\CppUTest
SYSTEMINCLUDE \epoc32\include \epoc32\include\stdapis
SOURCEPATH ..\src\CppUTest
diff --git a/cmake/Modules/CppUTest.cmake b/cmake/Modules/CppUTest.cmake
new file mode 100644
index 000000000..160959a5e
--- /dev/null
+++ b/cmake/Modules/CppUTest.cmake
@@ -0,0 +1,117 @@
+set(_CPPUTEST_DISCOVERY_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/_CppUTestDiscovery.cmake
+ CACHE INTERNAL "CppUTest discovery scripts"
+)
+
+option(CPPUTEST_TESTS_DETAILED "Run discovered tests individually")
+option(CPPUTEST_JUNIT_REPORT "Output JUnit test reports")
+
+function(cpputest_discover_tests target)
+ set(options JUNIT)
+ set(oneValueArgs DETAILED)
+ set(multiValueArgs EXTRA_ARGS)
+ cmake_parse_arguments(
+ ""
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+
+ # Validate arguments.
+ if(NOT TARGET ${target})
+ message(FATAL_ERROR
+ "Cannot discover tests for target \"${target}\" "
+ "which is not built by this project."
+ )
+ endif()
+
+ get_property(target_type
+ TARGET ${target}
+ PROPERTY TYPE
+ )
+ if(NOT target_type STREQUAL "EXECUTABLE")
+ message(FATAL_ERROR
+ "Cannot discover tests for target \"${target}\" "
+ "which is not an executable."
+ )
+ endif()
+
+ get_property(emulator
+ TARGET ${target}
+ PROPERTY CROSSCOMPILING_EMULATOR
+ )
+ if(CMAKE_CROSSCOMPILING)
+ if(NOT emulator)
+ message(WARNING "Cannot discover cross compiled tests without an emulator")
+ return()
+ endif()
+ endif()
+
+ if(NOT DEFINED _EXTRA_ARGS)
+ set(_EXTRA_ARGS -v)
+ endif()
+
+ if(NOT DEFINED _DETAILED)
+ set(_DETAILED ${CPPUTEST_TESTS_DETAILED})
+ endif()
+
+ if(_JUNIT OR CPPUTEST_JUNIT_REPORT)
+ list(APPEND _EXTRA_ARGS -ojunit)
+ endif()
+
+ set(CTEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}_include.cmake")
+ if(CMAKE_CONFIGURATION_TYPES)
+ set(CTEST_GENERATED_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}.$.cmake")
+ file(WRITE "${CTEST_INCLUDE_FILE}"
+ "if(EXISTS \"${CMAKE_CURRENT_BINARY_DIR}/${target}.\${CTEST_CONFIGURATION_TYPE}.cmake\")\n"
+ " include(\"${CMAKE_CURRENT_BINARY_DIR}/${target}.\${CTEST_CONFIGURATION_TYPE}.cmake\")\n"
+ "endif()\n"
+ )
+ else()
+ set(CTEST_GENERATED_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}.cmake")
+ file(WRITE "${CTEST_INCLUDE_FILE}"
+ "if(EXISTS \"${CTEST_GENERATED_FILE}\")\n"
+ " include(\"${CTEST_GENERATED_FILE}\")\n"
+ "endif()\n"
+ )
+ endif()
+
+ add_custom_command(
+ TARGET ${target} POST_BUILD
+ BYPRODUCTS "${CTEST_GENERATED_FILE}"
+ COMMAND
+ "${CMAKE_COMMAND}"
+ -D "TESTS_DETAILED:BOOL=${_DETAILED}"
+ -D "EXECUTABLE=$"
+ -D "EMULATOR=${emulator}"
+ -D "ARGS=${_EXTRA_ARGS}"
+ -D "CTEST_FILE=${CTEST_GENERATED_FILE}"
+ -P "${_CPPUTEST_DISCOVERY_SCRIPT}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+ VERBATIM
+ )
+
+ if(${CMAKE_VERSION} VERSION_LESS "3.10")
+ # We can only set one.
+ get_property(already_set
+ DIRECTORY
+ PROPERTY TEST_INCLUDE_FILE
+ SET
+ )
+ if(${already_set})
+ message(FATAL_ERROR
+ "Cannot discovery multiple tests from the same file"
+ )
+ endif()
+ set_property(
+ DIRECTORY
+ PROPERTY TEST_INCLUDE_FILE "${CTEST_INCLUDE_FILE}"
+ )
+ else()
+ set_property(
+ DIRECTORY APPEND
+ PROPERTY TEST_INCLUDE_FILES "${CTEST_INCLUDE_FILE}"
+ )
+ endif()
+
+endfunction()
diff --git a/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake b/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
index 49b297319..cfffad56c 100644
--- a/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
+++ b/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
@@ -1,19 +1,55 @@
+option(CPPUTEST_TESTS_DETAILED "Run discovered tests individually")
+
+set(_DISCOVER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/../Scripts/CppUTestBuildTimeDiscoverTests.cmake")
+
# Create target to discover tests
-function (cpputest_buildtime_discover_tests EXECUTABLE)
- # The path to the discover script depends on execution mode:
- # - internal (building CppUTest it self).
- # - imported (installed, imported, and executed by a client of the CppUTest lib)
- if (PROJECT_NAME STREQUAL "CppUTest") # internal - (path is relative to source dir)
- SET(DISCOVER_SCRIPT ${PROJECT_SOURCE_DIR}/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake)
- else (PROJECT_NAME STREQUAL "CppUTest") # Installed (path is relative to install directory)
- SET(DISCOVER_SCRIPT ${CppUTest_DIR}/Scripts/CppUTestBuildTimeDiscoverTests.cmake)
- endif (PROJECT_NAME STREQUAL "CppUTest")
+function (cpputest_buildtime_discover_tests tgt)
+ message(DEPRECATION
+ "Use cpputest_discover_tests from the CppUTest module instead"
+ )
- add_custom_command (TARGET ${EXECUTABLE}
- POST_BUILD
- COMMAND ${CMAKE_COMMAND} -DTESTS_DETAILED:BOOL=${TESTS_DETAILED} -DEXECUTABLE=$ -P ${DISCOVER_SCRIPT}
- VERBATIM
+ set(options)
+ set(oneValueArgs DETAILED)
+ set(multiValueArgs)
+ cmake_parse_arguments(
+ ""
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+ if(NOT DEFINED _DETAILED)
+ set(_DETAILED ${CPPUTEST_TESTS_DETAILED})
+ endif()
+
+ if(NOT TARGET ${tgt})
+ message(FATAL_ERROR
+ "Cannot discover tests for target \"${tgt}\" "
+ "which is not built by this project."
+ )
+ endif()
+
+ get_property(target_type
+ TARGET ${tgt}
+ PROPERTY TYPE
+ )
+ if(NOT target_type STREQUAL "EXECUTABLE")
+ message(FATAL_ERROR
+ "Cannot discover tests for target \"${tgt}\" "
+ "which is not an executable."
+ )
+ endif()
+
+ add_custom_command(
+ TARGET ${tgt} POST_BUILD
+ COMMAND
+ ${CMAKE_COMMAND}
+ -D "TESTS_DETAILED:BOOL=${_DETAILED}"
+ -D "EXECUTABLE=$"
+ -D "EMULATOR=$"
+ -P "${_DISCOVER_SCRIPT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Discovering Tests in ${EXECUTABLE}"
- VERBATIM)
+ COMMENT "Discovering Tests in ${tgt}"
+ VERBATIM
+ )
endfunction ()
diff --git a/cmake/Modules/CppUTestConfigurationOptions.cmake b/cmake/Modules/CppUTestConfigurationOptions.cmake
deleted file mode 100644
index 43147cb5d..000000000
--- a/cmake/Modules/CppUTestConfigurationOptions.cmake
+++ /dev/null
@@ -1,98 +0,0 @@
-if (MSVC)
- set(CPP_PLATFORM VisualCpp)
- include_directories(${CppUTestRootDirectory}/include/Platforms/${CPP_PLATFORM})
- option(STDC_WANT_SECURE_LIB "Use MSVC safe functions" ON)
- if(STDC_WANT_SECURE_LIB)
- ADD_DEFINITIONS(-DSTDC_WANT_SECURE_LIB)
- endif(STDC_WANT_SECURE_LIB)
-elseif (STD_C)
- if(NOT CPP_PLATFORM)
- set(CPP_PLATFORM Gcc)
- endif(NOT CPP_PLATFORM)
-else (MSVC)
- set(STD_CPP False)
- set(MEMORY_LEAK_DETECTION False)
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc")
- set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -nostdinc")
- set(CPPUTEST_STD_C_LIB_DISABLED 1)
- set(CPP_PLATFORM GccNoStdC)
-endif (MSVC)
-
-include("${CppUTestRootDirectory}/cmake/Modules/CppUTestWarningFlags.cmake")
-
-if (NOT STD_CPP)
- set(CPPUTEST_STD_CPP_LIB_DISABLED 1)
- if (STD_C AND NOT MSVC)
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc++")
- endif (STD_C AND NOT MSVC)
-endif (NOT STD_CPP)
-
-if (MEMORY_LEAK_DETECTION)
- if (MSVC)
- set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} /FI \"${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} /FI \"${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
- else (MSVC)
- set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} -include \"${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -include \"${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorNewMacros.h\"")
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -include \"${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
- endif (MSVC)
-else (MEMORY_LEAK_DETECTION)
- set(CPPUTEST_MEM_LEAK_DETECTION_DISABLED 1)
-endif (MEMORY_LEAK_DETECTION)
-
-if (LONGLONG)
- set(CPPUTEST_USE_LONG_LONG 1)
-endif (LONGLONG)
-
-if (MAP_FILE AND NOT MSVC)
- set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -Wl,-Map,$<.map.txt")
-endif (MAP_FILE AND NOT MSVC)
-
-if (COVERAGE AND NOT MSVC)
- set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} --coverage")
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} --coverage")
- set(CMAKE_BUILD_TYPE "Debug")
- find_program(GCOVR gcovr DOC "gcovr executable")
-
- if (NOT GCOVR)
- message(SEND_ERROR "gcovr not found")
- endif()
-
- add_custom_target(coverage ${GCOVR}
- --root ${PROJECT_SOURCE_DIR}
- --output "${CMAKE_BINARY_DIR}/coverage/coverage.html"
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- COMMENT "Generate coverage data"
- VERBATIM
- )
-endif()
-
-if (CMAKE_CXX_STANDARD)
- set(CMAKE_CXX_EXTENSIONS OFF)
-elseif (C++11)
- find_package(CXX11 REQUIRED)
- set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} ${CXX11_FLAGS}")
-else()
- # No standard specified
-endif ()
-
-set(GMOCK_HOME $ENV{GMOCK_HOME})
-if (DEFINED ENV{GMOCK_HOME})
- # GMock pulls in gtest.
- set(CPPUTEST_INCLUDE_GTEST_TESTS 1)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1")
- include_directories(${GMOCK_HOME}/include ${GMOCK_HOME}/gtest ${GMOCK_HOME}/gtest/include)
- add_subdirectory(${GMOCK_HOME} "${CMAKE_CURRENT_BINARY_DIR}/gmock")
-
- set(CPPUTEST_C_WARNING_FLAGS "")
- set(CPPUTEST_CXX_WARNING_FLAGS "")
-endif (DEFINED ENV{GMOCK_HOME})
-
-set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} ${CPPUTEST_C_WARNING_FLAGS}")
-set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} ${CPPUTEST_CXX_WARNING_FLAGS}")
-
-if (CPPUTEST_FLAGS)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CPPUTEST_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPPUTEST_CXX_FLAGS}")
- set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} ${CPPUTEST_LD_FLAGS}")
-endif (CPPUTEST_FLAGS)
diff --git a/cmake/Modules/CppUTestNormalizeTestOutputLocation.cmake b/cmake/Modules/CppUTestNormalizeTestOutputLocation.cmake
deleted file mode 100644
index acb5efb34..000000000
--- a/cmake/Modules/CppUTestNormalizeTestOutputLocation.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-# Override output properties to put test executable at specificied location
-function (cpputest_normalize_test_output_location TEST_TARGET)
- set_target_properties(${TEST_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
- foreach(OUTPUT_CONFIG ${CMAKE_CONFIGURATION_TYPES})
- string(TOUPPER ${OUTPUT_CONFIG} OUTPUT_CONFIG)
- set_target_properties(${TEST_TARGET} PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY_${OUTPUT_CONFIG} ${CMAKE_CURRENT_BINARY_DIR})
- endforeach(OUTPUT_CONFIG)
-endfunction ()
-
diff --git a/cmake/Modules/CppUTestWarningFlags.cmake b/cmake/Modules/CppUTestWarningFlags.cmake
deleted file mode 100644
index 3b8f2d7f2..000000000
--- a/cmake/Modules/CppUTestWarningFlags.cmake
+++ /dev/null
@@ -1,80 +0,0 @@
-if (MSVC)
- set(CPPUTEST_C_WARNING_FLAGS "/WX")
- set(CPPUTEST_CXX_WARNING_FLAGS "/WX /wd4290")
-else (MSVC)
- include(CheckCCompilerFlag)
- include(CheckCXXCompilerFlag)
-
- macro(check_and_append_c_warning_flags)
- foreach (flag ${ARGN})
- check_c_compiler_flag("-${flag}" WARNING_C_FLAG_${flag})
- if (WARNING_C_FLAG_${flag})
- set(CPPUTEST_C_WARNING_FLAGS "${CPPUTEST_C_WARNING_FLAGS} -${flag}")
- endif (WARNING_C_FLAG_${flag})
- endforeach (flag)
- endmacro(check_and_append_c_warning_flags)
-
- macro(check_and_append_cxx_warning_flags)
- foreach (flag ${ARGN})
- string(REPLACE "++" "xx" WARNING_CXX_FLAG_VAR "WARNING_CXX_FLAG_${flag}")
- check_cxx_compiler_flag("-${flag}" ${WARNING_CXX_FLAG_VAR})
- if (${WARNING_CXX_FLAG_VAR})
- set(CPPUTEST_CXX_WARNING_FLAGS "${CPPUTEST_CXX_WARNING_FLAGS} -${flag}")
- endif (${WARNING_CXX_FLAG_VAR})
- endforeach (flag)
- endmacro(check_and_append_cxx_warning_flags)
-
- if (NOT GMOCK AND NOT REAL_GTEST)
- list(APPEND WARNING_C_FLAGS Werror pedantic-errors)
- endif (NOT GMOCK AND NOT REAL_GTEST)
-
- set(WARNING_C_FLAGS
- Weverything
- Wall
- Wextra
- pedantic
- Wshadow
- Wswitch-default
- Wswitch-enum
- Wconversion
- Wsign-conversion
- Wno-padded
- Wno-disabled-macro-expansion
- Wno-reserved-id-macro
- Wno-keyword-macro
- Wno-long-long
- )
-
- if (WERROR)
- list(APPEND WARNING_C_FLAGS Werror)
- endif (WERROR)
-
-
- set(WARNING_C_ONLY_FLAGS
- Wstrict-prototypes
- )
-
- set(WARNING_CXX_FLAGS
- ${WARNING_C_FLAGS}
- Woverloaded-virtual
- Wno-global-constructors
- Wno-exit-time-destructors
- Wno-weak-vtables
- Wno-old-style-cast
- )
-
- if (C++11 OR (DEFINED CMAKE_CXX_STANDARD AND NOT CMAKE_CXX_STANDARD EQUAL 98))
- set(WARNING_CXX_FLAGS
- ${WARNING_CXX_FLAGS}
- Wno-c++98-compat
- Wno-c++98-compat-pedantic
- Wno-c++14-compat
- Wno-inconsistent-missing-destructor-override
- )
- endif ()
-
- check_and_append_c_warning_flags(${WARNING_C_FLAGS})
- check_and_append_c_warning_flags(${WARNING_C_ONLY_FLAGS})
- check_and_append_cxx_warning_flags(${WARNING_CXX_FLAGS})
-
-endif (MSVC)
diff --git a/cmake/Modules/FindCXX11.cmake b/cmake/Modules/FindCXX11.cmake
deleted file mode 100644
index 8718ec107..000000000
--- a/cmake/Modules/FindCXX11.cmake
+++ /dev/null
@@ -1,54 +0,0 @@
-# - Finds if the compiler has C++11 support
-# This module can be used to detect compiler flags for using C++11, and checks
-# a small subset of the language.
-#
-# The following variables are set:
-# CXX11_FLAGS - flags to add to the CXX compiler for C++11 support
-# CXX11_FOUND - true if the compiler supports C++11
-#
-# TODO: When compilers starts implementing the whole C++11, check the full set
-
-include(CheckCXXSourceCompiles)
-include(FindPackageHandleStandardArgs)
-
-set(CXX11_FLAG_CANDIDATES
- # Eveerything that automatically accepts C++11
- " "
- # gcc, clang and Intel Linux
- "-std=c++11"
- # Intel windows
- "/Qstd=c++0x"
- "/Qstd=c++11"
- )
-
-set(CXX11_TEST_SOURCE
-"
-#if defined(_MSC_VER)
- #if _MSC_VER < 1800
- #error \"Can not compile with C++11\"
- #endif
-#elif __cplusplus < 201103L
- #error \"Can not compile with C++11\"
-#endif
-
-int main()
-{}
-")
-
-foreach(FLAG ${CXX11_FLAG_CANDIDATES})
- set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_REQUIRED_FLAGS "${FLAG}")
- unset(CXX11_FLAG_DETECTED CACHE)
- message(STATUS "Try C++11 flag = [${FLAG}]")
- check_cxx_source_compiles("${CXX11_TEST_SOURCE}" CXX11_FLAG_DETECTED)
- set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
- if(CXX11_FLAG_DETECTED)
- set(CXX11_FLAGS_INTERNAL "${FLAG}")
- break()
- endif(CXX11_FLAG_DETECTED)
-endforeach(FLAG ${CXX11_FLAG_CANDIDATES})
-
-set(CXX11_FLAGS "${CXX11_FLAGS_INTERNAL}")
-
-find_package_handle_standard_args(CXX11 DEFAULT_MSG CXX11_FLAGS)
-mark_as_advanced(CXX11_FLAGS)
diff --git a/cmake/Modules/_CppUTestDiscovery.cmake b/cmake/Modules/_CppUTestDiscovery.cmake
new file mode 100644
index 000000000..a970fbc37
--- /dev/null
+++ b/cmake/Modules/_CppUTestDiscovery.cmake
@@ -0,0 +1,98 @@
+set(script)
+
+function(add_command NAME)
+ set(_args "")
+ # use ARGV* instead of ARGN, because ARGN splits arrays into multiple arguments
+ math(EXPR _last_arg ${ARGC}-1)
+ foreach(_n RANGE 1 ${_last_arg})
+ set(_arg "${ARGV${_n}}")
+ if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
+ set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument
+ else()
+ set(_args "${_args} ${_arg}")
+ endif()
+ endforeach()
+ set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
+endfunction()
+
+if(NOT EXISTS "${EXECUTABLE}")
+ message(FATAL_ERROR
+ "Executable \"${EXECUTABLE}\" does not exist"
+ )
+endif()
+
+macro(add_test_to_script TEST_NAME TEST_LOCATION SELECT_ARG)
+ add_command(
+ add_test
+ "${TEST_NAME}"
+ ${EMULATOR}
+ "${EXECUTABLE}"
+ ${ARGS}
+ ${SELECT_ARG}
+ ${TEST_NAME}
+ )
+ add_command(
+ set_tests_properties
+ "${TEST_NAME}"
+ PROPERTIES
+ DEF_SOURCE_LINE
+ "${TEST_LOCATION}"
+ )
+endmacro()
+
+execute_process(
+ COMMAND ${EMULATOR} "${EXECUTABLE}" -ll
+ OUTPUT_VARIABLE discovered_tests
+ RESULT_VARIABLE result
+ ERROR_VARIABLE error
+)
+if(NOT ${result} EQUAL 0)
+ message(FATAL_ERROR
+ "Error executing ${EXECUTABLE}:\n"
+ "${error}"
+ )
+endif()
+
+string(CONCAT LL_LINE_REGEX
+ "^([^.]*)" # test group
+ "\\."
+ "([^.]*)" # test name
+ "\\."
+ "(.*)" # file name (only this field is allowed to contain dots)
+ "\\."
+ "([^.]*)" # line number
+ "\n"
+)
+string(REGEX MATCHALL "[^\n]+\n" discovered_test_lines "${discovered_tests}")
+if(TESTS_DETAILED)
+ foreach(line IN LISTS discovered_test_lines)
+ string(REGEX MATCH "${LL_LINE_REGEX}" __unused "${line}")
+ set(test_name "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
+ file(TO_CMAKE_PATH "${CMAKE_MATCH_3}" test_file)
+ set(test_location "${test_file}:${CMAKE_MATCH_4}")
+ add_test_to_script("${test_name}" "${test_location}" -st)
+ endforeach()
+else()
+ foreach(line IN LISTS discovered_test_lines)
+ string(REGEX MATCH "${LL_LINE_REGEX}" __unused "${line}")
+ set(test_name "${CMAKE_MATCH_1}")
+ file(TO_CMAKE_PATH "${CMAKE_MATCH_3}" test_file)
+ set(test_line "${CMAKE_MATCH_4}")
+ if (NOT _${test_name}_file)
+ # if the group spans two files, arbitrarily choose the first one encountered
+ set(_${test_name}_file "${test_file}")
+ set(_${test_name}_line "${test_line}")
+ elseif(test_file STREQUAL _${test_name}_file AND test_line LESS _${test_name}_line)
+ # line number will eventually be the first line of the first test in the group's file
+ set(_${test_name}_line ${test_line})
+ endif()
+ list(APPEND groups_seen ${test_name})
+ endforeach()
+ list(REMOVE_DUPLICATES groups_seen)
+ foreach(test_name IN LISTS groups_seen)
+ set(test_location "${_${test_name}_file}:${_${test_name}_line}")
+ add_test_to_script("${test_name}" "${test_location}" -sg)
+ endforeach()
+endif()
+
+file(WRITE "${CTEST_FILE}" "${script}")
diff --git a/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake b/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
index 01eb45b3c..c5d96c031 100644
--- a/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
+++ b/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
@@ -41,7 +41,7 @@ function (JOIN VALUES GLUE OUTPUT)
endfunction()
function (buildtime_discover_tests EXECUTABLE DISCOVER_ARG OUTPUT)
- execute_process(COMMAND ${EXECUTABLE} ${DISCOVER_ARG}
+ execute_process(COMMAND ${EMULATOR} ${EXECUTABLE} ${DISCOVER_ARG}
OUTPUT_VARIABLE _TMP_OUTPUT
ERROR_VARIABLE DISCOVER_ERR
RESULT_VARIABLE DISCOVER_ERR)
@@ -75,14 +75,14 @@ if (TESTS_DETAILED)
set(lastgroup "${groupname}")
endif (NOT ("${groupname}" STREQUAL "${lastgroup}"))
message("... ${testname}")
- buildtime_add_test(${EXECUTABLE_SHORT_NAME}.${testfullname} ${EXECUTABLE} -sg ${groupname} -sn ${testname})
+ buildtime_add_test(${EXECUTABLE_SHORT_NAME}.${testfullname} ${EMULATOR} ${EXECUTABLE} -sg ${groupname} -sn ${testname})
endforeach()
else (TESTS_DETAILED)
set(DISCOVER_ARG "-lg")
buildtime_discover_tests("${EXECUTABLE}" "${DISCOVER_ARG}" TestList_Groups)
foreach(group ${TestList_Groups})
message("TestGroup: ${group}")
- buildtime_add_test(${EXECUTABLE_SHORT_NAME}.${group} "${EXECUTABLE}" -sg ${group})
+ buildtime_add_test(${EXECUTABLE_SHORT_NAME}.${group} ${EMULATOR} "${EXECUTABLE}" -sg ${group})
endforeach()
endif (TESTS_DETAILED)
diff --git a/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake b/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake
new file mode 100644
index 000000000..b9ab5030e
--- /dev/null
+++ b/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
+
+set(CMAKE_C_COMPILER arm-none-eabi-gcc)
+
+set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m4")
+set(CMAKE_CXX_FLAGS_INIT "-mcpu=cortex-m4")
+set(CMAKE_EXE_LINKER_FLAGS_INIT "-specs=rdimon.specs")
diff --git a/cmake/clang+mingw-win32.toolchain.cmake b/cmake/Toolchains/clang+mingw-win32.toolchain.cmake
similarity index 100%
rename from cmake/clang+mingw-win32.toolchain.cmake
rename to cmake/Toolchains/clang+mingw-win32.toolchain.cmake
diff --git a/cmake/clang+mingw-win64.toolchain.cmake b/cmake/Toolchains/clang+mingw-win64.toolchain.cmake
similarity index 100%
rename from cmake/clang+mingw-win64.toolchain.cmake
rename to cmake/Toolchains/clang+mingw-win64.toolchain.cmake
diff --git a/cmake/Toolchains/ewarm-linux.toolchain.cmake b/cmake/Toolchains/ewarm-linux.toolchain.cmake
new file mode 100644
index 000000000..e0053a7bf
--- /dev/null
+++ b/cmake/Toolchains/ewarm-linux.toolchain.cmake
@@ -0,0 +1,21 @@
+### BEGIN CMAKE_TOOLCHAIN_FILE
+# "Generic" is used when compiling for bare-metal
+set(CMAKE_SYSTEM_NAME Generic)
+
+# Set the EW installation root directory
+#(Avoid spaces in the path or you need to escape them)
+set(EW_ROOT_DIR "/opt/iarsystems/bxarm/arm/")
+
+# Compiler flags needed to compile for this CPU
+set(CPU_FLAGS "--cpu Cortex-M4F")
+
+# Set up the CMake variables for compiler and assembler
+# (The reason for both C and CXX variables is that CMake
+# treats C and C++ tools individually)
+set(CMAKE_C_COMPILER "${EW_ROOT_DIR}/bin/iccarm" "${CPU_FLAGS} --dlib_config normal")
+set(CMAKE_CXX_COMPILER "${EW_ROOT_DIR}/bin/iccarm" "${CPU_FLAGS} --dlib_config normal")
+set(CMAKE_ASM_COMPILER "${EW_ROOT_DIR}/bin/iasmarm" "${CPU_FLAGS}")
+
+# Build with cmake -S. -Bbuild -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ewarm-linux.toolchain.cmake
+
+### END CMAKE_TOOLCHAIN_FILE
diff --git a/cmake/Toolchains/ewarm-win.toolchain.cmake b/cmake/Toolchains/ewarm-win.toolchain.cmake
new file mode 100644
index 000000000..ab28b445f
--- /dev/null
+++ b/cmake/Toolchains/ewarm-win.toolchain.cmake
@@ -0,0 +1,21 @@
+### BEGIN CMAKE_TOOLCHAIN_FILE
+# "Generic" is used when compiling for bare-metal
+set(CMAKE_SYSTEM_NAME Generic)
+
+# Set the EW installation root directory
+#(Avoid spaces in the path or you need to escape them)
+set(EW_ROOT_DIR "E:/Program Files\ (x86)/IAR\ Systems/Embedded\ Workbench\ Arm 8.50.6/arm")
+
+# Compiler flags needed to compile for this CPU
+set(CPU_FLAGS "--cpu Cortex-M4F")
+
+# Set up the CMake variables for compiler and assembler
+# (The reason for both C and CXX variables is that CMake
+# treats C and C++ tools individually)
+set(CMAKE_C_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe" "${CPU_FLAGS} --dlib_config normal")
+set(CMAKE_CXX_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe" "${CPU_FLAGS} --dlib_config normal")
+set(CMAKE_ASM_COMPILER "${EW_ROOT_DIR}/bin/iasmarm.exe" "${CPU_FLAGS}")
+
+# Build with cmake -S. -Bbuild -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ewarm-win.toolchain.cmake
+
+### END CMAKE_TOOLCHAIN_FILE
diff --git a/cmake/install.cmake b/cmake/install.cmake
new file mode 100644
index 000000000..f58ba31b9
--- /dev/null
+++ b/cmake/install.cmake
@@ -0,0 +1,65 @@
+set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
+set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+# Pkg-config file.
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+set(exec_prefix "\${prefix}")
+set(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
+set(includedir "\${prefix}/${INCLUDE_INSTALL_DIR}")
+set(PACKAGE_VERSION "${PROJECT_VERSION}")
+
+configure_file(cpputest.pc.in cpputest.pc @ONLY)
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/cpputest.pc"
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
+)
+
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/CppUTestGeneratedConfig.h"
+ DESTINATION "${INCLUDE_INSTALL_DIR}/generated"
+)
+
+include(CMakePackageConfigHelpers)
+
+set(CPPUTEST_CONFIG_DEST "${LIB_INSTALL_DIR}/CppUTest/cmake")
+
+configure_package_config_file(CppUTestConfig.cmake.install.in
+ ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
+ INSTALL_DESTINATION "${CPPUTEST_CONFIG_DEST}"
+ PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
+ COMPATIBILITY SameMajorVersion
+)
+install(
+ FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
+ DESTINATION "${CPPUTEST_CONFIG_DEST}"
+)
+install(
+ EXPORT CppUTestTargets
+ NAMESPACE CppUTest::
+ DESTINATION "${CPPUTEST_CONFIG_DEST}"
+)
+install(
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
+ DESTINATION "${CPPUTEST_CONFIG_DEST}/Scripts"
+)
+install(
+ FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CppUTest.cmake
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/_CppUTestDiscovery.cmake
+ DESTINATION "${CPPUTEST_CONFIG_DEST}/Modules"
+)
+configure_package_config_file(CppUTestConfig.cmake.build.in
+ ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfig.cmake
+ INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
+ PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR
+)
+write_basic_package_version_file(
+ ${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfigVersion.cmake
+ COMPATIBILITY SameMajorVersion
+)
diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake
new file mode 100644
index 000000000..4b763f684
--- /dev/null
+++ b/cmake/warnings.cmake
@@ -0,0 +1,68 @@
+unset(WARNING_COMMON_FLAGS)
+unset(WARNING_C_FLAGS)
+unset(WARNING_CXX_FLAGS)
+
+if(
+ (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
+ (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR
+ (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+)
+ set(WARNING_COMMON_FLAGS
+ -Wall
+ -Wextra
+ -pedantic
+ -Wshadow
+ -Wswitch-default
+ -Wswitch-enum
+ -Wconversion
+ -Wsign-conversion
+ -Wmissing-include-dirs
+ -Wno-padded
+ -Wno-disabled-macro-expansion
+ -Wreserved-id-macro
+ -Wreserved-identifier
+ -Wno-long-long
+ -Wno-unsafe-buffer-usage
+ )
+
+ set(WARNING_C_FLAGS
+ -Wstrict-prototypes
+ )
+
+ set(WARNING_CXX_FLAGS
+ -Woverloaded-virtual
+ -Wno-global-constructors
+ -Wno-exit-time-destructors
+ -Wno-weak-vtables
+ -Wno-old-style-cast
+ )
+
+ if(DEFINED CMAKE_CXX_STANDARD AND NOT CMAKE_CXX_STANDARD EQUAL 98)
+ list(APPEND WARNING_CXX_FLAGS
+ -Wno-c++98-compat
+ -Wno-c++98-compat-pedantic
+ -Wno-c++14-compat
+ -Wno-inconsistent-missing-destructor-override
+ -Wsuggest-override
+ )
+ endif()
+
+ set(CMAKE_REQUIRED_FLAGS "-Wno-error")
+endif()
+
+include(CheckCCompilerFlag)
+foreach(flag IN LISTS WARNING_COMMON_FLAGS WARNING_C_FLAGS)
+ check_c_compiler_flag("${flag}" WARNING_C_FLAG_${flag})
+ if(WARNING_C_FLAG_${flag})
+ add_compile_options("$<$:${flag}>")
+ endif()
+endforeach()
+
+include(CheckCXXCompilerFlag)
+foreach(flag IN LISTS WARNING_COMMON_FLAGS WARNING_CXX_FLAGS)
+ string(REPLACE "++" "xx" WARNING_CXX_FLAG_VAR "WARNING_CXX_FLAG_${flag}")
+ check_cxx_compiler_flag("${flag}" ${WARNING_CXX_FLAG_VAR})
+ if(${WARNING_CXX_FLAG_VAR})
+ add_compile_options("$<$:${flag}>")
+ endif()
+endforeach()
diff --git a/config.h.cmake b/config.h.cmake
index e8a4b9fd4..037a695fb 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -2,11 +2,17 @@
#define CONFIG_H_
#cmakedefine CPPUTEST_MEM_LEAK_DETECTION_DISABLED
-#cmakedefine CPPUTEST_USE_LONG_LONG
+#cmakedefine01 CPPUTEST_USE_LONG_LONG
+#cmakedefine CPPUTEST_HAVE_STRDUP
+
+#cmakedefine CPPUTEST_HAVE_FORK
+#cmakedefine CPPUTEST_HAVE_WAITPID
+#cmakedefine CPPUTEST_HAVE_KILL
+#cmakedefine CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+
+#cmakedefine CPPUTEST_HAVE_GETTIMEOFDAY
#cmakedefine CPPUTEST_STD_C_LIB_DISABLED
#cmakedefine CPPUTEST_STD_CPP_LIB_DISABLED
-#cmakedefine INCLUDE_GTEST_TESTS
-
#endif
diff --git a/configure.ac b/configure.ac
index a6cd8328e..3120f9571 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,7 +62,7 @@ AC_TYPE_LONG_LONG_INT
# Checks for library functions.
AC_FUNC_FORK
-AC_CHECK_FUNCS([gettimeofday memset strstr strdup pthread_mutex_lock])
+AC_CHECK_FUNCS([waitpid gettimeofday memset strstr strdup pthread_mutex_lock kill])
AC_CHECK_PROG([CPPUTEST_HAS_GCC], [gcc], [yes], [no])
AC_CHECK_PROG([CPPUTEST_HAS_CLANG], [clang], [yes], [no])
@@ -76,7 +76,7 @@ saved_cxxflags="$CXXFLAGS"
saved_ldflags="$LDFLAGS"
if test "x$USE_MAINTAINER_MODE" = "xyes"; then
-# FLag -Werror.
+# Flag -Werror.
CFLAGS=-Werror
AC_MSG_CHECKING([whether CC and CXX supports -Werror])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS_STRICT="${CPPUTEST_CWARNINGFLAGS} -Werror"; CPPUTEST_CXXWARNINGFLAGS_STRICT="${CPPUTEST_CXXWARNINGFLAGS} -Werror" ], [AC_MSG_RESULT([no])])
@@ -87,31 +87,31 @@ AC_LANG_PUSH([C++])
#####################################################################################
##### C++ checks
-# FLag -std=c++1y
+# Flag -std=c++1y
CXXFLAGS="-Werror -std=c++1y"
AC_MSG_CHECKING([whether CXX supports -std=c++1y])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP14FLAG="-std=c++1y" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag std=c++14
+# Flag std=c++14
CXXFLAGS="-Werror -std=c++14"
AC_MSG_CHECKING([whether CXX supports -std=c++14])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP14FLAG="-std=c++14" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag std=c++17
+# Flag std=c++17
CXXFLAGS="-Werror -std=c++17"
AC_MSG_CHECKING([whether CXX supports -std=c++17])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP17FLAG="-std=c++17" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag std=c++20
+# Flag std=c++20
CXXFLAGS="-Werror -std=c++2a"
AC_MSG_CHECKING([whether CXX supports -std=c++2a])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP20FLAG="-std=c++2a" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag std=c++20
+# Flag std=c++20
CXXFLAGS="-Werror -std=c++20"
AC_MSG_CHECKING([whether CXX supports -std=c++20])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP20FLAG="-std=c++20" ], [AC_MSG_RESULT([no])])
@@ -122,13 +122,13 @@ CXXFLAGS="$saved_cxxflags"
### Checking for C++ version compiler flags
-# FLag -std=c++98
+# Flag -std=c++98
CXXFLAGS="-Werror -std=c++98"
AC_MSG_CHECKING([whether CXX supports -std=c++98])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP98FLAG="-std=c++98" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag -std=c++0x
+# Flag -std=c++0x
CXXFLAGS="-Werror -std=c++0x"
AC_MSG_CHECKING([whether CXX supports -std=c++0x])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP11FLAG="-std=c++0x" ], [AC_MSG_RESULT([no])])
@@ -164,13 +164,13 @@ CXXFLAGS="$saved_cxxflags"
AC_LANG_POP
-# FLag -Wno-c++11-long-long. This must be on if it is available as otherwise long long is supported but causes a warning.
+# Flag -Wno-c++11-long-long. This must be on if it is available as otherwise long long is supported but causes a warning.
CFLAGS="-Werror -Wno-c++11-long-long"
AC_MSG_CHECKING([whether CC and CXX supports -Wno-c++11-long-long])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-c++11-long-long" CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-c++11-long-long" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wno-long-long must be on for C.
+# Flag -Wno-long-long must be on for C.
CFLAGS="-Werror -Wno-long-long"
AC_MSG_CHECKING([whether CC and CXX supports -Wno-long-long])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-long-long" CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-long-long"], [AC_MSG_RESULT([no])])
@@ -178,63 +178,68 @@ CFLAGS="$saved_cflags"
#####################################################################################
-##### More of these warnings
-# FLag -Weverything.
-CFLAGS="-Werror -Weverything -Wno-unused-macros"
-AC_MSG_CHECKING([whether CC and CXX supports -Weverything])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Weverything"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Weverything" ], [AC_MSG_RESULT([no])])
-CFLAGS="$saved_cflags"
-
-# FLag -Wall.
+# Flag -Wall.
CFLAGS="-Werror -Wall"
AC_MSG_CHECKING([whether CC and CXX supports -Wall])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wall"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wall" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wextra.
+# Flag -Wextra.
CFLAGS="-Werror -Wextra"
AC_MSG_CHECKING([whether CC and CXX supports -Wextra])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wextra"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wextra" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wshadow.
+# Flag -Wshadow.
CFLAGS="-Werror -Wshadow"
AC_MSG_CHECKING([whether CC and CXX supports -Wshadow])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wshadow"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wshadow" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wswitch-default
+# Flag -Wswitch-default
CFLAGS="-Werror -Wswitch-default"
AC_MSG_CHECKING([whether CC and CXX supports -Wswitch-default])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wswitch-default"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wswitch-default" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wswitch-enum
+# Flag -Wswitch-enum
CFLAGS="-Werror -Wswitch-enum"
AC_MSG_CHECKING([whether CC and CXX supports -Wswitch-enum])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wswitch-enum"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wswitch-enum" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wconversion
+# Flag -Wconversion
CFLAGS="-Werror -Wconversion"
AC_MSG_CHECKING([whether CC and CXX supports -Wconversion])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wconversion"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wconversion" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -pedantic
+# Flag -pedantic
CFLAGS="-Werror -pedantic"
AC_MSG_CHECKING([whether CC and CXX supports -pedantic])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -pedantic"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -pedantic" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wsign-conversion
+# Flag -Wsign-conversion
CFLAGS="-Werror -Wsign-conversion"
AC_MSG_CHECKING([whether CC supports -Wsign-conversion])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wsign-conversion"], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
+# Flag -Wreserved-id-macro
+CFLAGS="-Werror -Wreserved-id-macro"
+AC_MSG_CHECKING([whether CC support -Wreserved-id-macro])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wreserved-id-macro"], [AC_MSG_RESULT([no])])
+CFLAGS="$saved_cflags"
+
+# Flag -Wreserved-identifier
+CFLAGS="-Werror -Wreserved-identifier"
+AC_MSG_CHECKING([whether CC supports -Wreserved-identifier])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wreserved-identifier"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wreserved-identifier" ], [AC_MSG_RESULT([no])])
+CFLAGS="$saved_cflags"
+
##### C++ Warnings
-# FLag -Wsign-conversion (for CXX)
+# Flag -Wsign-conversion (for CXX)
AC_LANG_PUSH([C++])
CXXFLAGS="-Werror -Wsign-conversion"
@@ -242,7 +247,7 @@ AC_MSG_CHECKING([whether CXX supports -Wsign-conversion])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wsign-conversion"], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag -Woverloaded-virtual
+# Flag -Woverloaded-virtual
CXXFLAGS="-Werror -Woverloaded-virtual"
AC_MSG_CHECKING([whether CXX supports -Woverloaded-virtual])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Woverloaded-virtual" ], [AC_MSG_RESULT([no])])
@@ -250,7 +255,7 @@ CXXFLAGS="$saved_cxxflags"
AC_LANG_POP
-# FLag -Wstrict-prototypes
+# Flag -Wstrict-prototypes
CFLAGS="-Werror -Wstrict-prototypes"
AC_MSG_CHECKING([whether CC supports -Wstrict-prototypes])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wstrict-prototypes" ], [AC_MSG_RESULT([no])])
@@ -261,61 +266,58 @@ CFLAGS="$saved_cflags"
##### Less of these warnings
#
# Disable some warnings as CppUTest has this and can't be prevented at the moment.
-# FLag -Wno-disabled-macro-expansion.
+# Flag -Wno-disabled-macro-expansion.
CFLAGS="-Werror -Wno-disabled-macro-expansion"
AC_MSG_CHECKING([whether CC and CXX supports -Wno-disabled-macro-expansion])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-disabled-macro-expansion"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-disabled-macro-expansion" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wno-padded.
+# Flag -Wno-padded.
CFLAGS="-Werror -Wno-padded"
AC_MSG_CHECKING([whether CC and CXX supports -Wno-padded])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-padded"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-padded" ], [AC_MSG_RESULT([no])])
CFLAGS="$saved_cflags"
-# FLag -Wno-reserved-id-macro.
-CFLAGS="-Werror -Wno-reserved-id-macro"
-AC_MSG_CHECKING([whether CC and CXX supports -Wno-reserved-id-macro])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-reserved-id-macro"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-reserved-id-macro" ], [AC_MSG_RESULT([no])])
-CFLAGS="$saved_cflags"
-
-# FLag -Wno-keyword-macro.
-CFLAGS="-Werror -Wno-keyword-macro"
-AC_MSG_CHECKING([whether CC and CXX supports -Wno-keyword-macro])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} -Wno-keyword-macro"; CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-keyword-macro" ], [AC_MSG_RESULT([no])])
-CFLAGS="$saved_cflags"
-
AC_LANG_PUSH([C++])
-# FLag -Wno-global-constructors.
+# Flag -Wno-global-constructors.
CXXFLAGS="-Werror -Wno-global-constructors"
AC_MSG_CHECKING([whether CXX supports -Wno-global-constructors])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-global-constructors" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag -Wno-exit-time-destructors.
+# Flag -Wno-exit-time-destructors.
CXXFLAGS="-Werror -Wno-exit-time-destructors"
AC_MSG_CHECKING([whether CXX supports -Wno-exit-time-destructors])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-exit-time-destructors" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag -Wno-weak-vtables.
+# Flag -Wno-weak-vtables.
CXXFLAGS="-Werror -Wno-weak-vtables"
AC_MSG_CHECKING([whether CXX supports -Wno-weak-vtables])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-weak-vtables" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
-# FLag -Wno-old-style-cast.
+# Flag -Wno-old-style-cast.
CXXFLAGS="-Werror -Wno-old-style-cast"
AC_MSG_CHECKING([whether CXX supports -Wno-old-style-cast])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-old-style-cast" ], [AC_MSG_RESULT([no])])
CXXFLAGS="$saved_cxxflags"
+if test "x${memory_leak_detection}" = xyes; then
+ # GCC's default optimization breaks leak detection:
+ # https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-fassume-sane-operators-new-delete
+ CXXFLAGS="-Werror -fno-assume-sane-operators-new-delete"
+ AC_MSG_CHECKING([whether CXX supports -fno-assume-sane-operators-new-delete])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -fno-assume-sane-operators-new-delete" ], [AC_MSG_RESULT([no])])
+ CXXFLAGS="$saved_cxxflags"
+fi
+
AC_LANG_POP
#####################################################
######## End warning section
-# FLag --coverage
+# Flag --coverage
AC_LANG_PUSH([C++])
CXXFLAGS="-Werror --coverage"
AC_MSG_CHECKING([whether CXX and the linker supports --coverage (broken in clang 3.3)])
@@ -341,7 +343,7 @@ AC_MSG_CHECKING([whether CXX supports operator new with exception handling speci
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include \nvoid* operator new(size_t size) throw(std::bad_alloc);;])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); UT_NEW_CANT_HAVE_EXCEPTION_SPECIFIER="yes"])
CXXFLAGS="$saved_cxxflags"
-# FLag -Wno-missing-exception-spec
+# Flag -Wno-missing-exception-spec
CXXFLAGS="-Werror -Wno-missing-exception-spec"
AC_MSG_CHECKING([whether CXX supports -Wno-missing-exception-spec])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXX_NO_INC_WARNINGFLAGS="${CPPUTEST_CXX_NO_INC_WARNINGFLAGS} -Wno-missing-exception-spec" ], [AC_MSG_RESULT([no])])
diff --git a/cpputest_build/.gitignore b/cpputest_build/.gitignore
deleted file mode 100644
index d6b7ef32c..000000000
--- a/cpputest_build/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*
-!.gitignore
diff --git a/examples/AllTests/AllTests.cpp b/examples/AllTests/AllTests.cpp
index 5ff9de3b1..7d17d6f3d 100644
--- a/examples/AllTests/AllTests.cpp
+++ b/examples/AllTests/AllTests.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -34,12 +34,12 @@
class MyDummyComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void* object1, const void* object2)
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return object1 == object2;
}
- virtual SimpleString valueToString(const void* object)
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
return StringFrom(object);
}
diff --git a/examples/AllTests/AllTests.h b/examples/AllTests/AllTests.h
index aebcc310d..9902c6f17 100644
--- a/examples/AllTests/AllTests.h
+++ b/examples/AllTests/AllTests.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-IMPORT_TEST_GROUP( Printer);
-IMPORT_TEST_GROUP( CircularBuffer);
-IMPORT_TEST_GROUP( HelloWorld);
-IMPORT_TEST_GROUP( EventDispatcher);
-IMPORT_TEST_GROUP( MockDocumentation);
+IMPORT_TEST_GROUP(Printer);
+IMPORT_TEST_GROUP(CircularBuffer);
+IMPORT_TEST_GROUP(HelloWorld);
+IMPORT_TEST_GROUP(EventDispatcher);
+IMPORT_TEST_GROUP(MockDocumentation);
diff --git a/examples/AllTests/AllTests.vcproj b/examples/AllTests/AllTests.vcproj
index 4d1be1530..ad9ab2b72 100644
--- a/examples/AllTests/AllTests.vcproj
+++ b/examples/AllTests/AllTests.vcproj
@@ -45,7 +45,7 @@
:/wd4723>
+)
+
+target_link_libraries(ExampleTests
+ PRIVATE
+ ApplicationLib
+ CppUTest::CppUTestExt
+)
+
+include(CppUTest)
+cpputest_discover_tests(ExampleTests)
diff --git a/examples/AllTests/CircularBufferTest.cpp b/examples/AllTests/CircularBufferTest.cpp
index 7554385ce..4602e5ab9 100644
--- a/examples/AllTests/CircularBufferTest.cpp
+++ b/examples/AllTests/CircularBufferTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,27 +30,28 @@
#include "CircularBuffer.h"
TEST_GROUP(CircularBuffer)
-{ CircularBuffer* buffer;
-
-void setup()
-{
- buffer = new CircularBuffer();
-}
-void teardown()
-{
- delete buffer;
-}
-
-void fillTheQueue(int seed, int howMany)
{
- for (int i = 0; i < howMany; i++)
- buffer->Put(seed + i);
-}
-void removeFromQueue(int howMany)
-{
- for (int i = 0; i < howMany; i++)
- buffer->Get();
-}
+ CircularBuffer* buffer;
+
+ void setup() CPPUTEST_OVERRIDE
+ {
+ buffer = new CircularBuffer();
+ }
+ void teardown() CPPUTEST_OVERRIDE
+ {
+ delete buffer;
+ }
+
+ void fillTheQueue(int seed, int howMany)
+ {
+ for (int i = 0; i < howMany; i++)
+ buffer->Put(seed + i);
+ }
+ void removeFromQueue(int howMany)
+ {
+ for (int i = 0; i < howMany; i++)
+ buffer->Get();
+ }
};
TEST(CircularBuffer, EmptyAfterCreation)
@@ -134,15 +135,14 @@ TEST(CircularBuffer, PutToFull)
buffer->Put(9999);
for (int i = 0; i < buffer->Capacity() - 1; i++)
- LONGS_EQUAL(i+900+1, buffer->Get());
+ LONGS_EQUAL(i + 900 + 1, buffer->Get());
LONGS_EQUAL(9999, buffer->Get());
CHECK(buffer->IsEmpty());
}
-//Sometime people ask what tests the tests.
-//Do you know the answer
-
+// Sometime people ask what tests the tests.
+// Do you know the answer
TEST(CircularBuffer, GetFromEmpty)
{
@@ -162,8 +162,7 @@ TEST(CircularBuffer, PrintEmpty)
Printer* p = &mock;
buffer->Print(p);
- STRCMP_EQUAL("Circular buffer content:\n<>\n",
- mock.getOutput().c_str());
+ STRCMP_EQUAL("Circular buffer content:\n<>\n", mock.getOutput().c_str());
}
TEST(CircularBuffer, PrintAfterOnePut)
@@ -172,8 +171,7 @@ TEST(CircularBuffer, PrintAfterOnePut)
buffer->Put(1);
buffer->Print(&mock);
- STRCMP_EQUAL("Circular buffer content:\n<1>\n",
- mock.getOutput().c_str());
+ STRCMP_EQUAL("Circular buffer content:\n<1>\n", mock.getOutput().c_str());
}
TEST(CircularBuffer, PrintNotYetWrappedOrFull)
@@ -184,8 +182,7 @@ TEST(CircularBuffer, PrintNotYetWrappedOrFull)
buffer->Put(2);
buffer->Put(3);
buffer->Print(&mock);
- STRCMP_EQUAL("Circular buffer content:\n<1, 2, 3>\n",
- mock.getOutput().c_str());
+ STRCMP_EQUAL("Circular buffer content:\n<1, 2, 3>\n", mock.getOutput().c_str());
}
TEST(CircularBuffer, PrintNotYetWrappedAndIsFull)
@@ -195,7 +192,8 @@ TEST(CircularBuffer, PrintNotYetWrappedAndIsFull)
fillTheQueue(200, buffer->Capacity());
buffer->Print(&mock);
- const char* expected = "Circular buffer content:\n"
+ const char* expected =
+ "Circular buffer content:\n"
"<200, 201, 202, 203, 204>\n";
STRCMP_EQUAL(expected, mock.getOutput().c_str());
@@ -210,7 +208,8 @@ TEST(CircularBuffer, PrintWrappedAndIsFullOldestToNewest)
buffer->Put(999);
buffer->Print(&mock);
- const char* expected = "Circular buffer content:\n"
+ const char* expected =
+ "Circular buffer content:\n"
"<201, 202, 203, 204, 999>\n";
STRCMP_EQUAL(expected, mock.getOutput().c_str());
@@ -224,7 +223,8 @@ TEST(CircularBuffer, PrintWrappedAndFullOverwriteOldest)
buffer->Put(9999);
buffer->Print(&mock);
- const char* expected = "Circular buffer content:\n"
+ const char* expected =
+ "Circular buffer content:\n"
"<201, 202, 203, 204, 9999>\n";
STRCMP_EQUAL(expected, mock.getOutput().c_str());
@@ -240,7 +240,8 @@ TEST(CircularBuffer, PrintBoundary)
fillTheQueue(300, buffer->Capacity() - 1);
buffer->Print(&mock);
- const char* expected = "Circular buffer content:\n"
+ const char* expected =
+ "Circular buffer content:\n"
"<888, 300, 301, 302, 303>\n";
STRCMP_EQUAL(expected, mock.getOutput().c_str());
@@ -253,7 +254,8 @@ TEST(CircularBuffer, FillEmptyThenPrint)
fillTheQueue(200, buffer->Capacity());
removeFromQueue(buffer->Capacity());
buffer->Print(&mock);
- const char* expected = "Circular buffer content:\n"
+ const char* expected =
+ "Circular buffer content:\n"
"<>\n";
STRCMP_EQUAL(expected, mock.getOutput().c_str());
diff --git a/examples/AllTests/EventDispatcherTest.cpp b/examples/AllTests/EventDispatcherTest.cpp
index 4515ff559..7ea4b52a4 100644
--- a/examples/AllTests/EventDispatcherTest.cpp
+++ b/examples/AllTests/EventDispatcherTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,18 +25,32 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#if CPPUTEST_USE_NEW_MACROS
+ #undef realloc
+ #undef new
+#endif
+
+#include "EventDispatcher.h"
+
+#if CPPUTEST_USE_NEW_MACROS
+ #include "CppUTest/MemoryLeakDetectorNewMacros.h"
+#endif
+
#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"
-#include "EventDispatcher.h"
class ObserverMock : public EventObserver
{
public:
- virtual void notify(const Event& event, int timeOutInSeconds)
+ virtual void notify(const Event& event, int timeOutInSeconds) CPPUTEST_OVERRIDE
{
- mock().actualCall("notify").onObject(this).withParameterOfType("Event", "event", (void*) &event).withParameter("timeOutInSeconds", timeOutInSeconds);
+ mock()
+ .actualCall("notify")
+ .onObject(this)
+ .withParameterOfType("Event", "event", (void*)&event)
+ .withParameter("timeOutInSeconds", timeOutInSeconds);
}
- virtual void notifyRegistration(EventObserver* newObserver)
+ virtual void notifyRegistration(EventObserver* newObserver) CPPUTEST_OVERRIDE
{
mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver);
}
@@ -45,17 +59,16 @@ class ObserverMock : public EventObserver
class EventComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void* object1, const void* object2)
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return ((const Event*)object1)->type == ((const Event*)object2)->type;
}
- virtual SimpleString valueToString(const void* object)
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
return StringFrom(((const Event*)object)->type);
}
};
-
TEST_GROUP(EventDispatcher)
{
Event event;
@@ -64,19 +77,18 @@ TEST_GROUP(EventDispatcher)
ObserverMock observer2;
EventComparator eventComparator;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
dispatcher = new EventDispatcher;
mock().installComparator("Event", eventComparator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete dispatcher;
mock().removeAllComparatorsAndCopiers();
}
};
-
TEST(EventDispatcher, EventWithoutRegistrationsResultsIntoNoCalls)
{
dispatcher->dispatchEvent(event, 10);
@@ -84,7 +96,11 @@ TEST(EventDispatcher, EventWithoutRegistrationsResultsIntoNoCalls)
TEST(EventDispatcher, EventWithRegistrationForEventResultsIntoCallback)
{
- mock().expectOneCall("notify").onObject(&observer).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
+ mock()
+ .expectOneCall("notify")
+ .onObject(&observer)
+ .withParameterOfType("Event", "event", &event)
+ .withParameter("timeOutInSeconds", 10);
event.type = IMPORTANT_EVENT;
dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
@@ -100,8 +116,16 @@ TEST(EventDispatcher, DifferentEventWithRegistrationDoesNotResultIntoCallback)
TEST(EventDispatcher, RegisterTwoObserversResultIntoTwoCallsAndARegistrationNotification)
{
- mock().expectOneCall("notify").onObject(&observer).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
- mock().expectOneCall("notify").onObject(&observer2).withParameterOfType("Event", "event", &event).withParameter("timeOutInSeconds", 10);
+ mock()
+ .expectOneCall("notify")
+ .onObject(&observer)
+ .withParameterOfType("Event", "event", &event)
+ .withParameter("timeOutInSeconds", 10);
+ mock()
+ .expectOneCall("notify")
+ .onObject(&observer2)
+ .withParameterOfType("Event", "event", &event)
+ .withParameter("timeOutInSeconds", 10);
mock().expectOneCall("notifyRegistration").onObject(&observer).withParameter("newObserver", &observer2);
event.type = IMPORTANT_EVENT;
diff --git a/examples/AllTests/FEDemoTest.cpp b/examples/AllTests/FEDemoTest.cpp
index 8737ca9a4..c2f6c17f2 100644
--- a/examples/AllTests/FEDemoTest.cpp
+++ b/examples/AllTests/FEDemoTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -29,8 +29,8 @@
#include "CppUTest/TestHarness.h"
#include "CppUTest/TestRegistry.h"
-#ifdef CPPUTEST_HAVE_FENV
-#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
+#if CPPUTEST_HAVE_FENV
+ #include "CppUTestExt/IEEE754ExceptionsPlugin.h"
/*
* To see a demonstration of tests failing as a result of IEEE754ExceptionsPlugin
@@ -42,43 +42,43 @@ extern "C" {
#include
}
-#include
-
-static volatile float f;
+ #include
TEST_GROUP(FE_Demo)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
IEEE754ExceptionsPlugin::disableInexact();
}
};
-IGNORE_TEST(FE_Demo, should_fail_when__FE_DIVBYZERO__is_set)
+IGNORE_TEST(FE_Demo, should_fail_when_FE_DIVBYZERO_is_set)
{
- f = 1.0f;
+ float f = 1.0f;
CHECK((f /= 0.0f) >= std::numeric_limits::infinity());
}
-IGNORE_TEST(FE_Demo, should_fail_when__FE_UNDERFLOW__is_set)
+IGNORE_TEST(FE_Demo, should_fail_when_FE_UNDERFLOW_is_set)
{
- f = 0.01f;
- while (f > 0.0f) f *= f;
+ volatile float f = 0.01f;
+ while (f > 0.0f)
+ f = f * f;
CHECK(f == 0.0f);
}
-IGNORE_TEST(FE_Demo, should_fail_when__FE_OVERFLOW__is_set)
+IGNORE_TEST(FE_Demo, should_fail_when_FE_OVERFLOW_is_set)
{
- f = 1000.0f;
- while (f < std::numeric_limits::infinity()) f *= f;
+ volatile float f = 1000.0f;
+ while (f < std::numeric_limits::infinity())
+ f = f * f;
CHECK(f >= std::numeric_limits::infinity());
}
-IGNORE_TEST(FE_Demo, should_fail_when__FE_INEXACT____is_set)
+IGNORE_TEST(FE_Demo, should_fail_when_FE_INEXACT_is_set)
{
IEEE754ExceptionsPlugin::enableInexact();
- f = 10.0f;
- DOUBLES_EQUAL((double) (f / 3.0f), (double) 3.333f, (double) 0.001f);
+ float f = 10.0f;
+ DOUBLES_EQUAL((double)(f / 3.0f), (double)3.333f, (double)0.001f);
}
TEST(FE_Demo, should_succeed_when_no_flags_are_set)
diff --git a/examples/AllTests/HelloTest.cpp b/examples/AllTests/HelloTest.cpp
index 84407906d..7bc644e0e 100644
--- a/examples/AllTests/HelloTest.cpp
+++ b/examples/AllTests/HelloTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -34,23 +34,24 @@
static SimpleString* buffer;
TEST_GROUP(HelloWorld)
-{ static int output_method(const char* output, ...)
{
- va_list arguments;
- va_start(arguments, output);
- *buffer = VStringFromFormat(output, arguments);
- va_end(arguments);
- return 1;
-}
-void setup()
-{
- buffer = new SimpleString();
- UT_PTR_SET(PrintFormated, &output_method);
-}
-void teardown()
-{
- delete buffer;
-}
+ static int output_method(const char* output, ...)
+ {
+ va_list arguments;
+ va_start(arguments, output);
+ *buffer = VStringFromFormat(output, arguments);
+ va_end(arguments);
+ return 1;
+ }
+ void setup() CPPUTEST_OVERRIDE
+ {
+ buffer = new SimpleString();
+ UT_PTR_SET(PrintFormated, &output_method);
+ }
+ void teardown() CPPUTEST_OVERRIDE
+ {
+ delete buffer;
+ }
};
TEST(HelloWorld, PrintOk)
diff --git a/examples/AllTests/MockDocumentationTest.cpp b/examples/AllTests/MockDocumentationTest.cpp
index e2b79d726..0bd578ea8 100644
--- a/examples/AllTests/MockDocumentationTest.cpp
+++ b/examples/AllTests/MockDocumentationTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,7 +25,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"
#include "CppUTestExt/MockSupport_c.h"
@@ -36,15 +35,14 @@ TEST_GROUP(FirstTestGroup)
TEST(FirstTestGroup, FirsTest)
{
-// FAIL("Fail me!");
+ // FAIL("Fail me!");
}
TEST(FirstTestGroup, SecondTest)
{
-// STRCMP_EQUAL("hello", "world");
+ // STRCMP_EQUAL("hello", "world");
}
-
TEST_GROUP(MockDocumentation)
{
};
@@ -64,14 +62,14 @@ TEST(MockDocumentation, SimpleScenario)
class ClassFromProductionCode
{
public:
- virtual void importantFunction(){}
+ virtual void importantFunction() {}
virtual ~ClassFromProductionCode() {}
};
class ClassFromProductionCodeMock : public ClassFromProductionCode
{
public:
- virtual void importantFunction()
+ virtual void importantFunction() CPPUTEST_OVERRIDE
{
mock().actualCall("importantFunction").onObject(this);
}
@@ -90,13 +88,13 @@ TEST(MockDocumentation, SimpleScenarioObject)
static void parameters_function(int p1, const char* p2)
{
- void* object = (void*) 1;
+ void* object = (void*)1;
mock().actualCall("function").onObject(object).withParameter("p1", p1).withParameter("p2", p2);
}
TEST(MockDocumentation, parameters)
{
- void* object = (void*) 1;
+ void* object = (void*)1;
mock().expectOneCall("function").onObject(object).withParameter("p1", 2).withParameter("p2", "hah");
parameters_function(2, "hah");
}
@@ -104,11 +102,11 @@ TEST(MockDocumentation, parameters)
class MyTypeComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void* object1, const void* object2)
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return object1 == object2;
}
- virtual SimpleString valueToString(const void* object)
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
return StringFrom(object);
}
@@ -116,7 +114,7 @@ class MyTypeComparator : public MockNamedValueComparator
TEST(MockDocumentation, ObjectParameters)
{
- void* object = (void*) 1;
+ void* object = (void*)1;
MyTypeComparator comparator;
mock().installComparator("myType", comparator);
mock().expectOneCall("function").withParameterOfType("myType", "parameterName", object);
@@ -127,8 +125,8 @@ TEST(MockDocumentation, ObjectParameters)
TEST(MockDocumentation, returnValue)
{
mock().expectOneCall("function").andReturnValue(10);
- int value = mock().actualCall("function").returnValue().getIntValue();
- value = mock().returnValue().getIntValue();
+ mock().actualCall("function").returnValue().getIntValue();
+ int value = mock().returnValue().getIntValue();
LONGS_EQUAL(10, value);
}
@@ -138,22 +136,20 @@ TEST(MockDocumentation, setData)
mock().setData("importantValue", 10);
mock().setDataObject("importantObject", "ClassFromProductionCode", &object);
- ClassFromProductionCode * pobject;
+ ClassFromProductionCode* pobject;
int value = mock().getData("importantValue").getIntValue();
- pobject = (ClassFromProductionCode*) mock().getData("importantObject").getObjectPointer();
+ pobject = (ClassFromProductionCode*)mock().getData("importantObject").getObjectPointer();
LONGS_EQUAL(10, value);
POINTERS_EQUAL(pobject, &object);
}
-static void doSomethingThatWouldOtherwiseBlowUpTheMockingFramework()
-{
-}
+static void doSomethingThatWouldOtherwiseBlowUpTheMockingFramework() {}
TEST(MockDocumentation, otherMockSupport)
{
mock().crashOnFailure();
-// mock().actualCall("unex");
+ // mock().actualCall("unex");
mock().expectOneCall("foo");
mock().ignoreOtherCalls();
@@ -163,7 +159,6 @@ TEST(MockDocumentation, otherMockSupport)
mock().enable();
mock().clear();
-
}
TEST(MockDocumentation, scope)
@@ -174,7 +169,7 @@ TEST(MockDocumentation, scope)
mock("xmlparser").actualCall("open");
}
-static int equalMethod(const void* object1, const void* object2)
+static int equalMethod(const void* object1, const void* object2)
{
return object1 == object2;
}
@@ -186,13 +181,12 @@ static const char* toStringMethod(const void*)
TEST(MockDocumentation, CInterface)
{
- void* object = (void*) 0x1;
+ void* object = (void*)0x1;
mock_c()->expectOneCall("foo")->withIntParameters("integer", 10)->andReturnDoubleValue(1.11);
double d = mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
DOUBLES_EQUAL(1.11, d, 0.00001);
-
mock_c()->installComparator("type", equalMethod, toStringMethod);
mock_scope_c("scope")->expectOneCall("bar")->withParameterOfType("type", "name", object);
mock_scope_c("scope")->actualCall("bar")->withParameterOfType("type", "name", object);
@@ -205,12 +199,12 @@ TEST(MockDocumentation, CInterface)
TEST_GROUP(FooTestGroup)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
// Init stuff
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
// Uninit stuff
}
@@ -228,7 +222,7 @@ TEST(FooTestGroup, MoreFoo)
TEST_GROUP(BarTestGroup)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
// Init Bar
}
diff --git a/examples/AllTests/MockPrinter.h b/examples/AllTests/MockPrinter.h
index 90dd435d5..1df48962f 100644
--- a/examples/AllTests/MockPrinter.h
+++ b/examples/AllTests/MockPrinter.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -40,22 +40,18 @@
#include
#include
-class MockPrinter: public Printer
+class MockPrinter : public Printer
{
public:
- explicit MockPrinter()
- {
- }
- virtual ~MockPrinter()
- {
- }
+ explicit MockPrinter() {}
+ virtual ~MockPrinter() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- virtual void Print(const char* s)
+ virtual void Print(const char* s) CPPUTEST_OVERRIDE
{
savedOutput.append(s);
}
- virtual void Print(long int value)
+ virtual void Print(long int value) CPPUTEST_OVERRIDE
{
SimpleString buffer;
buffer = StringFromFormat("%ld", value);
@@ -68,12 +64,10 @@ class MockPrinter: public Printer
}
private:
-
std::string savedOutput;
MockPrinter(const MockPrinter&);
MockPrinter& operator=(const MockPrinter&);
-
};
-#endif // D_MockPrinter_H
+#endif // D_MockPrinter_H
diff --git a/examples/AllTests/PrinterTest.cpp b/examples/AllTests/PrinterTest.cpp
index 1f872597a..88a5d1ca3 100644
--- a/examples/AllTests/PrinterTest.cpp
+++ b/examples/AllTests/PrinterTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,18 +30,19 @@
#include "MockPrinter.h"
TEST_GROUP(Printer)
-{ Printer* printer;
-MockPrinter* mockPrinter;
-
-void setup()
-{
- mockPrinter = new MockPrinter();
- printer = mockPrinter;
-}
-void teardown()
{
- delete printer;
-}
+ Printer* printer;
+ MockPrinter* mockPrinter;
+
+ void setup() CPPUTEST_OVERRIDE
+ {
+ mockPrinter = new MockPrinter();
+ printer = mockPrinter;
+ }
+ void teardown() CPPUTEST_OVERRIDE
+ {
+ delete printer;
+ }
};
TEST(Printer, PrintConstCharStar)
@@ -65,4 +66,3 @@ TEST(Printer, StreamOperators)
const char* expected = "n=1234";
CHECK_EQUAL(expected, mockPrinter->getOutput());
}
-
diff --git a/examples/ApplicationLib/ApplicationLib.vcproj b/examples/ApplicationLib/ApplicationLib.vcproj
index bf83e4718..f7b054bbe 100644
--- a/examples/ApplicationLib/ApplicationLib.vcproj
+++ b/examples/ApplicationLib/ApplicationLib.vcproj
@@ -42,7 +42,7 @@
BE LIABLE FOR ANY
@@ -29,10 +29,9 @@
#include "Printer.h"
#include
-CircularBuffer::CircularBuffer(int _capacity) :
- index(0), outdex(0), capacity(_capacity), empty(true), full(false)
+CircularBuffer::CircularBuffer(int _capacity) : index(0), outdex(0), capacity(_capacity), empty(true), full(false)
{
- buffer = new int[(size_t) this->capacity];
+ buffer = new int[(size_t)this->capacity];
}
CircularBuffer::~CircularBuffer()
@@ -55,8 +54,10 @@ void CircularBuffer::Put(int i)
empty = false;
buffer[index] = i;
index = Next(index);
- if (full) outdex = Next(outdex);
- else if (index == outdex) full = true;
+ if (full)
+ outdex = Next(outdex);
+ else if (index == outdex)
+ full = true;
}
int CircularBuffer::Get()
@@ -67,7 +68,8 @@ int CircularBuffer::Get()
if (!empty) {
result = buffer[outdex];
outdex = Next(outdex);
- if (outdex == index) empty = true;
+ if (outdex == index)
+ empty = true;
}
return result;
}
@@ -79,7 +81,8 @@ int CircularBuffer::Capacity()
int CircularBuffer::Next(int i)
{
- if (++i >= capacity) i = 0;
+ if (++i >= capacity)
+ i = 0;
return i;
}
@@ -90,12 +93,14 @@ void CircularBuffer::Print(Printer* p)
int printIndex = outdex;
int count = index - outdex;
- if (!empty && (index <= outdex)) count = capacity - (outdex - index);
+ if (!empty && (index <= outdex))
+ count = capacity - (outdex - index);
for (int i = 0; i < count; i++) {
p->Print(buffer[printIndex]);
printIndex = Next(printIndex);
- if (i + 1 != count) p->Print(", ");
+ if (i + 1 != count)
+ p->Print(", ");
}
p->Print(">\n");
}
diff --git a/examples/ApplicationLib/CircularBuffer.h b/examples/ApplicationLib/CircularBuffer.h
index e804c29ba..e9634f10a 100644
--- a/examples/ApplicationLib/CircularBuffer.h
+++ b/examples/ApplicationLib/CircularBuffer.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -52,7 +52,6 @@ class CircularBuffer
void Print(Printer*);
private:
-
int index;
int outdex;
int* buffer;
@@ -66,7 +65,6 @@ class CircularBuffer
CircularBuffer(const CircularBuffer&);
CircularBuffer& operator=(const CircularBuffer&);
-
};
-#endif // D_CircularBuffer_H
+#endif // D_CircularBuffer_H
diff --git a/examples/ApplicationLib/EventDispatcher.cpp b/examples/ApplicationLib/EventDispatcher.cpp
index ef5ebbcba..140be3547 100644
--- a/examples/ApplicationLib/EventDispatcher.cpp
+++ b/examples/ApplicationLib/EventDispatcher.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -28,9 +28,7 @@
#include "EventDispatcher.h"
using namespace std;
-EventDispatcher::EventDispatcher()
-{
-}
+EventDispatcher::EventDispatcher() {}
void EventDispatcher::registerObserver(EventType type, EventObserver* observer)
{
@@ -42,8 +40,7 @@ void EventDispatcher::registerObserver(EventType type, EventObserver* observer)
void EventDispatcher::dispatchEvent(const Event& event, int timeoutSeconds)
{
- for (list >::iterator i = observerList_.begin(); i != observerList_.end(); i++)
- {
+ for (list >::iterator i = observerList_.begin(); i != observerList_.end(); i++) {
if (i->first == event.type)
i->second->notify(event, timeoutSeconds);
}
diff --git a/examples/ApplicationLib/EventDispatcher.h b/examples/ApplicationLib/EventDispatcher.h
index 06e2c687c..a27eb056f 100644
--- a/examples/ApplicationLib/EventDispatcher.h
+++ b/examples/ApplicationLib/EventDispatcher.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef EVENTDISPATCHER__H
-#define EVENTDISPATCHER__H
+#ifndef EVENTDISPATCHER_H
+#define EVENTDISPATCHER_H
#include
@@ -45,14 +45,15 @@ class Event
class EventObserver
{
public:
- virtual void notify(const Event& event, int timeOutInSeconds)=0;
- virtual void notifyRegistration(EventObserver* newObserver)=0;
+ virtual void notify(const Event& event, int timeOutInSeconds) = 0;
+ virtual void notifyRegistration(EventObserver* newObserver) = 0;
virtual ~EventObserver() {}
};
class EventDispatcher
{
std::list > observerList_;
+
public:
EventDispatcher();
diff --git a/examples/ApplicationLib/ExamplesNewOverrides.h b/examples/ApplicationLib/ExamplesNewOverrides.h
index ad108fc7a..86cb0219b 100644
--- a/examples/ApplicationLib/ExamplesNewOverrides.h
+++ b/examples/ApplicationLib/ExamplesNewOverrides.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/examples/ApplicationLib/Printer.cpp b/examples/ApplicationLib/Printer.cpp
index af9c9266d..893ae1a40 100644
--- a/examples/ApplicationLib/Printer.cpp
+++ b/examples/ApplicationLib/Printer.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -28,13 +28,9 @@
#include "Printer.h"
#include
-Printer::Printer()
-{
-}
+Printer::Printer() {}
-Printer::~Printer()
-{
-}
+Printer::~Printer() {}
void Printer::Print(const char* s)
{
@@ -44,7 +40,7 @@ void Printer::Print(const char* s)
void Printer::Print(long int n)
{
- printf("%ld", n);
+ printf("%ld", n);
}
Printer& operator<<(Printer& p, const char* s)
diff --git a/examples/ApplicationLib/Printer.h b/examples/ApplicationLib/Printer.h
index dcfc59ccd..51aa63313 100644
--- a/examples/ApplicationLib/Printer.h
+++ b/examples/ApplicationLib/Printer.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,13 +44,11 @@ class Printer
virtual void Print(long int);
private:
-
Printer(const Printer&);
Printer& operator=(const Printer&);
-
};
Printer& operator<<(Printer&, const char*);
Printer& operator<<(Printer&, long int);
-#endif // D_Printer_H
+#endif // D_Printer_H
diff --git a/examples/ApplicationLib/hello.c b/examples/ApplicationLib/hello.c
index 6cbe03f44..2ab67a69c 100644
--- a/examples/ApplicationLib/hello.c
+++ b/examples/ApplicationLib/hello.c
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -28,7 +28,7 @@
#include
#include "hello.h"
-void printHelloWorld()
+void printHelloWorld(void)
{
PrintFormated("Hello World!\n");
}
diff --git a/examples/ApplicationLib/hello.h b/examples/ApplicationLib/hello.h
index 5154b3cf1..83524a5c0 100644
--- a/examples/ApplicationLib/hello.h
+++ b/examples/ApplicationLib/hello.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index d4b547439..98244cee6 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,2 +1,20 @@
+cmake_minimum_required(VERSION 3.8...3.31)
+
+project(CppUTestExample)
+
+if (CMAKE_VERSION GREATER_EQUAL "3.21")
+ # PROJECT_IS_TOP_LEVEL is defined automatically
+elseif(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
+ set(PROJECT_IS_TOP_LEVEL TRUE)
+else()
+ set(PROJECT_IS_TOP_LEVEL FALSE)
+endif()
+
+if(PROJECT_IS_TOP_LEVEL)
+ find_package(CppUTest 4.0 REQUIRED)
+endif()
+
+include(CTest)
+
add_subdirectory(AllTests)
add_subdirectory(ApplicationLib)
diff --git a/include/CppUTest/CommandLineArguments.h b/include/CppUTest/CommandLineArguments.h
index afd134047..d162a5e2f 100644
--- a/include/CppUTest/CommandLineArguments.h
+++ b/include/CppUTest/CommandLineArguments.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -47,10 +47,13 @@ class CommandLineArguments
bool isColor() const;
bool isListingTestGroupNames() const;
bool isListingTestGroupAndCaseNames() const;
+ bool isListingTestLocations() const;
bool isRunIgnored() const;
size_t getRepeatCount() const;
bool isShuffling() const;
bool isReversing() const;
+ bool isCrashingOnFail() const;
+ bool isRethrowingExceptions() const;
size_t getShuffleSeed() const;
const TestFilter* getGroupFilters() const;
const TestFilter* getNameFilters() const;
@@ -79,8 +82,11 @@ class CommandLineArguments
bool runTestsAsSeperateProcess_;
bool listTestGroupNames_;
bool listTestGroupAndCaseNames_;
+ bool listTestLocations_;
bool runIgnored_;
bool reversing_;
+ bool crashOnFail_;
+ bool rethrowExceptions_;
bool shuffling_;
bool shufflingPreSeeded_;
size_t repeat_;
@@ -94,7 +100,7 @@ class CommandLineArguments
void setRepeatCount(int ac, const char *const *av, int& index);
bool setShuffle(int ac, const char *const *av, int& index);
void addGroupFilter(int ac, const char *const *av, int& index);
- bool addGroupDotNameFilter(int ac, const char *const *av, int& index);
+ bool addGroupDotNameFilter(int ac, const char *const *av, int& index, const SimpleString& parameterName, bool strict, bool exclude);
void addStrictGroupFilter(int ac, const char *const *av, int& index);
void addExcludeGroupFilter(int ac, const char *const *av, int& index);
void addExcludeStrictGroupFilter(int ac, const char *const *av, int& index);
diff --git a/include/CppUTest/CommandLineTestRunner.h b/include/CppUTest/CommandLineTestRunner.h
index 194cd4cb2..91c52d177 100644
--- a/include/CppUTest/CommandLineTestRunner.h
+++ b/include/CppUTest/CommandLineTestRunner.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/CppUTestConfig.h b/include/CppUTest/CppUTestConfig.h
index 7c7371fe3..435ea74d2 100644
--- a/include/CppUTest/CppUTestConfig.h
+++ b/include/CppUTest/CppUTestConfig.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -29,7 +29,17 @@
#define CPPUTESTCONFIG_H_
#ifndef CPPUTEST_USE_OWN_CONFIGURATION
-#include "CppUTestGeneratedConfig.h"
+ // The autotools generated header uses reserved names in macros
+ #ifdef __clang__
+ #pragma clang diagnostic push
+ #if __clang_major__ >= 13
+ #pragma clang diagnostic ignored "-Wreserved-identifier"
+ #endif
+ #endif
+ #include "CppUTestGeneratedConfig.h"
+ #ifdef __clang__
+ #pragma clang diagnostic pop
+ #endif
#endif
/*
@@ -40,13 +50,6 @@
*
*/
-#ifdef __clang__
- #pragma clang diagnostic push
- #if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ >= 4
- #pragma clang diagnostic ignored "-Wreserved-id-macro"
- #endif
-#endif
-
/*
* Lib C dependencies that are currently still left:
*
@@ -94,56 +97,35 @@
/* Should be the only #include here. Standard C library wrappers */
#include "StandardCLibrary.h"
-/* Create a _no_return_ macro, which is used to flag a function as not returning.
+/* Create a CPPUTEST_NORETURN macro, which is used to flag a function as not returning.
* Used for functions that always throws for instance.
*
* This is needed for compiling with clang, without breaking other compilers.
*/
#ifndef __has_attribute
- #define __has_attribute(x) 0
-#endif
-
-#if __has_attribute(noreturn)
- #define _no_return_ __attribute__((noreturn))
+ #define CPPUTEST_HAS_ATTRIBUTE(x) 0
#else
- #define _no_return_
+ #define CPPUTEST_HAS_ATTRIBUTE(x) __has_attribute(x)
#endif
-#if __has_attribute(format)
- #define _check_format_(type, format_parameter, other_parameters) __attribute__ ((format (type, format_parameter, other_parameters)))
+#if defined (__cplusplus) && __cplusplus >= 201103L
+ #define CPPUTEST_NORETURN [[noreturn]]
+#elif CPPUTEST_HAS_ATTRIBUTE(noreturn)
+ #define CPPUTEST_NORETURN __attribute__((noreturn))
#else
- #define _check_format_(type, format_parameter, other_parameters) /* type, format_parameter, other_parameters */
+ #define CPPUTEST_NORETURN
#endif
-/*
- * When we don't link Standard C++, then we won't throw exceptions as we assume the compiler might not support that!
- */
-
-#if CPPUTEST_USE_STD_CPP_LIB
- #if defined(__cplusplus) && __cplusplus >= 201103L
- #define UT_THROW(exception)
- #define UT_NOTHROW noexcept
- #else
- #define UT_THROW(exception) throw (exception)
- #define UT_NOTHROW throw()
- #endif
+#if defined(__MINGW32__)
+#define CPPUTEST_CHECK_FORMAT_TYPE __MINGW_PRINTF_FORMAT
#else
- #define UT_THROW(exception)
- #ifdef __clang__
- #define UT_NOTHROW throw()
- #else
- #define UT_NOTHROW
- #endif
+#define CPPUTEST_CHECK_FORMAT_TYPE printf
#endif
-/*
- * Visual C++ doesn't define __cplusplus as C++11 yet (201103), however it doesn't want the throw(exception) either, but
- * it does want throw().
- */
-
-#ifdef _MSC_VER
- #undef UT_THROW
- #define UT_THROW(exception)
+#if CPPUTEST_HAS_ATTRIBUTE(format)
+ #define CPPUTEST_CHECK_FORMAT(type, format_parameter, other_parameters) __attribute__ ((format (type, format_parameter, other_parameters)))
+#else
+ #define CPPUTEST_CHECK_FORMAT(type, format_parameter, other_parameters) /* type, format_parameter, other_parameters */
#endif
#if defined(__cplusplus) && __cplusplus >= 201103L
@@ -152,69 +134,124 @@
#define DEFAULT_COPY_CONSTRUCTOR(classname)
#endif
-/*
- * g++-4.7 with stdc++11 enabled On MacOSX! will have a different exception specifier for operator new (and thank you!)
- * I assume they'll fix this in the future, but for now, we'll change that here.
- * (This should perhaps also be done in the configure.ac)
- */
-
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
-#ifdef __APPLE__
-#ifdef _GLIBCXX_THROW
-#undef UT_THROW
-#define UT_THROW(exception) _GLIBCXX_THROW(exception)
-#endif
-#endif
-#endif
-
/*
* Address sanitizer is a good thing... and it causes some conflicts with the CppUTest tests
* To check whether it is on or off, we create a CppUTest define here.
*/
#if defined(__has_feature)
-#if __has_feature(address_sanitizer)
-#define CPPUTEST_SANITIZE_ADDRESS 1
-#endif
-#endif
-
-#ifdef __SANITIZE_ADDRESS__
-#define CPPUTEST_SANITIZE_ADDRESS 1
+ #if __has_feature(address_sanitizer)
+ #define CPPUTEST_SANITIZE_ADDRESS 1
+ #endif
+#elif defined(__SANITIZE_ADDRESS__)
+ #define CPPUTEST_SANITIZE_ADDRESS 1
#endif
#ifndef CPPUTEST_SANITIZE_ADDRESS
-#define CPPUTEST_SANITIZE_ADDRESS 0
+ #define CPPUTEST_SANITIZE_ADDRESS 0
#endif
#if CPPUTEST_SANITIZE_ADDRESS
-#define CPPUTEST_SANITIZE_ADDRESS 1
-#define CPPUTEST_DO_NOT_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
- #if defined(__linux__) && defined(__clang__)
- #if CPPUTEST_USE_MEM_LEAK_DETECTION
- #warning Compiling with Address Sanitizer with clang on linux will cause duplicate symbols for operator new. Turning off memory leak detection. Compile with -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED to get rid of this warning.
- #undef CPPUTEST_USE_MEM_LEAK_DETECTION
- #define CPPUTEST_USE_MEM_LEAK_DETECTION 0
- #endif
+ #if defined(__linux__) && defined(__clang__) && CPPUTEST_USE_STD_CPP_LIB && CPPUTEST_USE_MEM_LEAK_DETECTION
+ #warning Compiling with Address Sanitizer with clang on linux may cause duplicate symbols for operator new. Turning off memory leak detection. Compile with -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED to get rid of this warning.
#endif
+ #define CPPUTEST_DO_NOT_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
-#define CPPUTEST_SANITIZER_ADDRESS 0
-#define CPPUTEST_DO_NOT_SANITIZE_ADDRESS
+ #define CPPUTEST_DO_NOT_SANITIZE_ADDRESS
#endif
/*
- * Handling of IEEE754 floating point exceptions via fenv.h
+ * Handling of IEEE754 (IEC559) floating point exceptions via fenv.h
* Predominantly works on non-Visual C++ compilers and Visual C++ 2008 and newer
*/
-
-#if CPPUTEST_USE_STD_C_LIB && \
- (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \
- (!defined(__APPLE__)) && \
- (!defined(__ghs__) || !defined(__ColdFire__))
-#define CPPUTEST_HAVE_FENV
-#if defined(__WATCOMC__) || defined(__ARMEL__) || defined(__m68k__)
-#define CPPUTEST_FENV_IS_WORKING_PROPERLY 0
-#else
-#define CPPUTEST_FENV_IS_WORKING_PROPERLY 1
+#ifndef CPPUTEST_HAVE_FENV
+ #if (defined(__STDC_IEC_559__) && __STDC_IEC_559__) && CPPUTEST_USE_STD_C_LIB
+ #define CPPUTEST_HAVE_FENV 1
+ #else
+ #define CPPUTEST_HAVE_FENV 0
+ #endif
#endif
+
+#ifdef __cplusplus
+ /*
+ * Detection of run-time type information (RTTI) presence. Since it's a
+ * standard language feature, assume it is enabled unless we see otherwise.
+ */
+ #ifndef CPPUTEST_HAVE_RTTI
+ #if ((__cplusplus >= 202002L) && !__cpp_rtti) || \
+ (defined(_MSC_VER) && !_CPPRTTI) || \
+ (defined(__GNUC__) && !__GXX_RTTI) || \
+ (defined(__ghs__) && !__RTTI) || \
+ (defined(__WATCOMC__) && !_CPPRTTI)
+ #define CPPUTEST_HAVE_RTTI 0
+ #else
+ #define CPPUTEST_HAVE_RTTI 1
+ #endif
+ #endif
+
+ /*
+ * Detection of exception support. Since it's a standard language feature,
+ * assume it is enabled unless we see otherwise.
+ */
+ #ifndef CPPUTEST_HAVE_EXCEPTIONS
+ #if ((__cplusplus >= 202002L) && !__cpp_exceptions) || \
+ (defined(_MSC_VER) && !_CPPUNWIND) || \
+ (defined(__GNUC__) && !__EXCEPTIONS) || \
+ (defined(__ghs__) && !__EXCEPTION_HANDLING) || \
+ (defined(__WATCOMC__) && !_CPPUNWIND)
+ #define CPPUTEST_HAVE_EXCEPTIONS 0
+ #else
+ #define CPPUTEST_HAVE_EXCEPTIONS 1
+ #endif
+ #endif
+
+ #if CPPUTEST_HAVE_EXCEPTIONS
+ #if defined(__cplusplus) && __cplusplus >= 201103L
+ #define UT_THROW(exception)
+ #define UT_NOTHROW noexcept
+ #else
+ #define UT_THROW(exception) throw (exception)
+ #define UT_NOTHROW throw()
+ #endif
+ #else
+ #define UT_THROW(exception)
+ #if defined(__clang__) || defined(__GNUC__)
+ #if defined(__cplusplus) && __cplusplus >= 201103L
+ #define UT_NOTHROW noexcept
+ #else
+ #define UT_NOTHROW throw()
+ #endif
+ #else
+ #define UT_NOTHROW
+ #endif
+ #endif
+
+ /*
+ * Visual C++ doesn't define __cplusplus as C++11 yet (201103), however it doesn't want the throw(exception) either, but
+ * it does want throw().
+ */
+ #ifdef _MSC_VER
+ #undef UT_THROW
+ #define UT_THROW(exception)
+ #endif
+
+ /*
+ * g++-4.7 with stdc++11 enabled On MacOSX! will have a different exception specifier for operator new (and thank you!)
+ * I assume they'll fix this in the future, but for now, we'll change that here.
+ * (This should perhaps also be done in the configure.ac)
+ */
+ #if defined(__GXX_EXPERIMENTAL_CXX0X__) && \
+ defined(__APPLE__) && \
+ defined(_GLIBCXX_THROW)
+ #undef UT_THROW
+ #define UT_THROW(exception) _GLIBCXX_THROW(exception)
+ #endif
+
+ #if CPPUTEST_USE_STD_CPP_LIB
+ #define CPPUTEST_BAD_ALLOC std::bad_alloc
+ #else
+ class CppUTestBadAlloc {};
+ #define CPPUTEST_BAD_ALLOC CppUTestBadAlloc
+ #endif
#endif
/*
@@ -228,13 +265,16 @@
#endif
#endif
-/* Handling of systems with a different byte-width (e.g. 16 bit).
- * Since CHAR_BIT is defined in limits.h (ANSI C), use default of 8 when building without Std C library.
+/* Handling of systems with a different byte-width (e.g. 16 bit). Since
+ * CHAR_BIT is defined in limits.h (ANSI C), the user must provide a definition
+ * when building without Std C library.
*/
-#if CPPUTEST_USE_STD_C_LIB
-#define CPPUTEST_CHAR_BIT CHAR_BIT
-#else
-#define CPPUTEST_CHAR_BIT 8
+#ifndef CPPUTEST_CHAR_BIT
+ #if defined(CHAR_BIT)
+ #define CPPUTEST_CHAR_BIT CHAR_BIT
+ #else
+ #error "Provide a definition for CPPUTEST_CHAR_BIT"
+ #endif
#endif
/* Handling of systems with a different int-width (e.g. 16 bit).
@@ -249,18 +289,19 @@
* Not supported when CPPUTEST_LONG_LONG_DISABLED is set.
* Can be overridden by using CPPUTEST_USE_LONG_LONG
*
- * CPPUTEST_HAVE_LONG_LONG_INT is set by configure
+ * CPPUTEST_HAVE_LONG_LONG_INT is set by configure or CMake.
* LLONG_MAX is set in limits.h. This is a crude attempt to detect long long support when no configure is used
*
*/
-
-#if !defined(CPPUTEST_LONG_LONG_DISABLED) && !defined(CPPUTEST_USE_LONG_LONG)
-#if defined(CPPUTEST_HAVE_LONG_LONG_INT) || defined(LLONG_MAX)
+#ifndef CPPUTEST_USE_LONG_LONG
+#if !defined(CPPUTEST_LONG_LONG_DISABLED) && (defined(CPPUTEST_HAVE_LONG_LONG_INT) || defined(LLONG_MAX))
#define CPPUTEST_USE_LONG_LONG 1
+#else
+#define CPPUTEST_USE_LONG_LONG 0
#endif
#endif
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
typedef long long cpputest_longlong;
typedef unsigned long long cpputest_ulonglong;
#else
@@ -274,59 +315,44 @@ typedef unsigned long long cpputest_ulonglong;
#define CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE 8
#endif
-struct cpputest_longlong
-{
#if defined(__cplusplus)
- cpputest_longlong() {}
- cpputest_longlong(int) {}
+extern "C" {
#endif
+
+typedef struct
+{
char dummy[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE];
-};
+} cpputest_longlong;
-struct cpputest_ulonglong
+typedef struct
{
-#if defined(__cplusplus)
- cpputest_ulonglong() {}
- cpputest_ulonglong(int) {}
-#endif
char dummy[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE];
-};
+} cpputest_ulonglong;
-#if !defined(__cplusplus)
-typedef struct cpputest_longlong cpputest_longlong;
-typedef struct cpputest_ulonglong cpputest_ulonglong;
+#if defined(__cplusplus)
+} /* extern "C" */
#endif
#endif
-/* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
-#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)))
-#if !defined(__ghs__)
-#define CPPUTEST_COMPILER_FULLY_SUPPORTS_CXX11
-#define _override override
-#else
-/* GreenHills is not compatible with other compilers with regards to where
- * it expects the override specifier to be on methods that return function
- * pointers. Given this, it is easiest to not use the override specifier.
- */
-#define _override
-#endif
-#define NULLPTR nullptr
-#else
-#define _override
-#define NULLPTR NULL
-#endif
-
-/* Visual C++ 11.0+ (2012+) supports the override keyword on destructors */
-#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1700)))
-#define _destructor_override override
-#else
-#define _destructor_override
+#ifdef __cplusplus
+ /* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
+ #if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
+ #define CPPUTEST_OVERRIDE override
+ #define NULLPTR nullptr
+ #else
+ #define CPPUTEST_OVERRIDE
+ #define NULLPTR NULL
+ #endif
#endif
-#ifdef __clang__
- #pragma clang diagnostic pop
+#ifdef __cplusplus
+ /* Visual C++ 11.0+ (2012+) supports the override keyword on destructors */
+ #if (__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1700))
+ #define CPPUTEST_DESTRUCTOR_OVERRIDE override
+ #else
+ #define CPPUTEST_DESTRUCTOR_OVERRIDE
+ #endif
#endif
-
#endif
diff --git a/include/CppUTest/CppUTestGeneratedConfig.h b/include/CppUTest/CppUTestGeneratedConfig.h
index 94e293f9c..5bcd53768 100644
--- a/include/CppUTest/CppUTestGeneratedConfig.h
+++ b/include/CppUTest/CppUTestGeneratedConfig.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/JUnitTestOutput.h b/include/CppUTest/JUnitTestOutput.h
index 1c4a0b0eb..5e5746f56 100644
--- a/include/CppUTest/JUnitTestOutput.h
+++ b/include/CppUTest/JUnitTestOutput.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,22 +38,22 @@ class JUnitTestOutput: public TestOutput
{
public:
JUnitTestOutput();
- virtual ~JUnitTestOutput() _destructor_override;
+ virtual ~JUnitTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void printTestsStarted() _override;
- virtual void printTestsEnded(const TestResult& result) _override;
- virtual void printCurrentTestStarted(const UtestShell& test) _override;
- virtual void printCurrentTestEnded(const TestResult& res) _override;
- virtual void printCurrentGroupStarted(const UtestShell& test) _override;
- virtual void printCurrentGroupEnded(const TestResult& res) _override;
+ virtual void printTestsStarted() CPPUTEST_OVERRIDE;
+ virtual void printTestsEnded(const TestResult& result) CPPUTEST_OVERRIDE;
+ virtual void printCurrentTestStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentTestEnded(const TestResult& res) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupEnded(const TestResult& res) CPPUTEST_OVERRIDE;
- virtual void printBuffer(const char*) _override;
- virtual void print(const char*) _override;
- virtual void print(long) _override;
- virtual void print(size_t) _override;
- virtual void printFailure(const TestFailure& failure) _override;
+ virtual void printBuffer(const char*) CPPUTEST_OVERRIDE;
+ virtual void print(const char*) CPPUTEST_OVERRIDE;
+ virtual void print(long) CPPUTEST_OVERRIDE;
+ virtual void print(size_t) CPPUTEST_OVERRIDE;
+ virtual void printFailure(const TestFailure& failure) CPPUTEST_OVERRIDE;
- virtual void flush() _override;
+ virtual void flush() CPPUTEST_OVERRIDE;
virtual SimpleString createFileName(const SimpleString& group);
void setPackageName(const SimpleString &package);
diff --git a/include/CppUTest/MemoryLeakDetector.h b/include/CppUTest/MemoryLeakDetector.h
index 4057ca806..195a3384a 100644
--- a/include/CppUTest/MemoryLeakDetector.h
+++ b/include/CppUTest/MemoryLeakDetector.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -58,7 +58,7 @@ struct SimpleStringBuffer
SimpleStringBuffer();
void clear();
- void add(const char* format, ...) _check_format_(printf, 2, 3);
+ void add(const char* format, ...) CPPUTEST_CHECK_FORMAT(CPPUTEST_CHECK_FORMAT_TYPE, 2, 3);
void addMemoryDump(const void* memory, size_t memorySize);
char* toString();
diff --git a/include/CppUTest/MemoryLeakDetectorForceInclude.h b/include/CppUTest/MemoryLeakDetectorForceInclude.h
new file mode 100644
index 000000000..6de90e177
--- /dev/null
+++ b/include/CppUTest/MemoryLeakDetectorForceInclude.h
@@ -0,0 +1,4 @@
+// Not all toolchains support multiple force includes (namely IAR),
+// so we wrap the two in a single header.
+#include "MemoryLeakDetectorMallocMacros.h"
+#include "MemoryLeakDetectorNewMacros.h"
diff --git a/include/CppUTest/MemoryLeakDetectorNewMacros.h b/include/CppUTest/MemoryLeakDetectorNewMacros.h
index 4f4699cbe..880b89560 100644
--- a/include/CppUTest/MemoryLeakDetectorNewMacros.h
+++ b/include/CppUTest/MemoryLeakDetectorNewMacros.h
@@ -34,29 +34,38 @@
* Some platforms (OSx, i.e.) will get or included when using header,
* in order to avoid conflicts with strdup and strndup macros defined by MemoryLeakDetectorMallocMacros.h
* we will undefined those macros, include the C++ headers and then reinclude MemoryLeakDetectorMallocMacros.h.
- * The check `#if CPPUTEST_USE_STRDUP_MACROS` will ensure we only include MemoryLeakDetectorMallocMacros.h if
+ * The check '#if CPPUTEST_USE_STRDUP_MACROS' will ensure we only include MemoryLeakDetectorMallocMacros.h if
* it has already been includeded earlier.
*/
#undef strdup
#undef strndup
#undef CPPUTEST_USE_STRDUP_MACROS
- #define __CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
+ #define CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
#endif
#endif
#include
#include
#include
- #ifdef __CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
+ #ifdef CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR
#include "MemoryLeakDetectorMallocMacros.h"
#endif
#endif
- void* operator new(size_t size, const char* file, size_t line) UT_THROW (std::bad_alloc);
- void* operator new[](size_t size, const char* file, size_t line) UT_THROW (std::bad_alloc);
- void* operator new(size_t size) UT_THROW(std::bad_alloc);
- void* operator new[](size_t size) UT_THROW(std::bad_alloc);
+ /* Some toolkits, e.g. MFC, provide their own new overloads with signature (size_t, const char *, int).
+ * If we don't provide them, in addition to the (size_t, const char *, size_t) version, we don't get to
+ * know about all allocations and report freeing of unallocated blocks. Hence, provide both overloads.
+ */
+ void* operator new(size_t size, const char* file, int line) UT_THROW (CPPUTEST_BAD_ALLOC);
+ void* operator new(size_t size, const char* file, size_t line) UT_THROW (CPPUTEST_BAD_ALLOC);
+ void* operator new[](size_t size, const char* file, int line) UT_THROW (CPPUTEST_BAD_ALLOC);
+ void* operator new[](size_t size, const char* file, size_t line) UT_THROW (CPPUTEST_BAD_ALLOC);
+ void* operator new(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC);
+ void* operator new[](size_t size) UT_THROW(CPPUTEST_BAD_ALLOC);
+
+ void operator delete(void* mem, const char* file, int line) UT_NOTHROW;
void operator delete(void* mem, const char* file, size_t line) UT_NOTHROW;
+ void operator delete[](void* mem, const char* file, int line) UT_NOTHROW;
void operator delete[](void* mem, const char* file, size_t line) UT_NOTHROW;
void operator delete(void* mem) UT_NOTHROW;
void operator delete[](void* mem) UT_NOTHROW;
diff --git a/include/CppUTest/MemoryLeakWarningPlugin.h b/include/CppUTest/MemoryLeakWarningPlugin.h
index ec3c824d9..01ae95be7 100644
--- a/include/CppUTest/MemoryLeakWarningPlugin.h
+++ b/include/CppUTest/MemoryLeakWarningPlugin.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -43,10 +43,10 @@ class MemoryLeakWarningPlugin: public TestPlugin
{
public:
MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector = NULLPTR);
- virtual ~MemoryLeakWarningPlugin() _destructor_override;
+ virtual ~MemoryLeakWarningPlugin() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void preTestAction(UtestShell& test, TestResult& result) _override;
- virtual void postTestAction(UtestShell& test, TestResult& result) _override;
+ virtual void preTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
+ virtual void postTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
virtual const char* FinalReport(size_t toBeDeletedLeaks = 0);
diff --git a/include/CppUTest/PlatformSpecificFunctions.h b/include/CppUTest/PlatformSpecificFunctions.h
index 6737f582a..3b2f983cc 100644
--- a/include/CppUTest/PlatformSpecificFunctions.h
+++ b/include/CppUTest/PlatformSpecificFunctions.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/PlatformSpecificFunctions_c.h b/include/CppUTest/PlatformSpecificFunctions_c.h
index b39d88fd3..36700818b 100644
--- a/include/CppUTest/PlatformSpecificFunctions_c.h
+++ b/include/CppUTest/PlatformSpecificFunctions_c.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -47,7 +47,7 @@ extern void (*PlatformSpecificLongJmp)(void);
extern void (*PlatformSpecificRestoreJumpBuffer)(void);
/* Time operations */
-extern long (*GetPlatformSpecificTimeInMillis)(void);
+extern unsigned long (*GetPlatformSpecificTimeInMillis)(void);
extern const char* (*GetPlatformSpecificTimeString)(void);
/* String operations */
@@ -62,11 +62,12 @@ extern int (*PlatformSpecificAtExit)(void(*func)(void));
/* IO operations */
typedef void* PlatformSpecificFile;
+extern PlatformSpecificFile PlatformSpecificStdOut;
+
extern PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag);
extern void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file);
extern void (*PlatformSpecificFClose)(PlatformSpecificFile file);
-extern int (*PlatformSpecificPutchar)(int c);
extern void (*PlatformSpecificFlush)(void);
/* Random operations */
@@ -82,9 +83,12 @@ extern void* (*PlatformSpecificMemset)(void* mem, int c, size_t size);
typedef void* PlatformSpecificMutex;
extern PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void);
+extern void (*PlatformSpecificSrand)(unsigned int);
+extern int (*PlatformSpecificRand)(void);
extern void (*PlatformSpecificMutexLock)(PlatformSpecificMutex mtx);
extern void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex mtx);
extern void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex mtx);
+extern void (*PlatformSpecificAbort)(void);
#ifdef __cplusplus
}
diff --git a/include/CppUTest/SimpleMutex.h b/include/CppUTest/SimpleMutex.h
index eb4990054..8bb59fb69 100644
--- a/include/CppUTest/SimpleMutex.h
+++ b/include/CppUTest/SimpleMutex.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/SimpleString.h b/include/CppUTest/SimpleString.h
index e56e6947c..63e7684d0 100644
--- a/include/CppUTest/SimpleString.h
+++ b/include/CppUTest/SimpleString.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -83,6 +83,8 @@ class SimpleString
SimpleString subStringFromTill(char startChar, char lastExcludedChar) const;
void copyToBuffer(char* buffer, size_t bufferSize) const;
+ SimpleString printable() const;
+
const char *asCharString() const;
size_t size() const;
bool isEmpty() const;
@@ -125,6 +127,10 @@ class SimpleString
static bool isDigit(char ch);
static bool isSpace(char ch);
static bool isUpper(char ch);
+ static bool isControl(char ch);
+ static bool isControlWithShortEscapeSequence(char ch);
+
+ size_t getPrintableSize() const;
};
class SimpleStringCollection
@@ -203,7 +209,7 @@ SimpleString HexStringFrom(const void* value);
SimpleString HexStringFrom(void (*value)());
SimpleString StringFrom(double value, int precision = 6);
SimpleString StringFrom(const SimpleString& other);
-SimpleString StringFromFormat(const char* format, ...) _check_format_(printf, 1, 2);
+SimpleString StringFromFormat(const char* format, ...) CPPUTEST_CHECK_FORMAT(CPPUTEST_CHECK_FORMAT_TYPE, 1, 2);
SimpleString VStringFromFormat(const char* format, va_list args);
SimpleString StringFromBinary(const unsigned char* value, size_t size);
SimpleString StringFromBinaryOrNull(const unsigned char* value, size_t size);
@@ -219,6 +225,7 @@ SimpleString BracketsFormattedHexStringFrom(cpputest_longlong value);
SimpleString BracketsFormattedHexStringFrom(cpputest_ulonglong value);
SimpleString BracketsFormattedHexStringFrom(signed char value);
SimpleString BracketsFormattedHexString(SimpleString hexString);
+SimpleString PrintableStringFromOrNull(const char * expected);
/*
* ARM compiler has only partial support for C++11.
@@ -230,8 +237,6 @@ SimpleString StringFrom(const std::nullptr_t value);
#if CPPUTEST_USE_STD_CPP_LIB
-#include
-
SimpleString StringFrom(const std::string& other);
#endif
diff --git a/include/CppUTest/SimpleStringInternalCache.h b/include/CppUTest/SimpleStringInternalCache.h
index 94bfdd808..ebbd30f6b 100644
--- a/include/CppUTest/SimpleStringInternalCache.h
+++ b/include/CppUTest/SimpleStringInternalCache.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -79,16 +79,16 @@ class SimpleStringCacheAllocator : public TestMemoryAllocator
{
public:
SimpleStringCacheAllocator(SimpleStringInternalCache& cache, TestMemoryAllocator* previousAllocator);
- virtual ~SimpleStringCacheAllocator() _destructor_override;
+ virtual ~SimpleStringCacheAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
- virtual const char* name() const _override;
- virtual const char* alloc_name() const _override;
- virtual const char* free_name() const _override;
+ virtual const char* name() const CPPUTEST_OVERRIDE;
+ virtual const char* alloc_name() const CPPUTEST_OVERRIDE;
+ virtual const char* free_name() const CPPUTEST_OVERRIDE;
- virtual TestMemoryAllocator* actualAllocator() _override;
+ virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE;
TestMemoryAllocator* originalAllocator();
private:
SimpleStringInternalCache& cache_;
diff --git a/include/CppUTest/StandardCLibrary.h b/include/CppUTest/StandardCLibrary.h
index a2171eafe..d518236ca 100644
--- a/include/CppUTest/StandardCLibrary.h
+++ b/include/CppUTest/StandardCLibrary.h
@@ -14,6 +14,8 @@
#ifdef __cplusplus
#if CPPUTEST_USE_STD_CPP_LIB
#include
+ #include
+ #include
#endif
#endif
@@ -43,7 +45,7 @@
#include
/* Needed to ensure that string.h is included prior to strdup redefinition */
-#ifdef CPPUTEST_HAVE_STRING_H
+#ifdef CPPUTEST_HAVE_STRDUP
#include
#endif
@@ -78,8 +80,15 @@ typedef long unsigned int size_t;
#endif
#define NULL (0)
+#ifdef __cplusplus
+extern "C" {
+#endif
extern void* malloc(size_t);
extern void free(void *);
+#ifdef __cplusplus
+}
+#endif
+
#define _bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd)))
diff --git a/include/CppUTest/TeamCityTestOutput.h b/include/CppUTest/TeamCityTestOutput.h
index 186d21867..caf67d586 100644
--- a/include/CppUTest/TeamCityTestOutput.h
+++ b/include/CppUTest/TeamCityTestOutput.h
@@ -8,14 +8,14 @@ class TeamCityTestOutput: public ConsoleTestOutput
{
public:
TeamCityTestOutput(void);
- virtual ~TeamCityTestOutput(void) _destructor_override;
+ virtual ~TeamCityTestOutput(void) CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void printCurrentTestStarted(const UtestShell& test) _override;
- virtual void printCurrentTestEnded(const TestResult& res) _override;
- virtual void printCurrentGroupStarted(const UtestShell& test) _override;
- virtual void printCurrentGroupEnded(const TestResult& res) _override;
+ virtual void printCurrentTestStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentTestEnded(const TestResult& res) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupEnded(const TestResult& res) CPPUTEST_OVERRIDE;
- virtual void printFailure(const TestFailure& failure) _override;
+ virtual void printFailure(const TestFailure& failure) CPPUTEST_OVERRIDE;
protected:
diff --git a/include/CppUTest/TestFailure.h b/include/CppUTest/TestFailure.h
index 8b93fe332..7dc816f2c 100644
--- a/include/CppUTest/TestFailure.h
+++ b/include/CppUTest/TestFailure.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,6 +38,10 @@
#include "SimpleString.h"
+#if CPPUTEST_USE_STD_CPP_LIB
+#include
+#endif
+
class UtestShell;
class TestOutput;
@@ -63,13 +67,8 @@ class TestFailure
protected:
- enum DifferenceFormat
- {
- DIFFERENCE_STRING, DIFFERENCE_BINARY
- };
-
SimpleString createButWasString(const SimpleString& expected, const SimpleString& actual);
- SimpleString createDifferenceAtPosString(const SimpleString& actual, size_t position, DifferenceFormat format = DIFFERENCE_STRING);
+ SimpleString createDifferenceAtPosString(const SimpleString& actual, size_t offset, size_t reportedPosition);
SimpleString createUserText(const SimpleString& text);
SimpleString testName_;
@@ -187,4 +186,15 @@ class FeatureUnsupportedFailure : public TestFailure
FeatureUnsupportedFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& featureName, const SimpleString& text);
};
+#if CPPUTEST_HAVE_EXCEPTIONS
+class UnexpectedExceptionFailure : public TestFailure
+{
+public:
+ UnexpectedExceptionFailure(UtestShell* test);
+#if CPPUTEST_USE_STD_CPP_LIB
+ UnexpectedExceptionFailure(UtestShell* test, const std::exception &e);
+#endif
+};
+#endif
+
#endif
diff --git a/include/CppUTest/TestFilter.h b/include/CppUTest/TestFilter.h
index 6f92a00bd..730f52e14 100644
--- a/include/CppUTest/TestFilter.h
+++ b/include/CppUTest/TestFilter.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/TestHarness.h b/include/CppUTest/TestHarness.h
index 8eb5b29bf..a4f1a8f71 100644
--- a/include/CppUTest/TestHarness.h
+++ b/include/CppUTest/TestHarness.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/TestHarness_c.h b/include/CppUTest/TestHarness_c.h
index d859c4ff6..f3a64cf83 100644
--- a/include/CppUTest/TestHarness_c.h
+++ b/include/CppUTest/TestHarness_c.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,85 +37,91 @@
#include "CppUTestConfig.h"
#define CHECK_EQUAL_C_BOOL(expected,actual) \
- CHECK_EQUAL_C_BOOL_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_BOOL_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_BOOL_TEXT(expected,actual,text) \
CHECK_EQUAL_C_BOOL_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_INT(expected,actual) \
- CHECK_EQUAL_C_INT_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_INT_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_INT_TEXT(expected,actual,text) \
CHECK_EQUAL_C_INT_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_UINT(expected,actual) \
- CHECK_EQUAL_C_UINT_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_UINT_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_UINT_TEXT(expected,actual,text) \
CHECK_EQUAL_C_UINT_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_LONG(expected,actual) \
- CHECK_EQUAL_C_LONG_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_LONG_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_LONG_TEXT(expected,actual,text) \
CHECK_EQUAL_C_LONG_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_ULONG(expected,actual) \
- CHECK_EQUAL_C_ULONG_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_ULONG_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_ULONG_TEXT(expected,actual,text) \
CHECK_EQUAL_C_ULONG_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_LONGLONG(expected,actual) \
- CHECK_EQUAL_C_LONGLONG_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_LONGLONG_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_LONGLONG_TEXT(expected,actual,text) \
CHECK_EQUAL_C_LONGLONG_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_ULONGLONG(expected,actual) \
- CHECK_EQUAL_C_ULONGLONG_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_ULONGLONG_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_ULONGLONG_TEXT(expected,actual,text) \
CHECK_EQUAL_C_ULONGLONG_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_REAL(expected,actual,threshold) \
- CHECK_EQUAL_C_REAL_LOCATION(expected,actual,threshold,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_REAL_LOCATION(expected,actual,threshold,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_REAL_TEXT(expected,actual,threshold,text) \
CHECK_EQUAL_C_REAL_LOCATION(expected,actual,threshold,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_CHAR(expected,actual) \
- CHECK_EQUAL_C_CHAR_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_CHAR_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_CHAR_TEXT(expected,actual,text) \
CHECK_EQUAL_C_CHAR_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_UBYTE(expected,actual) \
- CHECK_EQUAL_C_UBYTE_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_UBYTE_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_UBYTE_TEXT(expected,actual,text) \
CHECK_EQUAL_C_UBYTE_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_SBYTE(expected,actual) \
- CHECK_EQUAL_C_SBYTE_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_SBYTE_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_SBYTE_TEXT(expected,actual,text) \
CHECK_EQUAL_C_SBYTE_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_STRING(expected,actual) \
- CHECK_EQUAL_C_STRING_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_STRING_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_STRING_TEXT(expected,actual,text) \
CHECK_EQUAL_C_STRING_LOCATION(expected,actual,text,__FILE__,__LINE__)
#define CHECK_EQUAL_C_POINTER(expected,actual) \
- CHECK_EQUAL_C_POINTER_LOCATION(expected,actual,NULLPTR,__FILE__,__LINE__)
+ CHECK_EQUAL_C_POINTER_LOCATION(expected,actual,NULL,__FILE__,__LINE__)
#define CHECK_EQUAL_C_POINTER_TEXT(expected,actual,text) \
CHECK_EQUAL_C_POINTER_LOCATION(expected,actual,text,__FILE__,__LINE__)
+#define CHECK_EQUAL_C_MEMCMP(expected, actual, size) \
+ CHECK_EQUAL_C_MEMCMP_LOCATION(expected, actual, size, NULL, __FILE__, __LINE__)
+
+#define CHECK_EQUAL_C_MEMCMP_TEXT(expected, actual, size, text) \
+ CHECK_EQUAL_C_MEMCMP_LOCATION(expected, actual, size, text, __FILE__, __LINE__)
+
#define CHECK_EQUAL_C_BITS(expected, actual, mask) \
- CHECK_EQUAL_C_BITS_LOCATION(expected, actual, mask, sizeof(actual), NULLPTR, __FILE__, __LINE__)
+ CHECK_EQUAL_C_BITS_LOCATION(expected, actual, mask, sizeof(actual), NULL, __FILE__, __LINE__)
#define CHECK_EQUAL_C_BITS_TEXT(expected, actual, mask, text) \
CHECK_EQUAL_C_BITS_LOCATION(expected, actual, mask, sizeof(actual), text, __FILE__, __LINE__)
@@ -127,7 +133,7 @@
FAIL_C_LOCATION(__FILE__,__LINE__)
#define CHECK_C(condition) \
- CHECK_C_LOCATION(condition, #condition, NULLPTR, __FILE__,__LINE__)
+ CHECK_C_LOCATION(condition, #condition, NULL, __FILE__,__LINE__)
#define CHECK_C_TEXT(condition, text) \
CHECK_C_LOCATION(condition, #condition, text, __FILE__, __LINE__)
@@ -141,19 +147,19 @@
/* For use in C file */
#define TEST_GROUP_C_SETUP(group_name) \
extern void group_##group_name##_setup_wrapper_c(void); \
- void group_##group_name##_setup_wrapper_c()
+ void group_##group_name##_setup_wrapper_c(void)
#define TEST_GROUP_C_TEARDOWN(group_name) \
extern void group_##group_name##_teardown_wrapper_c(void); \
- void group_##group_name##_teardown_wrapper_c()
+ void group_##group_name##_teardown_wrapper_c(void)
#define TEST_C(group_name, test_name) \
extern void test_##group_name##_##test_name##_wrapper_c(void);\
- void test_##group_name##_##test_name##_wrapper_c()
+ void test_##group_name##_##test_name##_wrapper_c(void)
#define IGNORE_TEST_C(group_name, test_name) \
extern void ignore_##group_name##_##test_name##_wrapper_c(void);\
- void ignore_##group_name##_##test_name##_wrapper_c()
+ void ignore_##group_name##_##test_name##_wrapper_c(void)
/* For use in C++ file */
@@ -164,12 +170,12 @@
TEST_GROUP(group_name)
#define TEST_GROUP_C_SETUP_WRAPPER(group_name) \
- void setup() { \
+ void setup() CPPUTEST_OVERRIDE { \
group_##group_name##_setup_wrapper_c(); \
}
#define TEST_GROUP_C_TEARDOWN_WRAPPER(group_name) \
- void teardown() { \
+ void teardown() CPPUTEST_OVERRIDE { \
group_##group_name##_teardown_wrapper_c(); \
}
@@ -205,6 +211,7 @@ extern void CHECK_EQUAL_C_UBYTE_LOCATION(unsigned char expected, unsigned char a
extern void CHECK_EQUAL_C_SBYTE_LOCATION(signed char expected, signed char actual, const char* text, const char* fileName, size_t lineNumber);
extern void CHECK_EQUAL_C_STRING_LOCATION(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber);
extern void CHECK_EQUAL_C_POINTER_LOCATION(const void* expected, const void* actual, const char* text, const char* fileName, size_t lineNumber);
+extern void CHECK_EQUAL_C_MEMCMP_LOCATION(const void* expected, const void* actual, size_t size, const char* text, const char* fileName, size_t lineNumber);
extern void CHECK_EQUAL_C_BITS_LOCATION(unsigned int expected, unsigned int actual, unsigned int mask, size_t size, const char* text, const char* fileName, size_t lineNumber);
extern void FAIL_TEXT_C_LOCATION(const char* text, const char* fileName, size_t lineNumber);
extern void FAIL_C_LOCATION(const char* fileName, size_t lineNumber);
diff --git a/include/CppUTest/TestMemoryAllocator.h b/include/CppUTest/TestMemoryAllocator.h
index 17e5b11f8..8f65bf508 100644
--- a/include/CppUTest/TestMemoryAllocator.h
+++ b/include/CppUTest/TestMemoryAllocator.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -93,16 +93,16 @@ class MemoryLeakAllocator : public TestMemoryAllocator
{
public:
MemoryLeakAllocator(TestMemoryAllocator* originalAllocator);
- virtual ~MemoryLeakAllocator() _destructor_override;
+ virtual ~MemoryLeakAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
- virtual const char* name() const _override;
- virtual const char* alloc_name() const _override;
- virtual const char* free_name() const _override;
+ virtual const char* name() const CPPUTEST_OVERRIDE;
+ virtual const char* alloc_name() const CPPUTEST_OVERRIDE;
+ virtual const char* free_name() const CPPUTEST_OVERRIDE;
- virtual TestMemoryAllocator* actualAllocator() _override;
+ virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE;
private:
TestMemoryAllocator* originalAllocator_;
};
@@ -112,11 +112,11 @@ class CrashOnAllocationAllocator : public TestMemoryAllocator
unsigned allocationToCrashOn_;
public:
CrashOnAllocationAllocator();
- virtual ~CrashOnAllocationAllocator() _destructor_override;
+ virtual ~CrashOnAllocationAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
virtual void setNumberToCrashOn(unsigned allocationToCrashOn);
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
};
@@ -124,10 +124,10 @@ class NullUnknownAllocator: public TestMemoryAllocator
{
public:
NullUnknownAllocator();
- virtual ~NullUnknownAllocator() _destructor_override;
+ virtual ~NullUnknownAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
static TestMemoryAllocator* defaultAllocator();
};
@@ -138,10 +138,10 @@ class FailableMemoryAllocator: public TestMemoryAllocator
{
public:
FailableMemoryAllocator(const char* name_str = "failable alloc", const char* alloc_name_str = "alloc", const char* free_name_str = "free");
- virtual ~FailableMemoryAllocator() _destructor_override;
+ virtual ~FailableMemoryAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual char* allocMemoryLeakNode(size_t size) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual char* allocMemoryLeakNode(size_t size) CPPUTEST_OVERRIDE;
virtual void failAllocNumber(int number);
virtual void failNthAllocAt(int allocationNumber, const char* file, size_t line);
@@ -207,16 +207,16 @@ class AccountingTestMemoryAllocator : public TestMemoryAllocator
{
public:
AccountingTestMemoryAllocator(MemoryAccountant& accountant, TestMemoryAllocator* originalAllocator);
- virtual ~AccountingTestMemoryAllocator() _destructor_override;
+ virtual ~AccountingTestMemoryAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
- virtual TestMemoryAllocator* actualAllocator() _override;
+ virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE;
TestMemoryAllocator* originalAllocator();
- virtual const char* alloc_name() const _override;
- virtual const char* free_name() const _override;
+ virtual const char* alloc_name() const CPPUTEST_OVERRIDE;
+ virtual const char* free_name() const CPPUTEST_OVERRIDE;
private:
void addMemoryToMemoryTrackingToKeepTrackOfSize(char* memory, size_t size);
diff --git a/include/CppUTest/TestOutput.h b/include/CppUTest/TestOutput.h
index dff6e0af9..47fbe02ea 100644
--- a/include/CppUTest/TestOutput.h
+++ b/include/CppUTest/TestOutput.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -117,12 +117,12 @@ class ConsoleTestOutput: public TestOutput
explicit ConsoleTestOutput()
{
}
- virtual ~ConsoleTestOutput() _destructor_override
+ virtual ~ConsoleTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
- virtual void printBuffer(const char* s) _override;
- virtual void flush() _override;
+ virtual void printBuffer(const char* s) CPPUTEST_OVERRIDE;
+ virtual void flush() CPPUTEST_OVERRIDE;
private:
ConsoleTestOutput(const ConsoleTestOutput&);
@@ -145,14 +145,14 @@ class StringBufferTestOutput: public TestOutput
{
}
- virtual ~StringBufferTestOutput() _destructor_override;
+ virtual ~StringBufferTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE;
- void printBuffer(const char* s) _override
+ void printBuffer(const char* s) CPPUTEST_OVERRIDE
{
output += s;
}
- void flush() _override
+ void flush() CPPUTEST_OVERRIDE
{
output = "";
}
@@ -178,27 +178,29 @@ class CompositeTestOutput : public TestOutput
virtual void setOutputTwo(TestOutput* output);
CompositeTestOutput();
- virtual ~CompositeTestOutput() _destructor_override;
-
- virtual void printTestsStarted() _override;
- virtual void printTestsEnded(const TestResult& result) _override;
-
- virtual void printCurrentTestStarted(const UtestShell& test) _override;
- virtual void printCurrentTestEnded(const TestResult& res) _override;
- virtual void printCurrentGroupStarted(const UtestShell& test) _override;
- virtual void printCurrentGroupEnded(const TestResult& res) _override;
-
- virtual void verbose(VerbosityLevel level) _override;
- virtual void color() _override;
- virtual void printBuffer(const char*) _override;
- virtual void print(const char*) _override;
- virtual void print(long) _override;
- virtual void print(size_t) _override;
- virtual void printDouble(double) _override;
- virtual void printFailure(const TestFailure& failure) _override;
- virtual void setProgressIndicator(const char*) _override;
-
- virtual void flush() _override;
+ virtual ~CompositeTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE;
+
+ virtual void printTestsStarted() CPPUTEST_OVERRIDE;
+ virtual void printTestsEnded(const TestResult& result) CPPUTEST_OVERRIDE;
+
+ virtual void printCurrentTestStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentTestEnded(const TestResult& res) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupStarted(const UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void printCurrentGroupEnded(const TestResult& res) CPPUTEST_OVERRIDE;
+
+ virtual void verbose(VerbosityLevel level) CPPUTEST_OVERRIDE;
+ virtual void color() CPPUTEST_OVERRIDE;
+ virtual void printBuffer(const char*) CPPUTEST_OVERRIDE;
+ virtual void print(const char*) CPPUTEST_OVERRIDE;
+ virtual void print(long) CPPUTEST_OVERRIDE;
+ virtual void print(size_t) CPPUTEST_OVERRIDE;
+ virtual void printDouble(double) CPPUTEST_OVERRIDE;
+ virtual void printFailure(const TestFailure& failure) CPPUTEST_OVERRIDE;
+ virtual void setProgressIndicator(const char*) CPPUTEST_OVERRIDE;
+
+ virtual void printVeryVerbose(const char*) CPPUTEST_OVERRIDE;
+
+ virtual void flush() CPPUTEST_OVERRIDE;
protected:
CompositeTestOutput(const TestOutput&);
diff --git a/include/CppUTest/TestPlugin.h b/include/CppUTest/TestPlugin.h
index 2b2ed932b..d0b3c41b3 100644
--- a/include/CppUTest/TestPlugin.h
+++ b/include/CppUTest/TestPlugin.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -28,6 +28,8 @@
#ifndef D_TestPlugin_h
#define D_TestPlugin_h
+#include "SimpleString.h"
+
class UtestShell;
class TestResult;
@@ -90,7 +92,7 @@ class SetPointerPlugin: public TestPlugin
{
public:
SetPointerPlugin(const SimpleString& name);
- virtual void postTestAction(UtestShell&, TestResult&) _override;
+ virtual void postTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE;
enum
{
@@ -98,7 +100,11 @@ class SetPointerPlugin: public TestPlugin
};
};
-#define UT_PTR_SET(a, b) do { CppUTestStore( (void**)&a ); a = b; } while(0)
+#define UT_PTR_SET(a, b) \
+ do { \
+ CppUTestStore((void**)&(a)); \
+ (a) = b; \
+ } while (0)
///////////// Null Plugin
@@ -108,8 +114,8 @@ class NullTestPlugin: public TestPlugin
NullTestPlugin();
- virtual void runAllPreTestAction(UtestShell& test, TestResult& result) _override;
- virtual void runAllPostTestAction(UtestShell& test, TestResult& result) _override;
+ virtual void runAllPreTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
+ virtual void runAllPostTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
static NullTestPlugin* instance();
};
diff --git a/include/CppUTest/TestRegistry.h b/include/CppUTest/TestRegistry.h
index 36617a2c7..20575dd5a 100644
--- a/include/CppUTest/TestRegistry.h
+++ b/include/CppUTest/TestRegistry.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -55,6 +55,7 @@ class TestRegistry
virtual void reverseTests();
virtual void listTestGroupNames(TestResult& result);
virtual void listTestGroupAndCaseNames(TestResult& result);
+ virtual void listTestLocations(TestResult& result);
virtual void setNameFilters(const TestFilter* filters);
virtual void setGroupFilters(const TestFilter* filters);
virtual void installPlugin(TestPlugin* plugin);
diff --git a/include/CppUTest/TestResult.h b/include/CppUTest/TestResult.h
index 62c4f77fe..fc6e63fd6 100644
--- a/include/CppUTest/TestResult.h
+++ b/include/CppUTest/TestResult.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/TestTestingFixture.h b/include/CppUTest/TestTestingFixture.h
index 17d12d0cb..2c7cdd5ba 100644
--- a/include/CppUTest/TestTestingFixture.h
+++ b/include/CppUTest/TestTestingFixture.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTest/Utest.h b/include/CppUTest/Utest.h
index 5d7a7f9a3..02e865b76 100644
--- a/include/CppUTest/Utest.h
+++ b/include/CppUTest/Utest.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -69,15 +69,29 @@ class TestTerminator
class NormalTestTerminator : public TestTerminator
{
public:
- virtual void exitCurrentTest() const _override;
- virtual ~NormalTestTerminator() _destructor_override;
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE;
+ virtual ~NormalTestTerminator() CPPUTEST_DESTRUCTOR_OVERRIDE;
};
class TestTerminatorWithoutExceptions : public TestTerminator
{
public:
- virtual void exitCurrentTest() const _override;
- virtual ~TestTerminatorWithoutExceptions() _destructor_override;
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE;
+ virtual ~TestTerminatorWithoutExceptions() CPPUTEST_DESTRUCTOR_OVERRIDE;
+};
+
+class CrashingTestTerminator : public NormalTestTerminator
+{
+public:
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE;
+ virtual ~CrashingTestTerminator() CPPUTEST_DESTRUCTOR_OVERRIDE;
+};
+
+class CrashingTestTerminatorWithoutExceptions : public TestTerminatorWithoutExceptions
+{
+public:
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE;
+ virtual ~CrashingTestTerminatorWithoutExceptions() CPPUTEST_DESTRUCTOR_OVERRIDE;
};
//////////////////// UtestShell
@@ -87,6 +101,15 @@ class UtestShell
public:
static UtestShell *getCurrent();
+ static const TestTerminator &getCurrentTestTerminator();
+ static const TestTerminator &getCurrentTestTerminatorWithoutExceptions();
+
+ static void setCrashOnFail();
+ static void restoreDefaultTestTerminator();
+
+ static void setRethrowExceptions(bool rethrowExceptions);
+ static bool isRethrowingExceptions();
+
public:
UtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber);
virtual ~UtestShell();
@@ -105,26 +128,26 @@ class UtestShell
virtual bool hasFailed() const;
void countCheck();
- virtual void assertTrue(bool condition, const char *checkString, const char *conditionString, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertCstrEqual(const char *expected, const char *actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertCstrNEqual(const char *expected, const char *actual, size_t length, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
+ virtual void assertTrue(bool condition, const char *checkString, const char *conditionString, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertCstrEqual(const char *expected, const char *actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertCstrNEqual(const char *expected, const char *actual, size_t length, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
virtual void assertCstrNoCaseEqual(const char *expected, const char *actual, const char* text, const char *fileName, size_t lineNumber);
virtual void assertCstrContains(const char *expected, const char *actual, const char* text, const char *fileName, size_t lineNumber);
virtual void assertCstrNoCaseContains(const char *expected, const char *actual, const char* text, const char *fileName, size_t lineNumber);
- virtual void assertLongsEqual(long expected, long actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertUnsignedLongsEqual(unsigned long expected, unsigned long actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertLongLongsEqual(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertUnsignedLongLongsEqual(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertSignedBytesEqual(signed char expected, signed char actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertPointersEqual(const void *expected, const void *actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertFunctionPointersEqual(void (*expected)(), void (*actual)(), const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertDoublesEqual(double expected, double actual, double threshold, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertEquals(bool failed, const char* expected, const char* actual, const char* text, const char* file, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertBinaryEqual(const void *expected, const void *actual, size_t length, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertBitsEqual(unsigned long expected, unsigned long actual, unsigned long mask, size_t byteCount, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void assertCompare(bool comparison, const char *checkString, const char *comparisonString, const char *text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void fail(const char *text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = NormalTestTerminator());
- virtual void exitTest(const TestTerminator& testTerminator = NormalTestTerminator());
+ virtual void assertLongsEqual(long expected, long actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertUnsignedLongsEqual(unsigned long expected, unsigned long actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertLongLongsEqual(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertUnsignedLongLongsEqual(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertSignedBytesEqual(signed char expected, signed char actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertPointersEqual(const void *expected, const void *actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertFunctionPointersEqual(void (*expected)(), void (*actual)(), const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertDoublesEqual(double expected, double actual, double threshold, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertEquals(bool failed, const char* expected, const char* actual, const char* text, const char* file, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertBinaryEqual(const void *expected, const void *actual, size_t length, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertBitsEqual(unsigned long expected, unsigned long actual, unsigned long mask, size_t byteCount, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void assertCompare(bool comparison, const char *checkString, const char *comparisonString, const char *text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void fail(const char *text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator = getCurrentTestTerminator());
+ virtual void exitTest(const TestTerminator& testTerminator = getCurrentTestTerminator());
virtual void print(const char *text, const char *fileName, size_t lineNumber);
virtual void print(const SimpleString & text, const char *fileName, size_t lineNumber);
@@ -153,6 +176,8 @@ class UtestShell
virtual void failWith(const TestFailure& failure);
virtual void failWith(const TestFailure& failure, const TestTerminator& terminator);
+ virtual void addFailure(const TestFailure& failure);
+
protected:
UtestShell();
UtestShell(const char *groupName, const char *testName, const char *fileName, size_t lineNumber, UtestShell *nextTest);
@@ -175,6 +200,9 @@ class UtestShell
static UtestShell* currentTest_;
static TestResult* testResult_;
+ static const TestTerminator *currentTestTerminator_;
+ static const TestTerminator *currentTestTerminatorWithoutExceptions_;
+ static bool rethrowExceptions_;
};
@@ -187,9 +215,9 @@ class ExecFunctionTest : public Utest
{
public:
ExecFunctionTest(ExecFunctionTestShell* shell);
- void testBody() _override;
- virtual void setup() _override;
- virtual void teardown() _override;
+ void testBody() CPPUTEST_OVERRIDE;
+ virtual void setup() CPPUTEST_OVERRIDE;
+ virtual void teardown() CPPUTEST_OVERRIDE;
private:
ExecFunctionTestShell* shell_;
};
@@ -211,9 +239,9 @@ class ExecFunctionWithoutParameters : public ExecFunction
void (*testFunction_)();
ExecFunctionWithoutParameters(void(*testFunction)());
- virtual ~ExecFunctionWithoutParameters() _destructor_override;
+ virtual ~ExecFunctionWithoutParameters() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void exec() _override;
+ virtual void exec() CPPUTEST_OVERRIDE;
};
//////////////////// ExecFunctionTestShell
@@ -230,8 +258,8 @@ class ExecFunctionTestShell : public UtestShell
{
}
- Utest* createTest() _override { return new ExecFunctionTest(this); }
- virtual ~ExecFunctionTestShell() _destructor_override;
+ Utest* createTest() CPPUTEST_OVERRIDE { return new ExecFunctionTest(this); }
+ virtual ~ExecFunctionTestShell() CPPUTEST_DESTRUCTOR_OVERRIDE;
};
//////////////////// CppUTestFailedException
@@ -248,14 +276,14 @@ class IgnoredUtestShell : public UtestShell
{
public:
IgnoredUtestShell();
- virtual ~IgnoredUtestShell() _destructor_override;
+ virtual ~IgnoredUtestShell() CPPUTEST_DESTRUCTOR_OVERRIDE;
explicit IgnoredUtestShell(const char* groupName, const char* testName,
const char* fileName, size_t lineNumber);
- virtual bool willRun() const _override;
- virtual void setRunIgnored() _override;
+ virtual bool willRun() const CPPUTEST_OVERRIDE;
+ virtual void setRunIgnored() CPPUTEST_OVERRIDE;
protected:
- virtual SimpleString getMacroName() const _override;
- virtual void runOneTest(TestPlugin* plugin, TestResult& result) _override;
+ virtual SimpleString getMacroName() const CPPUTEST_OVERRIDE;
+ virtual void runOneTest(TestPlugin* plugin, TestResult& result) CPPUTEST_OVERRIDE;
private:
IgnoredUtestShell(const IgnoredUtestShell&);
diff --git a/include/CppUTest/UtestMacros.h b/include/CppUTest/UtestMacros.h
index 8e144996b..743bf069e 100644
--- a/include/CppUTest/UtestMacros.h
+++ b/include/CppUTest/UtestMacros.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -50,10 +50,10 @@
TEST_GROUP_BASE(testGroup, Utest)
#define TEST_SETUP() \
- virtual void setup()
+ virtual void setup() CPPUTEST_OVERRIDE
#define TEST_TEARDOWN() \
- virtual void teardown()
+ virtual void teardown() CPPUTEST_OVERRIDE
#define TEST(testGroup, testName) \
/* External declarations for strict compilers */ \
@@ -62,9 +62,9 @@
\
class TEST_##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
{ public: TEST_##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
- void testBody() _override; }; \
+ void testBody() CPPUTEST_OVERRIDE; }; \
class TEST_##testGroup##_##testName##_TestShell : public UtestShell { \
- virtual Utest* createTest() _override { return new TEST_##testGroup##_##testName##_Test; } \
+ virtual Utest* createTest() CPPUTEST_OVERRIDE { return new TEST_##testGroup##_##testName##_Test; } \
} TEST_##testGroup##_##testName##_TestShell_instance; \
static TestInstaller TEST_##testGroup##_##testName##_Installer(TEST_##testGroup##_##testName##_TestShell_instance, #testGroup, #testName, __FILE__,__LINE__); \
void TEST_##testGroup##_##testName##_Test::testBody()
@@ -76,9 +76,9 @@
\
class IGNORE##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
{ public: IGNORE##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
- public: void testBody() _override; }; \
+ public: void testBody() CPPUTEST_OVERRIDE; }; \
class IGNORE##testGroup##_##testName##_TestShell : public IgnoredUtestShell { \
- virtual Utest* createTest() _override { return new IGNORE##testGroup##_##testName##_Test; } \
+ virtual Utest* createTest() CPPUTEST_OVERRIDE { return new IGNORE##testGroup##_##testName##_Test; } \
} IGNORE##testGroup##_##testName##_TestShell_instance; \
static TestInstaller TEST_##testGroup##testName##_Installer(IGNORE##testGroup##_##testName##_TestShell_instance, #testGroup, #testName, __FILE__,__LINE__); \
void IGNORE##testGroup##_##testName##_Test::testBody ()
@@ -142,6 +142,10 @@
UtestShell::getCurrent()->assertLongsEqual((long)0, (long)0, NULLPTR, file, line); \
} } while(0)
+#define CHECK_EQUAL_ZERO(actual) CHECK_EQUAL(0, (actual))
+
+#define CHECK_EQUAL_ZERO_TEXT(actual, text) CHECK_EQUAL_TEXT(0, (actual), (text))
+
#define CHECK_COMPARE(first, relop, second)\
CHECK_COMPARE_TEXT(first, relop, second, NULLPTR)
@@ -149,11 +153,15 @@
CHECK_COMPARE_LOCATION(first, relop, second, text, __FILE__, __LINE__)
#define CHECK_COMPARE_LOCATION(first, relop, second, text, file, line)\
- do { SimpleString conditionString;\
- conditionString += StringFrom(first); conditionString += " ";\
- conditionString += #relop; conditionString += " ";\
- conditionString += StringFrom(second);\
- UtestShell::getCurrent()->assertCompare((first) relop (second), "CHECK_COMPARE", conditionString.asCharString(), text, __FILE__, __LINE__);\
+ do {\
+ bool success = (first) relop (second);\
+ if (!success) {\
+ SimpleString conditionString;\
+ conditionString += StringFrom(first); conditionString += " ";\
+ conditionString += #relop; conditionString += " ";\
+ conditionString += StringFrom(second);\
+ UtestShell::getCurrent()->assertCompare(false, "CHECK_COMPARE", conditionString.asCharString(), text, __FILE__, __LINE__);\
+ }\
} while(0)
//This check checks for char* string equality using strcmp.
@@ -217,11 +225,12 @@
UNSIGNED_LONGS_EQUAL_LOCATION((expected), (actual), text, __FILE__, __LINE__)
#define LONGS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertLongsEqual((long)expected, (long)actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertLongsEqual((long)(expected), (long)(actual), text, file, line); } while(0)
#define UNSIGNED_LONGS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertUnsignedLongsEqual((unsigned long)expected, (unsigned long)actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertUnsignedLongsEqual((unsigned long)(expected), (unsigned long)(actual), text, file, line); } while(0)
+#if CPPUTEST_USE_LONG_LONG
#define LONGLONGS_EQUAL(expected, actual)\
LONGLONGS_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__)
@@ -235,10 +244,11 @@
UNSIGNED_LONGLONGS_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__)
#define LONGLONGS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertLongLongsEqual((long long)expected, (long long)actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertLongLongsEqual((cpputest_longlong)(expected), (cpputest_longlong)(actual), text, file, line); } while(0)
#define UNSIGNED_LONGLONGS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertUnsignedLongLongsEqual((unsigned long long)expected, (unsigned long long)actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertUnsignedLongLongsEqual((cpputest_ulonglong)(expected), (cpputest_ulonglong)(actual), text, file, line); } while(0)
+#endif // CPPUTEST_USE_LONG_LONG
#define BYTES_EQUAL(expected, actual)\
LONGS_EQUAL((expected) & 0xff,(actual) & 0xff)
@@ -265,7 +275,7 @@
POINTERS_EQUAL_LOCATION((expected), (actual), text, __FILE__, __LINE__)
#define POINTERS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertPointersEqual((const void *)expected, (const void *)actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertPointersEqual((const void *)(expected), (const void *)(actual), text, file, line); } while(0)
#define FUNCTIONPOINTERS_EQUAL(expected, actual)\
FUNCTIONPOINTERS_EQUAL_LOCATION((expected), (actual), NULLPTR, __FILE__, __LINE__)
@@ -274,7 +284,7 @@
FUNCTIONPOINTERS_EQUAL_LOCATION((expected), (actual), text, __FILE__, __LINE__)
#define FUNCTIONPOINTERS_EQUAL_LOCATION(expected, actual, text, file, line)\
- do { UtestShell::getCurrent()->assertFunctionPointersEqual((void (*)())expected, (void (*)())actual, text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertFunctionPointersEqual((void (*)())(expected), (void (*)())(actual), text, file, line); } while(0)
//Check two doubles for equality within a tolerance threshold
#define DOUBLES_EQUAL(expected, actual, threshold)\
@@ -302,7 +312,7 @@
BITS_LOCATION(expected, actual, mask, text, __FILE__, __LINE__)
#define BITS_LOCATION(expected, actual, mask, text, file, line)\
- do { UtestShell::getCurrent()->assertBitsEqual(expected, actual, mask, sizeof(actual), text, file, line); } while(0)
+ do { UtestShell::getCurrent()->assertBitsEqual(expected, actual, mask, sizeof(actual), text, file, line); } while(0) // NOLINT(bugprone-sizeof-expression)
#define ENUMS_EQUAL_INT(expected, actual)\
ENUMS_EQUAL_TYPE(int, expected, actual)
@@ -353,7 +363,7 @@
#define UT_PRINT(text) \
UT_PRINT_LOCATION(text, __FILE__, __LINE__)
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
#define CHECK_THROWS(expected, expression) \
do { \
SimpleString failure_msg("expected to throw "#expected "\nbut threw nothing"); \
@@ -372,7 +382,7 @@
UtestShell::getCurrent()->countCheck(); \
} \
} while(0)
-#endif /* CPPUTEST_USE_STD_CPP_LIB */
+#endif /* CPPUTEST_HAVE_EXCEPTIONS */
#define UT_CRASH() do { UtestShell::crash(); } while(0)
#define RUN_ALL_TESTS(ac, av) CommandLineTestRunner::RunAllTests(ac, av)
diff --git a/include/CppUTestExt/CodeMemoryReportFormatter.h b/include/CppUTestExt/CodeMemoryReportFormatter.h
index 466784123..6e87fe302 100644
--- a/include/CppUTestExt/CodeMemoryReportFormatter.h
+++ b/include/CppUTestExt/CodeMemoryReportFormatter.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -39,16 +39,16 @@ class CodeMemoryReportFormatter : public MemoryReportFormatter
public:
CodeMemoryReportFormatter(TestMemoryAllocator* internalAllocator);
- virtual ~CodeMemoryReportFormatter() _destructor_override;
+ virtual ~CodeMemoryReportFormatter() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void report_testgroup_start(TestResult* result, UtestShell& test) _override;
- virtual void report_testgroup_end(TestResult* /*result*/, UtestShell& /*test*/) _override {} // LCOV_EXCL_LINE
+ virtual void report_testgroup_start(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void report_testgroup_end(TestResult* /*result*/, UtestShell& /*test*/) CPPUTEST_OVERRIDE {} // LCOV_EXCL_LINE
- virtual void report_test_start(TestResult* result, UtestShell& test) _override;
- virtual void report_test_end(TestResult* result, UtestShell& test) _override;
+ virtual void report_test_start(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void report_test_end(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE;
- virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) _override;
- virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) _override;
+ virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) CPPUTEST_OVERRIDE;
private:
diff --git a/include/CppUTestExt/GMock.h b/include/CppUTestExt/GMock.h
index 71e4c7052..131597371 100644
--- a/include/CppUTestExt/GMock.h
+++ b/include/CppUTestExt/GMock.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTestExt/GTest.h b/include/CppUTestExt/GTest.h
index 1d3a7d124..a2472d3c7 100644
--- a/include/CppUTestExt/GTest.h
+++ b/include/CppUTestExt/GTest.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GTEST__H_
-#define GTEST__H_
+#ifndef GTEST_H_
+#define GTEST_H_
#undef new
#undef strdup
diff --git a/include/CppUTestExt/GTestConvertor.h b/include/CppUTestExt/GTestConvertor.h
index d7853ff1a..c606d6c18 100644
--- a/include/CppUTestExt/GTestConvertor.h
+++ b/include/CppUTestExt/GTestConvertor.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,8 +30,8 @@
#include "CppUTest/Utest.h"
-#ifdef GTEST__H_
-#error "Please include this file before you include any other GTest files"
+#ifdef GTEST_H_
+ #error "Please include this file before you include any other GTest files"
#endif
/*
@@ -63,10 +63,11 @@ class GTestShell : public UtestShell
::testing::TestInfo* testinfo_;
GTestShell* next_;
GTestFlagsThatAllocateMemory* flags_;
+
public:
GTestShell(::testing::TestInfo* testinfo, GTestShell* next, GTestFlagsThatAllocateMemory* flags);
- virtual Utest* createTest() _override;
+ virtual Utest* createTest() CPPUTEST_OVERRIDE;
GTestShell* nextGTest()
{
@@ -101,7 +102,7 @@ class GTestShell : public UtestShell
*
*/
#define GTEST_IMPLEMENTATION_ 1
-#include "src/gtest-internal-inl.h"
+#include "../src/gtest-internal-inl.h"
#include "CppUTest/TestRegistry.h"
#include "CppUTest/TestFailure.h"
@@ -121,7 +122,7 @@ class GTestShell : public UtestShell
class GTestFlagsThatAllocateMemory
{
public:
- void storeValuesOfGTestFLags()
+ void storeValuesOfGTestFlags()
{
GTestFlagcolor = ::testing::GTEST_FLAG(color);
GTestFlagfilter = ::testing::GTEST_FLAG(filter);
@@ -145,7 +146,7 @@ class GTestFlagsThatAllocateMemory
#endif
}
- void setGTestFLagValuesToNULLToAvoidMemoryLeaks()
+ void setGTestFlagValuesToNULLToAvoidMemoryLeaks()
{
#ifndef GTEST_VERSION_GTEST_1_7
::testing::GTEST_FLAG(color) = GTEST_NO_STRING_VALUE;
@@ -207,7 +208,7 @@ class GMockTestTerminator : public TestTerminator
virtual void exitCurrentTest() const
{
/*
- * When using GMock, it throws an exception fromt he destructor leaving
+ * When using GMock, it throws an exception from the destructor leaving
* the system in an unstable state.
* Therefore, when the test fails because of failed gmock expectation
* then don't throw the exception, but let it return. Usually this should
@@ -300,7 +301,7 @@ class GTestUTest: public Utest {
::testing::UnitTest::GetInstance()->impl()->set_current_test_info(NULL);
delete test_;
- flags_->setGTestFLagValuesToNULLToAvoidMemoryLeaks();
+ flags_->setGTestFlagValuesToNULLToAvoidMemoryLeaks();
::testing::internal::DeathTest::set_last_death_test_message(GTEST_NO_STRING_VALUE);
}
@@ -366,7 +367,7 @@ inline void GTestConvertor::createDummyInSequenceToAndFailureReporterAvoidMemory
inline void GTestConvertor::addAllGTestToTestRegistry()
{
createDummyInSequenceToAndFailureReporterAvoidMemoryLeakInGMock();
- flags_.storeValuesOfGTestFLags();
+ flags_.storeValuesOfGTestFlags();
int argc = 2;
const char * argv[] = {"NameOfTheProgram", "--gmock_catch_leaked_mocks=0"};
diff --git a/include/CppUTestExt/GTestSupport.h b/include/CppUTestExt/GTestSupport.h
index 9cbb27bb5..80892a0fa 100644
--- a/include/CppUTestExt/GTestSupport.h
+++ b/include/CppUTestExt/GTestSupport.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,8 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef GTESTSUPPORT__H_
-#define GTESTSUPPORT__H_
+#ifndef GTESTSUPPORT_H_
+#define GTESTSUPPORT_H_
extern void CppuTestGTestIgnoreLeaksInTest();
diff --git a/include/CppUTestExt/IEEE754ExceptionsPlugin.h b/include/CppUTestExt/IEEE754ExceptionsPlugin.h
index 9d3f0cdc1..35a18181f 100644
--- a/include/CppUTestExt/IEEE754ExceptionsPlugin.h
+++ b/include/CppUTestExt/IEEE754ExceptionsPlugin.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -35,8 +35,8 @@ class IEEE754ExceptionsPlugin: public TestPlugin
public:
IEEE754ExceptionsPlugin(const SimpleString& name = "IEEE754ExceptionsPlugin");
- virtual void preTestAction(UtestShell& test, TestResult& result) _override;
- virtual void postTestAction(UtestShell& test, TestResult& result) _override;
+ virtual void preTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
+ virtual void postTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE;
static void disableInexact(void);
static void enableInexact(void);
diff --git a/include/CppUTestExt/MemoryReportAllocator.h b/include/CppUTestExt/MemoryReportAllocator.h
index becdb4ac4..2cca67e25 100644
--- a/include/CppUTestExt/MemoryReportAllocator.h
+++ b/include/CppUTestExt/MemoryReportAllocator.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -40,7 +40,7 @@ class MemoryReportAllocator : public TestMemoryAllocator
MemoryReportFormatter* formatter_;
public:
MemoryReportAllocator();
- virtual ~MemoryReportAllocator() _destructor_override;
+ virtual ~MemoryReportAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE;
virtual void setFormatter(MemoryReportFormatter* formatter);
virtual void setTestResult(TestResult* result);
@@ -48,14 +48,14 @@ class MemoryReportAllocator : public TestMemoryAllocator
virtual TestMemoryAllocator* getRealAllocator();
- virtual char* alloc_memory(size_t size, const char* file, size_t line) _override;
- virtual void free_memory(char* memory, size_t size, const char* file, size_t line) _override;
+ virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE;
- virtual const char* name() const _override;
- virtual const char* alloc_name() const _override;
- virtual const char* free_name() const _override;
+ virtual const char* name() const CPPUTEST_OVERRIDE;
+ virtual const char* alloc_name() const CPPUTEST_OVERRIDE;
+ virtual const char* free_name() const CPPUTEST_OVERRIDE;
- virtual TestMemoryAllocator* actualAllocator() _override;
+ virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE;
};
#endif
diff --git a/include/CppUTestExt/MemoryReportFormatter.h b/include/CppUTestExt/MemoryReportFormatter.h
index d0034b686..2c7af57aa 100644
--- a/include/CppUTestExt/MemoryReportFormatter.h
+++ b/include/CppUTestExt/MemoryReportFormatter.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -50,16 +50,16 @@ class NormalMemoryReportFormatter : public MemoryReportFormatter
{
public:
NormalMemoryReportFormatter();
- virtual ~NormalMemoryReportFormatter() _destructor_override;
+ virtual ~NormalMemoryReportFormatter() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void report_testgroup_start(TestResult* /*result*/, UtestShell& /*test*/) _override;
- virtual void report_testgroup_end(TestResult* /*result*/, UtestShell& /*test*/) _override {} // LCOV_EXCL_LINE
+ virtual void report_testgroup_start(TestResult* /*result*/, UtestShell& /*test*/) CPPUTEST_OVERRIDE;
+ virtual void report_testgroup_end(TestResult* /*result*/, UtestShell& /*test*/) CPPUTEST_OVERRIDE {} // LCOV_EXCL_LINE
- virtual void report_test_start(TestResult* result, UtestShell& test) _override;
- virtual void report_test_end(TestResult* result, UtestShell& test) _override;
+ virtual void report_test_start(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE;
+ virtual void report_test_end(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE;
- virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) _override;
- virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) _override;
+ virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) CPPUTEST_OVERRIDE;
+ virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) CPPUTEST_OVERRIDE;
};
#endif
diff --git a/include/CppUTestExt/MemoryReporterPlugin.h b/include/CppUTestExt/MemoryReporterPlugin.h
index 9874cade6..5b1816f9b 100644
--- a/include/CppUTestExt/MemoryReporterPlugin.h
+++ b/include/CppUTestExt/MemoryReporterPlugin.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,11 +44,11 @@ class MemoryReporterPlugin : public TestPlugin
SimpleString currentTestGroup_;
public:
MemoryReporterPlugin();
- virtual ~MemoryReporterPlugin() _destructor_override;
+ virtual ~MemoryReporterPlugin() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void preTestAction(UtestShell & test, TestResult & result) _override;
- virtual void postTestAction(UtestShell & test, TestResult & result) _override;
- virtual bool parseArguments(int, const char *const *, int) _override;
+ virtual void preTestAction(UtestShell & test, TestResult & result) CPPUTEST_OVERRIDE;
+ virtual void postTestAction(UtestShell & test, TestResult & result) CPPUTEST_OVERRIDE;
+ virtual bool parseArguments(int, const char *const *, int) CPPUTEST_OVERRIDE;
MemoryReportAllocator* getMallocAllocator();
MemoryReportAllocator* getNewAllocator();
diff --git a/include/CppUTestExt/MockActualCall.h b/include/CppUTestExt/MockActualCall.h
index b41c3fdd5..51f2fa7e5 100644
--- a/include/CppUTestExt/MockActualCall.h
+++ b/include/CppUTestExt/MockActualCall.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTestExt/MockCheckedActualCall.h b/include/CppUTestExt/MockCheckedActualCall.h
index fd6ebd0ff..51b12e405 100644
--- a/include/CppUTestExt/MockCheckedActualCall.h
+++ b/include/CppUTestExt/MockCheckedActualCall.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -35,67 +35,68 @@ class MockCheckedActualCall : public MockActualCall
{
public:
MockCheckedActualCall(unsigned int callOrder, MockFailureReporter* reporter, const MockExpectedCallsList& expectations);
- virtual ~MockCheckedActualCall() _destructor_override;
+ virtual ~MockCheckedActualCall() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual MockActualCall& withName(const SimpleString& name) _override;
- virtual MockActualCall& withCallOrder(unsigned int) _override;
- virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value) _override;
- virtual MockActualCall& withIntParameter(const SimpleString& name, int value) _override;
- virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) _override;
- virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value) _override;
- virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) _override;
- virtual MockActualCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) _override;
- virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) _override;
- virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value) _override;
- virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value) _override;
- virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value) _override;
- virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value) _override;
- virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) _override;
- virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) _override;
- virtual MockActualCall& withParameterOfType(const SimpleString& type, const SimpleString& name, const void* value) _override;
- virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output) _override;
- virtual MockActualCall& withOutputParameterOfType(const SimpleString& type, const SimpleString& name, void* output) _override;
+ virtual MockActualCall& withName(const SimpleString& name) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withCallOrder(unsigned int) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withIntParameter(const SimpleString& name, int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withParameterOfType(const SimpleString& type, const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withOutputParameterOfType(const SimpleString& type, const SimpleString& name, void* output) CPPUTEST_OVERRIDE;
- virtual bool hasReturnValue() _override;
- virtual MockNamedValue returnValue() _override;
+ virtual bool hasReturnValue() CPPUTEST_OVERRIDE;
+ virtual MockNamedValue returnValue() CPPUTEST_OVERRIDE;
- virtual bool returnBoolValueOrDefault(bool default_value) _override;
- virtual bool returnBoolValue() _override;
+ virtual bool returnBoolValueOrDefault(bool default_value) CPPUTEST_OVERRIDE;
+ virtual bool returnBoolValue() CPPUTEST_OVERRIDE;
- virtual int returnIntValueOrDefault(int default_value) _override;
- virtual int returnIntValue() _override;
+ virtual int returnIntValueOrDefault(int default_value) CPPUTEST_OVERRIDE;
+ virtual int returnIntValue() CPPUTEST_OVERRIDE;
- virtual unsigned long int returnUnsignedLongIntValue() _override;
- virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) _override;
+ virtual unsigned long int returnUnsignedLongIntValue() CPPUTEST_OVERRIDE;
+ virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) CPPUTEST_OVERRIDE;
- virtual long int returnLongIntValue() _override;
- virtual long int returnLongIntValueOrDefault(long int default_value) _override;
+ virtual long int returnLongIntValue() CPPUTEST_OVERRIDE;
+ virtual long int returnLongIntValueOrDefault(long int default_value) CPPUTEST_OVERRIDE;
- virtual cpputest_ulonglong returnUnsignedLongLongIntValue() _override;
- virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) _override;
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValue() CPPUTEST_OVERRIDE;
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) CPPUTEST_OVERRIDE;
- virtual cpputest_longlong returnLongLongIntValue() _override;
- virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) _override;
+ virtual cpputest_longlong returnLongLongIntValue() CPPUTEST_OVERRIDE;
+ virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) CPPUTEST_OVERRIDE;
- virtual unsigned int returnUnsignedIntValue() _override;
- virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value) _override;
+ virtual unsigned int returnUnsignedIntValue() CPPUTEST_OVERRIDE;
+ virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value) CPPUTEST_OVERRIDE;
- virtual const char * returnStringValueOrDefault(const char * default_value) _override;
- virtual const char * returnStringValue() _override;
+ virtual const char * returnStringValueOrDefault(const char * default_value) CPPUTEST_OVERRIDE;
+ virtual const char * returnStringValue() CPPUTEST_OVERRIDE;
- virtual double returnDoubleValue() _override;
- virtual double returnDoubleValueOrDefault(double default_value) _override;
+ virtual double returnDoubleValue() CPPUTEST_OVERRIDE;
+ virtual double returnDoubleValueOrDefault(double default_value) CPPUTEST_OVERRIDE;
- virtual const void * returnConstPointerValue() _override;
- virtual const void * returnConstPointerValueOrDefault(const void * default_value) _override;
+ virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE;
+ virtual const void * returnConstPointerValueOrDefault(const void * default_value) CPPUTEST_OVERRIDE;
- virtual void * returnPointerValue() _override;
- virtual void * returnPointerValueOrDefault(void *) _override;
+ virtual void * returnPointerValue() CPPUTEST_OVERRIDE;
+ virtual void * returnPointerValueOrDefault(void *) CPPUTEST_OVERRIDE;
- virtual void (*returnFunctionPointerValue())() _override;
- virtual void (*returnFunctionPointerValueOrDefault(void (*)()))() _override;
+ typedef void (*FunctionPointerReturnValue)();
+ virtual FunctionPointerReturnValue returnFunctionPointerValue() CPPUTEST_OVERRIDE;
+ virtual FunctionPointerReturnValue returnFunctionPointerValueOrDefault(void (*)()) CPPUTEST_OVERRIDE;
- virtual MockActualCall& onObject(const void* objectPtr) _override;
+ virtual MockActualCall& onObject(const void* objectPtr) CPPUTEST_OVERRIDE;
virtual bool isFulfilled() const;
virtual bool hasFailed() const;
@@ -149,74 +150,74 @@ class MockCheckedActualCall : public MockActualCall
MockOutputParametersListNode* outputParameterExpectations_;
virtual void addOutputParameter(const SimpleString& name, const SimpleString& type, void* ptr);
- virtual void cleanUpOutputParameterList();
+ void cleanUpOutputParameterList();
};
class MockActualCallTrace : public MockActualCall
{
public:
MockActualCallTrace();
- virtual ~MockActualCallTrace() _destructor_override;
+ virtual ~MockActualCallTrace() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual MockActualCall& withName(const SimpleString& name) _override;
- virtual MockActualCall& withCallOrder(unsigned int) _override;
- virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value) _override;
- virtual MockActualCall& withIntParameter(const SimpleString& name, int value) _override;
- virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) _override;
- virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value) _override;
- virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) _override;
- virtual MockActualCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) _override;
- virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) _override;
- virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value) _override;
- virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value) _override;
- virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value) _override;
- virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value) _override;
- virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) _override;
- virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) _override;
- virtual MockActualCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value) _override;
- virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output) _override;
- virtual MockActualCall& withOutputParameterOfType(const SimpleString& typeName, const SimpleString& name, void* output) _override;
+ virtual MockActualCall& withName(const SimpleString& name) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withCallOrder(unsigned int) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withIntParameter(const SimpleString& name, int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output) CPPUTEST_OVERRIDE;
+ virtual MockActualCall& withOutputParameterOfType(const SimpleString& typeName, const SimpleString& name, void* output) CPPUTEST_OVERRIDE;
- virtual bool hasReturnValue() _override;
- virtual MockNamedValue returnValue() _override;
+ virtual bool hasReturnValue() CPPUTEST_OVERRIDE;
+ virtual MockNamedValue returnValue() CPPUTEST_OVERRIDE;
- virtual bool returnBoolValueOrDefault(bool default_value) _override;
- virtual bool returnBoolValue() _override;
+ virtual bool returnBoolValueOrDefault(bool default_value) CPPUTEST_OVERRIDE;
+ virtual bool returnBoolValue() CPPUTEST_OVERRIDE;
- virtual int returnIntValueOrDefault(int default_value) _override;
- virtual int returnIntValue() _override;
+ virtual int returnIntValueOrDefault(int default_value) CPPUTEST_OVERRIDE;
+ virtual int returnIntValue() CPPUTEST_OVERRIDE;
- virtual unsigned long int returnUnsignedLongIntValue() _override;
- virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) _override;
+ virtual unsigned long int returnUnsignedLongIntValue() CPPUTEST_OVERRIDE;
+ virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) CPPUTEST_OVERRIDE;
- virtual long int returnLongIntValue() _override;
- virtual long int returnLongIntValueOrDefault(long int default_value) _override;
+ virtual long int returnLongIntValue() CPPUTEST_OVERRIDE;
+ virtual long int returnLongIntValueOrDefault(long int default_value) CPPUTEST_OVERRIDE;
- virtual cpputest_ulonglong returnUnsignedLongLongIntValue() _override;
- virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) _override;
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValue() CPPUTEST_OVERRIDE;
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) CPPUTEST_OVERRIDE;
- virtual cpputest_longlong returnLongLongIntValue() _override;
- virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) _override;
+ virtual cpputest_longlong returnLongLongIntValue() CPPUTEST_OVERRIDE;
+ virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) CPPUTEST_OVERRIDE;
- virtual unsigned int returnUnsignedIntValue() _override;
- virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value) _override;
+ virtual unsigned int returnUnsignedIntValue() CPPUTEST_OVERRIDE;
+ virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value) CPPUTEST_OVERRIDE;
- virtual const char * returnStringValueOrDefault(const char * default_value) _override;
- virtual const char * returnStringValue() _override;
+ virtual const char * returnStringValueOrDefault(const char * default_value) CPPUTEST_OVERRIDE;
+ virtual const char * returnStringValue() CPPUTEST_OVERRIDE;
- virtual double returnDoubleValue() _override;
- virtual double returnDoubleValueOrDefault(double default_value) _override;
+ virtual double returnDoubleValue() CPPUTEST_OVERRIDE;
+ virtual double returnDoubleValueOrDefault(double default_value) CPPUTEST_OVERRIDE;
- virtual void * returnPointerValue() _override;
- virtual void * returnPointerValueOrDefault(void *) _override;
+ virtual void * returnPointerValue() CPPUTEST_OVERRIDE;
+ virtual void * returnPointerValueOrDefault(void *) CPPUTEST_OVERRIDE;
- virtual const void * returnConstPointerValue() _override;
- virtual const void * returnConstPointerValueOrDefault(const void * default_value) _override;
+ virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE;
+ virtual const void * returnConstPointerValueOrDefault(const void * default_value) CPPUTEST_OVERRIDE;
- virtual void (*returnFunctionPointerValue())() _override;
- virtual void (*returnFunctionPointerValueOrDefault(void (*)()))() _override;
+ virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValue() CPPUTEST_OVERRIDE;
+ virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValueOrDefault(void (*)()) CPPUTEST_OVERRIDE;
- virtual MockActualCall& onObject(const void* objectPtr) _override;
+ virtual MockActualCall& onObject(const void* objectPtr) CPPUTEST_OVERRIDE;
const char* getTraceOutput();
void clear();
@@ -234,65 +235,83 @@ class MockActualCallTrace : public MockActualCall
class MockIgnoredActualCall: public MockActualCall
{
public:
- virtual MockActualCall& withName(const SimpleString&) _override { return *this;}
- virtual MockActualCall& withCallOrder(unsigned int) _override { return *this; }
- virtual MockActualCall& withBoolParameter(const SimpleString&, bool) _override { return *this; }
- virtual MockActualCall& withIntParameter(const SimpleString&, int) _override { return *this; }
- virtual MockActualCall& withUnsignedIntParameter(const SimpleString&, unsigned int) _override { return *this; }
- virtual MockActualCall& withLongIntParameter(const SimpleString&, long int) _override { return *this; }
- virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString&, unsigned long int) _override { return *this; }
- virtual MockActualCall& withLongLongIntParameter(const SimpleString&, cpputest_longlong) _override { return *this; }
- virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) _override { return *this; }
- virtual MockActualCall& withDoubleParameter(const SimpleString&, double) _override { return *this; }
- virtual MockActualCall& withStringParameter(const SimpleString&, const char*) _override { return *this; }
- virtual MockActualCall& withPointerParameter(const SimpleString& , void*) _override { return *this; }
- virtual MockActualCall& withConstPointerParameter(const SimpleString& , const void*) _override { return *this; }
- virtual MockActualCall& withFunctionPointerParameter(const SimpleString& , void (*)()) _override { return *this; }
- virtual MockActualCall& withMemoryBufferParameter(const SimpleString&, const unsigned char*, size_t) _override { return *this; }
- virtual MockActualCall& withParameterOfType(const SimpleString&, const SimpleString&, const void*) _override { return *this; }
- virtual MockActualCall& withOutputParameter(const SimpleString&, void*) _override { return *this; }
- virtual MockActualCall& withOutputParameterOfType(const SimpleString&, const SimpleString&, void*) _override { return *this; }
-
- virtual bool hasReturnValue() _override { return false; }
- virtual MockNamedValue returnValue() _override { return MockNamedValue(""); }
-
- virtual bool returnBoolValueOrDefault(bool value) _override { return value; }
- virtual bool returnBoolValue() _override { return false; }
-
- virtual int returnIntValue() _override { return 0; }
- virtual int returnIntValueOrDefault(int value) _override { return value; }
-
- virtual unsigned long int returnUnsignedLongIntValue() _override { return 0; }
- virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int value) _override { return value; }
+ virtual MockActualCall& withName(const SimpleString&) CPPUTEST_OVERRIDE { return *this;}
+ virtual MockActualCall& withCallOrder(unsigned int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withBoolParameter(const SimpleString&, bool) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withIntParameter(const SimpleString&, int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withUnsignedIntParameter(const SimpleString&, unsigned int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withLongIntParameter(const SimpleString&, long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString&, unsigned long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withLongLongIntParameter(const SimpleString&, cpputest_longlong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withDoubleParameter(const SimpleString&, double) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withStringParameter(const SimpleString&, const char*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withPointerParameter(const SimpleString& , void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withConstPointerParameter(const SimpleString& , const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withFunctionPointerParameter(const SimpleString& , void (*)()) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withMemoryBufferParameter(const SimpleString&, const unsigned char*, size_t) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withParameterOfType(const SimpleString&, const SimpleString&, const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withOutputParameter(const SimpleString&, void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockActualCall& withOutputParameterOfType(const SimpleString&, const SimpleString&, void*) CPPUTEST_OVERRIDE { return *this; }
+
+ virtual bool hasReturnValue() CPPUTEST_OVERRIDE { return false; }
+ virtual MockNamedValue returnValue() CPPUTEST_OVERRIDE { return MockNamedValue(""); }
+
+ virtual bool returnBoolValueOrDefault(bool value) CPPUTEST_OVERRIDE { return value; }
+ virtual bool returnBoolValue() CPPUTEST_OVERRIDE { return false; }
+
+ virtual int returnIntValue() CPPUTEST_OVERRIDE { return 0; }
+ virtual int returnIntValueOrDefault(int value) CPPUTEST_OVERRIDE { return value; }
+
+ virtual unsigned long int returnUnsignedLongIntValue() CPPUTEST_OVERRIDE { return 0; }
+ virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int value) CPPUTEST_OVERRIDE { return value; }
+
+ virtual long int returnLongIntValue() CPPUTEST_OVERRIDE { return 0; }
+ virtual long int returnLongIntValueOrDefault(long int value) CPPUTEST_OVERRIDE { return value; }
+
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValue() CPPUTEST_OVERRIDE
+ {
+#if CPPUTEST_USE_LONG_LONG
+ return 0;
+#else
+ cpputest_ulonglong ret = {};
+ return ret;
+#endif
+ }
- virtual long int returnLongIntValue() _override { return 0; }
- virtual long int returnLongIntValueOrDefault(long int value) _override { return value; }
+ virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong value) CPPUTEST_OVERRIDE { return value; }
- virtual cpputest_ulonglong returnUnsignedLongLongIntValue() _override { return 0; }
- virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong value) _override { return value; }
+ virtual cpputest_longlong returnLongLongIntValue() CPPUTEST_OVERRIDE
+ {
+#if CPPUTEST_USE_LONG_LONG
+ return 0;
+#else
+ cpputest_longlong ret = {};
+ return ret;
+#endif
+ }
- virtual cpputest_longlong returnLongLongIntValue() _override { return 0; }
- virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong value) _override { return value; }
+ virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong value) CPPUTEST_OVERRIDE { return value; }
- virtual unsigned int returnUnsignedIntValue() _override { return 0; }
- virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int value) _override { return value; }
+ virtual unsigned int returnUnsignedIntValue() CPPUTEST_OVERRIDE { return 0; }
+ virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int value) CPPUTEST_OVERRIDE { return value; }
- virtual double returnDoubleValue() _override { return 0.0; }
- virtual double returnDoubleValueOrDefault(double value) _override { return value; }
+ virtual double returnDoubleValue() CPPUTEST_OVERRIDE { return 0.0; }
+ virtual double returnDoubleValueOrDefault(double value) CPPUTEST_OVERRIDE { return value; }
- virtual const char * returnStringValue() _override { return ""; }
- virtual const char * returnStringValueOrDefault(const char * value) _override { return value; }
+ virtual const char * returnStringValue() CPPUTEST_OVERRIDE { return ""; }
+ virtual const char * returnStringValueOrDefault(const char * value) CPPUTEST_OVERRIDE { return value; }
- virtual void * returnPointerValue() _override { return NULLPTR; }
- virtual void * returnPointerValueOrDefault(void * value) _override { return value; }
+ virtual void * returnPointerValue() CPPUTEST_OVERRIDE { return NULLPTR; }
+ virtual void * returnPointerValueOrDefault(void * value) CPPUTEST_OVERRIDE { return value; }
- virtual const void * returnConstPointerValue() _override { return NULLPTR; }
- virtual const void * returnConstPointerValueOrDefault(const void * value) _override { return value; }
+ virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE { return NULLPTR; }
+ virtual const void * returnConstPointerValueOrDefault(const void * value) CPPUTEST_OVERRIDE { return value; }
- virtual void (*returnFunctionPointerValue())() _override { return NULLPTR; }
- virtual void (*returnFunctionPointerValueOrDefault(void (*value)()))() _override { return value; }
+ virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValue() CPPUTEST_OVERRIDE { return NULLPTR; }
+ virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValueOrDefault(void (*value)()) CPPUTEST_OVERRIDE { return value; }
- virtual MockActualCall& onObject(const void* ) _override { return *this; }
+ virtual MockActualCall& onObject(const void* ) CPPUTEST_OVERRIDE { return *this; }
static MockIgnoredActualCall& instance();
};
diff --git a/include/CppUTestExt/MockCheckedExpectedCall.h b/include/CppUTestExt/MockCheckedExpectedCall.h
index 2079577f0..a1a87fd6e 100644
--- a/include/CppUTestExt/MockCheckedExpectedCall.h
+++ b/include/CppUTestExt/MockCheckedExpectedCall.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,47 +37,47 @@ class MockCheckedExpectedCall : public MockExpectedCall
public:
MockCheckedExpectedCall();
MockCheckedExpectedCall(unsigned int numCalls);
- virtual ~MockCheckedExpectedCall() _destructor_override;
-
- virtual MockExpectedCall& withName(const SimpleString& name) _override;
- virtual MockExpectedCall& withCallOrder(unsigned int callOrder) _override { return withCallOrder(callOrder, callOrder); }
- virtual MockExpectedCall& withCallOrder(unsigned int initialCallOrder, unsigned int finalCallOrder) _override;
- virtual MockExpectedCall& withBoolParameter(const SimpleString& name, bool value) _override;
- virtual MockExpectedCall& withIntParameter(const SimpleString& name, int value) _override;
- virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) _override;
- virtual MockExpectedCall& withLongIntParameter(const SimpleString& name, long int value) _override;
- virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) _override;
- virtual MockExpectedCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) _override;
- virtual MockExpectedCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) _override;
- virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value) _override;
- virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value, double tolerance) _override;
- virtual MockExpectedCall& withStringParameter(const SimpleString& name, const char* value) _override;
- virtual MockExpectedCall& withPointerParameter(const SimpleString& name, void* value) _override;
- virtual MockExpectedCall& withConstPointerParameter(const SimpleString& name, const void* value) _override;
- virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) _override;
- virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) _override;
- virtual MockExpectedCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value) _override;
- virtual MockExpectedCall& withOutputParameterReturning(const SimpleString& name, const void* value, size_t size) _override;
- virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString& typeName, const SimpleString& name, const void* value) _override;
- virtual MockExpectedCall& withUnmodifiedOutputParameter(const SimpleString& name) _override;
- virtual MockExpectedCall& ignoreOtherParameters() _override;
-
- virtual MockExpectedCall& andReturnValue(bool value) _override;
- virtual MockExpectedCall& andReturnValue(int value) _override;
- virtual MockExpectedCall& andReturnValue(unsigned int value) _override;
- virtual MockExpectedCall& andReturnValue(long int value) _override;
- virtual MockExpectedCall& andReturnValue(unsigned long int value) _override;
- virtual MockExpectedCall& andReturnValue(cpputest_longlong value) _override;
- virtual MockExpectedCall& andReturnValue(cpputest_ulonglong value) _override;
- virtual MockExpectedCall& andReturnValue(double value) _override;
- virtual MockExpectedCall& andReturnValue(const char* value) _override;
- virtual MockExpectedCall& andReturnValue(void* value) _override;
- virtual MockExpectedCall& andReturnValue(const void* value) _override;
- virtual MockExpectedCall& andReturnValue(void (*value)()) _override;
+ virtual ~MockCheckedExpectedCall() CPPUTEST_DESTRUCTOR_OVERRIDE;
+
+ virtual MockExpectedCall& withName(const SimpleString& name) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withCallOrder(unsigned int callOrder) CPPUTEST_OVERRIDE { return withCallOrder(callOrder, callOrder); }
+ virtual MockExpectedCall& withCallOrder(unsigned int initialCallOrder, unsigned int finalCallOrder) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withBoolParameter(const SimpleString& name, bool value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withIntParameter(const SimpleString& name, int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withLongIntParameter(const SimpleString& name, long int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value, double tolerance) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withStringParameter(const SimpleString& name, const char* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withPointerParameter(const SimpleString& name, void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withConstPointerParameter(const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& name, void (*value)()) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withOutputParameterReturning(const SimpleString& name, const void* value, size_t size) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString& typeName, const SimpleString& name, const void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& withUnmodifiedOutputParameter(const SimpleString& name) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& ignoreOtherParameters() CPPUTEST_OVERRIDE;
+
+ virtual MockExpectedCall& andReturnValue(bool value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(unsigned int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(long int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(unsigned long int value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(cpputest_longlong value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(cpputest_ulonglong value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(double value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(const char* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(const void* value) CPPUTEST_OVERRIDE;
+ virtual MockExpectedCall& andReturnValue(void (*value)()) CPPUTEST_OVERRIDE;
virtual MockNamedValue returnValue();
- virtual MockExpectedCall& onObject(void* objectPtr) _override;
+ virtual MockExpectedCall& onObject(void* objectPtr) CPPUTEST_OVERRIDE;
virtual MockNamedValue getInputParameter(const SimpleString& name);
virtual MockNamedValue getOutputParameter(const SimpleString& name);
@@ -151,43 +151,43 @@ class MockIgnoredExpectedCall: public MockExpectedCall
{
public:
- virtual MockExpectedCall& withName(const SimpleString&) _override { return *this;}
- virtual MockExpectedCall& withCallOrder(unsigned int) _override { return *this; }
- virtual MockExpectedCall& withCallOrder(unsigned int, unsigned int) _override { return *this; }
- virtual MockExpectedCall& withBoolParameter(const SimpleString&, bool) _override { return *this; }
- virtual MockExpectedCall& withIntParameter(const SimpleString&, int) _override { return *this; }
- virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString&, unsigned int) _override{ return *this; }
- virtual MockExpectedCall& withLongIntParameter(const SimpleString&, long int) _override { return *this; }
- virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString&, unsigned long int) _override { return *this; }
- virtual MockExpectedCall& withLongLongIntParameter(const SimpleString&, cpputest_longlong) _override { return *this; }
- virtual MockExpectedCall& withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) _override { return *this; }
- virtual MockExpectedCall& withDoubleParameter(const SimpleString&, double) _override { return *this; }
- virtual MockExpectedCall& withDoubleParameter(const SimpleString&, double, double) _override { return *this; }
- virtual MockExpectedCall& withStringParameter(const SimpleString&, const char*) _override { return *this; }
- virtual MockExpectedCall& withPointerParameter(const SimpleString& , void*) _override { return *this; }
- virtual MockExpectedCall& withConstPointerParameter(const SimpleString& , const void*) _override { return *this; }
- virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& , void(*)()) _override { return *this; }
- virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString&, const unsigned char*, size_t) _override { return *this; }
- virtual MockExpectedCall& withParameterOfType(const SimpleString&, const SimpleString&, const void*) _override { return *this; }
- virtual MockExpectedCall& withOutputParameterReturning(const SimpleString&, const void*, size_t) _override { return *this; }
- virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString&, const SimpleString&, const void*) _override { return *this; }
- virtual MockExpectedCall& withUnmodifiedOutputParameter(const SimpleString&) _override { return *this; }
- virtual MockExpectedCall& ignoreOtherParameters() _override { return *this;}
-
- virtual MockExpectedCall& andReturnValue(bool) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(int) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(unsigned int) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(long int) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(unsigned long int) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(cpputest_longlong) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(cpputest_ulonglong) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(double) _override { return *this;}
- virtual MockExpectedCall& andReturnValue(const char*) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(void*) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(const void*) _override { return *this; }
- virtual MockExpectedCall& andReturnValue(void (*)()) _override { return *this; }
-
- virtual MockExpectedCall& onObject(void*) _override { return *this; }
+ virtual MockExpectedCall& withName(const SimpleString&) CPPUTEST_OVERRIDE { return *this;}
+ virtual MockExpectedCall& withCallOrder(unsigned int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withCallOrder(unsigned int, unsigned int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withBoolParameter(const SimpleString&, bool) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withIntParameter(const SimpleString&, int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString&, unsigned int) CPPUTEST_OVERRIDE{ return *this; }
+ virtual MockExpectedCall& withLongIntParameter(const SimpleString&, long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString&, unsigned long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withLongLongIntParameter(const SimpleString&, cpputest_longlong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withDoubleParameter(const SimpleString&, double) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withDoubleParameter(const SimpleString&, double, double) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withStringParameter(const SimpleString&, const char*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withPointerParameter(const SimpleString& , void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withConstPointerParameter(const SimpleString& , const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& , void(*)()) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString&, const unsigned char*, size_t) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withParameterOfType(const SimpleString&, const SimpleString&, const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withOutputParameterReturning(const SimpleString&, const void*, size_t) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString&, const SimpleString&, const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& withUnmodifiedOutputParameter(const SimpleString&) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& ignoreOtherParameters() CPPUTEST_OVERRIDE { return *this;}
+
+ virtual MockExpectedCall& andReturnValue(bool) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(unsigned int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(unsigned long int) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(cpputest_longlong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(cpputest_ulonglong) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(double) CPPUTEST_OVERRIDE { return *this;}
+ virtual MockExpectedCall& andReturnValue(const char*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(const void*) CPPUTEST_OVERRIDE { return *this; }
+ virtual MockExpectedCall& andReturnValue(void (*)()) CPPUTEST_OVERRIDE { return *this; }
+
+ virtual MockExpectedCall& onObject(void*) CPPUTEST_OVERRIDE { return *this; }
static MockExpectedCall& instance();
};
diff --git a/include/CppUTestExt/MockExpectedCall.h b/include/CppUTestExt/MockExpectedCall.h
index 51630dc3d..e043de886 100644
--- a/include/CppUTestExt/MockExpectedCall.h
+++ b/include/CppUTestExt/MockExpectedCall.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTestExt/MockExpectedCallsList.h b/include/CppUTestExt/MockExpectedCallsList.h
index 74c920dee..3cb2e651d 100644
--- a/include/CppUTestExt/MockExpectedCallsList.h
+++ b/include/CppUTestExt/MockExpectedCallsList.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -75,7 +75,8 @@ class MockExpectedCallsList
virtual SimpleString unfulfilledCallsToString(const SimpleString& linePrefix = "") const;
virtual SimpleString fulfilledCallsToString(const SimpleString& linePrefix = "") const;
- virtual SimpleString missingParametersToString() const;
+ virtual SimpleString callsWithMissingParametersToString(const SimpleString& linePrefix,
+ const SimpleString& missingParametersPrefix) const;
protected:
virtual void pruneEmptyNodeFromList();
diff --git a/include/CppUTestExt/MockFailure.h b/include/CppUTestExt/MockFailure.h
index af2578575..3ee4f73d3 100644
--- a/include/CppUTestExt/MockFailure.h
+++ b/include/CppUTestExt/MockFailure.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -54,7 +54,7 @@ class MockFailure : public TestFailure
{
public:
MockFailure(UtestShell* test);
- virtual ~MockFailure() _destructor_override {}
+ virtual ~MockFailure() CPPUTEST_DESTRUCTOR_OVERRIDE {}
protected:
void addExpectationsAndCallHistory(const MockExpectedCallsList& expectations);
void addExpectationsAndCallHistoryRelatedTo(const SimpleString& function, const MockExpectedCallsList& expectations);
@@ -93,7 +93,8 @@ class MockUnexpectedOutputParameterFailure : public MockFailure
class MockExpectedParameterDidntHappenFailure : public MockFailure
{
public:
- MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& expectations);
+ MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& allExpectations,
+ const MockExpectedCallsList& matchingExpectations);
};
class MockNoWayToCompareCustomTypeFailure : public MockFailure
diff --git a/include/CppUTestExt/MockNamedValue.h b/include/CppUTestExt/MockNamedValue.h
index 426b70c9d..b6e5be2cc 100644
--- a/include/CppUTestExt/MockNamedValue.h
+++ b/include/CppUTestExt/MockNamedValue.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -69,8 +69,8 @@ class MockFunctionComparator : public MockNamedValueComparator
MockFunctionComparator(isEqualFunction equal, valueToStringFunction valToString)
: equal_(equal), valueToString_(valToString) {}
- virtual bool isEqual(const void* object1, const void* object2) _override { return equal_(object1, object2); }
- virtual SimpleString valueToString(const void* object) _override { return valueToString_(object); }
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE { return equal_(object1, object2); }
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE { return valueToString_(object); }
private:
isEqualFunction equal_;
valueToStringFunction valueToString_;
@@ -83,7 +83,7 @@ class MockFunctionCopier : public MockNamedValueCopier
MockFunctionCopier(copyFunction copier) : copier_(copier) {}
- virtual void copy(void* dst, const void* src) _override { copier_(dst, src); }
+ virtual void copy(void* dst, const void* src) CPPUTEST_OVERRIDE { copier_(dst, src); }
private:
copyFunction copier_;
@@ -167,7 +167,7 @@ class MockNamedValue
unsigned int unsignedIntValue_;
long int longIntValue_;
unsigned long int unsignedLongIntValue_;
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong longLongIntValue_;
cpputest_ulonglong unsignedLongLongIntValue_;
#else
diff --git a/include/CppUTestExt/MockSupport.h b/include/CppUTestExt/MockSupport.h
index 60a5131f1..ea770ab3a 100644
--- a/include/CppUTestExt/MockSupport.h
+++ b/include/CppUTestExt/MockSupport.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/include/CppUTestExt/MockSupportPlugin.h b/include/CppUTestExt/MockSupportPlugin.h
index cc0be2099..b77041c38 100644
--- a/include/CppUTestExt/MockSupportPlugin.h
+++ b/include/CppUTestExt/MockSupportPlugin.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -35,10 +35,10 @@ class MockSupportPlugin : public TestPlugin
{
public:
MockSupportPlugin(const SimpleString& name = "MockSupportPLugin");
- virtual ~MockSupportPlugin() _destructor_override;
+ virtual ~MockSupportPlugin() CPPUTEST_DESTRUCTOR_OVERRIDE;
- virtual void preTestAction(UtestShell&, TestResult&) _override;
- virtual void postTestAction(UtestShell&, TestResult&) _override;
+ virtual void preTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE;
+ virtual void postTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE;
virtual void installComparator(const SimpleString& name, MockNamedValueComparator& comparator);
virtual void installCopier(const SimpleString& name, MockNamedValueCopier& copier);
diff --git a/include/CppUTestExt/MockSupport_c.h b/include/CppUTestExt/MockSupport_c.h
index 32f2b7d40..b133e3682 100644
--- a/include/CppUTestExt/MockSupport_c.h
+++ b/include/CppUTestExt/MockSupport_c.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -61,7 +61,7 @@ typedef struct SMockValue_c
unsigned int unsignedIntValue;
long int longIntValue;
unsigned long int unsignedLongIntValue;
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong longLongIntValue;
cpputest_ulonglong unsignedLongLongIntValue;
#else
diff --git a/include/CppUTestExt/OrderedTest.h b/include/CppUTestExt/OrderedTest.h
index a3687fa99..3db756b2a 100644
--- a/include/CppUTestExt/OrderedTest.h
+++ b/include/CppUTestExt/OrderedTest.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -32,7 +32,7 @@ class OrderedTestShell : public UtestShell
{
public:
OrderedTestShell();
- virtual ~OrderedTestShell() _destructor_override;
+ virtual ~OrderedTestShell() CPPUTEST_DESTRUCTOR_OVERRIDE;
virtual OrderedTestShell* addOrderedTest(OrderedTestShell* test);
virtual OrderedTestShell* getNextOrderedTest();
@@ -71,9 +71,9 @@ class OrderedTestInstaller
extern TEST_##testGroup##_##testName##_TestShell TEST_##testGroup##_##testName##_Instance; \
class TEST_##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
{ public: TEST_##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
- void testBody(); }; \
+ void testBody() CPPUTEST_OVERRIDE; }; \
class TEST_##testGroup##_##testName##_TestShell : public OrderedTestShell { \
- virtual Utest* createTest() _override { return new TEST_##testGroup##_##testName##_Test; } \
+ virtual Utest* createTest() CPPUTEST_OVERRIDE { return new TEST_##testGroup##_##testName##_Test; } \
} TEST_##testGroup##_##testName##_Instance; \
static OrderedTestInstaller TEST_##testGroup##_##testName##_Installer(TEST_##testGroup##_##testName##_Instance, #testGroup, #testName, __FILE__,__LINE__, testLevel); \
void TEST_##testGroup##_##testName##_Test::testBody()
@@ -85,4 +85,3 @@ class OrderedTestInstaller
}
#endif
-
diff --git a/include/Platforms/c2000/stdint.h b/include/Platforms/c2000/stdint.h
index e2831fdc0..3e076a500 100644
--- a/include/Platforms/c2000/stdint.h
+++ b/include/Platforms/c2000/stdint.h
@@ -14,7 +14,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp b/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp
index 47cda0edc..1c977dbde 100644
--- a/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp
+++ b/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp
@@ -14,7 +14,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp b/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp
index 4d7ec09df..d55800a2d 100644
--- a/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp
+++ b/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp
@@ -14,7 +14,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/platforms/Dos/Makefile b/platforms/Dos/Makefile
index 9273c1a2b..7b19cafa4 100644
--- a/platforms/Dos/Makefile
+++ b/platforms/Dos/Makefile
@@ -9,23 +9,33 @@ comma := ,
path_separator := /
drive = $(subst $(CYGDRIVE),$(lastword $(subst /, ,$(CYGDRIVE))):/,$(1))
convert_paths = $(if $(CYGDRIVE),$(subst /,$(path_separator),$(call drive,$(1))),$(1))
+export CPPUTEST_HOME ?= .
-include $(CPPUTEST_HOME)/platforms/Dos/platform.mk
include $(CPPUTEST_HOME)/platforms/Dos/sources.mk
-# Disable W013 unreachable code - it overreacts to CHECK_EQUAL macros
-# Disable W367 conditional expression in if statement is always true - same
-# Disable W368 conditional expression in if statement is always false - same
-# Disable W391 assignment found in boolean expression - we don't care
-
-CFLAGS := \
- -q -c -os -oc -d0 -we -w=3 -wcd=13 -wcd=367 -wcd=368 -wcd391 -wcd=472 -ml -zm \
+COMMONFLAGS := \
+ -q -c -os -oc -d0 -we -w=3 -ml -zm \
-dCPPUTEST_MEM_LEAK_DETECTION_DISABLED=1 -dCPPUTEST_STD_CPP_LIB_DISABLED=1 \
-i$(call convert_paths,$(CPPUTEST_HOME)/include) \
- -i$(call convert_paths,$(CPPUTEST_HOME)/include/Platforms/Dos) \
-i$(call convert_paths,$(WATCOM)/h) -i$(call convert_paths,$(WATCOM)/h/nt) \
-CXXFLAGS := $(CFLAGS) -xds
+# Disable W303 unreferenced parameter - PUNUSED is GNU-specific
+CFLAGS := \
+ $(COMMONFLAGS) \
+ -wcd=303
+
+# Disable W013 unreachable code - it overreacts to CHECK_EQUAL macros
+# Disable W367 conditional expression in if statement is always true - same
+# Disable W368 conditional expression in if statement is always false - same
+# Disable W391 assignment found in boolean expression - we don't care
+CXXFLAGS := \
+ $(COMMONFLAGS) \
+ -wcd=13 \
+ -wcd=367 \
+ -wcd=368 \
+ -wcd=391 \
+ -xds
.PHONY: all clean
@@ -36,7 +46,7 @@ all: CPPU.LIB CPPUX.LIB \
clean:
rm -rf ../src/CppUTest/*.o ../src/CppUTestExt/*.o \
../src/Platforms/dos/*.o ../tests/*.o ../tests/CppUTestExt/*.o \
- *.o *.map *.txt *.LOG *.EXE *.err *.LIB *.LST
+ *.o *.map *.LOG *.EXE *.err *.LIB *.LST
%.o: %.cpp
$(CXX) $(CXXFLAGS) -fo=$(call convert_paths,$@) $(call convert_paths,$<)
@@ -52,3 +62,7 @@ clean:
%.EXE: $$($$*_OBJECTS) | CPPU.LIB CPPUX.LIB
$(LINK) opt q,map,st=50k sys dos lib CPPU.LIB,CPPUX.LIB \
file $(subst $(space),$(comma),$(call convert_paths,$?)) name $@
+
+.PHONY:
+test:
+ $(CPPUTEST_HOME)/platforms/Dos/alltests.sh
diff --git a/platforms/Dos/alltests.sh b/platforms/Dos/alltests.sh
index 2acebbcb9..9c54b3e0b 100755
--- a/platforms/Dos/alltests.sh
+++ b/platforms/Dos/alltests.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+: "${CPPUTEST_HOME:=.}"
+
checkForCppUTestToolsEnvVariable() {
if [ -z "$CPPUTEST_HOME" ] ; then
echo "CPPUTEST_HOME not set. You must set CPPUTEST_HOME to the top level CppUTest directory"
diff --git a/platforms/IAR-STR912.zip b/platforms/IAR-STR912.zip
deleted file mode 100644
index f5e69943e..000000000
Binary files a/platforms/IAR-STR912.zip and /dev/null differ
diff --git a/platforms/armcc/Makefile b/platforms/armcc/Makefile
index 83e64c57a..0bb7c5db9 100644
--- a/platforms/armcc/Makefile
+++ b/platforms/armcc/Makefile
@@ -29,7 +29,6 @@ COMPONENT_NAME := CppUTest
INCLUDE_DIRS :=\
$(CPPUTEST_HOME)/include \
- $(CPPUTEST_HOME)/include/Platforms/armcc \
# armcc system include path
SYS_INCLUDE_DIRS:=$(KEIL_DIR)/include
diff --git a/platforms/iar/CppUTest.ewp b/platforms/iar/CppUTest.ewp
index cef9176ad..f2f1fbe16 100644
--- a/platforms/iar/CppUTest.ewp
+++ b/platforms/iar/CppUTest.ewp
@@ -77,7 +77,7 @@
IarchiveOutput
- C:\Lokalt\test_tools\cpputest\platforms\iar\Debug\Exe\CppUTest.a
+ E:\temp\cpputest\platforms\iar\Debug\Exe\CppUTest.a
@@ -1603,7 +1607,7 @@
ILINK
0
- 17
+ 18
1
0
@@ -1875,7 +1879,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -1891,6 +1895,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
diff --git a/platforms/iar/CppUTestExt.ewp b/platforms/iar/CppUTestExt.ewp
index baafa6ab2..429c3f5cf 100644
--- a/platforms/iar/CppUTestExt.ewp
+++ b/platforms/iar/CppUTestExt.ewp
@@ -77,7 +77,7 @@
OGLastSavedByProductVersion
- 7.70.1.11471
+ 7.80.4.12487
GeneralEnableMisra
@@ -128,7 +128,7 @@
GBECoreSlave
24
- 40
+ 39
OGUseCmsis
@@ -242,7 +242,7 @@
CCAllowList
1
- 00000000
+ 11111110
CCDebugInfo
@@ -262,7 +262,7 @@
IExtraOptions
-
+ --preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h
CCLangConformance
@@ -330,7 +330,7 @@
CCOptLevel
- 1
+ 3
CCOptStrategy
@@ -339,7 +339,7 @@
CCOptLevelSlave
- 1
+ 3
CompilerMisraRules98
@@ -385,7 +385,7 @@
IccRTTI
- 0
+ 1
IccStaticDestr
@@ -644,7 +644,7 @@
ILINK
0
- 17
+ 18
1
1
@@ -916,7 +916,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -932,6 +932,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
@@ -951,7 +955,7 @@
IarchiveOutput
- C:\Lokalt\test_tools\cpputest\platforms\iar\Debug\Exe\CppUTestExt.a
+ E:\temp\cpputest\platforms\iar\Debug\Exe\CppUTestExt.a
@@ -1603,7 +1607,7 @@
ILINK
0
- 17
+ 18
1
0
@@ -1875,7 +1879,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -1891,6 +1895,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
diff --git a/platforms/iar/CppUTestExtTest.ewp b/platforms/iar/CppUTestExtTest.ewp
index 5693a97d1..6ad4084c7 100644
--- a/platforms/iar/CppUTestExtTest.ewp
+++ b/platforms/iar/CppUTestExtTest.ewp
@@ -77,7 +77,7 @@
OGLastSavedByProductVersion
- 7.70.1.11471
+ 7.80.4.12487
GeneralEnableMisra
@@ -101,7 +101,7 @@
OGBufferedTerminalOutput
- 0
+ 1
GenStdoutInterface
@@ -262,7 +262,7 @@
IExtraOptions
-
+ --preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h
CCLangConformance
@@ -335,7 +335,7 @@
CCOptStrategy
0
- 1
+ 0
CCOptLevelSlave
@@ -385,7 +385,7 @@
IccRTTI
- 0
+ 1
IccStaticDestr
@@ -414,7 +414,7 @@
CCOptStrategySlave
0
- 1
+ 0
CCGuardCalls
@@ -644,7 +644,7 @@
ILINK
0
- 17
+ 18
1
1
@@ -697,7 +697,7 @@
IlinkMapFile
- 0
+ 1
IlinkLogFile
@@ -917,7 +917,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -933,6 +933,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
@@ -1604,7 +1608,7 @@
ILINK
0
- 17
+ 18
1
0
@@ -1876,7 +1880,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -1892,6 +1896,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
@@ -2019,17 +2027,20 @@
$PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest.cpp
- $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest_c.c
+ $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest.h
- $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest.h
+ $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest_c.c
warnings
- $PROJ_DIR$\tests\CppUTestExt\AllTests.cpp
+ $PROJ_DIR$\..\..\tests\CppUTestExt\AllTests.cpp
+
+
+ $PROJ_DIR$\tests\iar_argc_argv.c
diff --git a/platforms/iar/CppUTestExtTest.icf b/platforms/iar/CppUTestExtTest.icf
index 2d0a73bfd..23bfb64c3 100644
--- a/platforms/iar/CppUTestExtTest.icf
+++ b/platforms/iar/CppUTestExtTest.icf
@@ -5,7 +5,7 @@
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080;
-define symbol __ICFEDIT_region_IROM1_end__ = 0x0009FFFF;
+define symbol __ICFEDIT_region_IROM1_end__ = 0x000FFFFF;
define symbol __ICFEDIT_region_IROM2_start__ = 0x0;
define symbol __ICFEDIT_region_IROM2_end__ = 0x0;
define symbol __ICFEDIT_region_EROM1_start__ = 0x0;
@@ -25,13 +25,13 @@ define symbol __ICFEDIT_region_ERAM2_end__ = 0x0;
define symbol __ICFEDIT_region_ERAM3_start__ = 0x0;
define symbol __ICFEDIT_region_ERAM3_end__ = 0x0;
/*-Sizes-*/
-define symbol __ICFEDIT_size_cstack__ = 0x600;
+define symbol __ICFEDIT_size_cstack__ = 0x2000;
define symbol __ICFEDIT_size_svcstack__ = 0x100;
define symbol __ICFEDIT_size_irqstack__ = 0x100;
define symbol __ICFEDIT_size_fiqstack__ = 0x100;
define symbol __ICFEDIT_size_undstack__ = 0x100;
define symbol __ICFEDIT_size_abtstack__ = 0x100;
-define symbol __ICFEDIT_size_heap__ = 0x8000;
+define symbol __ICFEDIT_size_heap__ = 0x10000;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
diff --git a/platforms/iar/CppUTestTest.ewp b/platforms/iar/CppUTestTest.ewp
index d9200406c..c1283fe9e 100644
--- a/platforms/iar/CppUTestTest.ewp
+++ b/platforms/iar/CppUTestTest.ewp
@@ -77,7 +77,7 @@
OGLastSavedByProductVersion
- 7.70.1.11471
+ 7.80.4.12487
GeneralEnableMisra
@@ -101,7 +101,7 @@
OGBufferedTerminalOutput
- 0
+ 1
GenStdoutInterface
@@ -128,7 +128,7 @@
GBECoreSlave
24
- 40
+ 39
OGUseCmsis
@@ -262,7 +262,7 @@
IExtraOptions
-
+ --preinclude $PROJ_DIR$\..\..\include\CppUTest\MemoryLeakDetectorForceInclude.h
CCLangConformance
@@ -335,7 +335,7 @@
CCOptStrategy
0
- 1
+ 0
CCOptLevelSlave
@@ -385,7 +385,7 @@
IccRTTI
- 0
+ 1
IccStaticDestr
@@ -414,7 +414,7 @@
CCOptStrategySlave
0
- 1
+ 0
CCGuardCalls
@@ -644,7 +644,7 @@
ILINK
0
- 17
+ 18
1
1
@@ -697,7 +697,7 @@
IlinkMapFile
- 0
+ 1
IlinkLogFile
@@ -916,7 +916,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -932,6 +932,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
@@ -1603,7 +1607,7 @@
ILINK
0
- 17
+ 18
1
0
@@ -1875,7 +1879,7 @@
CrcAlgorithm
- 0
+ 1
1
@@ -1891,6 +1895,10 @@
IlinkLogCallGraph
0
+
+ IlinkIcfFile_AltDefault
+
+
@@ -1942,15 +1950,18 @@
$PROJ_DIR$\..\..\tests\CppUTest\CheatSheetTest.cpp
-
- $PROJ_DIR$\..\..\tests\CppUTest\CompatabilityTests.cpp
-
$PROJ_DIR$\..\..\tests\CppUTest\CommandLineArgumentsTest.cpp
$PROJ_DIR$\..\..\tests\CppUTest\CommandLineTestRunnerTest.cpp
+
+ $PROJ_DIR$\..\..\tests\CppUTest\CompatabilityTests.cpp
+
+
+ $PROJ_DIR$\..\..\tests\CppUTest\DummyMemoryLeakDetector.cpp
+
$PROJ_DIR$\..\..\tests\CppUTest\JUnitOutputTest.cpp
@@ -1975,6 +1986,9 @@
$PROJ_DIR$\..\..\tests\CppUTest\SimpleMutexTest.cpp
+
+ $PROJ_DIR$\..\..\tests\CppUTest\SimpleStringCacheTest.cpp
+
$PROJ_DIR$\..\..\tests\CppUTest\SimpleStringTest.cpp
@@ -2028,7 +2042,10 @@
warnings
- $PROJ_DIR$\tests\AllTests.cpp
+ $PROJ_DIR$\..\..\tests\CppUTest\AllTests.cpp
+
+
+ $PROJ_DIR$\tests\iar_argc_argv.c
diff --git a/platforms/iar/CppUTestTest.icf b/platforms/iar/CppUTestTest.icf
index 2d0a73bfd..23bfb64c3 100644
--- a/platforms/iar/CppUTestTest.icf
+++ b/platforms/iar/CppUTestTest.icf
@@ -5,7 +5,7 @@
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080;
-define symbol __ICFEDIT_region_IROM1_end__ = 0x0009FFFF;
+define symbol __ICFEDIT_region_IROM1_end__ = 0x000FFFFF;
define symbol __ICFEDIT_region_IROM2_start__ = 0x0;
define symbol __ICFEDIT_region_IROM2_end__ = 0x0;
define symbol __ICFEDIT_region_EROM1_start__ = 0x0;
@@ -25,13 +25,13 @@ define symbol __ICFEDIT_region_ERAM2_end__ = 0x0;
define symbol __ICFEDIT_region_ERAM3_start__ = 0x0;
define symbol __ICFEDIT_region_ERAM3_end__ = 0x0;
/*-Sizes-*/
-define symbol __ICFEDIT_size_cstack__ = 0x600;
+define symbol __ICFEDIT_size_cstack__ = 0x2000;
define symbol __ICFEDIT_size_svcstack__ = 0x100;
define symbol __ICFEDIT_size_irqstack__ = 0x100;
define symbol __ICFEDIT_size_fiqstack__ = 0x100;
define symbol __ICFEDIT_size_undstack__ = 0x100;
define symbol __ICFEDIT_size_abtstack__ = 0x100;
-define symbol __ICFEDIT_size_heap__ = 0x8000;
+define symbol __ICFEDIT_size_heap__ = 0x10000;
/**** End of ICF editor section. ###ICF###*/
define memory mem with size = 4G;
diff --git a/platforms/iar/tests/AllTests.cpp b/platforms/iar/tests/AllTests.cpp
deleted file mode 100644
index 5b9de6830..000000000
--- a/platforms/iar/tests/AllTests.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "CppUTest/CommandLineTestRunner.h"
-
-
-int main(int ac, const char** av)
-{
- /* These checks are here to make sure assertions outside test runs don't crash */
- CHECK(true);
- LONGS_EQUAL(1, 1);
- const char * av_override[] = {"exe", "-v"};
-
- int rv = CommandLineTestRunner::RunAllTests(2, av_override);
-
- //Exiting from main causes IAR simulator to issue out-of-bounds memory access warnings.
- volatile int wait = 1;
- while (wait){}
- return rv;
-}
-
diff --git a/platforms/iar/tests/AllTests.h b/platforms/iar/tests/AllTests.h
deleted file mode 100644
index 9e2fb1649..000000000
--- a/platforms/iar/tests/AllTests.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-//Include this in the test main to execute these tests
-IMPORT_TEST_GROUP( Utest);
-IMPORT_TEST_GROUP( Failure);
-IMPORT_TEST_GROUP( TestOutput);
-IMPORT_TEST_GROUP( SimpleString);
-IMPORT_TEST_GROUP( TestInstaller);
-IMPORT_TEST_GROUP( NullTest);
-IMPORT_TEST_GROUP( MemoryLeakWarningTest);
-IMPORT_TEST_GROUP( TestHarness_c);
-IMPORT_TEST_GROUP( CommandLineTestRunner);
-IMPORT_TEST_GROUP( JUnitOutputTest);
-IMPORT_TEST_GROUP( MemoryLeakDetectorTest);
-
-/* In allTest.cpp */
-IMPORT_TEST_GROUP(CheatSheet);
-
diff --git a/platforms/iar/tests/CppUTestExt/AllTests.cpp b/platforms/iar/tests/CppUTestExt/AllTests.cpp
deleted file mode 100644
index ac048b20f..000000000
--- a/platforms/iar/tests/CppUTestExt/AllTests.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTest/TestRegistry.h"
-#include "CppUTestExt/MemoryReporterPlugin.h"
-#include "CppUTestExt/MockSupportPlugin.h"
-
-#ifdef CPPUTEST_INCLUDE_GTEST_TESTS
-#include "CppUTestExt/GTestConvertor.h"
-#endif
-
-int main(int ac, const char** av)
-{
- const char * av_override[] = {"exe", "-v"};
-#ifdef CPPUTEST_INCLUDE_GTEST_TESTS
- GTestConvertor convertor;
- convertor.addAllGTestToTestRegistry();
-#endif
-
- MemoryReporterPlugin plugin;
- MockSupportPlugin mockPlugin;
- TestRegistry::getCurrentRegistry()->installPlugin(&plugin);
- TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin);
-
-#ifndef GMOCK_RENAME_MAIN
- int rv = CommandLineTestRunner::RunAllTests(2, av_override);
-#else
- /* Don't have any memory leak detector when running the Google Test tests */
-
- testing::GMOCK_FLAG(verbose) = testing::internal::kWarningVerbosity;
-
- ConsoleTestOutput output;
- CommandLineTestRunner runner(ac, av, &output, TestRegistry::getCurrentRegistry());
- return runner.runAllTestsMain();
-#endif
-
- //Exiting from main causes IAR simulator to issue out-of-bounds memory access warnings.
- volatile int wait = 1;
- while (wait){}
- return rv;
-}
-
diff --git a/platforms/iar/tests/iar_argc_argv.c b/platforms/iar/tests/iar_argc_argv.c
new file mode 100644
index 000000000..e12de9d41
--- /dev/null
+++ b/platforms/iar/tests/iar_argc_argv.c
@@ -0,0 +1,14 @@
+#define NUM_ARGS 2
+
+static char __argvbuf0[] = {"exe"};
+static char __argvbuf1[] = {"-v"};
+
+static int __argc = NUM_ARGS;
+static char * __argv[NUM_ARGS] = { __argvbuf0, __argvbuf1 };
+
+void __iar_argc_argv(void)
+{
+ // setup R0 (argc) and R1 (argv) arguments to main (see cmain.s)
+ asm volatile ("MOVS R1, %0" : : "r" (__argv));
+ asm volatile ("MOVS R0, %0" : : "r" (__argc));
+}
diff --git a/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp b/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp
index e1eac674c..8199883d5 100644
--- a/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp
+++ b/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/platforms_examples/armcc/LPC1768/tests/main.cpp b/platforms_examples/armcc/LPC1768/tests/main.cpp
index b8dd10eec..254b171ae 100644
--- a/platforms_examples/armcc/LPC1768/tests/main.cpp
+++ b/platforms_examples/armcc/LPC1768/tests/main.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/platforms_examples/armcc/LPC1833/tests/main.cpp b/platforms_examples/armcc/LPC1833/tests/main.cpp
index 90f317a05..f1299259f 100644
--- a/platforms_examples/armcc/LPC1833/tests/main.cpp
+++ b/platforms_examples/armcc/LPC1833/tests/main.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/scripts/README.txt b/scripts/README.txt
index 2ca147527..c6adab6f0 100644
--- a/scripts/README.txt
+++ b/scripts/README.txt
@@ -14,7 +14,7 @@ Like this:
You might have to add the execute privilege to the shell scripts.
Like this:
- chmod *.sh
+ chmod +x *.sh
Using NewClass for example:
cd to the directory where you want the files located
diff --git a/scripts/VS2010Templates/CppUTest_VS2010.props b/scripts/VS2010Templates/CppUTest_VS2010.props
index fad877723..7655261a1 100644
--- a/scripts/VS2010Templates/CppUTest_VS2010.props
+++ b/scripts/VS2010Templates/CppUTest_VS2010.props
@@ -2,9 +2,9 @@
- $(CPPUTEST_HOME)\include;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGTest;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGMock;$(CPPUTEST_HOME)\include\Platforms\VisualCpp
+ $(CPPUTEST_HOME)\include;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGTest;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGMock
$(CPPUTEST_HOME)\lib
- $(CPPUTEST_HOME)\include\Platforms\VisualCpp\Platform.h;$(CPPUTEST_HOME)\include\CppUTest\MemoryLeakDetectorMallocMacros.h;
+ $(CPPUTEST_HOME)\include\CppUTest\MemoryLeakDetectorMallocMacros.h;
CppUTest.lib
diff --git a/scripts/appveyor_ci_build.ps1 b/scripts/appveyor_ci_build.ps1
index 9bb238a61..5f33eacd6 100644
--- a/scripts/appveyor_ci_build.ps1
+++ b/scripts/appveyor_ci_build.ps1
@@ -2,6 +2,8 @@
# Load functions from the helper file
. (Join-Path (Split-Path $MyInvocation.MyCommand.Path) 'appveyor_helpers.ps1')
+mkdir cpputest_build
+
function Invoke-BuildCommand($command, $directory = '.')
{
$command_wrapped = "$command;`$err = `$?"
@@ -76,8 +78,8 @@ switch -Wildcard ($env:Platform)
if ($env:Platform -like 'MinGWClang*')
{
$toolchain_filename = Get-ClangToolchainFilename
- $toolchain_path = (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "..\cmake\$toolchain_filename")
- $toolchain = "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path"
+ $toolchain_path = (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "..\cmake\Toolchains\$toolchain_filename")
+ $toolchain = "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path -DCPPUTEST_WERROR=OFF"
}
# Add mingw to the path
diff --git a/scripts/filterGcov.sh b/scripts/filterGcov.sh
index 2f6ec1d41..b3ff67fee 100755
--- a/scripts/filterGcov.sh
+++ b/scripts/filterGcov.sh
@@ -22,7 +22,7 @@ getRidOfCruft() {
sed '-e s/^Lines.*://g' \
'-e s/^[0-9]\./ &/g' \
'-e s/^[0-9][0-9]\./ &/g' \
- '-e s/of.*File/ /g' \
+ '-e s/of.\w[^'File']*File/ /g' \
"-e s/'//g" \
'-e s/^.*\/usr\/.*$//g' \
'-e s/^.*\.$//g'
diff --git a/scripts/templates/ProjectTemplate/ProjectMakefile b/scripts/templates/ProjectTemplate/ProjectMakefile
index 68747610f..f426016c8 100644
--- a/scripts/templates/ProjectTemplate/ProjectMakefile
+++ b/scripts/templates/ProjectTemplate/ProjectMakefile
@@ -32,7 +32,6 @@ INCLUDE_DIRS =\
include \
include/* \
$(CPPUTEST_HOME)/include/ \
- $(CPPUTEST_HOME)/include/Platforms/Gcc\
mocks
CPPUTEST_WARNINGFLAGS = -Wall -Werror -Wswitch-default
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 000000000..8bee1d9b8
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_subdirectory(CppUTest)
+if (CPPUTEST_EXTENSIONS)
+ add_subdirectory(CppUTestExt)
+endif ()
diff --git a/src/CppUTest/CMakeIntegration-README.md b/src/CppUTest/CMakeIntegration-README.md
index d39bcced8..74ec44aaa 100644
--- a/src/CppUTest/CMakeIntegration-README.md
+++ b/src/CppUTest/CMakeIntegration-README.md
@@ -1,24 +1,110 @@
-It is possible to integrate CppUTest as a sub-module of an enclosing CMake
-project. This may be useful if CppUTest is being built for a target platform
-other than that of the development host. The following is an example how an
-external project can refer to this CMakeLists.txt to build CppUTest as a
+# CMake Integration
+
+## FetchContent
+
+CMake can automatically download and integrate CppUTest with
+[`FetchContent`](https://cmake.org/cmake/help/latest/module/FetchContent.html).
+This is the recommended strategy for CMake integration.
+
+```cmake
+cmake_minimum_required(VERSION 3.11)
+project(trying_CppUtest)
+
+include(FetchContent)
+FetchContent_Declare(
+ CppUTest
+ GIT_REPOSITORY https://github.com/cpputest/cpputest.git
+ GIT_TAG master # or use release tag, eg. v4.0
+ # FIND_PACKAGE_ARGS # Recent CMake versions can integrate FetchContent with find_package
+ # https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package
+)
+
+# Either set CPPUTEST_PLATFORM to off and # provide a project-specific
+# platform.cpp, assign # one of the provided platforms under
+# src/Platforms/ # (as shown below), or let CppUTest
+# select an appropriate default.
+set(CPPUTEST_PLATFORM Gcc STRING BOOL "Platform implementation")
+
+FetchContent_MakeAvailable(CppUTest)
+
+add_executable(trying_CppUtest main.cpp)
+
+target_link_libraries(trying_CppUtest
+ PRIVATE
+ CppUTest::CppUTest
+ #or CppUTest::CppUTestExt
+)
+
+include(CTest) # Enable testing
+
+# automatically discover CppUTest tests
+include(CppUTest)
+cpputest_discover_tests(trying_CppUtest)
+```
+
+## System install
+
+If CppUTest has been installed on the system, it can be integrated with
+[`find_package`](https://cmake.org/cmake/help/latest/command/find_package.html).
+The target platform will be the same as the development host.
+This is useful for managing a common
+CppUTest installation with the system's package manager.
+
+```cmake
+cmake_minimum_required(VERSION 3.10)
+project(trying_CppUtest)
+
+find_package(CppUTest REQUIRED)
+
+add_executable(trying_CppUtest main.cpp)
+
+target_link_libraries(trying_CppUtest
+ PRIVATE
+ CppUTest
+ #or CppUTestExt
+)
+
+include(CTest) # Enable testing
+
+# automatically discover CppUTest tests
+include(CppUTest)
+cpputest_discover_tests(trying_CppUtest)
+```
+
+## Shared directory
+
+It is possible to integrate CppUTest from a local directory. This may be useful
+if CppUTest is being built for a target platform other than that of the
+development host and CMake 3.11 is not available. The following is an example
+how an external project can refer to this CMakeLists.txt to build CppUTest as a
library and include it as a target dependency.
```cmake
-cmake_minimum_required(VERSION 3.7)
+cmake_minimum_required(VERSION 3.10)
project(trying_CppUtest)
SET(CppUTestRootDirectory /path/to/cpputest)
-# Either set CPP_PLATFORM to one of the provided platforms under
-# ${CppUTestRootDirectory}/src/Platforms/, or provide a project-specific
+# Either set CPPUTEST_PLATFORM to one of the provided platforms under
+# /src/Platforms/, or provide a project-specific
# platform.cpp (as shown below)
-add_subdirectory(${CppUTestRootDirectory}/src/CppUTest CppUTest)
+set(CPPUTEST_PLATFORM OFF CACHE BOOL "Platform implementation")
+add_subdirectory(${CppUTestRootDirectory} CppUTest)
target_sources(CppUTest
- PRIVATE
- ${PROJECT_SOURCE_DIR}/UtestPlatform.cpp
+ PRIVATE
+ ${PROJECT_SOURCE_DIR}/UtestPlatform.cpp
)
add_executable(trying_CppUtest main.cpp)
-target_link_libraries(trying_CppUtest CppUTest)
+target_link_libraries(trying_CppUtest
+ PRIVATE
+ CppUTest::CppUTest
+ #or CppUTest::CppUTestExt
+)
+
+include(CTest) # Enable testing
+
+# automatically discover CppUTest tests
+include(CppUTest)
+cpputest_discover_tests(trying_CppUtest)
```
diff --git a/src/CppUTest/CMakeLists.txt b/src/CppUTest/CMakeLists.txt
index 81eda28df..f7c737b0c 100644
--- a/src/CppUTest/CMakeLists.txt
+++ b/src/CppUTest/CMakeLists.txt
@@ -18,62 +18,110 @@ add_library(CppUTest
TestTestingFixture.cpp
SimpleMutex.cpp
Utest.cpp
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/CommandLineArguments.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/PlatformSpecificFunctions.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestMemoryAllocator.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/CommandLineTestRunner.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/PlatformSpecificFunctions_c.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestOutput.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/CppUTestConfig.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/SimpleString.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/SimpleStringInternalCache.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestPlugin.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/JUnitTestOutput.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TeamCityTestOutput.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/StandardCLibrary.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestRegistry.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetector.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestFailure.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestResult.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorMallocMacros.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestFilter.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestTestingFixture.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorNewMacros.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorForceInclude.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestHarness.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/Utest.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/MemoryLeakWarningPlugin.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/TestHarness_c.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/UtestMacros.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTest/SimpleMutex.h
)
-#[[Set CPP_PLATFORM in a parent CMakeLists.txt if reusing one of the provided platforms, else supply the missing definitions]]
-if (CPP_PLATFORM)
+#[[Set CPPUTEST_PLATFORM in a parent CMakeLists.txt if reusing one of the provided platforms, else supply the missing definitions]]
+if(CPPUTEST_PLATFORM)
target_sources(CppUTest
PRIVATE
- ../Platforms/${CPP_PLATFORM}/UtestPlatform.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/../Platforms/${CPPUTEST_PLATFORM}/UtestPlatform.cpp
)
-endif(CPP_PLATFORM)
+endif()
+
+if(CPPUTEST_PLATFORM STREQUAL "c2000")
+ target_include_directories(CppUTest
+ PUBLIC
+ $
+ )
+elseif(CPPUTEST_PLATFORM STREQUAL "Iar")
+ target_compile_options(CppUTest
+ PRIVATE
+ --dlib_config full
+ )
+endif()
+
+if (MINGW)
+ include(CheckStructHasMember)
+ check_struct_has_member("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC LANGUAGE CXX)
+endif()
#[[Arrange for the include directory to be added to the include paths of any CMake target depending on CppUTest.]]
target_include_directories(CppUTest
PUBLIC
- $
- $
+ $
+ $
+)
+
+target_compile_definitions(CppUTest
+ PRIVATE
+ $<$:STDC_WANT_SECURE_LIB>
+ # Apply workaround for MinGW timespec redefinition (pthread.h / time.h).
+ $<$:_TIMESPEC_DEFINED>
)
-set(CppUTest_headers
- ${CppUTestRootDirectory}/include/CppUTest/CommandLineArguments.h
- ${CppUTestRootDirectory}/include/CppUTest/PlatformSpecificFunctions.h
- ${CppUTestRootDirectory}/include/CppUTest/TestMemoryAllocator.h
- ${CppUTestRootDirectory}/include/CppUTest/CommandLineTestRunner.h
- ${CppUTestRootDirectory}/include/CppUTest/PlatformSpecificFunctions_c.h
- ${CppUTestRootDirectory}/include/CppUTest/TestOutput.h
- ${CppUTestRootDirectory}/include/CppUTest/CppUTestConfig.h
- ${CppUTestRootDirectory}/include/CppUTest/SimpleString.h
- ${CppUTestRootDirectory}/include/CppUTest/SimpleStringInternalCache.h
- ${CppUTestRootDirectory}/include/CppUTest/TestPlugin.h
- ${CppUTestRootDirectory}/include/CppUTest/JUnitTestOutput.h
- ${CppUTestRootDirectory}/include/CppUTest/TeamCityTestOutput.h
- ${CppUTestRootDirectory}/include/CppUTest/StandardCLibrary.h
- ${CppUTestRootDirectory}/include/CppUTest/TestRegistry.h
- ${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetector.h
- ${CppUTestRootDirectory}/include/CppUTest/TestFailure.h
- ${CppUTestRootDirectory}/include/CppUTest/TestResult.h
- ${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorMallocMacros.h
- ${CppUTestRootDirectory}/include/CppUTest/TestFilter.h
- ${CppUTestRootDirectory}/include/CppUTest/TestTestingFixture.h
- ${CppUTestRootDirectory}/include/CppUTest/MemoryLeakDetectorNewMacros.h
- ${CppUTestRootDirectory}/include/CppUTest/TestHarness.h
- ${CppUTestRootDirectory}/include/CppUTest/Utest.h
- ${CppUTestRootDirectory}/include/CppUTest/MemoryLeakWarningPlugin.h
- ${CppUTestRootDirectory}/include/CppUTest/TestHarness_c.h
- ${CppUTestRootDirectory}/include/CppUTest/UtestMacros.h
- ${CppUTestRootDirectory}/include/CppUTest/SimpleMutex.h
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+
+target_link_libraries(CppUTest
+ PRIVATE
+ $<$:winmm>
+ $<$:${CMAKE_THREAD_LIBS_INIT}>
)
-set_target_properties(CppUTest PROPERTIES
- PUBLIC_HEADER "${CppUTest_headers}")
+add_library(CppUTest::CppUTest ALIAS CppUTest)
+
+if(NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
+ if(MSVC)
+ set(force_include "/FI")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IAR")
+ set(force_include "--preinclude=")
+ else()
+ set(force_include "-include")
+ endif()
+ target_compile_options(CppUTest
+ PUBLIC
+ ${force_include}CppUTest/MemoryLeakDetectorForceInclude.h
+ )
+endif()
-if (WIN32)
- target_link_libraries(CppUTest winmm.lib)
-endif (WIN32)
-install(TARGETS CppUTest
- EXPORT CppUTestTargets
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CppUTest"
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CppUTest")
+# Installation
+if(PROJECT_IS_TOP_LEVEL)
+ install(
+ TARGETS CppUTest
+ EXPORT CppUTestTargets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+ install(
+ DIRECTORY "${PROJECT_SOURCE_DIR}/include/CppUTest"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ )
+endif()
diff --git a/src/CppUTest/CommandLineArguments.cpp b/src/CppUTest/CommandLineArguments.cpp
index 627ec757a..e3d1a8cbe 100644
--- a/src/CppUTest/CommandLineArguments.cpp
+++ b/src/CppUTest/CommandLineArguments.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,7 +30,10 @@
#include "CppUTest/PlatformSpecificFunctions.h"
CommandLineArguments::CommandLineArguments(int ac, const char *const *av) :
- ac_(ac), av_(av), needHelp_(false), verbose_(false), veryVerbose_(false), color_(false), runTestsAsSeperateProcess_(false), listTestGroupNames_(false), listTestGroupAndCaseNames_(false), runIgnored_(false), reversing_(false), shuffling_(false), shufflingPreSeeded_(false), repeat_(1), shuffleSeed_(0), groupFilters_(NULLPTR), nameFilters_(NULLPTR), outputType_(OUTPUT_ECLIPSE)
+ ac_(ac), av_(av), needHelp_(false), verbose_(false), veryVerbose_(false), color_(false), runTestsAsSeperateProcess_(false),
+ listTestGroupNames_(false), listTestGroupAndCaseNames_(false), listTestLocations_(false), runIgnored_(false), reversing_(false),
+ crashOnFail_(false), rethrowExceptions_(true), shuffling_(false), shufflingPreSeeded_(false), repeat_(1), shuffleSeed_(0),
+ groupFilters_(NULLPTR), nameFilters_(NULLPTR), outputType_(OUTPUT_ECLIPSE)
{
}
@@ -65,10 +68,16 @@ bool CommandLineArguments::parse(TestPlugin* plugin)
else if (argument == "-b") reversing_ = true;
else if (argument == "-lg") listTestGroupNames_ = true;
else if (argument == "-ln") listTestGroupAndCaseNames_ = true;
+ else if (argument == "-ll") listTestLocations_ = true;
else if (argument == "-ri") runIgnored_ = true;
+ else if (argument == "-f") crashOnFail_ = true;
+ else if ((argument == "-e") || (argument == "-ci")) rethrowExceptions_ = false;
else if (argument.startsWith("-r")) setRepeatCount(ac_, av_, i);
else if (argument.startsWith("-g")) addGroupFilter(ac_, av_, i);
- else if (argument.startsWith("-t")) correctParameters = addGroupDotNameFilter(ac_, av_, i);
+ else if (argument.startsWith("-t")) correctParameters = addGroupDotNameFilter(ac_, av_, i, "-t", false, false);
+ else if (argument.startsWith("-st")) correctParameters = addGroupDotNameFilter(ac_, av_, i, "-st", true, false);
+ else if (argument.startsWith("-xt")) correctParameters = addGroupDotNameFilter(ac_, av_, i, "-xt", false, true);
+ else if (argument.startsWith("-xst")) correctParameters = addGroupDotNameFilter(ac_, av_, i, "-xst", true, true);
else if (argument.startsWith("-sg")) addStrictGroupFilter(ac_, av_, i);
else if (argument.startsWith("-xg")) addExcludeGroupFilter(ac_, av_, i);
else if (argument.startsWith("-xsg")) addExcludeStrictGroupFilter(ac_, av_, i);
@@ -93,9 +102,11 @@ bool CommandLineArguments::parse(TestPlugin* plugin)
const char* CommandLineArguments::usage() const
{
- return "use -h for more extensive help\nusage [-h] [-v] [-vv] [-c] [-p] [-lg] [-ln] [-ri] [-r#]\n"
- " [-g|sg|xg|xsg groupName]... [-n|sn|xn|xsn testName]... [-t groupName.testName]...\n"
- " [-b] [-s [randomizerSeed>0]] [\"TEST(groupName, testName)\"]... [-o{normal, junit, teamcity}] [-k packageName]\n";
+ return "use -h for more extensive help\n"
+ "usage [-h] [-v] [-vv] [-c] [-p] [-lg] [-ln] [-ll] [-ri] [-r[<#>]] [-f] [-e] [-ci]\n"
+ " [-g|sg|xg|xsg ]... [-n|sn|xn|xsn ]... [-t|st|xt|xst .]...\n"
+ " [-b] [-s []] [\"[IGNORE_]TEST(, )\"]...\n"
+ " [-o{normal|eclipse|junit|teamcity}] [-k ]\n";
}
const char* CommandLineArguments::help() const
@@ -104,9 +115,10 @@ const char* CommandLineArguments::help() const
"Thanks for using CppUTest.\n"
"\n"
"Options that do not run tests but query:\n"
- " -h - this wonderful help screen. Joy!\n"
- " -lg - print a list of group names, separated by spaces\n"
- " -ln - print a list of test names in the form of group.name, separated by spaces\n"
+ " -h - this wonderful help screen. Joy!\n"
+ " -lg - print a list of group names, separated by spaces\n"
+ " -ln - print a list of test names in the form of group.name, separated by spaces\n"
+ " -ll - print a list of test names in the form of group.name.test_file_path.line\n"
"\n"
"Options that change the output format:\n"
" -c - colorize output, print green if OK, or red if failed\n"
@@ -114,27 +126,38 @@ const char* CommandLineArguments::help() const
" -vv - very verbose, print internal information during test run\n"
"\n"
"Options that change the output location:\n"
- " -oteamcity - output to xml files (as the name suggests, for TeamCity)\n"
- " -ojunit - output to JUnit ant plugin style xml files (for CI systems)\n"
- " -k package name - Add a package name in JUnit output (for classification in CI systems)\n"
+ " -onormal - no output to files\n"
+ " -oeclipse - equivalent to -onormal\n"
+ " -oteamcity - output to xml files (as the name suggests, for TeamCity)\n"
+ " -ojunit - output to JUnit ant plugin style xml files (for CI systems)\n"
+ " -k - add a package name in JUnit output (for classification in CI systems)\n"
"\n"
"\n"
"Options that control which tests are run:\n"
- " -g group - only run test whose group contains the substring group\n"
- " -n name - only run test whose name contains the substring name\n"
- " -t group.name - only run test whose name contains the substring group and name\n"
- " -sg group - only run test whose group exactly matches the string group\n"
- " -sn name - only run test whose name exactly matches the string name\n"
- " -xg group - exclude tests whose group contains the substring group (v3.8)\n"
- " -xn name - exclude tests whose name contains the substring name (v3.8)\n"
- " TEST(group,name) - only run test whose group and name matches the strings group and name.\n"
- " This can be used to copy-paste output from the -v option on the command line.\n"
+ " -g - only run tests whose group contains \n"
+ " -n - only run tests whose name contains \n"
+ " -t . - only run tests whose group and name contain and \n"
+ " -sg - only run tests whose group exactly matches \n"
+ " -sn - only run tests whose name exactly matches \n"
+ " -st . - only run tests whose group and name exactly match and \n"
+ " -xg - exclude tests whose group contains \n"
+ " -xn - exclude tests whose name contains \n"
+ " -xt . - exclude tests whose group and name contain and \n"
+ " -xsg - exclude tests whose group exactly matches \n"
+ " -xsn - exclude tests whose name exactly matches \n"
+ " -xst . - exclude tests whose group and name exactly match and \n"
+ " \"[IGNORE_]TEST(, )\"\n"
+ " - only run tests whose group and name exactly match and \n"
+ " (this can be used to copy-paste output from the -v option on the command line)\n"
"\n"
"Options that control how the tests are run:\n"
- " -p - run tests in a separate process.\n"
- " -b - run the tests backwards, reversing the normal way\n"
- " -s [seed] - shuffle tests randomly. Seed is optional\n"
- " -r# - repeat the tests some number (#) of times, or twice if # is not specified.\n";
+ " -p - run tests in a separate process\n"
+ " -b - run the tests backwards, reversing the normal way\n"
+ " -s [] - shuffle tests randomly (randomization seed is optional, must be greater than 0)\n"
+ " -r[<#>] - repeat the tests <#> times (or twice if <#> is not specified)\n"
+ " -f - Cause the tests to crash on failure (to allow the test to be debugged if necessary)\n"
+ " -e - do not rethrow unexpected exceptions on failure\n"
+ " -ci - continuous integration mode (equivalent to -e)\n";
}
bool CommandLineArguments::needHelp() const
@@ -167,6 +190,11 @@ bool CommandLineArguments::isListingTestGroupAndCaseNames() const
return listTestGroupAndCaseNames_;
}
+bool CommandLineArguments::isListingTestLocations() const
+{
+ return listTestLocations_;
+}
+
bool CommandLineArguments::isRunIgnored() const
{
return runIgnored_;
@@ -188,6 +216,16 @@ bool CommandLineArguments::isReversing() const
return reversing_;
}
+bool CommandLineArguments::isCrashingOnFail() const
+{
+ return crashOnFail_;
+}
+
+bool CommandLineArguments::isRethrowingExceptions() const
+{
+ return rethrowExceptions_;
+}
+
bool CommandLineArguments::isShuffling() const
{
return shuffling_;
@@ -260,16 +298,29 @@ void CommandLineArguments::addGroupFilter(int ac, const char *const *av, int& i)
groupFilters_ = groupFilter->add(groupFilters_);
}
-bool CommandLineArguments::addGroupDotNameFilter(int ac, const char *const *av, int& i)
+bool CommandLineArguments::addGroupDotNameFilter(int ac, const char *const *av, int& i, const SimpleString& parameterName,
+ bool strict, bool exclude)
{
- SimpleString groupDotName = getParameterField(ac, av, i, "-t");
+ SimpleString groupDotName = getParameterField(ac, av, i, parameterName);
SimpleStringCollection collection;
groupDotName.split(".", collection);
if (collection.size() != 2) return false;
- groupFilters_ = (new TestFilter(collection[0].subString(0, collection[0].size()-1)))->add(groupFilters_);
- nameFilters_ = (new TestFilter(collection[1]))->add(nameFilters_);
+ TestFilter* groupFilter = new TestFilter(collection[0].subString(0, collection[0].size()-1));
+ TestFilter* nameFilter = new TestFilter(collection[1]);
+ if (strict)
+ {
+ groupFilter->strictMatching();
+ nameFilter->strictMatching();
+ }
+ if (exclude)
+ {
+ groupFilter->invertMatching();
+ nameFilter->invertMatching();
+ }
+ groupFilters_ = groupFilter->add(groupFilters_);
+ nameFilters_ = nameFilter->add(nameFilters_);
return true;
}
diff --git a/src/CppUTest/CommandLineTestRunner.cpp b/src/CppUTest/CommandLineTestRunner.cpp
index 39290c720..b50e897e7 100644
--- a/src/CppUTest/CommandLineTestRunner.cpp
+++ b/src/CppUTest/CommandLineTestRunner.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -29,7 +29,6 @@
#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/TestOutput.h"
#include "CppUTest/JUnitTestOutput.h"
-#include "CppUTest/PlatformSpecificFunctions.h"
#include "CppUTest/TeamCityTestOutput.h"
#include "CppUTest/TestRegistry.h"
@@ -95,6 +94,9 @@ void CommandLineTestRunner::initializeTestRun()
if (arguments_->isColor()) output_->color();
if (arguments_->runTestsInSeperateProcess()) registry_->setRunTestsInSeperateProcess();
if (arguments_->isRunIgnored()) registry_->setRunIgnored();
+ if (arguments_->isCrashingOnFail()) UtestShell::setCrashOnFail();
+
+ UtestShell::setRethrowExceptions( arguments_->isRethrowingExceptions() );
}
int CommandLineTestRunner::runAllTests()
@@ -119,6 +121,13 @@ int CommandLineTestRunner::runAllTests()
return 0;
}
+ if (arguments_->isListingTestLocations())
+ {
+ TestResult tr(*output_);
+ registry_->listTestLocations(tr);
+ return 0;
+ }
+
if (arguments_->isReversing())
registry_->reverseTests();
@@ -181,7 +190,7 @@ bool CommandLineTestRunner::parseArguments(TestPlugin* plugin)
if (arguments_->isJUnitOutput()) {
output_= createJUnitOutput(arguments_->getPackageName());
- if (arguments_->isVerbose())
+ if (arguments_->isVerbose() || arguments_->isVeryVerbose())
output_ = createCompositeOutput(output_, createConsoleOutput());
} else if (arguments_->isTeamCityOutput()) {
output_ = createTeamCityOutput();
diff --git a/src/CppUTest/JUnitTestOutput.cpp b/src/CppUTest/JUnitTestOutput.cpp
index e85999144..f509d9b72 100644
--- a/src/CppUTest/JUnitTestOutput.cpp
+++ b/src/CppUTest/JUnitTestOutput.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -209,7 +209,8 @@ SimpleString JUnitTestOutput::encodeXmlText(const SimpleString& textbody)
buf.replace("\"", """);
buf.replace("<", "<");
buf.replace(">", ">");
- buf.replace("\n", "{newline}");
+ buf.replace("\r", "
");
+ buf.replace("\n", "
");
return buf;
}
diff --git a/src/CppUTest/MemoryLeakDetector.cpp b/src/CppUTest/MemoryLeakDetector.cpp
index 6c30e429f..89e45908e 100644
--- a/src/CppUTest/MemoryLeakDetector.cpp
+++ b/src/CppUTest/MemoryLeakDetector.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/MemoryLeakWarningPlugin.cpp b/src/CppUTest/MemoryLeakWarningPlugin.cpp
index 52b975000..e954d6338 100644
--- a/src/CppUTest/MemoryLeakWarningPlugin.cpp
+++ b/src/CppUTest/MemoryLeakWarningPlugin.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -130,13 +130,13 @@ void cpputest_free_location_with_leak_detection(void* buffer, const char* file,
#if CPPUTEST_USE_MEM_LEAK_DETECTION
#undef new
-#if CPPUTEST_USE_STD_CPP_LIB
-#define UT_THROW_BAD_ALLOC_WHEN_NULL(memory) if (memory == NULLPTR) throw std::bad_alloc()
+#if CPPUTEST_HAVE_EXCEPTIONS
+#define UT_THROW_BAD_ALLOC_WHEN_NULL(memory) if ((memory) == NULLPTR) throw CPPUTEST_BAD_ALLOC()
#else
#define UT_THROW_BAD_ALLOC_WHEN_NULL(memory)
#endif
-static void* threadsafe_mem_leak_operator_new (size_t size) UT_THROW(std::bad_alloc)
+static void* threadsafe_mem_leak_operator_new (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
MemLeakScopedMutex lock;
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size);
@@ -150,7 +150,7 @@ static void* threadsafe_mem_leak_operator_new_nothrow (size_t size) UT_NOTHROW
return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size);
}
-static void* threadsafe_mem_leak_operator_new_debug (size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+static void* threadsafe_mem_leak_operator_new_debug (size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
MemLeakScopedMutex lock;
void *memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size, file, line);
@@ -158,7 +158,7 @@ static void* threadsafe_mem_leak_operator_new_debug (size_t size, const char* fi
return memory;
}
-static void* threadsafe_mem_leak_operator_new_array (size_t size) UT_THROW(std::bad_alloc)
+static void* threadsafe_mem_leak_operator_new_array (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
MemLeakScopedMutex lock;
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size);
@@ -172,7 +172,7 @@ static void* threadsafe_mem_leak_operator_new_array_nothrow (size_t size) UT_NOT
return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size);
}
-static void* threadsafe_mem_leak_operator_new_array_debug (size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+static void* threadsafe_mem_leak_operator_new_array_debug (size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
MemLeakScopedMutex lock;
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size, file, line);
@@ -195,7 +195,7 @@ static void threadsafe_mem_leak_operator_delete_array (void* mem) UT_NOTHROW
}
-static void* mem_leak_operator_new (size_t size) UT_THROW(std::bad_alloc)
+static void* mem_leak_operator_new (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -207,14 +207,14 @@ static void* mem_leak_operator_new_nothrow (size_t size) UT_NOTHROW
return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size);
}
-static void* mem_leak_operator_new_debug (size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+static void* mem_leak_operator_new_debug (size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void *memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size, file, line);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
return memory;
}
-static void* mem_leak_operator_new_array (size_t size) UT_THROW(std::bad_alloc)
+static void* mem_leak_operator_new_array (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -226,7 +226,7 @@ static void* mem_leak_operator_new_array_nothrow (size_t size) UT_NOTHROW
return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size);
}
-static void* mem_leak_operator_new_array_debug (size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+static void* mem_leak_operator_new_array_debug (size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size, file, line);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -245,7 +245,7 @@ static void mem_leak_operator_delete_array (void* mem) UT_NOTHROW
MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewArrayAllocator(), (char*) mem);
}
-static void* normal_operator_new (size_t size) UT_THROW(std::bad_alloc)
+static void* normal_operator_new (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = PlatformSpecificMalloc(size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -257,14 +257,14 @@ static void* normal_operator_new_nothrow (size_t size) UT_NOTHROW
return PlatformSpecificMalloc(size);
}
-static void* normal_operator_new_debug (size_t size, const char* /*file*/, size_t /*line*/) UT_THROW(std::bad_alloc)
+static void* normal_operator_new_debug (size_t size, const char* /*file*/, size_t /*line*/) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = PlatformSpecificMalloc(size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
return memory;
}
-static void* normal_operator_new_array (size_t size) UT_THROW(std::bad_alloc)
+static void* normal_operator_new_array (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = PlatformSpecificMalloc(size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -276,7 +276,7 @@ static void* normal_operator_new_array_nothrow (size_t size) UT_NOTHROW
return PlatformSpecificMalloc(size);
}
-static void* normal_operator_new_array_debug (size_t size, const char* /*file*/, size_t /*line*/) UT_THROW(std::bad_alloc)
+static void* normal_operator_new_array_debug (size_t size, const char* /*file*/, size_t /*line*/) UT_THROW(CPPUTEST_BAD_ALLOC)
{
void* memory = PlatformSpecificMalloc(size);
UT_THROW_BAD_ALLOC_WHEN_NULL(memory);
@@ -293,31 +293,36 @@ static void normal_operator_delete_array (void* mem) UT_NOTHROW
PlatformSpecificFree(mem);
}
-static void *(*operator_new_fptr)(size_t size) UT_THROW(std::bad_alloc) = mem_leak_operator_new;
+static void *(*operator_new_fptr)(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new;
static void *(*operator_new_nothrow_fptr)(size_t size) UT_NOTHROW = mem_leak_operator_new_nothrow;
-static void *(*operator_new_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc) = mem_leak_operator_new_debug;
-static void *(*operator_new_array_fptr)(size_t size) UT_THROW(std::bad_alloc) = mem_leak_operator_new_array;
+static void *(*operator_new_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_debug;
+static void *(*operator_new_array_fptr)(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_array;
static void *(*operator_new_array_nothrow_fptr)(size_t size) UT_NOTHROW = mem_leak_operator_new_array_nothrow;
-static void *(*operator_new_array_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc) = mem_leak_operator_new_array_debug;
+static void *(*operator_new_array_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_array_debug;
static void (*operator_delete_fptr)(void* mem) UT_NOTHROW = mem_leak_operator_delete;
static void (*operator_delete_array_fptr)(void* mem) UT_NOTHROW = mem_leak_operator_delete_array;
-static void *(*saved_operator_new_fptr)(size_t size) UT_THROW(std::bad_alloc) = mem_leak_operator_new;
+static void *(*saved_operator_new_fptr)(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new;
static void *(*saved_operator_new_nothrow_fptr)(size_t size) UT_NOTHROW = mem_leak_operator_new_nothrow;
-static void *(*saved_operator_new_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc) = mem_leak_operator_new_debug;
-static void *(*saved_operator_new_array_fptr)(size_t size) UT_THROW(std::bad_alloc) = mem_leak_operator_new_array;
+static void *(*saved_operator_new_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_debug;
+static void *(*saved_operator_new_array_fptr)(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_array;
static void *(*saved_operator_new_array_nothrow_fptr)(size_t size) UT_NOTHROW = mem_leak_operator_new_array_nothrow;
-static void *(*saved_operator_new_array_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc) = mem_leak_operator_new_array_debug;
+static void *(*saved_operator_new_array_debug_fptr)(size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC) = mem_leak_operator_new_array_debug;
static void (*saved_operator_delete_fptr)(void* mem) UT_NOTHROW = mem_leak_operator_delete;
static void (*saved_operator_delete_array_fptr)(void* mem) UT_NOTHROW = mem_leak_operator_delete_array;
static int save_counter = 0;
-void* operator new(size_t size) UT_THROW(std::bad_alloc)
+void* operator new(size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
return operator_new_fptr(size);
}
-void* operator new(size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+void* operator new(size_t size, const char* file, int line) UT_THROW(CPPUTEST_BAD_ALLOC)
+{
+ return operator_new_debug_fptr(size, file, (size_t)line);
+}
+
+void* operator new(size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
return operator_new_debug_fptr(size, file, line);
}
@@ -327,6 +332,11 @@ void operator delete(void* mem) UT_NOTHROW
operator_delete_fptr(mem);
}
+void operator delete(void* mem, const char*, int) UT_NOTHROW
+{
+ operator_delete_fptr(mem);
+}
+
void operator delete(void* mem, const char*, size_t) UT_NOTHROW
{
operator_delete_fptr(mem);
@@ -339,12 +349,17 @@ void operator delete (void* mem, size_t) UT_NOTHROW
}
#endif
-void* operator new[](size_t size) UT_THROW(std::bad_alloc)
+void* operator new[](size_t size) UT_THROW(CPPUTEST_BAD_ALLOC)
{
return operator_new_array_fptr(size);
}
-void* operator new [](size_t size, const char* file, size_t line) UT_THROW(std::bad_alloc)
+void* operator new [](size_t size, const char* file, int line) UT_THROW(CPPUTEST_BAD_ALLOC)
+{
+ return operator_new_array_debug_fptr(size, file, (size_t)line);
+}
+
+void* operator new [](size_t size, const char* file, size_t line) UT_THROW(CPPUTEST_BAD_ALLOC)
{
return operator_new_array_debug_fptr(size, file, line);
}
@@ -354,6 +369,11 @@ void operator delete[](void* mem) UT_NOTHROW
operator_delete_array_fptr(mem);
}
+void operator delete[](void* mem, const char*, int) UT_NOTHROW
+{
+ operator_delete_array_fptr(mem);
+}
+
void operator delete[](void* mem, const char*, size_t) UT_NOTHROW
{
operator_delete_array_fptr(mem);
@@ -518,14 +538,14 @@ void crash_on_allocation_number(unsigned alloc_number)
class MemoryLeakWarningReporter: public MemoryLeakFailure
{
public:
- virtual ~MemoryLeakWarningReporter() _destructor_override
+ virtual ~MemoryLeakWarningReporter() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
- virtual void fail(char* fail_string) _override
+ virtual void fail(char* fail_string) CPPUTEST_OVERRIDE
{
UtestShell* currentTest = UtestShell::getCurrent();
- currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(), currentTest->getLineNumber(), fail_string), TestTerminatorWithoutExceptions());
+ currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(), currentTest->getLineNumber(), fail_string), UtestShell::getCurrentTestTerminatorWithoutExceptions());
} // LCOV_EXCL_LINE
};
diff --git a/src/CppUTest/SimpleMutex.cpp b/src/CppUTest/SimpleMutex.cpp
index a1f4d7027..8fd9c887f 100644
--- a/src/CppUTest/SimpleMutex.cpp
+++ b/src/CppUTest/SimpleMutex.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/SimpleString.cpp b/src/CppUTest/SimpleString.cpp
index 02137dce5..a62491e32 100644
--- a/src/CppUTest/SimpleString.cpp
+++ b/src/CppUTest/SimpleString.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -62,7 +62,7 @@ GlobalSimpleStringMemoryAccountant::~GlobalSimpleStringMemoryAccountant()
void GlobalSimpleStringMemoryAccountant::restoreAllocator()
{
- if (SimpleString::getStringAllocator() == allocator_)
+ if (allocator_ && (SimpleString::getStringAllocator() == allocator_))
SimpleString::setStringAllocator(allocator_->originalAllocator());
}
@@ -196,8 +196,10 @@ char* SimpleString::StrNCpy(char* s1, const char* s2, size_t n)
if((NULLPTR == s1) || (0 == n)) return result;
- while ((*s1++ = *s2++) && --n != 0)
- ;
+ *s1 = *s2;
+ while ((--n != 0) && *s1){
+ *++s1 = *++s2;
+ }
return result;
}
@@ -356,9 +358,15 @@ size_t SimpleString::count(const SimpleString& substr) const
{
size_t num = 0;
const char* str = getBuffer();
- while (*str && (str = StrStr(str, substr.getBuffer()))) {
+ const char* strpart = NULLPTR;
+ if (*str){
+ strpart = StrStr(str, substr.getBuffer());
+ }
+ while (*str && strpart) {
+ str = strpart;
str++;
num++;
+ strpart = StrStr(str, substr.getBuffer());
}
return num;
}
@@ -422,6 +430,70 @@ void SimpleString::replace(const char* to, const char* with)
setInternalBufferAsEmptyString();
}
+SimpleString SimpleString::printable() const
+{
+ static const char* shortEscapeCodes[] =
+ {
+ "\\a",
+ "\\b",
+ "\\t",
+ "\\n",
+ "\\v",
+ "\\f",
+ "\\r"
+ };
+
+ SimpleString result;
+ result.setInternalBufferToNewBuffer(getPrintableSize() + 1);
+
+ size_t str_size = size();
+ size_t j = 0;
+ for (size_t i = 0; i < str_size; i++)
+ {
+ char c = buffer_[i];
+ if (isControlWithShortEscapeSequence(c))
+ {
+ StrNCpy(&result.buffer_[j], shortEscapeCodes[(unsigned char)(c - '\a')], 2);
+ j += 2;
+ }
+ else if (isControl(c))
+ {
+ SimpleString hexEscapeCode = StringFromFormat("\\x%02X ", c);
+ StrNCpy(&result.buffer_[j], hexEscapeCode.asCharString(), 4);
+ j += 4;
+ }
+ else
+ {
+ result.buffer_[j] = c;
+ j++;
+ }
+ }
+ result.buffer_[j] = 0;
+
+ return result;
+}
+
+size_t SimpleString::getPrintableSize() const
+{
+ size_t str_size = size();
+ size_t printable_str_size = str_size;
+
+ for (size_t i = 0; i < str_size; i++)
+ {
+ char c = buffer_[i];
+ if (isControlWithShortEscapeSequence(c))
+ {
+ printable_str_size += 1;
+ }
+ else if (isControl(c))
+ {
+ printable_str_size += 3;
+ }
+ }
+
+ return printable_str_size;
+}
+
SimpleString SimpleString::lowerCase() const
{
SimpleString str(*this);
@@ -586,6 +658,16 @@ bool SimpleString::isUpper(char ch)
return 'A' <= ch && 'Z' >= ch;
}
+bool SimpleString::isControl(char ch)
+{
+ return ch < ' ' || ch == char(0x7F);
+}
+
+bool SimpleString::isControlWithShortEscapeSequence(char ch)
+{
+ return '\a' <= ch && '\r' >= ch;
+}
+
SimpleString StringFrom(bool value)
{
return SimpleString(StringFromFormat("%s", value ? "true" : "false"));
@@ -598,7 +680,12 @@ SimpleString StringFrom(const char *value)
SimpleString StringFromOrNull(const char * expected)
{
- return (expected) ? StringFrom(expected) : "(null)";
+ return (expected) ? StringFrom(expected) : StringFrom("(null)");
+}
+
+SimpleString PrintableStringFromOrNull(const char * expected)
+{
+ return (expected) ? StringFrom(expected).printable() : StringFrom("(null)");
}
SimpleString StringFrom(int value)
@@ -623,12 +710,12 @@ SimpleString StringFrom(void (*value)())
SimpleString HexStringFrom(long value)
{
- return StringFromFormat("%lx", value);
+ return HexStringFrom((unsigned long)value);
}
SimpleString HexStringFrom(int value)
{
- return StringFromFormat("%x", value);
+ return HexStringFrom((unsigned int)value);
}
SimpleString HexStringFrom(signed char value)
@@ -694,7 +781,7 @@ SimpleString StringFrom(const std::nullptr_t value)
}
#endif
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
SimpleString StringFrom(cpputest_longlong value)
{
@@ -708,7 +795,7 @@ SimpleString StringFrom(cpputest_ulonglong value)
SimpleString HexStringFrom(cpputest_longlong value)
{
- return StringFromFormat("%llx", value);
+ return HexStringFrom((cpputest_ulonglong)value);
}
SimpleString HexStringFrom(cpputest_ulonglong value)
@@ -897,7 +984,7 @@ SimpleString StringFromBinary(const unsigned char* value, size_t size)
SimpleString StringFromBinaryOrNull(const unsigned char* value, size_t size)
{
- return (value) ? StringFromBinary(value, size) : "(null)";
+ return (value) ? StringFromBinary(value, size) : StringFrom("(null)");
}
SimpleString StringFromBinaryWithSize(const unsigned char* value, size_t size)
@@ -914,7 +1001,7 @@ SimpleString StringFromBinaryWithSize(const unsigned char* value, size_t size)
SimpleString StringFromBinaryWithSizeOrNull(const unsigned char* value, size_t size)
{
- return (value) ? StringFromBinaryWithSize(value, size) : "(null)";
+ return (value) ? StringFromBinaryWithSize(value, size) : StringFrom("(null)");
}
SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_t byteCount)
@@ -944,19 +1031,17 @@ SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_
SimpleString StringFromOrdinalNumber(unsigned int number)
{
- unsigned int onesDigit = number % 10;
-
- const char* suffix;
- if (number >= 11 && number <= 13) {
- suffix = "th";
- } else if (3 == onesDigit) {
- suffix = "rd";
- } else if (2 == onesDigit) {
- suffix = "nd";
- } else if (1 == onesDigit) {
- suffix = "st";
- } else {
- suffix = "th";
+ const char* suffix = "th";
+
+ if ((number < 11) || (number > 13)) {
+ unsigned int const onesDigit = number % 10;
+ if (3 == onesDigit) {
+ suffix = "rd";
+ } else if (2 == onesDigit) {
+ suffix = "nd";
+ } else if (1 == onesDigit) {
+ suffix = "st";
+ }
}
return StringFromFormat("%u%s", number, suffix);
diff --git a/src/CppUTest/SimpleStringInternalCache.cpp b/src/CppUTest/SimpleStringInternalCache.cpp
index f339fa4c7..2964a2d2c 100644
--- a/src/CppUTest/SimpleStringInternalCache.cpp
+++ b/src/CppUTest/SimpleStringInternalCache.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/TestFailure.cpp b/src/CppUTest/TestFailure.cpp
index a6400878b..a3a9bb82e 100644
--- a/src/CppUTest/TestFailure.cpp
+++ b/src/CppUTest/TestFailure.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,34 +31,13 @@
#include "CppUTest/SimpleString.h"
#include "CppUTest/PlatformSpecificFunctions.h"
-static SimpleString removeAllPrintableCharactersFrom(const SimpleString& str)
-{
- size_t bufferSize = str.size()+1;
- char* buffer = (char*) PlatformSpecificMalloc(bufferSize);
- str.copyToBuffer(buffer, bufferSize);
-
- for (size_t i = 0; i < bufferSize-1; i++)
- if (buffer[i] != '\t' && buffer[i] != '\n')
- buffer[i] = ' ';
-
- SimpleString result(buffer);
- PlatformSpecificFree(buffer);
- return result;
-}
-
-static SimpleString addMarkerToString(const SimpleString& str, int markerPos)
-{
- size_t bufferSize = str.size()+1;
- char* buffer = (char*) PlatformSpecificMalloc(bufferSize);
- str.copyToBuffer(buffer, bufferSize);
-
- buffer[markerPos] = '^';
-
- SimpleString result(buffer);
- PlatformSpecificFree(buffer);
- return result;
-
-}
+#if CPPUTEST_USE_STD_CPP_LIB
+#include
+#if defined(__GNUC__)
+#include
+#include
+#endif
+#endif
TestFailure::TestFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& theMessage) :
testName_(test->getFormattedName()), testNameOnly_(test->getName()), fileName_(fileName), lineNumber_(lineNumber), testFileName_(test->getFile()), testLineNumber_(test->getLineNumber()), message_(theMessage)
@@ -135,25 +114,21 @@ SimpleString TestFailure::createButWasString(const SimpleString& expected, const
return StringFromFormat("expected <%s>\n\tbut was <%s>", expected.asCharString(), actual.asCharString());
}
-SimpleString TestFailure::createDifferenceAtPosString(const SimpleString& actual, size_t position, DifferenceFormat format)
+SimpleString TestFailure::createDifferenceAtPosString(const SimpleString& actual, size_t offset, size_t reportedPosition)
{
SimpleString result;
const size_t extraCharactersWindow = 20;
const size_t halfOfExtraCharactersWindow = extraCharactersWindow / 2;
- const size_t actualOffset = (format == DIFFERENCE_STRING) ? position : (position * 3 + 1);
SimpleString paddingForPreventingOutOfBounds (" ", halfOfExtraCharactersWindow);
SimpleString actualString = paddingForPreventingOutOfBounds + actual + paddingForPreventingOutOfBounds;
- SimpleString differentString = StringFromFormat("difference starts at position %lu at: <", (unsigned long) position);
+ SimpleString differentString = StringFromFormat("difference starts at position %lu at: <", (unsigned long) reportedPosition);
result += "\n";
- result += StringFromFormat("\t%s%s>\n", differentString.asCharString(), actualString.subString(actualOffset, extraCharactersWindow).asCharString());
+ result += StringFromFormat("\t%s%s>\n", differentString.asCharString(), actualString.subString(offset, extraCharactersWindow).asCharString());
- SimpleString markString = actualString.subString(actualOffset, halfOfExtraCharactersWindow+1);
- markString = removeAllPrintableCharactersFrom(markString);
- markString = addMarkerToString(markString, halfOfExtraCharactersWindow);
- result += StringFromFormat("\t%s%s", SimpleString(" ", differentString.size()).asCharString(), markString.asCharString());
+ result += StringFromFormat("\t%s^", SimpleString(" ", (differentString.size() + halfOfExtraCharactersWindow)).asCharString());
return result;
}
@@ -208,12 +183,18 @@ CheckEqualFailure::CheckEqualFailure(UtestShell* test, const char* fileName, siz
{
message_ = createUserText(text);
+ SimpleString printableExpected = PrintableStringFromOrNull(expected.asCharString());
+ SimpleString printableActual = PrintableStringFromOrNull(actual.asCharString());
+
+ message_ += createButWasString(printableExpected, printableActual);
+
size_t failStart;
- for (failStart = 0; actual.asCharString()[failStart] == expected.asCharString()[failStart]; failStart++)
+ for (failStart = 0; actual.at(failStart) == expected.at(failStart); failStart++)
;
- message_ += createButWasString(expected, actual);
- message_ += createDifferenceAtPosString(actual, failStart);
-
+ size_t failStartPrintable;
+ for (failStartPrintable = 0; printableActual.at(failStartPrintable) == printableExpected.at(failStartPrintable); failStartPrintable++)
+ ;
+ message_ += createDifferenceAtPosString(printableActual, failStartPrintable, failStart);
}
ComparisonFailure::ComparisonFailure(UtestShell *test, const char *fileName, size_t lineNumber, const SimpleString& checkString, const SimpleString &comparisonString, const SimpleString &text)
@@ -331,13 +312,19 @@ StringEqualFailure::StringEqualFailure(UtestShell* test, const char* fileName, s
{
message_ = createUserText(text);
- message_ += createButWasString(StringFromOrNull(expected), StringFromOrNull(actual));
+ SimpleString printableExpected = PrintableStringFromOrNull(expected);
+ SimpleString printableActual = PrintableStringFromOrNull(actual);
+
+ message_ += createButWasString(printableExpected, printableActual);
if((expected) && (actual))
{
size_t failStart;
for (failStart = 0; actual[failStart] == expected[failStart]; failStart++)
;
- message_ += createDifferenceAtPosString(actual, failStart);
+ size_t failStartPrintable;
+ for (failStartPrintable = 0; printableActual.at(failStartPrintable) == printableExpected.at(failStartPrintable); failStartPrintable++)
+ ;
+ message_ += createDifferenceAtPosString(printableActual, failStartPrintable, failStart);
}
}
@@ -346,13 +333,21 @@ StringEqualNoCaseFailure::StringEqualNoCaseFailure(UtestShell* test, const char*
{
message_ = createUserText(text);
- message_ += createButWasString(StringFromOrNull(expected), StringFromOrNull(actual));
+ SimpleString printableExpected = PrintableStringFromOrNull(expected);
+ SimpleString printableActual = PrintableStringFromOrNull(actual);
+
+ message_ += createButWasString(printableExpected, printableActual);
if((expected) && (actual))
{
size_t failStart;
for (failStart = 0; SimpleString::ToLower(actual[failStart]) == SimpleString::ToLower(expected[failStart]); failStart++)
;
- message_ += createDifferenceAtPosString(actual, failStart);
+ size_t failStartPrintable;
+ for (failStartPrintable = 0;
+ SimpleString::ToLower(printableActual.at(failStartPrintable)) == SimpleString::ToLower(printableExpected.at(failStartPrintable));
+ failStartPrintable++)
+ ;
+ message_ += createDifferenceAtPosString(printableActual, failStartPrintable, failStart);
}
}
@@ -362,13 +357,15 @@ BinaryEqualFailure::BinaryEqualFailure(UtestShell* test, const char* fileName, s
{
message_ = createUserText(text);
- message_ += createButWasString(StringFromBinaryOrNull(expected, size), StringFromBinaryOrNull(actual, size));
+ SimpleString actualHex = StringFromBinaryOrNull(actual, size);
+
+ message_ += createButWasString(StringFromBinaryOrNull(expected, size), actualHex);
if ((expected) && (actual))
{
size_t failStart;
for (failStart = 0; actual[failStart] == expected[failStart]; failStart++)
;
- message_ += createDifferenceAtPosString(StringFromBinary(actual, size), failStart, DIFFERENCE_BINARY);
+ message_ += createDifferenceAtPosString(actualHex, (failStart * 3 + 1), failStart);
}
}
@@ -389,3 +386,47 @@ FeatureUnsupportedFailure::FeatureUnsupportedFailure(UtestShell* test, const cha
message_ += StringFromFormat("The feature \"%s\" is not supported in this environment or with the feature set selected when building the library.", featureName.asCharString());
}
+
+#if CPPUTEST_HAVE_EXCEPTIONS
+UnexpectedExceptionFailure::UnexpectedExceptionFailure(UtestShell* test)
+: TestFailure(test, "Unexpected exception of unknown type was thrown.")
+{
+}
+
+#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_RTTI
+static SimpleString getExceptionTypeName(const std::exception &e)
+{
+ const char *name = typeid(e).name();
+#if defined(__GNUC__) && (__cplusplus >= 201103L)
+ int status = -1;
+
+ std::unique_ptr demangledName(
+ abi::__cxa_demangle(name, NULLPTR, NULLPTR, &status),
+ std::free );
+
+ return (status==0) ? demangledName.get() : name;
+#else
+ return name;
+#endif
+}
+#endif // CPPUTEST_HAVE_RTTI
+
+UnexpectedExceptionFailure::UnexpectedExceptionFailure(UtestShell* test, const std::exception &e)
+: TestFailure(
+ test,
+#if CPPUTEST_HAVE_RTTI
+ StringFromFormat(
+ "Unexpected exception of type '%s' was thrown: %s",
+ getExceptionTypeName(e).asCharString(),
+ e.what()
+ )
+#else
+ "Unexpected exception of unknown type was thrown."
+#endif
+)
+{
+ (void) e;
+}
+#endif // CPPUTEST_USE_STD_CPP_LIB
+#endif // CPPUTEST_HAVE_EXCEPTIONS
diff --git a/src/CppUTest/TestFilter.cpp b/src/CppUTest/TestFilter.cpp
index c977b6fb5..326767afc 100644
--- a/src/CppUTest/TestFilter.cpp
+++ b/src/CppUTest/TestFilter.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/TestHarness_c.cpp b/src/CppUTest/TestHarness_c.cpp
index b97fdd5d8..149c8fbb6 100644
--- a/src/CppUTest/TestHarness_c.cpp
+++ b/src/CppUTest/TestHarness_c.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,87 +36,92 @@ extern "C"
void CHECK_EQUAL_C_BOOL_LOCATION(int expected, int actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertEquals(!!expected != !!actual, expected ? "true" : "false", actual ? "true" : "false", text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertEquals(!!expected != !!actual, expected ? "true" : "false", actual ? "true" : "false", text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_INT_LOCATION(int expected, int actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertLongsEqual((long)expected, (long)actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertLongsEqual((long)expected, (long)actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_UINT_LOCATION(unsigned int expected, unsigned int actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertUnsignedLongsEqual((unsigned long)expected, (unsigned long)actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertUnsignedLongsEqual((unsigned long)expected, (unsigned long)actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_LONG_LOCATION(long expected, long actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertLongsEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertLongsEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_ULONG_LOCATION(unsigned long expected, unsigned long actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertUnsignedLongsEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertUnsignedLongsEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_LONGLONG_LOCATION(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertLongLongsEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertLongLongsEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_ULONGLONG_LOCATION(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertUnsignedLongLongsEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertUnsignedLongLongsEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_REAL_LOCATION(double expected, double actual, double threshold, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertDoublesEqual(expected, actual, threshold, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertDoublesEqual(expected, actual, threshold, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_CHAR_LOCATION(char expected, char actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertEquals(((expected) != (actual)), StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertEquals(((expected) != (actual)), StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
extern void CHECK_EQUAL_C_UBYTE_LOCATION(unsigned char expected, unsigned char actual, const char* text, const char* fileName, size_t lineNumber)\
{
- UtestShell::getCurrent()->assertEquals(((expected) != (actual)),StringFrom((int)expected).asCharString(), StringFrom((int) actual).asCharString(), text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertEquals(((expected) != (actual)),StringFrom((int)expected).asCharString(), StringFrom((int) actual).asCharString(), text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_SBYTE_LOCATION(char signed expected, signed char actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertEquals(((expected) != (actual)),StringFrom((int)expected).asCharString(), StringFrom((int) actual).asCharString(), text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertEquals(((expected) != (actual)),StringFrom((int)expected).asCharString(), StringFrom((int) actual).asCharString(), text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_STRING_LOCATION(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertCstrEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertCstrEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void CHECK_EQUAL_C_POINTER_LOCATION(const void* expected, const void* actual, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertPointersEqual(expected, actual, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertPointersEqual(expected, actual, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
+}
+
+extern void CHECK_EQUAL_C_MEMCMP_LOCATION(const void* expected, const void* actual, size_t size, const char* text, const char* fileName, size_t lineNumber)
+{
+ UtestShell::getCurrent()->assertBinaryEqual(expected, actual, size, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
extern void CHECK_EQUAL_C_BITS_LOCATION(unsigned int expected, unsigned int actual, unsigned int mask, size_t size, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertBitsEqual(expected, actual, mask, size, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertBitsEqual(expected, actual, mask, size, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
void FAIL_TEXT_C_LOCATION(const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->fail(text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->fail(text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
} // LCOV_EXCL_LINE
void FAIL_C_LOCATION(const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->fail("", fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->fail("", fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
} // LCOV_EXCL_LINE
void CHECK_C_LOCATION(int condition, const char* conditionString, const char* text, const char* fileName, size_t lineNumber)
{
- UtestShell::getCurrent()->assertTrue(condition != 0, "CHECK_C", conditionString, text, fileName, lineNumber, TestTerminatorWithoutExceptions());
+ UtestShell::getCurrent()->assertTrue(condition != 0, "CHECK_C", conditionString, text, fileName, lineNumber, UtestShell::getCurrentTestTerminatorWithoutExceptions());
}
enum { NO_COUNTDOWN = -1, OUT_OF_MEMORRY = 0 };
diff --git a/src/CppUTest/TestMemoryAllocator.cpp b/src/CppUTest/TestMemoryAllocator.cpp
index 2f96874fb..71e3a7ca6 100644
--- a/src/CppUTest/TestMemoryAllocator.cpp
+++ b/src/CppUTest/TestMemoryAllocator.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -418,7 +418,7 @@ MemoryAccountantAllocationNode* MemoryAccountant::createNewAccountantAllocationN
void MemoryAccountant::destroyAccountantAllocationNode(MemoryAccountantAllocationNode* node) const
{
- allocator_->free_memory((char*) node, sizeof(node), __FILE__, __LINE__);
+ allocator_->free_memory((char*) node, sizeof(*node), __FILE__, __LINE__);
}
MemoryAccountant::MemoryAccountant()
@@ -479,9 +479,9 @@ MemoryAccountantAllocationNode* MemoryAccountant::findNodeOfSize(size_t size) co
{
if (useCacheSizes_) {
for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) {
- if (size > node->size_ && node->next_ == NULLPTR)
- return node;
- else if (size <= node->size_ && !(node->next_->size_ != 0 && node->next_->size_ <= size))
+ if (((size > node->size_) && (node->next_ == NULLPTR))
+ || ((size <= node->size_) &&
+ !((node->next_->size_ != 0) && (node->next_->size_ <= size))))
return node;
}
}
@@ -598,7 +598,7 @@ SimpleString MemoryAccountant::reportFooter() const
SimpleString MemoryAccountant::stringSize(size_t size) const
{
- return (size == 0) ? "other" : StringFromFormat("%5d", (int) size);
+ return (size == 0) ? StringFrom("other") : StringFromFormat("%5d", (int) size);
}
SimpleString MemoryAccountant::report() const
diff --git a/src/CppUTest/TestOutput.cpp b/src/CppUTest/TestOutput.cpp
index 21a3b08cc..cb4ced54e 100644
--- a/src/CppUTest/TestOutput.cpp
+++ b/src/CppUTest/TestOutput.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -274,10 +274,7 @@ void TestOutput::printVeryVerbose(const char* str)
void ConsoleTestOutput::printBuffer(const char* s)
{
- while (*s) {
- PlatformSpecificPutchar(*s);
- s++;
- }
+ PlatformSpecificFPuts(s, PlatformSpecificStdOut);
flush();
}
@@ -403,6 +400,12 @@ void CompositeTestOutput::setProgressIndicator(const char* indicator)
if (outputTwo_) outputTwo_->setProgressIndicator(indicator);
}
+void CompositeTestOutput::printVeryVerbose(const char* str)
+{
+ if (outputOne_) outputOne_->printVeryVerbose(str);
+ if (outputTwo_) outputTwo_->printVeryVerbose(str);
+}
+
void CompositeTestOutput::flush()
{
if (outputOne_) outputOne_->flush();
diff --git a/src/CppUTest/TestPlugin.cpp b/src/CppUTest/TestPlugin.cpp
index ac45e52e4..29aa38bcf 100644
--- a/src/CppUTest/TestPlugin.cpp
+++ b/src/CppUTest/TestPlugin.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/TestRegistry.cpp b/src/CppUTest/TestRegistry.cpp
index aa99c531e..542ab51a8 100644
--- a/src/CppUTest/TestRegistry.cpp
+++ b/src/CppUTest/TestRegistry.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -123,6 +123,26 @@ void TestRegistry::listTestGroupAndCaseNames(TestResult& result)
result.print(groupAndNameList.asCharString());
}
+void TestRegistry::listTestLocations(TestResult& result)
+{
+ SimpleString testLocations;
+
+ for (UtestShell *test = tests_; test != NULLPTR; test = test->getNext()) {
+ SimpleString testLocation;
+ testLocation += test->getGroup();
+ testLocation += ".";
+ testLocation += test->getName();
+ testLocation += ".";
+ testLocation += test->getFile();
+ testLocation += ".";
+ testLocation += StringFromFormat("%d\n",(int) test->getLineNumber());
+
+ testLocations += testLocation;
+ }
+
+ result.print(testLocations.asCharString());
+}
+
bool TestRegistry::endOfGroup(UtestShell* test)
{
return (!test || !test->getNext() || test->getGroup() != test->getNext()->getGroup());
diff --git a/src/CppUTest/TestResult.cpp b/src/CppUTest/TestResult.cpp
index b081f49b7..37ff57f84 100644
--- a/src/CppUTest/TestResult.cpp
+++ b/src/CppUTest/TestResult.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/TestTestingFixture.cpp b/src/CppUTest/TestTestingFixture.cpp
index 1f23e5fac..a5e73d33e 100644
--- a/src/CppUTest/TestTestingFixture.cpp
+++ b/src/CppUTest/TestTestingFixture.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTest/Utest.cpp b/src/CppUTest/Utest.cpp
index d078bdf2b..d74a87c79 100644
--- a/src/CppUTest/Utest.cpp
+++ b/src/CppUTest/Utest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,6 +30,10 @@
#include "CppUTest/PlatformSpecificFunctions.h"
#include "CppUTest/TestOutput.h"
+#if defined(__GNUC__) && __GNUC__ >= 11
+# define NEEDS_DISABLE_NULL_WARNING
+#endif /* GCC >= 11 */
+
bool doubles_equal(double d1, double d2, double threshold)
{
if (PlatformSpecificIsNan(d1) || PlatformSpecificIsNan(d2) || PlatformSpecificIsNan(threshold))
@@ -55,7 +59,7 @@ class OutsideTestRunnerUTest: public UtestShell
{
return defaultTestResult;
}
- virtual ~OutsideTestRunnerUTest() _destructor_override
+ virtual ~OutsideTestRunnerUTest() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
private:
@@ -131,6 +135,18 @@ extern "C" {
/******************************** */
+static const NormalTestTerminator normalTestTerminator = NormalTestTerminator();
+static const CrashingTestTerminator crashingTestTerminator = CrashingTestTerminator();
+static const TestTerminatorWithoutExceptions normalTestTerminatorWithoutExceptions = TestTerminatorWithoutExceptions();
+static const CrashingTestTerminatorWithoutExceptions crashingTestTerminatorWithoutExceptions = CrashingTestTerminatorWithoutExceptions();
+
+const TestTerminator *UtestShell::currentTestTerminator_ = &normalTestTerminator;
+const TestTerminator *UtestShell::currentTestTerminatorWithoutExceptions_ = &normalTestTerminatorWithoutExceptions;
+
+bool UtestShell::rethrowExceptions_ = false;
+
+/******************************** */
+
UtestShell::UtestShell() :
group_("UndefinedTestGroup"), name_("UndefinedTest"), file_("UndefinedFile"), lineNumber_(0), next_(NULLPTR), isRunAsSeperateProcess_(false), hasFailed_(false)
{
@@ -150,14 +166,7 @@ UtestShell::~UtestShell()
{
}
-// LCOV_EXCL_START - actually covered but not in .gcno due to race condition
-static void defaultCrashMethod()
-{
- UtestShell* ptr = (UtestShell*) NULLPTR; ptr->countTests();
-}
-// LCOV_EXCL_STOP
-
-static void (*pleaseCrashMeRightNow) () = defaultCrashMethod;
+static void (*pleaseCrashMeRightNow) () = PlatformSpecificAbort;
void UtestShell::setCrashMethod(void (*crashme)())
{
@@ -166,7 +175,7 @@ void UtestShell::setCrashMethod(void (*crashme)())
void UtestShell::resetCrashMethod()
{
- pleaseCrashMeRightNow = defaultCrashMethod;
+ pleaseCrashMeRightNow = PlatformSpecificAbort;
}
void UtestShell::crash()
@@ -208,16 +217,30 @@ void UtestShell::runOneTestInCurrentProcess(TestPlugin* plugin, TestResult& resu
UtestShell::setTestResult(&result);
UtestShell::setCurrentTest(this);
- result.printVeryVerbose("\n---- before createTest: ");
- Utest* testToRun = createTest();
- result.printVeryVerbose("\n---- after createTest: ");
+ Utest* testToRun = NULLPTR;
- result.printVeryVerbose("\n------ before runTest: ");
- testToRun->run();
- result.printVeryVerbose("\n------ after runTest: ");
+#if CPPUTEST_HAVE_EXCEPTIONS
+ try
+ {
+#endif
+ result.printVeryVerbose("\n---- before createTest: ");
+ testToRun = createTest();
+ result.printVeryVerbose("\n---- after createTest: ");
- UtestShell::setCurrentTest(savedTest);
- UtestShell::setTestResult(savedResult);
+ result.printVeryVerbose("\n------ before runTest: ");
+ testToRun->run();
+ result.printVeryVerbose("\n------ after runTest: ");
+
+ UtestShell::setCurrentTest(savedTest);
+ UtestShell::setTestResult(savedResult);
+#if CPPUTEST_HAVE_EXCEPTIONS
+ }
+ catch(...)
+ {
+ destroyTest(testToRun);
+ throw;
+ }
+#endif
result.printVeryVerbose("\n---- before destroyTest: ");
destroyTest(testToRun);
@@ -349,16 +372,21 @@ bool UtestShell::shouldRun(const TestFilter* groupFilters, const TestFilter* nam
void UtestShell::failWith(const TestFailure& failure)
{
- failWith(failure, NormalTestTerminator());
+ failWith(failure, getCurrentTestTerminator());
} // LCOV_EXCL_LINE
void UtestShell::failWith(const TestFailure& failure, const TestTerminator& terminator)
{
- hasFailed_ = true;
- getTestResult()->addFailure(failure);
+ addFailure(failure);
terminator.exitCurrentTest();
} // LCOV_EXCL_LINE
+void UtestShell::addFailure(const TestFailure& failure)
+{
+ hasFailed_ = true;
+ getTestResult()->addFailure(failure);
+}
+
void UtestShell::exitTest(const TestTerminator& terminator)
{
terminator.exitCurrentTest();
@@ -444,7 +472,7 @@ void UtestShell::assertUnsignedLongsEqual(unsigned long expected, unsigned long
void UtestShell::assertLongLongsEqual(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator)
{
getTestResult()->countCheck();
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
if (expected != actual)
failWith(LongLongsEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator);
#else
@@ -457,7 +485,7 @@ void UtestShell::assertLongLongsEqual(cpputest_longlong expected, cpputest_longl
void UtestShell::assertUnsignedLongLongsEqual(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator)
{
getTestResult()->countCheck();
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
if (expected != actual)
failWith(UnsignedLongLongsEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator);
#else
@@ -575,6 +603,37 @@ UtestShell* UtestShell::getCurrent()
return currentTest_;
}
+const TestTerminator &UtestShell::getCurrentTestTerminator()
+{
+ return *currentTestTerminator_;
+}
+
+const TestTerminator &UtestShell::getCurrentTestTerminatorWithoutExceptions()
+{
+ return *currentTestTerminatorWithoutExceptions_;
+}
+
+void UtestShell::setCrashOnFail()
+{
+ currentTestTerminator_ = &crashingTestTerminator;
+ currentTestTerminatorWithoutExceptions_ = &crashingTestTerminatorWithoutExceptions;
+}
+
+void UtestShell::restoreDefaultTestTerminator()
+{
+ currentTestTerminator_ = &normalTestTerminator;
+ currentTestTerminatorWithoutExceptions_ = &normalTestTerminatorWithoutExceptions;
+}
+
+void UtestShell::setRethrowExceptions(bool rethrowExceptions)
+{
+ rethrowExceptions_ = rethrowExceptions;
+}
+
+bool UtestShell::isRethrowingExceptions()
+{
+ return rethrowExceptions_;
+}
ExecFunctionTestShell::~ExecFunctionTestShell()
{
@@ -590,7 +649,7 @@ Utest::~Utest()
{
}
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
void Utest::run()
{
@@ -611,6 +670,26 @@ void Utest::run()
{
PlatformSpecificRestoreJumpBuffer();
}
+#if CPPUTEST_USE_STD_CPP_LIB
+ catch (const std::exception &e)
+ {
+ current->addFailure(UnexpectedExceptionFailure(current, e));
+ PlatformSpecificRestoreJumpBuffer();
+ if (current->isRethrowingExceptions())
+ {
+ throw;
+ }
+ }
+#endif
+ catch (...)
+ {
+ current->addFailure(UnexpectedExceptionFailure(current));
+ PlatformSpecificRestoreJumpBuffer();
+ if (current->isRethrowingExceptions())
+ {
+ throw;
+ }
+ }
try {
current->printVeryVerbose("\n-------- before teardown: ");
@@ -621,7 +700,26 @@ void Utest::run()
{
PlatformSpecificRestoreJumpBuffer();
}
-
+#if CPPUTEST_USE_STD_CPP_LIB
+ catch (const std::exception &e)
+ {
+ current->addFailure(UnexpectedExceptionFailure(current, e));
+ PlatformSpecificRestoreJumpBuffer();
+ if (current->isRethrowingExceptions())
+ {
+ throw;
+ }
+ }
+#endif
+ catch (...)
+ {
+ current->addFailure(UnexpectedExceptionFailure(current));
+ PlatformSpecificRestoreJumpBuffer();
+ if (current->isRethrowingExceptions())
+ {
+ throw;
+ }
+ }
}
#else
@@ -656,7 +754,7 @@ TestTerminator::~TestTerminator()
void NormalTestTerminator::exitCurrentTest() const
{
- #if CPPUTEST_USE_STD_CPP_LIB
+ #if CPPUTEST_HAVE_EXCEPTIONS
throw CppUTestFailedException();
#else
TestTerminatorWithoutExceptions().exitCurrentTest();
@@ -676,6 +774,26 @@ TestTerminatorWithoutExceptions::~TestTerminatorWithoutExceptions()
{
}
+void CrashingTestTerminator::exitCurrentTest() const
+{
+ UtestShell::crash();
+ NormalTestTerminator::exitCurrentTest();
+}
+
+CrashingTestTerminator::~CrashingTestTerminator()
+{
+}
+
+void CrashingTestTerminatorWithoutExceptions::exitCurrentTest() const
+{
+ UtestShell::crash();
+ TestTerminatorWithoutExceptions::exitCurrentTest();
+}
+
+CrashingTestTerminatorWithoutExceptions::~CrashingTestTerminatorWithoutExceptions()
+{
+}
+
//////////////////// ExecFunction
//
ExecFunction::ExecFunction()
diff --git a/src/CppUTestExt/CMakeLists.txt b/src/CppUTestExt/CMakeLists.txt
index 72507f8a5..ec0f27586 100644
--- a/src/CppUTestExt/CMakeLists.txt
+++ b/src/CppUTestExt/CMakeLists.txt
@@ -1,60 +1,62 @@
-set(CppUTestExt_src
- CodeMemoryReportFormatter.cpp
- GTest.cpp
- IEEE754ExceptionsPlugin.cpp
- MemoryReporterPlugin.cpp
- MockFailure.cpp
- MockSupportPlugin.cpp
- MockActualCall.cpp
- MockSupport_c.cpp
- MemoryReportAllocator.cpp
- MockExpectedCall.cpp
- MockNamedValue.cpp
- OrderedTest.cpp
- MemoryReportFormatter.cpp
- MockExpectedCallsList.cpp
- MockSupport.cpp
+add_library(CppUTestExt STATIC
+ CodeMemoryReportFormatter.cpp
+ GTest.cpp
+ IEEE754ExceptionsPlugin.cpp
+ MemoryReporterPlugin.cpp
+ MockFailure.cpp
+ MockSupportPlugin.cpp
+ MockActualCall.cpp
+ MockSupport_c.cpp
+ MemoryReportAllocator.cpp
+ MockExpectedCall.cpp
+ MockNamedValue.cpp
+ OrderedTest.cpp
+ MemoryReportFormatter.cpp
+ MockExpectedCallsList.cpp
+ MockSupport.cpp
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/CodeMemoryReportFormatter.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/IEEE754ExceptionsPlugin.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MemoryReportAllocator.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockExpectedCall.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockCheckedExpectedCall.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockExpectedCallsList.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockSupportPlugin.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MemoryReportFormatter.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockFailure.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockSupport.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockSupport_c.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/GMock.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/GTest.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/GTestSupport.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MemoryReporterPlugin.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/OrderedTest.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/GTestConvertor.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockActualCall.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockCheckedActualCall.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockNamedValue.h
+ ${PROJECT_SOURCE_DIR}/include/CppUTestExt/MockSupport.h
)
-set(CppUTestExt_headers
- ${CppUTestRootDirectory}/include/CppUTestExt/CodeMemoryReportFormatter.h
- ${CppUTestRootDirectory}/include/CppUTestExt/IEEE754ExceptionsPlugin.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MemoryReportAllocator.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockExpectedCall.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockCheckedExpectedCall.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockExpectedCallsList.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockSupportPlugin.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MemoryReportFormatter.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockFailure.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockSupport.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockSupport_c.h
- ${CppUTestRootDirectory}/include/CppUTestExt/GMock.h
- ${CppUTestRootDirectory}/include/CppUTestExt/GTest.h
- ${CppUTestRootDirectory}/include/CppUTestExt/GTestSupport.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MemoryReporterPlugin.h
- ${CppUTestRootDirectory}/include/CppUTestExt/OrderedTest.h
- ${CppUTestRootDirectory}/include/CppUTestExt/GTestConvertor.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockActualCall.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockCheckedActualCall.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockNamedValue.h
- ${CppUTestRootDirectory}/include/CppUTestExt/MockSupport.h
-)
-
-add_library(CppUTestExt STATIC ${CppUTestExt_src} ${CppUTestExt_headers})
-target_link_libraries(CppUTestExt ${CPPUNIT_EXTERNAL_LIBRARIES})
+target_link_libraries(CppUTestExt PUBLIC CppUTest)
#[[Arrange for the include directory to be added to the include paths of any CMake target depending on CppUTestExt.]]
target_include_directories(CppUTestExt
PUBLIC
- $
- $
+ $
+ $
)
-set_target_properties(CppUTestExt PROPERTIES
- PUBLIC_HEADER "${CppUTestExt_headers}")
-install(TARGETS CppUTestExt
- EXPORT CppUTestTargets
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CppUTestExt"
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/CppUTestExt")
+add_library(CppUTest::CppUTestExt ALIAS CppUTestExt)
+
+if(PROJECT_IS_TOP_LEVEL)
+ install(
+ TARGETS CppUTestExt
+ EXPORT CppUTestTargets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+ install(
+ DIRECTORY "${PROJECT_SOURCE_DIR}/include/CppUTestExt"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ )
+endif()
diff --git a/src/CppUTestExt/CodeMemoryReportFormatter.cpp b/src/CppUTestExt/CodeMemoryReportFormatter.cpp
index 3fdf95f58..57c1e4f96 100644
--- a/src/CppUTestExt/CodeMemoryReportFormatter.cpp
+++ b/src/CppUTestExt/CodeMemoryReportFormatter.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -34,7 +34,7 @@
#define MAX_VARIABLE_NAME_LINE_PART 10
#define MAX_VARIABLE_NAME_FILE_PART 53
#define MAX_VARIABLE_NAME_SEPERATOR_PART 1
-#define MAX_VARIABLE_NAME_LENGTH MAX_VARIABLE_NAME_FILE_PART + MAX_VARIABLE_NAME_SEPERATOR_PART + MAX_VARIABLE_NAME_LINE_PART
+#define MAX_VARIABLE_NAME_LENGTH (MAX_VARIABLE_NAME_FILE_PART + MAX_VARIABLE_NAME_SEPERATOR_PART + MAX_VARIABLE_NAME_LINE_PART)
struct CodeReportingAllocationNode
{
diff --git a/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp b/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp
index c2815a3ad..5b84a4862 100644
--- a/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp
+++ b/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -28,7 +28,7 @@
#include "CppUTest/TestHarness.h"
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
-#ifdef CPPUTEST_HAVE_FENV
+#if CPPUTEST_HAVE_FENV
extern "C" {
#include
diff --git a/src/CppUTestExt/MemoryReportAllocator.cpp b/src/CppUTestExt/MemoryReportAllocator.cpp
index beea0e357..f51b932ab 100644
--- a/src/CppUTestExt/MemoryReportAllocator.cpp
+++ b/src/CppUTestExt/MemoryReportAllocator.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTestExt/MemoryReportFormatter.cpp b/src/CppUTestExt/MemoryReportFormatter.cpp
index 6ed6bcf58..13833e5d6 100644
--- a/src/CppUTestExt/MemoryReportFormatter.cpp
+++ b/src/CppUTestExt/MemoryReportFormatter.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTestExt/MemoryReporterPlugin.cpp b/src/CppUTestExt/MemoryReporterPlugin.cpp
index e42bcd6bc..8b81f5dc8 100644
--- a/src/CppUTestExt/MemoryReporterPlugin.cpp
+++ b/src/CppUTestExt/MemoryReporterPlugin.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/CppUTestExt/MockActualCall.cpp b/src/CppUTestExt/MockActualCall.cpp
index 495886657..319e20a60 100644
--- a/src/CppUTestExt/MockActualCall.cpp
+++ b/src/CppUTestExt/MockActualCall.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -241,7 +241,7 @@ MockActualCall& MockCheckedActualCall::withLongIntParameter(const SimpleString&
return *this;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockActualCall& MockCheckedActualCall::withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value)
{
@@ -398,7 +398,7 @@ void MockCheckedActualCall::checkExpectations()
}
if (potentiallyMatchingExpectations_.hasUnmatchingExpectationsBecauseOfMissingParameters()) {
- MockExpectedParameterDidntHappenFailure failure(getTest(), getName(), allExpectations_);
+ MockExpectedParameterDidntHappenFailure failure(getTest(), getName(), allExpectations_, potentiallyMatchingExpectations_);
failTest(failure);
}
else {
@@ -472,7 +472,7 @@ long int MockCheckedActualCall::returnLongIntValueOrDefault(long int default_val
return returnLongIntValue();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValue()
{
@@ -505,7 +505,8 @@ cpputest_longlong MockCheckedActualCall::returnLongLongIntValueOrDefault(cpputes
cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValue()
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value)
@@ -517,7 +518,8 @@ cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValueOrDefaul
cpputest_longlong MockCheckedActualCall::returnLongLongIntValue()
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_longlong MockCheckedActualCall::returnLongLongIntValueOrDefault(cpputest_longlong default_value)
@@ -727,7 +729,7 @@ MockActualCall& MockActualCallTrace::withLongIntParameter(const SimpleString& na
return *this;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockActualCall& MockActualCallTrace::withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value)
{
@@ -856,7 +858,7 @@ long int MockActualCallTrace::returnLongIntValueOrDefault(long int)
return 0;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong MockActualCallTrace::returnLongLongIntValue()
{
@@ -883,25 +885,29 @@ cpputest_longlong MockActualCallTrace::returnLongLongIntValueOrDefault(cpputest_
cpputest_longlong MockActualCallTrace::returnLongLongIntValue()
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValue()
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong)
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
cpputest_longlong MockActualCallTrace::returnLongLongIntValueOrDefault(cpputest_longlong)
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
#endif
diff --git a/src/CppUTestExt/MockExpectedCall.cpp b/src/CppUTestExt/MockExpectedCall.cpp
index de931dcbd..2e11e7385 100644
--- a/src/CppUTestExt/MockExpectedCall.cpp
+++ b/src/CppUTestExt/MockExpectedCall.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -125,7 +125,7 @@ MockExpectedCall& MockCheckedExpectedCall::withUnsignedLongIntParameter(const Si
return *this;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockExpectedCall& MockCheckedExpectedCall::withLongLongIntParameter(const SimpleString& name, cpputest_longlong value)
{
@@ -248,7 +248,7 @@ MockExpectedCall& MockCheckedExpectedCall::withUnmodifiedOutputParameter(const S
SimpleString MockCheckedExpectedCall::getInputParameterType(const SimpleString& name)
{
MockNamedValue * p = inputParameters_->getValueByName(name);
- return (p) ? p->getType() : "";
+ return (p) ? p->getType() : StringFrom("");
}
bool MockCheckedExpectedCall::hasInputParameterWithName(const SimpleString& name)
@@ -368,7 +368,7 @@ void MockCheckedExpectedCall::outputParameterWasPassed(const SimpleString& name)
SimpleString MockCheckedExpectedCall::getInputParameterValueString(const SimpleString& name)
{
MockNamedValue * p = inputParameters_->getValueByName(name);
- return (p) ? StringFrom(*p) : "failed";
+ return (p) ? StringFrom(*p) : StringFrom("failed");
}
bool MockCheckedExpectedCall::hasInputParameter(const MockNamedValue& parameter)
@@ -423,7 +423,7 @@ SimpleString MockCheckedExpectedCall::callToString()
str += ", other parameters are ignored";
}
- str += StringFromFormat(" (expected %d call%s, called %d time%s)",
+ str += StringFromFormat(" (expected %u call%s, called %u time%s)",
expectedCalls_, (expectedCalls_ == 1) ? "" : "s", actualCalls_, (actualCalls_ == 1) ? "" : "s" );
return str;
@@ -514,7 +514,7 @@ MockExpectedCall& MockCheckedExpectedCall::andReturnValue(unsigned long int valu
return *this;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockExpectedCall& MockCheckedExpectedCall::andReturnValue(cpputest_longlong value)
{
diff --git a/src/CppUTestExt/MockExpectedCallsList.cpp b/src/CppUTestExt/MockExpectedCallsList.cpp
index f66f46b66..dd2970d7d 100644
--- a/src/CppUTestExt/MockExpectedCallsList.cpp
+++ b/src/CppUTestExt/MockExpectedCallsList.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -344,14 +344,17 @@ SimpleString MockExpectedCallsList::fulfilledCallsToString(const SimpleString& l
return stringOrNoneTextWhenEmpty(str, linePrefix);
}
-SimpleString MockExpectedCallsList::missingParametersToString() const
+SimpleString MockExpectedCallsList::callsWithMissingParametersToString(const SimpleString& linePrefix,
+ const SimpleString& missingParametersPrefix) const
{
SimpleString str;
for (MockExpectedCallsListNode* p = head_; p; p = p->next_)
- if (! p->expectedCall_->isMatchingActualCall())
- str = appendStringOnANewLine(str, "", p->expectedCall_->missingParametersToString());
+ {
+ str = appendStringOnANewLine(str, linePrefix, p->expectedCall_->callToString());
+ str = appendStringOnANewLine(str, linePrefix + missingParametersPrefix, p->expectedCall_->missingParametersToString());
+ }
- return stringOrNoneTextWhenEmpty(str, "");
+ return stringOrNoneTextWhenEmpty(str, linePrefix);
}
bool MockExpectedCallsList::hasUnmatchingExpectationsBecauseOfMissingParameters() const
diff --git a/src/CppUTestExt/MockFailure.cpp b/src/CppUTestExt/MockFailure.cpp
index 703c0753a..1c0a40f4f 100644
--- a/src/CppUTestExt/MockFailure.cpp
+++ b/src/CppUTestExt/MockFailure.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,22 +31,22 @@
#include "CppUTestExt/MockExpectedCallsList.h"
#include "CppUTestExt/MockNamedValue.h"
-class MockFailureReporterTestTerminator : public NormalTestTerminator
+class MockFailureReporterTestTerminator : public TestTerminator
{
public:
MockFailureReporterTestTerminator(bool crashOnFailure) : crashOnFailure_(crashOnFailure)
{
}
- virtual void exitCurrentTest() const _override
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE
{
if (crashOnFailure_)
UT_CRASH();
- NormalTestTerminator::exitCurrentTest();
+ UtestShell::getCurrentTestTerminator().exitCurrentTest();
} // LCOV_EXCL_LINE
- virtual ~MockFailureReporterTestTerminator() _destructor_override
+ virtual ~MockFailureReporterTestTerminator() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
private:
@@ -199,20 +199,21 @@ MockUnexpectedOutputParameterFailure::MockUnexpectedOutputParameterFailure(Utest
message_ += parameter.getName();
}
-MockExpectedParameterDidntHappenFailure::MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& expectations) : MockFailure(test)
+MockExpectedParameterDidntHappenFailure::MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName,
+ const MockExpectedCallsList& allExpectations,
+ const MockExpectedCallsList& matchingExpectations) : MockFailure(test)
{
- MockExpectedCallsList expectationsForFunction;
- expectationsForFunction.addExpectationsRelatedTo(functionName, expectations);
-
message_ = "Mock Failure: Expected parameter for function \"";
message_ += functionName;
message_ += "\" did not happen.\n";
- addExpectationsAndCallHistoryRelatedTo(functionName, expectations);
+ message_ += "\tEXPECTED calls with MISSING parameters related to function: ";
+ message_ += functionName;
+ message_ += "\n";
+ message_ += matchingExpectations.callsWithMissingParametersToString("\t\t", "\tMISSING parameters: ");
+ message_ += "\n";
- message_ += "\n\tMISSING parameters that didn't happen:\n";
- message_ += "\t\t";
- message_ += expectationsForFunction.missingParametersToString();
+ addExpectationsAndCallHistoryRelatedTo(functionName, allExpectations);
}
MockNoWayToCompareCustomTypeFailure::MockNoWayToCompareCustomTypeFailure(UtestShell* test, const SimpleString& typeName) : MockFailure(test)
diff --git a/src/CppUTestExt/MockNamedValue.cpp b/src/CppUTestExt/MockNamedValue.cpp
index 50fe209d1..2d4f1d1a0 100644
--- a/src/CppUTestExt/MockNamedValue.cpp
+++ b/src/CppUTestExt/MockNamedValue.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -82,7 +82,7 @@ void MockNamedValue::setValue(unsigned long int value)
value_.unsignedLongIntValue_ = value;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
void MockNamedValue::setValue(cpputest_longlong value)
{
@@ -246,7 +246,7 @@ unsigned long int MockNamedValue::getUnsignedLongIntValue() const
}
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong MockNamedValue::getLongLongIntValue() const
{
@@ -289,13 +289,15 @@ cpputest_ulonglong MockNamedValue::getUnsignedLongLongIntValue() const
cpputest_longlong MockNamedValue::getLongLongIntValue() const
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_ulonglong MockNamedValue::getUnsignedLongLongIntValue() const
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
#endif
@@ -393,7 +395,7 @@ bool MockNamedValue::equals(const MockNamedValue& p) const
return (value_.longIntValue_ >= 0) && ((unsigned long)value_.longIntValue_ == p.value_.unsignedLongIntValue_);
else if((type_ == "unsigned long int") && (p.type_ == "long int"))
return (p.value_.longIntValue_ >= 0) && (value_.unsignedLongIntValue_ == (unsigned long) p.value_.longIntValue_);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
else if ((type_ == "long long int") && (p.type_ == "int"))
return value_.longLongIntValue_ == p.value_.intValue_;
else if ((type_ == "int") && (p.type_ == "long long int"))
@@ -444,7 +446,7 @@ bool MockNamedValue::equals(const MockNamedValue& p) const
return value_.longIntValue_ == p.value_.longIntValue_;
else if (type_ == "unsigned long int")
return value_.unsignedLongIntValue_ == p.value_.unsignedLongIntValue_;
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
else if (type_ == "long long int")
return value_.longLongIntValue_ == p.value_.longLongIntValue_;
else if (type_ == "unsigned long long int")
@@ -496,7 +498,7 @@ SimpleString MockNamedValue::toString() const
return StringFrom(value_.longIntValue_) + " " + BracketsFormattedHexStringFrom(value_.longIntValue_);
else if (type_ == "unsigned long int")
return StringFrom(value_.unsignedLongIntValue_) + " " + BracketsFormattedHexStringFrom(value_.unsignedLongIntValue_);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
else if (type_ == "long long int")
return StringFrom(value_.longLongIntValue_) + " " + BracketsFormattedHexStringFrom(value_.longLongIntValue_);
else if (type_ == "unsigned long long int")
diff --git a/src/CppUTestExt/MockSupport.cpp b/src/CppUTestExt/MockSupport.cpp
index 45f58b4eb..2328eb5cb 100644
--- a/src/CppUTestExt/MockSupport.cpp
+++ b/src/CppUTestExt/MockSupport.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,9 +44,18 @@ MockSupport& mock(const SimpleString& mockName, MockFailureReporter* failureRepo
}
MockSupport::MockSupport(const SimpleString& mockName)
- : actualCallOrder_(0), expectedCallOrder_(0), strictOrdering_(false), standardReporter_(&defaultReporter_), ignoreOtherCalls_(false), enabled_(true), lastActualFunctionCall_(NULLPTR), mockName_(mockName), tracing_(false)
+ :
+ actualCallOrder_(0),
+ expectedCallOrder_(0),
+ strictOrdering_(false),
+ activeReporter_(NULLPTR),
+ standardReporter_(&defaultReporter_),
+ ignoreOtherCalls_(false),
+ enabled_(true),
+ lastActualFunctionCall_(NULLPTR),
+ mockName_(mockName),
+ tracing_(false)
{
- setActiveReporter(NULLPTR);
}
MockSupport::~MockSupport()
@@ -245,6 +254,7 @@ const char* MockSupport::getTraceOutput()
bool MockSupport::expectedCallsLeft()
{
+ checkExpectationsOfLastActualCall();
int callsLeft = expectations_.hasUnfulfilledExpectations();
for (MockNamedValueListNode* p = data_.begin(); p; p = p->next())
@@ -546,7 +556,7 @@ unsigned long int MockSupport::unsignedLongIntReturnValue()
return returnValue().getUnsignedLongIntValue();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong MockSupport::longLongIntReturnValue()
{
@@ -579,13 +589,15 @@ cpputest_ulonglong MockSupport::returnUnsignedLongLongIntValueOrDefault(cpputest
cpputest_longlong MockSupport::longLongIntReturnValue()
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_ulonglong MockSupport::unsignedLongLongIntReturnValue()
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
cpputest_longlong MockSupport::returnLongLongIntValueOrDefault(cpputest_longlong defaultValue)
diff --git a/src/CppUTestExt/MockSupportPlugin.cpp b/src/CppUTestExt/MockSupportPlugin.cpp
index 8f299fa5f..e484c466c 100644
--- a/src/CppUTestExt/MockSupportPlugin.cpp
+++ b/src/CppUTestExt/MockSupportPlugin.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -39,12 +39,12 @@ class MockSupportPluginReporter : public MockFailureReporter
{
}
- virtual void failTest(const MockFailure& failure) _override
+ virtual void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE
{
result_.addFailure(failure);
}
- virtual UtestShell* getTestToFail() _override
+ virtual UtestShell* getTestToFail() CPPUTEST_OVERRIDE
{
return &test_;
}
diff --git a/src/CppUTestExt/MockSupport_c.cpp b/src/CppUTestExt/MockSupport_c.cpp
index ddfd24070..cc7c7e540 100644
--- a/src/CppUTestExt/MockSupport_c.cpp
+++ b/src/CppUTestExt/MockSupport_c.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -34,22 +34,22 @@
typedef void (*cpputest_cpp_function_pointer)(); /* Cl2000 requires cast to C++ function */
-class MockFailureReporterTestTerminatorForInCOnlyCode : public TestTerminatorWithoutExceptions
+class MockFailureReporterTestTerminatorForInCOnlyCode : public TestTerminator
{
public:
MockFailureReporterTestTerminatorForInCOnlyCode(bool crashOnFailure) : crashOnFailure_(crashOnFailure)
{
}
- virtual void exitCurrentTest() const _override
+ virtual void exitCurrentTest() const CPPUTEST_OVERRIDE
{
if (crashOnFailure_)
UT_CRASH();
- TestTerminatorWithoutExceptions::exitCurrentTest();
+ UtestShell::getCurrentTestTerminatorWithoutExceptions().exitCurrentTest();
} // LCOV_EXCL_LINE
// LCOV_EXCL_START
- virtual ~MockFailureReporterTestTerminatorForInCOnlyCode() _destructor_override
+ virtual ~MockFailureReporterTestTerminatorForInCOnlyCode() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
// LCOV_EXCL_STOP
@@ -61,7 +61,7 @@ class MockFailureReporterTestTerminatorForInCOnlyCode : public TestTerminatorWit
class MockFailureReporterForInCOnlyCode : public MockFailureReporter
{
public:
- void failTest(const MockFailure& failure) _override
+ void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE
{
if (!getTestToFail()->hasFailed())
getTestToFail()->failWith(failure, MockFailureReporterTestTerminatorForInCOnlyCode(crashOnFailure_));
@@ -79,13 +79,13 @@ class MockCFunctionComparatorNode : public MockNamedValueComparator
public:
MockCFunctionComparatorNode(MockCFunctionComparatorNode* next, MockTypeEqualFunction_c equal, MockTypeValueToStringFunction_c toString)
: next_(next), equal_(equal), toString_(toString) {}
- virtual ~MockCFunctionComparatorNode() _destructor_override {}
+ virtual ~MockCFunctionComparatorNode() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- virtual bool isEqual(const void* object1, const void* object2) _override
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return equal_(object1, object2) != 0;
}
- virtual SimpleString valueToString(const void* object) _override
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
return SimpleString(toString_(object));
}
@@ -102,9 +102,9 @@ class MockCFunctionCopierNode : public MockNamedValueCopier
public:
MockCFunctionCopierNode(MockCFunctionCopierNode* next, MockTypeCopyFunction_c copier)
: next_(next), copier_(copier) {}
- virtual ~MockCFunctionCopierNode() _destructor_override {}
+ virtual ~MockCFunctionCopierNode() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- virtual void copy(void* dst, const void* src) _override
+ virtual void copy(void* dst, const void* src) CPPUTEST_OVERRIDE
{
copier_(dst, src);
}
@@ -408,7 +408,7 @@ MockExpectedCall_c* withUnsignedLongIntParameters_c(const char* name, unsigned l
return &gExpectedCall;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockExpectedCall_c* withLongLongIntParameters_c(const char* name, cpputest_longlong value)
{
@@ -540,7 +540,7 @@ MockExpectedCall_c* andReturnUnsignedLongIntValue_c(unsigned long int value)
return &gExpectedCall;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockExpectedCall_c* andReturnLongLongIntValue_c(cpputest_longlong value)
{
@@ -623,7 +623,7 @@ static MockValue_c getMockValueCFromNamedValue(const MockNamedValue& namedValue)
returnValue.type = MOCKVALUETYPE_UNSIGNED_LONG_INTEGER;
returnValue.value.unsignedLongIntValue = namedValue.getUnsignedLongIntValue();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "long long int") == 0) {
returnValue.type = MOCKVALUETYPE_LONG_LONG_INTEGER;
returnValue.value.longLongIntValue = namedValue.getLongLongIntValue();
@@ -722,7 +722,7 @@ MockActualCall_c* withActualUnsignedLongIntParameters_c(const char* name, unsign
return &gActualCall;
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
MockActualCall_c* withActualLongLongIntParameters_c(const char* name, cpputest_longlong value)
{
@@ -876,7 +876,7 @@ unsigned long int returnUnsignedLongIntValueOrDefault_c(unsigned long int defaul
return unsignedLongIntReturnValue_c();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
cpputest_longlong longLongIntReturnValue_c()
{
@@ -909,25 +909,29 @@ cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault_c(cpputest_ulonglong
cpputest_longlong longLongIntReturnValue_c()
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_longlong returnLongLongIntValueOrDefault_c(cpputest_longlong)
{
FAIL("Long Long type is not supported");
- return cpputest_longlong(0);
+ cpputest_longlong ret = {};
+ return ret;
}
cpputest_ulonglong unsignedLongLongIntReturnValue_c()
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault_c(cpputest_ulonglong)
{
FAIL("Unsigned Long Long type is not supported");
- return cpputest_ulonglong(0);
+ cpputest_ulonglong ret = {};
+ return ret;
}
#endif
diff --git a/src/CppUTestExt/OrderedTest.cpp b/src/CppUTestExt/OrderedTest.cpp
index 17035102e..50d0b3440 100644
--- a/src/CppUTestExt/OrderedTest.cpp
+++ b/src/CppUTestExt/OrderedTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/Platforms/Borland/UtestPlatform.cpp b/src/Platforms/Borland/UtestPlatform.cpp
new file mode 100644
index 000000000..3a09a3e68
--- /dev/null
+++ b/src/Platforms/Borland/UtestPlatform.cpp
@@ -0,0 +1,332 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include "CppUTest/TestHarness.h"
+#undef malloc
+#undef free
+#undef calloc
+#undef realloc
+#undef strdup
+#undef strndup
+
+#ifdef CPPUTEST_HAVE_GETTIMEOFDAY
+#include
+#endif
+#if defined(CPPUTEST_HAVE_FORK) && defined(CPPUTEST_HAVE_WAITPID) && defined(CPPUTEST_HAVE_KILL)
+#include
+#include
+#include
+#include
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+#include
+#endif
+
+#include "CppUTest/PlatformSpecificFunctions.h"
+
+const std::nothrow_t std::nothrow;
+
+static jmp_buf test_exit_jmp_buf[10];
+static int jmp_buf_index = 0;
+
+// There is a possibility that a compiler provides fork but not waitpid.
+// TODO consider using spawn() and cwait()?
+#if !defined(CPPUTEST_HAVE_FORK) || !defined(CPPUTEST_HAVE_WAITPID) || !defined(CPPUTEST_HAVE_KILL)
+
+static void BorlandPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result)
+{
+ result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b"));
+}
+
+static int PlatformSpecificForkImplementation(void)
+{
+ return 0;
+}
+
+static int PlatformSpecificWaitPidImplementation(int, int*, int)
+{
+ return 0;
+}
+
+#else
+
+static void SetTestFailureByStatusCode(UtestShell* shell, TestResult* result, int status)
+{
+ if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
+ result->addFailure(TestFailure(shell, "Failed in separate process"));
+ } else if (WIFSIGNALED(status)) {
+ SimpleString message("Failed in separate process - killed by signal ");
+ message += StringFrom(WTERMSIG(status));
+ result->addFailure(TestFailure(shell, message));
+ } else if (WIFSTOPPED(status)) {
+ result->addFailure(TestFailure(shell, "Stopped in separate process - continuing"));
+ }
+}
+
+static void BorlandPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result)
+{
+ const pid_t syscallError = -1;
+ pid_t cpid;
+ pid_t w;
+ int status = 0;
+
+ cpid = PlatformSpecificFork();
+
+ if (cpid == syscallError) {
+ result->addFailure(TestFailure(shell, "Call to fork() failed"));
+ return;
+ }
+
+ if (cpid == 0) { /* Code executed by child */
+ const size_t initialFailureCount = result->getFailureCount(); // LCOV_EXCL_LINE
+ shell->runOneTestInCurrentProcess(plugin, *result); // LCOV_EXCL_LINE
+ _exit(initialFailureCount < result->getFailureCount()); // LCOV_EXCL_LINE
+ } else { /* Code executed by parent */
+ size_t amountOfRetries = 0;
+ do {
+ w = PlatformSpecificWaitPid(cpid, &status, WUNTRACED);
+ if (w == syscallError) {
+ // OS X debugger causes EINTR
+ if (EINTR == errno) {
+ if (amountOfRetries > 30) {
+ result->addFailure(TestFailure(shell, "Call to waitpid() failed with EINTR. Tried 30 times and giving up! Sometimes happens in debugger"));
+ return;
+ }
+ amountOfRetries++;
+ }
+ else {
+ result->addFailure(TestFailure(shell, "Call to waitpid() failed"));
+ return;
+ }
+ } else {
+ SetTestFailureByStatusCode(shell, result, status);
+ if (WIFSTOPPED(status)) kill(w, SIGCONT);
+ }
+ } while ((w == syscallError) || (!WIFEXITED(status) && !WIFSIGNALED(status)));
+ }
+}
+
+static pid_t PlatformSpecificForkImplementation(void)
+{
+ return fork();
+}
+
+static pid_t PlatformSpecificWaitPidImplementation(int pid, int* status, int options)
+{
+ return waitpid(pid, status, options);
+}
+
+#endif
+
+TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment()
+{
+ return TestOutput::eclipse;
+}
+
+void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) =
+ BorlandPlatformSpecificRunTestInASeperateProcess;
+int (*PlatformSpecificFork)(void) = PlatformSpecificForkImplementation;
+int (*PlatformSpecificWaitPid)(int, int*, int) = PlatformSpecificWaitPidImplementation;
+
+extern "C" {
+
+static int PlatformSpecificSetJmpImplementation(void (*function) (void* data), void* data)
+{
+ if (0 == setjmp(test_exit_jmp_buf[jmp_buf_index])) {
+ jmp_buf_index++;
+ function(data);
+ jmp_buf_index--;
+ return 1;
+ }
+ return 0;
+}
+
+static void PlatformSpecificLongJmpImplementation()
+{
+ jmp_buf_index--;
+ longjmp(test_exit_jmp_buf[jmp_buf_index], 1);
+}
+
+static void PlatformSpecificRestoreJumpBufferImplementation()
+{
+ jmp_buf_index--;
+}
+
+void (*PlatformSpecificLongJmp)() = PlatformSpecificLongJmpImplementation;
+int (*PlatformSpecificSetJmp)(void (*)(void*), void*) = PlatformSpecificSetJmpImplementation;
+void (*PlatformSpecificRestoreJumpBuffer)() = PlatformSpecificRestoreJumpBufferImplementation;
+
+///////////// Time in millis
+
+static unsigned long TimeInMillisImplementation()
+{
+#ifdef CPPUTEST_HAVE_GETTIMEOFDAY
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return ((unsigned long)tv.tv_sec * 1000) + ((unsigned long)tv.tv_usec / 1000));
+#else
+ return 0;
+#endif
+}
+
+static const char* TimeStringImplementation()
+{
+ time_t theTime = time(NULLPTR);
+ static char dateTime[80];
+ struct tm *tmp = localtime(&theTime);
+ strftime(dateTime, 80, "%Y-%m-%dT%H:%M:%S", tmp);
+ return dateTime;
+}
+
+unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation;
+
+static int BorlandVSNprintf(char *str, size_t size, const char* format, va_list args)
+{
+ int result = vsnprintf( str, size, format, args);
+ str[size-1] = 0;
+ return result;
+}
+
+int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list) = BorlandVSNprintf;
+
+static PlatformSpecificFile PlatformSpecificFOpenImplementation(const char* filename, const char* flag)
+{
+ return fopen(filename, flag);
+}
+
+static void PlatformSpecificFPutsImplementation(const char* str, PlatformSpecificFile file)
+{
+ fputs(str, (FILE*)file);
+}
+
+static void PlatformSpecificFCloseImplementation(PlatformSpecificFile file)
+{
+ fclose((FILE*)file);
+}
+
+static void PlatformSpecificFlushImplementation()
+{
+ fflush(stdout);
+}
+
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
+PlatformSpecificFile (*PlatformSpecificFOpen)(const char*, const char*) = PlatformSpecificFOpenImplementation;
+void (*PlatformSpecificFPuts)(const char*, PlatformSpecificFile) = PlatformSpecificFPutsImplementation;
+void (*PlatformSpecificFClose)(PlatformSpecificFile) = PlatformSpecificFCloseImplementation;
+
+void (*PlatformSpecificFlush)() = PlatformSpecificFlushImplementation;
+
+void* (*PlatformSpecificMalloc)(size_t size) = malloc;
+void* (*PlatformSpecificRealloc)(void*, size_t) = realloc;
+void (*PlatformSpecificFree)(void* memory) = free;
+void* (*PlatformSpecificMemCpy)(void*, const void*, size_t) = memcpy;
+void* (*PlatformSpecificMemset)(void*, int, size_t) = memset;
+
+static int IsNanImplementation(double d)
+{
+ return _isnan(d);
+}
+
+static int IsInfImplementation(double d)
+{
+ return !(_finite(d) || _isnan(d));
+}
+
+double (*PlatformSpecificFabs)(double) = fabs;
+void (*PlatformSpecificSrand)(unsigned int) = srand;
+int (*PlatformSpecificRand)(void) = rand;
+int (*PlatformSpecificIsNan)(double) = IsNanImplementation;
+int (*PlatformSpecificIsInf)(double) = IsInfImplementation;
+int (*PlatformSpecificAtExit)(void(*func)(void)) = atexit; /// this was undefined before
+
+static PlatformSpecificMutex PThreadMutexCreate(void)
+{
+#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+ pthread_mutex_t *mutex = new pthread_mutex_t;
+
+ pthread_mutex_init(mutex, NULLPTR);
+ return (PlatformSpecificMutex)mutex;
+#else
+ return NULLPTR;
+#endif
+
+}
+
+#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+static void PThreadMutexLock(PlatformSpecificMutex mtx)
+{
+ pthread_mutex_lock((pthread_mutex_t *)mtx);
+}
+#else
+static void PThreadMutexLock(PlatformSpecificMutex)
+{
+}
+#endif
+
+#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+static void PThreadMutexUnlock(PlatformSpecificMutex mtx)
+{
+ pthread_mutex_unlock((pthread_mutex_t *)mtx);
+}
+#else
+static void PThreadMutexUnlock(PlatformSpecificMutex)
+{
+}
+#endif
+
+#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
+static void PThreadMutexDestroy(PlatformSpecificMutex mtx)
+{
+ pthread_mutex_t *mutex = (pthread_mutex_t *)mtx;
+ pthread_mutex_destroy(mutex);
+ delete mutex;
+}
+#else
+static void PThreadMutexDestroy(PlatformSpecificMutex)
+{
+}
+#endif
+
+PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = PThreadMutexCreate;
+void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = PThreadMutexLock;
+void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = PThreadMutexUnlock;
+void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = PThreadMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
+
+}
diff --git a/src/Platforms/C2000/UtestPlatform.cpp b/src/Platforms/C2000/UtestPlatform.cpp
index 543ed1eb0..558245c5d 100644
--- a/src/Platforms/C2000/UtestPlatform.cpp
+++ b/src/Platforms/C2000/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,8 +36,8 @@
#undef realloc
#undef strdup
#undef strndup
-
#define far // eliminate "meaningless type qualifier" warning
+extern "C" {
#include
#include
#include
@@ -45,8 +45,8 @@
#include
#include
#include
+}
#undef far
-
#include "CppUTest/PlatformSpecificFunctions.h"
static jmp_buf test_exit_jmp_buf[10];
@@ -100,7 +100,7 @@ int (*PlatformSpecificSetJmp)(void (*function) (void*), void*) = C2000SetJmp;
void (*PlatformSpecificLongJmp)(void) = C2000LongJmp;
void (*PlatformSpecificRestoreJumpBuffer)(void) = C2000RestoreJumpBuffer;
-static long C2000TimeInMillis()
+static unsigned long C2000TimeInMillis()
{
/* The TI c2000 platform does not have Posix support and thus lacks struct timespec.
* Also, clock() always returns 0 in the simulator. Hence we work with struct tm.tm_hour
@@ -112,7 +112,7 @@ static long C2000TimeInMillis()
*/
time_t t = time((time_t*)0);
struct tm * ptm = gmtime(&t);
- long result = (long)
+ unsigned long result = (unsigned long)
((ptm->tm_sec + ptm->tm_min * (time_t)60 + ptm->tm_hour * (time_t)3600) * (time_t)1000);
return result;
}
@@ -123,7 +123,7 @@ static const char* TimeStringImplementation()
return ctime(&tm);
}
-long (*GetPlatformSpecificTimeInMillis)() = C2000TimeInMillis;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = C2000TimeInMillis;
const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation;
extern int vsnprintf(char*, size_t, const char*, va_list); // not std::vsnprintf()
@@ -137,7 +137,17 @@ PlatformSpecificFile C2000FOpen(const char* filename, const char* flag)
static void C2000FPuts(const char* str, PlatformSpecificFile file)
{
- fputs(str, (FILE*)file);
+#if USE_BUFFER_OUTPUT
+ if (file == PlatformSpecificStdOut) {
+ while (*str && (idx < BUFFER_SIZE)) {
+ buf[idx++] = *str++;
+ }
+ }
+ else
+#endif
+ {
+ fputs(str, (FILE*)file);
+ }
}
static void C2000FClose(PlatformSpecificFile file)
@@ -145,53 +155,36 @@ static void C2000FClose(PlatformSpecificFile file)
fclose((FILE*)file);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = C2000FOpen;
void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = C2000FPuts;
void (*PlatformSpecificFClose)(PlatformSpecificFile file) = C2000FClose;
-static int CL2000Putchar(int c)
-{
-#if USE_BUFFER_OUTPUT
- if(idx < BUFFER_SIZE) {
- buffer[idx] = (char) c;
- idx++;
- /* "buffer[idx]" instead of "c" eliminates "never used" warning */
- return (buffer[idx]);
- }
- else {
- return EOF;
- }
-#else
- return putchar(c);
-#endif
-}
-
static void CL2000Flush()
{
fflush(stdout);
}
-extern int (*PlatformSpecificPutchar)(int c) = CL2000Putchar;
extern void (*PlatformSpecificFlush)(void) = CL2000Flush;
static void* C2000Malloc(size_t size)
{
- return (void*)far_malloc((unsigned long)size);
+ return (void*)malloc((unsigned long)size);
}
static void* C2000Realloc (void* memory, size_t size)
{
- return (void*)far_realloc((long)memory, (unsigned long)size);
+ return (void*)realloc(memory, (unsigned long)size);
}
static void C2000Free(void* memory)
{
- far_free((long)memory);
+ free(memory);
}
static void* C2000MemCpy(void* s1, const void* s2, size_t size)
{
- return (void*)far_memlcpy((long)s1, (long)s2, size);
+ return (void*)memcpy(s1, s2, size);
}
static void* C2000Memset(void* mem, int c, size_t size)
@@ -247,8 +240,11 @@ static void DummyMutexDestroy(PlatformSpecificMutex mtx)
}
PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate;
+void (*PlatformSpecificSrand)(unsigned int) = srand;
+int (*PlatformSpecificRand)(void) = rand;
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
-}
\ No newline at end of file
+}
diff --git a/src/Platforms/Dos/UtestPlatform.cpp b/src/Platforms/Dos/UtestPlatform.cpp
index 9367214bf..c17cd1a4a 100644
--- a/src/Platforms/Dos/UtestPlatform.cpp
+++ b/src/Platforms/Dos/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -104,9 +104,9 @@ int (*PlatformSpecificSetJmp)(void (*function) (void*), void*) = DosSetJmp;
void (*PlatformSpecificLongJmp)(void) = DosLongJmp;
void (*PlatformSpecificRestoreJumpBuffer)(void) = DosRestoreJumpBuffer;
-static long DosTimeInMillis()
+static unsigned long DosTimeInMillis()
{
- return clock() * 1000 / CLOCKS_PER_SEC;
+ return (unsigned long)(clock() * 1000 / CLOCKS_PER_SEC);
}
static const char* DosTimeString()
@@ -119,7 +119,7 @@ static int DosVSNprintf(char* str, size_t size, const char* format, va_list args
return vsnprintf(str, size, format, args);
}
-long (*GetPlatformSpecificTimeInMillis)() = DosTimeInMillis;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = DosTimeInMillis;
const char* (*GetPlatformSpecificTimeString)() = DosTimeString;
int (*PlatformSpecificVSNprintf)(char *, size_t, const char*, va_list) = DosVSNprintf;
@@ -138,21 +138,16 @@ static void DosFClose(PlatformSpecificFile file)
fclose((FILE*)file);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = DosFOpen;
void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = DosFPuts;
void (*PlatformSpecificFClose)(PlatformSpecificFile file) = DosFClose;
-static int DosPutchar(int c)
-{
- return putchar(c);
-}
-
static void DosFlush()
{
fflush(stdout);
}
-extern int (*PlatformSpecificPutchar)(int c) = DosPutchar;
extern void (*PlatformSpecificFlush)(void) = DosFlush;
static void* DosMalloc(size_t size)
@@ -239,4 +234,11 @@ void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
+static void DosAbort()
+{
+ abort();
+}
+
+void (*PlatformSpecificAbort)(void) = DosAbort;
+
}
diff --git a/src/Platforms/Gcc/UtestPlatform.cpp b/src/Platforms/Gcc/UtestPlatform.cpp
index 7717f22d1..c86b47839 100644
--- a/src/Platforms/Gcc/UtestPlatform.cpp
+++ b/src/Platforms/Gcc/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,10 +37,11 @@
#ifdef CPPUTEST_HAVE_GETTIMEOFDAY
#include
#endif
-#ifdef CPPUTEST_HAVE_FORK
+#if defined(CPPUTEST_HAVE_FORK) && defined(CPPUTEST_HAVE_WAITPID) && defined(CPPUTEST_HAVE_KILL)
#include
#include
#include
+#include
#endif
#include
@@ -50,7 +51,6 @@
#include
#include
#include
-#include
#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK
#include
@@ -61,7 +61,8 @@
static jmp_buf test_exit_jmp_buf[10];
static int jmp_buf_index = 0;
-#ifndef CPPUTEST_HAVE_FORK
+// There is a possibility that a compiler provides fork but not waitpid.
+#if !defined(CPPUTEST_HAVE_FORK) || !defined(CPPUTEST_HAVE_WAITPID) || !defined(CPPUTEST_HAVE_KILL)
static void GccPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result)
{
@@ -172,11 +173,13 @@ static int PlatformSpecificSetJmpImplementation(void (*function) (void* data), v
}
/*
- * MacOSX clang 3.0 doesn't seem to recognize longjmp and thus complains about _no_return_.
+ * MacOSX clang 3.0 doesn't seem to recognize longjmp and thus complains about CPPUTEST_NORETURN.
* The later clang compilers complain when it isn't there. So only way is to check the clang compiler here :(
*/
-#if !((__clang_major__ == 3) && (__clang_minor__ == 0))
-_no_return_
+#ifdef __clang__
+ #if !((__clang_major__ == 3) && (__clang_minor__ == 0))
+ CPPUTEST_NORETURN
+ #endif
#endif
static void PlatformSpecificLongJmpImplementation()
{
@@ -195,13 +198,12 @@ void (*PlatformSpecificRestoreJumpBuffer)() = PlatformSpecificRestoreJumpBufferI
///////////// Time in millis
-static long TimeInMillisImplementation()
+static unsigned long TimeInMillisImplementation()
{
#ifdef CPPUTEST_HAVE_GETTIMEOFDAY
struct timeval tv;
- struct timezone tz;
- gettimeofday(&tv, &tz);
- return (tv.tv_sec * 1000) + (long)((double)tv.tv_usec * 0.001);
+ gettimeofday(&tv, NULL);
+ return (((unsigned long)tv.tv_sec * 1000) + ((unsigned long)tv.tv_usec / 1000));
#else
return 0;
#endif
@@ -211,7 +213,7 @@ static const char* TimeStringImplementation()
{
time_t theTime = time(NULLPTR);
static char dateTime[80];
-#ifdef _WIN32
+#ifdef STDC_WANT_SECURE_LIB
static struct tm lastlocaltime;
localtime_s(&lastlocaltime, &theTime);
struct tm *tmp = &lastlocaltime;
@@ -222,7 +224,7 @@ static const char* TimeStringImplementation()
return dateTime;
}
-long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation;
/* Wish we could add an attribute to the format for discovering mis-use... but the __attribute__(format) seems to not work on va_list */
@@ -237,7 +239,7 @@ int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_
static PlatformSpecificFile PlatformSpecificFOpenImplementation(const char* filename, const char* flag)
{
-#ifdef _WIN32
+#ifdef STDC_WANT_SECURE_LIB
FILE* file;
fopen_s(&file, filename, flag);
return file;
@@ -261,11 +263,12 @@ static void PlatformSpecificFlushImplementation()
fflush(stdout);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
+
PlatformSpecificFile (*PlatformSpecificFOpen)(const char*, const char*) = PlatformSpecificFOpenImplementation;
void (*PlatformSpecificFPuts)(const char*, PlatformSpecificFile) = PlatformSpecificFPutsImplementation;
void (*PlatformSpecificFClose)(PlatformSpecificFile) = PlatformSpecificFCloseImplementation;
-int (*PlatformSpecificPutchar)(int) = putchar;
void (*PlatformSpecificFlush)() = PlatformSpecificFlushImplementation;
void* (*PlatformSpecificMalloc)(size_t size) = malloc;
@@ -350,5 +353,6 @@ PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = PThreadMutexCreate;
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = PThreadMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = PThreadMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = PThreadMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
}
diff --git a/src/Platforms/GccNoStdC/UtestPlatform.cpp b/src/Platforms/GccNoStdC/UtestPlatform.cpp
index 5898e61b1..3b3c996b3 100644
--- a/src/Platforms/GccNoStdC/UtestPlatform.cpp
+++ b/src/Platforms/GccNoStdC/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -48,15 +48,15 @@ void (*PlatformSpecificLongJmp)() = NULLPTR;
int (*PlatformSpecificSetJmp)(void (*)(void*), void*) = NULLPTR;
void (*PlatformSpecificRestoreJumpBuffer)() = NULLPTR;
-long (*GetPlatformSpecificTimeInMillis)() = NULLPTR;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = NULLPTR;
const char* (*GetPlatformSpecificTimeString)() = NULLPTR;
/* IO operations */
+PlatformSpecificFile PlatformSpecificStdOut = NULLPTR;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = NULLPTR;
void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = NULLPTR;
void (*PlatformSpecificFClose)(PlatformSpecificFile file) = NULLPTR;
-int (*PlatformSpecificPutchar)(int c) = NULLPTR;
void (*PlatformSpecificFlush)(void) = NULLPTR;
int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list) = NULLPTR;
@@ -80,3 +80,4 @@ void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex mtx) = NULLPTR;
void (*PlatformSpecificSrand)(unsigned int) = NULLPTR;
int (*PlatformSpecificRand)(void) = NULLPTR;
+void (*PlatformSpecificAbort)(void) = NULLPTR;
diff --git a/src/Platforms/Iar/UtestPlatform.cpp b/src/Platforms/Iar/UtestPlatform.cpp
index ef3c184ad..771ca5804 100644
--- a/src/Platforms/Iar/UtestPlatform.cpp
+++ b/src/Platforms/Iar/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -101,13 +101,13 @@ void (*PlatformSpecificRestoreJumpBuffer)() = PlatformSpecificRestoreJumpBufferI
///////////// Time in millis
-static long TimeInMillisImplementation()
+static unsigned long TimeInMillisImplementation()
{
clock_t t = clock();
t = t * 10;
- return t;
+ return (unsigned long)t;
}
///////////// Time in String
@@ -121,7 +121,7 @@ static const char* TimeStringImplementation()
return (pTimeStr);
}
-long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation;
int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list args) = vsnprintf;
@@ -151,11 +151,11 @@ static void PlatformSpecificFlushImplementation()
{
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char*, const char*) = PlatformSpecificFOpenImplementation;
void (*PlatformSpecificFPuts)(const char*, PlatformSpecificFile) = PlatformSpecificFPutsImplementation;
void (*PlatformSpecificFClose)(PlatformSpecificFile) = PlatformSpecificFCloseImplementation;
-int (*PlatformSpecificPutchar)(int) = putchar;
void (*PlatformSpecificFlush)() = PlatformSpecificFlushImplementation;
void* (*PlatformSpecificMalloc)(size_t size) = malloc;
@@ -200,5 +200,7 @@ PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate;
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
-
+void (*PlatformSpecificSrand)(unsigned int) = srand;
+int (*PlatformSpecificRand)(void) = rand;
+void (*PlatformSpecificAbort)(void) = abort;
}
diff --git a/src/Platforms/Keil/UtestPlatform.cpp b/src/Platforms/Keil/UtestPlatform.cpp
index 261b266f5..9d2582eaa 100644
--- a/src/Platforms/Keil/UtestPlatform.cpp
+++ b/src/Platforms/Keil/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -108,16 +108,16 @@ extern "C"
* In Keil MDK-ARM, clock() default implementation used semihosting.
* Resolutions is user adjustable (1 ms for now)
*/
- static long TimeInMillisImplementation()
+ static unsigned long TimeInMillisImplementation()
{
clock_t t = clock();
- t = t * 10;
+ t = t * 10;
- return t;
+ return (unsigned long)t;
}
- long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+ unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
static const char* TimeStringImplementation()
{
@@ -155,11 +155,11 @@ extern "C"
{
}
+ PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char*, const char*) = PlatformSpecificFOpenImplementation;
void (*PlatformSpecificFPuts)(const char*, PlatformSpecificFile) = PlatformSpecificFPutsImplementation;
void (*PlatformSpecificFClose)(PlatformSpecificFile) = PlatformSpecificFCloseImplementation;
- int (*PlatformSpecificPutchar)(int) = putchar;
void (*PlatformSpecificFlush)() = PlatformSpecificFlushImplementation;
void* (*PlatformSpecificMalloc)(size_t) = malloc;
void* (*PlatformSpecificRealloc) (void*, size_t) = realloc;
@@ -216,5 +216,6 @@ extern "C"
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
+ void (*PlatformSpecificAbort)(void) = abort;
}
diff --git a/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp b/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp
index 0003442d2..dbea37a3c 100644
--- a/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp
+++ b/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/src/Platforms/Symbian/UtestPlatform.cpp b/src/Platforms/Symbian/UtestPlatform.cpp
index a4d5df7e0..2829a6f7d 100644
--- a/src/Platforms/Symbian/UtestPlatform.cpp
+++ b/src/Platforms/Symbian/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -67,14 +67,14 @@ void PlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin* pl
shell->runOneTest(plugin, *result);
}
-static long TimeInMillisImplementation() {
+static unsigned long TimeInMillisImplementation() {
struct timeval tv;
struct timezone tz;
::gettimeofday(&tv, &tz);
- return (tv.tv_sec * 1000) + (long)(tv.tv_usec * 0.001);
+ return ((unsigned long)tv.tv_sec * 1000) + ((unsigned long)tv.tv_usec / 1000);
}
-long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment()
{
@@ -96,10 +96,6 @@ void PlatformSpecificFlush() {
fflush(stdout);
}
-int PlatformSpecificPutchar(int c) {
- return putchar(c);
-}
-
double PlatformSpecificFabs(double d) {
return fabs(d);
}
@@ -125,6 +121,8 @@ void* PlatformSpecificMemset(void* mem, int c, size_t size)
return memset(mem, c, size);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
+
PlatformSpecificFile PlatformSpecificFOpen(const char* filename, const char* flag) {
return fopen(filename, flag);
}
@@ -179,4 +177,5 @@ PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate;
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
diff --git a/src/Platforms/VisualCpp/UtestPlatform.cpp b/src/Platforms/VisualCpp/UtestPlatform.cpp
index 6e3ab35c4..992c6b863 100644
--- a/src/Platforms/VisualCpp/UtestPlatform.cpp
+++ b/src/Platforms/VisualCpp/UtestPlatform.cpp
@@ -16,19 +16,19 @@
#include
#include "CppUTest/PlatformSpecificFunctions.h"
-#include
+#include
#include
#include
#ifdef STDC_WANT_SECURE_LIB
- #define FOPEN(fp, filename, flag) fopen_s((fp), (filename), (flag))
- #define _VSNPRINTF(str, size, trunc, format, args) _vsnprintf_s((str), (size), (trunc), (format), (args))
- #define LOCALTIME(_tm, timer) localtime_s((_tm), (timer))
+ #define MAYBE_SECURE_FOPEN(fp, filename, flag) fopen_s((fp), (filename), (flag))
+ #define MAYBE_SECURE_VSNPRINTF(str, size, trunc, format, args) _vsnprintf_s((str), (size), (trunc), (format), (args))
+ #define MAYBE_SECURE_LOCALTIME(_tm, timer) localtime_s((_tm), (timer))
#else
- #define FOPEN(fp, filename, flag) *(fp) = fopen((filename), (flag))
- #define _VSNPRINTF(str, size, trunc, format, args) _vsnprintf((str), (size), (format), (args))
- #define LOCALTIME(_tm, timer) memcpy(_tm, localtime(timer), sizeof(tm));
+ #define MAYBE_SECURE_FOPEN(fp, filename, flag) *(fp) = fopen((filename), (flag))
+ #define MAYBE_SECURE_VSNPRINTF(str, size, trunc, format, args) _vsnprintf((str), (size), (format), (args))
+ #define MAYBE_SECURE_LOCALTIME(_tm, timer) memcpy(_tm, localtime(timer), sizeof(tm));
#endif
static jmp_buf test_exit_jmp_buf[10];
@@ -45,7 +45,7 @@ static int VisualCppSetJmp(void (*function) (void* data), void* data)
return 0;
}
-static void VisualCppLongJmp()
+CPPUTEST_NORETURN static void VisualCppLongJmp()
{
jmp_buf_index--;
longjmp(test_exit_jmp_buf[jmp_buf_index], 1);
@@ -60,7 +60,7 @@ int (*PlatformSpecificSetJmp)(void (*function) (void*), void* data) = VisualCppS
void (*PlatformSpecificLongJmp)(void) = VisualCppLongJmp;
void (*PlatformSpecificRestoreJumpBuffer)(void) = VisualCppRestoreJumpBuffer;
-static void VisualCppRunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result)
+static void VisualCppRunTestInASeperateProcess(UtestShell* shell, TestPlugin* /* plugin */, TestResult* result)
{
result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b"));
}
@@ -75,7 +75,7 @@ TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment()
///////////// Time in millis
-static long VisualCppTimeInMillis()
+static unsigned long VisualCppTimeInMillis()
{
static LARGE_INTEGER s_frequency;
static const BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency);
@@ -83,32 +83,32 @@ static long VisualCppTimeInMillis()
{
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
- return (long)((now.QuadPart * 1000) / s_frequency.QuadPart);
- }
- else
+ return (unsigned long)((now.QuadPart * 1000) / s_frequency.QuadPart);
+ }
+ else
{
#ifdef TIMERR_NOERROR
- return timeGetTime();
+ return (unsigned long)timeGetTime();
#else
#if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || (_WIN32_WINNT < _WIN32_WINNT_VISTA)
- return GetTickCount();
+ return (unsigned long)GetTickCount();
#else
- return (long)GetTickCount64();
+ return (unsigned long)GetTickCount64();
#endif
#endif
}
}
-long (*GetPlatformSpecificTimeInMillis)() = VisualCppTimeInMillis;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = VisualCppTimeInMillis;
///////////// Time in String
static const char* VisualCppTimeString()
{
- time_t the_time = time(NULL);
+ time_t the_time = time(NULLPTR);
struct tm the_local_time;
static char dateTime[80];
- LOCALTIME(&the_local_time, &the_time);
+ MAYBE_SECURE_LOCALTIME(&the_local_time, &the_time);
strftime(dateTime, 80, "%Y-%m-%dT%H:%M:%S", &the_local_time);
return dateTime;
}
@@ -119,21 +119,21 @@ const char* (*GetPlatformSpecificTimeString)() = VisualCppTimeString;
static int VisualCppVSNprintf(char *str, size_t size, const char* format, va_list args)
{
- char* buf = 0;
+ char* buf = NULLPTR;
size_t sizeGuess = size;
- int result = _VSNPRINTF( str, size, _TRUNCATE, format, args);
+ int result = MAYBE_SECURE_VSNPRINTF( str, size, _TRUNCATE, format, args);
str[size-1] = 0;
while (result == -1)
{
- if (buf != 0)
+ if (buf)
free(buf);
sizeGuess += 10;
buf = (char*)malloc(sizeGuess);
- result = _VSNPRINTF( buf, sizeGuess, _TRUNCATE, format, args);
+ result = MAYBE_SECURE_VSNPRINTF( buf, sizeGuess, _TRUNCATE, format, args);
}
- if (buf != 0)
+ if (buf)
free(buf);
return result;
@@ -144,7 +144,7 @@ int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_
static PlatformSpecificFile VisualCppFOpen(const char* filename, const char* flag)
{
FILE* file;
- FOPEN(&file, filename, flag);
+ MAYBE_SECURE_FOPEN(&file, filename, flag);
return file;
}
@@ -158,6 +158,7 @@ static void VisualCppFClose(PlatformSpecificFile file)
fclose((FILE*)file);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = VisualCppFOpen;
void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = VisualCppFPuts;
void (*PlatformSpecificFClose)(PlatformSpecificFile file) = VisualCppFClose;
@@ -167,7 +168,6 @@ static void VisualCppFlush()
fflush(stdout);
}
-int (*PlatformSpecificPutchar)(int c) = putchar;
void (*PlatformSpecificFlush)(void) = VisualCppFlush;
static void* VisualCppMalloc(size_t size)
@@ -231,3 +231,4 @@ PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = VisualCppMutexCreat
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = VisualCppMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = VisualCppMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = VisualCppMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
diff --git a/src/Platforms/armcc/UtestPlatform.cpp b/src/Platforms/armcc/UtestPlatform.cpp
index 2e531c0c3..8c686c25a 100644
--- a/src/Platforms/armcc/UtestPlatform.cpp
+++ b/src/Platforms/armcc/UtestPlatform.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -107,10 +107,10 @@ void (*PlatformSpecificRestoreJumpBuffer)() = PlatformSpecificRestoreJumpBufferI
* In Keil MDK-ARM, clock() default implementation used semihosting.
* Resolutions is user adjustable (1 ms for now)
*/
-static long TimeInMillisImplementation()
+static unsigned long TimeInMillisImplementation()
{
clock_t t = clock();
- return t;
+ return (unsigned long)t;
}
///////////// Time in String
@@ -121,7 +121,7 @@ static const char* DummyTimeStringImplementation()
return ctime(&tm);
}
-long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
+unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation;
const char* (*GetPlatformSpecificTimeString)() = DummyTimeStringImplementation;
int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list args) = vsnprintf;
@@ -146,11 +146,11 @@ static void PlatformSpecificFlushImplementation()
fflush(stdout);
}
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
PlatformSpecificFile (*PlatformSpecificFOpen)(const char*, const char*) = PlatformSpecificFOpenImplementation;
void (*PlatformSpecificFPuts)(const char*, PlatformSpecificFile) = PlatformSpecificFPutsImplementation;
void (*PlatformSpecificFClose)(PlatformSpecificFile) = PlatformSpecificFCloseImplementation;
-int (*PlatformSpecificPutchar)(int) = putchar;
void (*PlatformSpecificFlush)() = PlatformSpecificFlushImplementation;
void* (*PlatformSpecificMalloc)(size_t size) = malloc;
@@ -159,6 +159,9 @@ void (*PlatformSpecificFree)(void* memory) = free;
void* (*PlatformSpecificMemCpy)(void*, const void*, size_t) = memcpy;
void* (*PlatformSpecificMemset)(void*, int, size_t) = memset;
+void (*PlatformSpecificSrand)(unsigned int) = srand;
+int (*PlatformSpecificRand)(void) = rand;
+
static int IsNanImplementation(double d)
{
return isnan(d);
@@ -200,5 +203,6 @@ PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate;
void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock;
void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock;
void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy;
+void (*PlatformSpecificAbort)(void) = abort;
}
diff --git a/tests/AllTests.vcproj b/tests/AllTests.vcproj
index 16ab375c9..7e32f154e 100644
--- a/tests/AllTests.vcproj
+++ b/tests/AllTests.vcproj
@@ -45,7 +45,7 @@
Name="VCCLCompilerTool"
Optimization="0"
InlineFunctionExpansion="1"
- AdditionalIncludeDirectories="..\include,..\include\Platforms\VisualCpp"
+ AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;CPPUTEST_USE_LONG_LONG"
StringPooling="true"
RuntimeLibrary="0"
@@ -129,14 +129,14 @@
<_ProjectFileVersion>10.0.30319.1
- ..\cpputest_build\
- ..\cpputest_build\
- ..\cpputest_build\Release\$(ProjectName)\
- ..\cpputest_build\Release\$(ProjectName)\
+ ..\cpputest_build\x86\
+ ..\cpputest_build\x64\
+ ..\cpputest_build\Release\x86\$(ProjectName)\
+ ..\cpputest_build\Release\x64\$(ProjectName)\
false
false
- ..\cpputest_build\
- ..\cpputest_build\
- ..\cpputest_build\Debug\$(ProjectName)\
- ..\cpputest_build\Debug\$(ProjectName)\
+ ..\cpputest_build\x86\
+ ..\cpputest_build\x64\
+ ..\cpputest_build\Debug\x86\$(ProjectName)\
+ ..\cpputest_build\Debug\x64\$(ProjectName)\
true
true
@@ -92,7 +92,7 @@
true
Level3
true
- ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;..\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories)
OldStyle
true
@@ -131,7 +131,7 @@
true
Level3
true
- ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;..\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories)
OldStyle
true
@@ -162,7 +162,7 @@
Disabled
- ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;..\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories)
+ ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories)
_CONSOLE;WIN32;_DEBUG;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)
EnableFastChecks
MultiThreadedDebugDLL
@@ -319,4 +319,4 @@
-
+
\ No newline at end of file
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 000000000..5d090ace3
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,23 @@
+# Helper to handle generating a map file, which is annoyingly tricky.
+function(add_mapfile target)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.13")
+ set(mapfile "$.map")
+ if(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ # ClangCL (lld-link) can't generate map files
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IAR")
+ target_link_options(${target} PRIVATE "SHELL:--map ${mapfile}.map")
+ elseif(MSVC)
+ target_link_options(${target} PRIVATE "/MAP:${mapfile}")
+ elseif(
+ (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
+ (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ )
+ target_link_options(${target} PRIVATE "LINKER:-Map=${mapfile}")
+ endif()
+ endif()
+endfunction()
+
+add_subdirectory(CppUTest)
+if (CPPUTEST_EXTENSIONS)
+ add_subdirectory(CppUTestExt)
+endif ()
diff --git a/tests/CppUTest/AllTests.cpp b/tests/CppUTest/AllTests.cpp
index 0ae63fdc7..e9e6a2b75 100644
--- a/tests/CppUTest/AllTests.cpp
+++ b/tests/CppUTest/AllTests.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -46,7 +46,7 @@ int main(int ac, char **av)
accountant.start();
#endif
- CommandLineTestRunner::RunAllTests(ac, av); /* cover alternate method */
+ returnValue = CommandLineTestRunner::RunAllTests(ac, av); /* cover alternate method */
#if SHOW_MEMORY_REPORT
accountant.stop();
diff --git a/tests/CppUTest/AllTests.h b/tests/CppUTest/AllTests.h
index 9e2fb1649..32ef2c770 100644
--- a/tests/CppUTest/AllTests.h
+++ b/tests/CppUTest/AllTests.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTest/AllocLetTestFreeTest.cpp b/tests/CppUTest/AllocLetTestFreeTest.cpp
index ef4edcef8..5c05464b7 100644
--- a/tests/CppUTest/AllocLetTestFreeTest.cpp
+++ b/tests/CppUTest/AllocLetTestFreeTest.cpp
@@ -16,12 +16,12 @@ TEST_GROUP(AllocLetTestFree)
{
AllocLetTestFree allocLetTestFree;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
allocLetTestFree = AllocLetTestFree_Create();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
AllocLetTestFree_Destroy(allocLetTestFree);
}
diff --git a/tests/CppUTest/AllocationInCFile.c b/tests/CppUTest/AllocationInCFile.c
index 5d1765c63..03165a958 100644
--- a/tests/CppUTest/AllocationInCFile.c
+++ b/tests/CppUTest/AllocationInCFile.c
@@ -4,12 +4,12 @@
/* This file is for simulating overloads of malloc */
-char* mallocAllocation()
+char* mallocAllocation(void)
{
return (char*) malloc(10UL);
}
-char* strdupAllocation()
+char* strdupAllocation(void)
{
#ifdef CPPUTEST_USE_STRDUP_MACROS
return strdup("0123456789");
@@ -19,7 +19,7 @@ char* strdupAllocation()
}
-char* strndupAllocation()
+char* strndupAllocation(void)
{
#ifdef CPPUTEST_USE_STRDUP_MACROS
return strndup("0123456789", 10);
diff --git a/tests/CppUTest/AllocationInCppFile.cpp b/tests/CppUTest/AllocationInCppFile.cpp
index d85e66bb5..b1a662b1c 100644
--- a/tests/CppUTest/AllocationInCppFile.cpp
+++ b/tests/CppUTest/AllocationInCppFile.cpp
@@ -27,7 +27,7 @@ char* newArrayAllocationWithoutMacro()
return new char[100];
}
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
ClassThatThrowsAnExceptionInTheConstructor::ClassThatThrowsAnExceptionInTheConstructor()
{
diff --git a/tests/CppUTest/AllocationInCppFile.h b/tests/CppUTest/AllocationInCppFile.h
index f3b47766a..1d59789df 100644
--- a/tests/CppUTest/AllocationInCppFile.h
+++ b/tests/CppUTest/AllocationInCppFile.h
@@ -7,12 +7,12 @@ char* newArrayAllocation();
char* newAllocationWithoutMacro();
char* newArrayAllocationWithoutMacro();
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
class ClassThatThrowsAnExceptionInTheConstructor
{
public:
- ClassThatThrowsAnExceptionInTheConstructor() _no_return_;
+ CPPUTEST_NORETURN ClassThatThrowsAnExceptionInTheConstructor();
};
#endif
diff --git a/tests/CppUTest/CMakeLists.txt b/tests/CppUTest/CMakeLists.txt
index 9ac1ea715..0471ce762 100644
--- a/tests/CppUTest/CMakeLists.txt
+++ b/tests/CppUTest/CMakeLists.txt
@@ -1,61 +1,101 @@
-set(CppUTestTests_src
+add_library(CppUTestTests_main OBJECT
AllTests.cpp
- SetPluginTest.cpp
+)
+
+if(CPPUTEST_STD_C_LIB_DISABLED)
+ target_sources(CppUTestTests_main
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/../DummyUTestPlatform/DummyUTestPlatform.cpp
+ )
+endif()
+
+target_link_libraries(CppUTestTests_main
+ PUBLIC CppUTest
+)
+
+include(CppUTest)
+
+if(NOT CPPUTEST_SPLIT_TESTS)
+ add_executable(CppUTestTests)
+
+ add_mapfile(CppUTestTests)
+
+ cpputest_discover_tests(CppUTestTests)
+endif()
+
+function(add_cpputest_test number)
+ set(name CppUTestTests)
+
+ if(CPPUTEST_SPLIT_TESTS)
+ string(APPEND name ${number})
+ add_executable(${name})
+ add_mapfile(${name})
+ cpputest_discover_tests(${name})
+ endif()
+
+ target_sources(${name}
+ PRIVATE ${ARGN}
+ )
+ target_link_libraries(${name}
+ PRIVATE CppUTestTests_main
+ )
+endfunction()
+
+add_cpputest_test(1
+ AllocLetTestFree.c
+ AllocLetTestFreeTest.cpp
CheatSheetTest.cpp
- SimpleStringTest.cpp
- SimpleStringCacheTest.cpp
CompatabilityTests.cpp
CommandLineArgumentsTest.cpp
- TestFailureTest.cpp
- TestFailureNaNTest.cpp
CommandLineTestRunnerTest.cpp
- TestFilterTest.cpp
- TestHarness_cTest.cpp
JUnitOutputTest.cpp
- TestHarness_cTestCFile.c
+)
+
+add_cpputest_test(2
DummyMemoryLeakDetector.cpp
- MemoryLeakDetectorTest.cpp
- TestInstallerTest.cpp
- AllocLetTestFree.c
- MemoryOperatorOverloadTest.cpp
- TestMemoryAllocatorTest.cpp
MemoryLeakWarningTest.cpp
- TestOutputTest.cpp
- AllocLetTestFreeTest.cpp
- TestRegistryTest.cpp
- AllocationInCFile.c
PluginTest.cpp
- TestResultTest.cpp
PreprocessorTest.cpp
- TestUTestMacro.cpp
- TestUTestStringMacro.cpp
- AllocationInCppFile.cpp
- UtestTest.cpp
+ SetPluginTest.cpp
SimpleMutexTest.cpp
- UtestPlatformTest.cpp
TeamCityOutputTest.cpp
+ TestFailureNaNTest.cpp
+ TestFailureTest.cpp
+ TestResultTest.cpp
)
-if (MSVC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4723")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4723")
-endif (MSVC)
+add_cpputest_test(3
+ MemoryLeakDetectorTest.cpp
+ SimpleStringTest.cpp
+ SimpleStringCacheTest.cpp
+)
-if (MINGW)
- find_package (Threads REQUIRED)
- set(THREAD_LIB "pthread")
-endif (MINGW)
+add_cpputest_test(4
+ TestOutputTest.cpp
+ TestRegistryTest.cpp
+)
-if (${CMAKE_HOST_SYSTEM_NAME} MATCHES "OpenBSD")
- set (THREADS_HAVE_PTHREAD_ARG 1)
- find_package (Threads REQUIRED)
- set (THREAD_LIB "pthread")
-endif ()
+add_cpputest_test(5
+ AllocationInCFile.c
+ AllocationInCppFile.cpp
+ MemoryOperatorOverloadTest.cpp
+ TeamCityOutputTest.cpp
+)
-add_executable(CppUTestTests ${CppUTestTests_src})
-cpputest_normalize_test_output_location(CppUTestTests)
-target_link_libraries(CppUTestTests CppUTest ${THREAD_LIB})
+add_cpputest_test(6
+ TestFilterTest.cpp
+ TestHarness_cTest.cpp
+ TestHarness_cTestCFile.c
+ TestInstallerTest.cpp
+)
-if (TESTS_BUILD_DISCOVER)
- cpputest_buildtime_discover_tests(CppUTestTests)
-endif()
+add_cpputest_test(7
+ TestMemoryAllocatorTest.cpp
+ TestUTestMacro.cpp
+)
+
+add_cpputest_test(8
+ UtestPlatformTest.cpp
+ UtestTest.cpp
+ TestUTestStringMacro.cpp
+)
diff --git a/tests/CppUTest/CheatSheetTest.cpp b/tests/CppUTest/CheatSheetTest.cpp
index fd44b8609..dbde888b7 100644
--- a/tests/CppUTest/CheatSheetTest.cpp
+++ b/tests/CppUTest/CheatSheetTest.cpp
@@ -9,14 +9,14 @@ static void stub(){}
TEST_GROUP(CheatSheet)
{
/* declare a setup method for the test group. Optional. */
- void setup ()
+ void setup() CPPUTEST_OVERRIDE
{
/* Set method real_one to stub. Automatically restore in teardown */
UT_PTR_SET(real_one, stub);
}
/* Declare a teardown method for the test group. Optional */
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
}
}; /* Do not forget semicolumn */
@@ -33,4 +33,3 @@ TEST(CheatSheet, TestName)
/* Check a string */
STRCMP_EQUAL("HelloWorld", "HelloWorld");
}
-
diff --git a/tests/CppUTest/CommandLineArgumentsTest.cpp b/tests/CppUTest/CommandLineArgumentsTest.cpp
index 407dc75ce..2a4e29b7f 100644
--- a/tests/CppUTest/CommandLineArgumentsTest.cpp
+++ b/tests/CppUTest/CommandLineArgumentsTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,10 +36,10 @@ class OptionsPlugin: public TestPlugin
TestPlugin(name)
{
}
- ~OptionsPlugin() _destructor_override
+ ~OptionsPlugin() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
- bool parseArguments(int /*ac*/, const char *const * /*av*/, int /*index*/) _override
+ bool parseArguments(int /*ac*/, const char *const * /*av*/, int /*index*/) CPPUTEST_OVERRIDE
{
return true;
}
@@ -50,12 +50,12 @@ TEST_GROUP(CommandLineArguments)
CommandLineArguments* args;
OptionsPlugin* plugin;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
plugin = new OptionsPlugin("options");
args = NULLPTR;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete args;
delete plugin;
@@ -206,6 +206,7 @@ TEST(CommandLineArguments, setCompleteGroupDotNameFilterInvalidArgument)
const char* argv[] = { "tests.exe", "-t", "groupname" };
CHECK_FALSE(newArgumentParser(argc, argv));
}
+
TEST(CommandLineArguments, setCompleteGroupDotNameFilter)
{
int argc = 3;
@@ -215,6 +216,67 @@ TEST(CommandLineArguments, setCompleteGroupDotNameFilter)
CHECK_EQUAL(TestFilter("name"), *args->getNameFilters());
}
+TEST(CommandLineArguments, setCompleteStrictGroupDotNameFilterInvalidArgument)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-st", "groupname" };
+ CHECK_FALSE(newArgumentParser(argc, argv));
+}
+
+TEST(CommandLineArguments, setCompleteStrictGroupDotNameFilter)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-st", "group.name" };
+ CHECK(newArgumentParser(argc, argv));
+ TestFilter groupFilter("group");
+ groupFilter.strictMatching();
+ CHECK_EQUAL(groupFilter, *args->getGroupFilters());
+ TestFilter nameFilter("name");
+ nameFilter.strictMatching();
+ CHECK_EQUAL(nameFilter, *args->getNameFilters());
+}
+
+TEST(CommandLineArguments, setCompleteExcludeGroupDotNameFilterInvalidArgument)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-xt", "groupname" };
+ CHECK_FALSE(newArgumentParser(argc, argv));
+}
+
+TEST(CommandLineArguments, setCompleteExcludeGroupDotNameFilter)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-xt", "group.name" };
+ CHECK(newArgumentParser(argc, argv));
+ TestFilter groupFilter("group");
+ groupFilter.invertMatching();
+ CHECK_EQUAL(groupFilter, *args->getGroupFilters());
+ TestFilter nameFilter("name");
+ nameFilter.invertMatching();
+ CHECK_EQUAL(nameFilter, *args->getNameFilters());
+}
+
+TEST(CommandLineArguments, setCompleteExcludeStrictGroupDotNameFilterInvalidArgument)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-xst", "groupname" };
+ CHECK_FALSE(newArgumentParser(argc, argv));
+}
+
+TEST(CommandLineArguments, setCompleteExcludeStrictGroupDotNameFilter)
+{
+ int argc = 3;
+ const char* argv[] = { "tests.exe", "-xst", "group.name" };
+ CHECK(newArgumentParser(argc, argv));
+ TestFilter groupFilter("group");
+ groupFilter.strictMatching();
+ groupFilter.invertMatching();
+ CHECK_EQUAL(groupFilter, *args->getGroupFilters());
+ TestFilter nameFilter("name");
+ nameFilter.strictMatching();
+ nameFilter.invertMatching();
+ CHECK_EQUAL(nameFilter, *args->getNameFilters());
+}
TEST(CommandLineArguments, setGroupFilterSameParameter)
{
@@ -464,9 +526,12 @@ TEST(CommandLineArguments, weirdParamatersReturnsFalse)
TEST(CommandLineArguments, printUsage)
{
- STRCMP_EQUAL("use -h for more extensive help\nusage [-h] [-v] [-vv] [-c] [-p] [-lg] [-ln] [-ri] [-r#]\n"
- " [-g|sg|xg|xsg groupName]... [-n|sn|xn|xsn testName]... [-t groupName.testName]...\n"
- " [-b] [-s [randomizerSeed>0]] [\"TEST(groupName, testName)\"]... [-o{normal, junit, teamcity}] [-k packageName]\n",
+ STRCMP_EQUAL(
+ "use -h for more extensive help\n"
+ "usage [-h] [-v] [-vv] [-c] [-p] [-lg] [-ln] [-ll] [-ri] [-r[<#>]] [-f] [-e] [-ci]\n"
+ " [-g|sg|xg|xsg ]... [-n|sn|xn|xsn ]... [-t|st|xt|xst .]...\n"
+ " [-b] [-s []] [\"[IGNORE_]TEST(, )\"]...\n"
+ " [-o{normal|eclipse|junit|teamcity}] [-k ]\n",
args->usage());
}
@@ -500,6 +565,23 @@ TEST(CommandLineArguments, checkDefaultArguments)
CHECK(NULLPTR == args->getNameFilters());
CHECK(args->isEclipseOutput());
CHECK(SimpleString("") == args->getPackageName());
+ CHECK(!args->isCrashingOnFail());
+ CHECK(args->isRethrowingExceptions());
+}
+
+TEST(CommandLineArguments, checkContinuousIntegrationMode)
+{
+ int argc = 2;
+ const char* argv[] = { "tests.exe", "-ci" };
+ CHECK(newArgumentParser(argc, argv));
+ CHECK(!args->isVerbose());
+ LONGS_EQUAL(1, args->getRepeatCount());
+ CHECK(NULLPTR == args->getGroupFilters());
+ CHECK(NULLPTR == args->getNameFilters());
+ CHECK(args->isEclipseOutput());
+ CHECK(SimpleString("") == args->getPackageName());
+ CHECK(!args->isCrashingOnFail());
+ CHECK_FALSE(args->isRethrowingExceptions());
}
TEST(CommandLineArguments, setPackageName)
@@ -539,3 +621,18 @@ TEST(CommandLineArguments, setOptRun)
CHECK(args->isRunIgnored());
}
+TEST(CommandLineArguments, setOptCrashOnFail)
+{
+ int argc = 2;
+ const char* argv[] = { "tests.exe", "-f"};
+ CHECK(newArgumentParser(argc, argv));
+ CHECK(args->isCrashingOnFail());
+}
+
+TEST(CommandLineArguments, setOptRethrowExceptions)
+{
+ int argc = 2;
+ const char* argv[] = { "tests.exe", "-e"};
+ CHECK(newArgumentParser(argc, argv));
+ CHECK_FALSE(args->isRethrowingExceptions());
+}
diff --git a/tests/CppUTest/CommandLineTestRunnerTest.cpp b/tests/CppUTest/CommandLineTestRunnerTest.cpp
index 122961ead..e0beed18e 100644
--- a/tests/CppUTest/CommandLineTestRunnerTest.cpp
+++ b/tests/CppUTest/CommandLineTestRunnerTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -32,7 +32,6 @@
#include "CppUTest/TestPlugin.h"
#include "CppUTest/JUnitTestOutput.h"
#include "CppUTest/PlatformSpecificFunctions.h"
-#include "CppUTestExt/MockSupport.h"
class DummyPluginWhichCountsThePlugins : public TestPlugin
@@ -47,7 +46,7 @@ class DummyPluginWhichCountsThePlugins : public TestPlugin
{
}
- virtual bool parseArguments(int, const char *const *, int)
+ virtual bool parseArguments(int, const char *const *, int) CPPUTEST_OVERRIDE
{
/* Remove ourselves from the count */
amountOfPlugins = registry_->countPlugins() - 1;
@@ -69,19 +68,19 @@ class CommandLineTestRunnerWithStringBufferOutput : public CommandLineTestRunner
fakeConsoleOutputWhichIsReallyABuffer(NULLPTR), fakeTCOutputWhichIsReallyABuffer(NULLPTR)
{}
- TestOutput* createConsoleOutput()
+ TestOutput* createConsoleOutput() CPPUTEST_OVERRIDE
{
fakeConsoleOutputWhichIsReallyABuffer = new StringBufferTestOutput;
return fakeConsoleOutputWhichIsReallyABuffer;
}
- TestOutput* createJUnitOutput(const SimpleString&)
+ TestOutput* createJUnitOutput(const SimpleString&) CPPUTEST_OVERRIDE
{
fakeJUnitOutputWhichIsReallyABuffer_ = new StringBufferTestOutput;
return fakeJUnitOutputWhichIsReallyABuffer_;
}
- TestOutput* createTeamCityOutput()
+ TestOutput* createTeamCityOutput() CPPUTEST_OVERRIDE
{
fakeTCOutputWhichIsReallyABuffer = new StringBufferTestOutput;
return fakeTCOutputWhichIsReallyABuffer;
@@ -95,14 +94,14 @@ TEST_GROUP(CommandLineTestRunner)
UtestShell *test2;
DummyPluginWhichCountsThePlugins* pluginCountingPlugin;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
test1 = new UtestShell("group1", "test1", "file1", 1);
test2 = new UtestShell("group2", "test2", "file2", 2);
registry.addTest(test1);
pluginCountingPlugin = new DummyPluginWhichCountsThePlugins("PluginCountingPlugin", ®istry);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete pluginCountingPlugin;
delete test2;
@@ -269,6 +268,16 @@ TEST(CommandLineTestRunner, listTestGroupAndCaseNamesShouldWorkProperly)
STRCMP_CONTAINS("group1.test1", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString());
}
+TEST(CommandLineTestRunner, listTestLocationsShouldWorkProperly)
+{
+ const char* argv[] = { "tests.exe", "-ll" };
+
+ CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry);
+ commandLineTestRunner.runAllTestsMain();
+
+ STRCMP_CONTAINS("group1.test1", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString());
+}
+
TEST(CommandLineTestRunner, randomShuffleSeedIsPrintedAndRandFuncIsExercised)
{
// more than 1 item in test list ensures that shuffle algorithm calls rand_()
@@ -293,13 +302,12 @@ extern "C" {
typedef PlatformSpecificFile (*FOpenFunc)(const char*, const char*);
typedef void (*FPutsFunc)(const char*, PlatformSpecificFile);
typedef void (*FCloseFunc)(PlatformSpecificFile);
- typedef int (*PutcharFunc)(int);
}
struct FakeOutput
{
FakeOutput() : SaveFOpen(PlatformSpecificFOpen), SaveFPuts(PlatformSpecificFPuts),
- SaveFClose(PlatformSpecificFClose), SavePutchar(PlatformSpecificPutchar)
+ SaveFClose(PlatformSpecificFClose)
{
installFakes();
currentFake = this;
@@ -316,12 +324,10 @@ struct FakeOutput
PlatformSpecificFOpen = (FOpenFunc)fopen_fake;
PlatformSpecificFPuts = (FPutsFunc)fputs_fake;
PlatformSpecificFClose = (FCloseFunc)fclose_fake;
- PlatformSpecificPutchar = (PutcharFunc)putchar_fake;
}
void restoreOriginals()
{
- PlatformSpecificPutchar = SavePutchar;
PlatformSpecificFOpen = SaveFOpen;
PlatformSpecificFPuts = SaveFPuts;
PlatformSpecificFClose = SaveFClose;
@@ -332,21 +338,20 @@ struct FakeOutput
return (PlatformSpecificFile) NULLPTR;
}
- static void fputs_fake(const char* str, PlatformSpecificFile)
+ static void fputs_fake(const char* str, PlatformSpecificFile f)
{
- currentFake->file += str;
+ if (f == PlatformSpecificStdOut) {
+ currentFake->console += str;
+ }
+ else {
+ currentFake->file += str;
+ }
}
static void fclose_fake(PlatformSpecificFile)
{
}
- static int putchar_fake(int c)
- {
- currentFake->console += StringFrom((char)c);
- return c;
- }
-
SimpleString file;
SimpleString console;
@@ -355,7 +360,6 @@ struct FakeOutput
FOpenFunc SaveFOpen;
FPutsFunc SaveFPuts;
FCloseFunc SaveFClose;
- PutcharFunc SavePutchar;
};
FakeOutput* FakeOutput::currentFake = NULLPTR;
@@ -398,7 +402,7 @@ class RunIgnoredUtest : public Utest
{
public:
static bool Checker;
- void testBody()
+ void testBody() CPPUTEST_OVERRIDE
{
Checker = true;
}
@@ -411,7 +415,7 @@ class RunIgnoredUtestShell : public IgnoredUtestShell
public:
RunIgnoredUtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber)
: IgnoredUtestShell(groupName, testName, fileName, lineNumber) {}
- virtual Utest* createTest() _override { return new RunIgnoredUtest; }
+ virtual Utest* createTest() CPPUTEST_OVERRIDE { return new RunIgnoredUtest; }
};
TEST_GROUP(RunIgnoredTest)
@@ -420,13 +424,13 @@ TEST_GROUP(RunIgnoredTest)
RunIgnoredUtestShell *runIgnoredTest;
DummyPluginWhichCountsThePlugins* pluginCountingPlugin;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
runIgnoredTest = new RunIgnoredUtestShell("group", "test", "file", 1);
registry.addTest(runIgnoredTest);
pluginCountingPlugin = new DummyPluginWhichCountsThePlugins("PluginCountingPlugin", ®istry);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete pluginCountingPlugin;
delete runIgnoredTest;
@@ -453,4 +457,3 @@ TEST(RunIgnoredTest, IgnoreTestWillGetRunIfOptionSpecified)
CHECK_TRUE( RunIgnoredUtest::Checker );
}
-
diff --git a/tests/CppUTest/CompatabilityTests.cpp b/tests/CppUTest/CompatabilityTests.cpp
index 7bce1100d..060881d24 100644
--- a/tests/CppUTest/CompatabilityTests.cpp
+++ b/tests/CppUTest/CompatabilityTests.cpp
@@ -13,7 +13,7 @@ TEST_GROUP(StandardCppLibrary)
TEST(StandardCppLibrary, UniquePtrConversationToBool)
{
- auto const aNull = std::unique_ptr(nullptr);
+ auto const aNull = std::unique_ptr(NULLPTR);
CHECK_FALSE(aNull);
auto const notNull = std::make_unique(1);
diff --git a/tests/CppUTest/DummyMemoryLeakDetector.cpp b/tests/CppUTest/DummyMemoryLeakDetector.cpp
index 1be2c872b..dc28bab68 100644
--- a/tests/CppUTest/DummyMemoryLeakDetector.cpp
+++ b/tests/CppUTest/DummyMemoryLeakDetector.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTest/DummyMemoryLeakDetector.h b/tests/CppUTest/DummyMemoryLeakDetector.h
index a6c1932c9..73824af27 100644
--- a/tests/CppUTest/DummyMemoryLeakDetector.h
+++ b/tests/CppUTest/DummyMemoryLeakDetector.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,11 +25,14 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef DUMMYMEMORYLEAKDETECTOR_H
+#define DUMMYMEMORYLEAKDETECTOR_H
+
class DummyMemoryLeakDetector : public MemoryLeakDetector
{
public:
DummyMemoryLeakDetector(MemoryLeakFailure* reporter);
- virtual ~DummyMemoryLeakDetector() _destructor_override;
+ virtual ~DummyMemoryLeakDetector() CPPUTEST_DESTRUCTOR_OVERRIDE;
static bool wasDeleted();
private:
@@ -41,11 +44,12 @@ class DummyMemoryLeakFailure : public MemoryLeakFailure
public:
DummyMemoryLeakFailure();
- virtual ~DummyMemoryLeakFailure() _destructor_override;
+ virtual ~DummyMemoryLeakFailure() CPPUTEST_DESTRUCTOR_OVERRIDE;
static bool wasDeleted();
- virtual void fail(char*) _override;
+ virtual void fail(char*) CPPUTEST_OVERRIDE;
private:
static bool memoryLeakFailureWasDelete;
};
+#endif /* DUMMYMEMORYLEAKDETECTOR_H */
diff --git a/tests/CppUTest/JUnitOutputTest.cpp b/tests/CppUTest/JUnitOutputTest.cpp
index c94e8a91c..32b5654d4 100644
--- a/tests/CppUTest/JUnitOutputTest.cpp
+++ b/tests/CppUTest/JUnitOutputTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -135,10 +135,10 @@ class FileSystemForJUnitTestOutputTests
};
extern "C" {
- static long millisTime = 0;
+ static unsigned long millisTime = 0;
static const char* theTime = "";
- static long MockGetPlatformSpecificTimeInMillis()
+ static unsigned long MockGetPlatformSpecificTimeInMillis()
{
return millisTime;
}
@@ -156,7 +156,7 @@ class JUnitTestOutputTestRunner
const char* currentGroupName_;
UtestShell* currentTest_;
bool firstTestInGroup_;
- int timeTheTestTakes_;
+ unsigned int timeTheTestTakes_;
unsigned int numberOfChecksInTest_;
TestFailure* testFailure_;
@@ -279,7 +279,7 @@ class JUnitTestOutputTestRunner
return *this;
}
- JUnitTestOutputTestRunner& thatTakes(int timeElapsed)
+ JUnitTestOutputTestRunner& thatTakes(unsigned int timeElapsed)
{
timeTheTestTakes_ = timeElapsed;
return *this;
@@ -312,19 +312,28 @@ class JUnitTestOutputTestRunner
extern "C" {
static FileSystemForJUnitTestOutputTests fileSystem;
+ static FileForJUnitOutputTests* currentFile = NULLPTR;
static PlatformSpecificFile mockFOpen(const char* filename, const char*)
{
- return fileSystem.openFile(filename);
+ currentFile = fileSystem.openFile(filename);
+ return currentFile;
}
+ static void (*originalFPuts)(const char* str, PlatformSpecificFile file);
static void mockFPuts(const char* str, PlatformSpecificFile file)
{
- ((FileForJUnitOutputTests*)file)->write(str);
+ if (file == currentFile) {
+ ((FileForJUnitOutputTests*)file)->write(str);
+ }
+ else {
+ originalFPuts(str, file);
+ }
}
static void mockFClose(PlatformSpecificFile file)
{
+ currentFile = NULLPTR;
((FileForJUnitOutputTests*)file)->close();
}
}
@@ -336,9 +345,10 @@ TEST_GROUP(JUnitOutputTest)
JUnitTestOutputTestRunner *testCaseRunner;
FileForJUnitOutputTests* outputFile;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
UT_PTR_SET(PlatformSpecificFOpen, mockFOpen);
+ originalFPuts = PlatformSpecificFPuts;
UT_PTR_SET(PlatformSpecificFPuts, mockFPuts);
UT_PTR_SET(PlatformSpecificFClose, mockFClose);
junitOutput = new JUnitTestOutput();
@@ -346,7 +356,7 @@ TEST_GROUP(JUnitOutputTest)
testCaseRunner = new JUnitTestOutputTestRunner(*result);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete testCaseRunner;
delete result;
@@ -544,7 +554,7 @@ TEST(JUnitOutputTest, testFailureWithNewlineInIt)
outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml");
- STRCMP_EQUAL("\n", outputFile->line(6));
+ STRCMP_EQUAL("\n", outputFile->line(6));
}
TEST(JUnitOutputTest, testFailureWithDifferentFileAndLine)
@@ -751,9 +761,9 @@ TEST(JUnitOutputTest, UTPRINTOutputInJUnitOutputWithSpecials)
{
testCaseRunner->start()
.withGroup("groupname")
- .withTest("testname").thatPrints("The in \"Spain\"\nGoes \\mainly\\ down the Dr&in\n")
+ .withTest("testname").thatPrints("The in \"Spain\"\nGoes\r \\mainly\\ down the Dr&in\n")
.end();
outputFile = fileSystem.file("cpputest_groupname.xml");
- STRCMP_EQUAL("The <rain> in "Spain"{newline}Goes \\mainly\\ down the Dr&in{newline}\n", outputFile->lineFromTheBack(3));
+ STRCMP_EQUAL("The <rain> in "Spain"
Goes
\\mainly\\ down the Dr&in
\n", outputFile->lineFromTheBack(3));
}
diff --git a/tests/CppUTest/MemoryLeakDetectorTest.cpp b/tests/CppUTest/MemoryLeakDetectorTest.cpp
index 53e457c9e..825ed312e 100644
--- a/tests/CppUTest/MemoryLeakDetectorTest.cpp
+++ b/tests/CppUTest/MemoryLeakDetectorTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -33,11 +33,11 @@
class MemoryLeakFailureForTest: public MemoryLeakFailure
{
public:
- virtual ~MemoryLeakFailureForTest() _destructor_override
+ virtual ~MemoryLeakFailureForTest() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
- virtual void fail(char* fail_string) _override
+ virtual void fail(char* fail_string) CPPUTEST_OVERRIDE
{
*message = fail_string;
}
@@ -56,12 +56,12 @@ class NewAllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator
int alloc_called;
int free_called;
- char* alloc_memory(size_t size, const char*, size_t)
+ char* alloc_memory(size_t size, const char*, size_t) CPPUTEST_OVERRIDE
{
alloc_called++;
return TestMemoryAllocator::alloc_memory(size, "file", 1);
}
- void free_memory(char* memory, size_t size, const char* file, size_t line)
+ void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE
{
free_called++;
TestMemoryAllocator::free_memory(memory, size, file, line);
@@ -81,24 +81,24 @@ class AllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator
int allocMemoryLeakNodeCalled;
int freeMemoryLeakNodeCalled;
- char* alloc_memory(size_t size, const char* file, size_t line)
+ char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE
{
alloc_called++;
return TestMemoryAllocator::alloc_memory(size, file, line);
}
- void free_memory(char* memory, size_t size, const char* file, size_t line)
+ void free_memory(char* memory, size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE
{
free_called++;
TestMemoryAllocator::free_memory(memory, size, file, line);
}
- char* allocMemoryLeakNode(size_t size)
+ char* allocMemoryLeakNode(size_t size) CPPUTEST_OVERRIDE
{
allocMemoryLeakNodeCalled++;
return TestMemoryAllocator::alloc_memory(size, __FILE__, __LINE__);
}
- void freeMemoryLeakNode(char* memory)
+ void freeMemoryLeakNode(char* memory) CPPUTEST_OVERRIDE
{
freeMemoryLeakNodeCalled++;
TestMemoryAllocator::free_memory(memory, 0, __FILE__, __LINE__);
@@ -111,7 +111,7 @@ TEST_GROUP(MemoryLeakDetectorTest)
MemoryLeakFailureForTest *reporter;
AllocatorForMemoryLeakDetectionTest* testAllocator;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
reporter = new MemoryLeakFailureForTest;
detector = new MemoryLeakDetector(reporter);
@@ -120,7 +120,7 @@ TEST_GROUP(MemoryLeakDetectorTest)
detector->startChecking();
reporter->message = new SimpleString();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete reporter->message;
delete detector;
diff --git a/tests/CppUTest/MemoryLeakWarningTest.cpp b/tests/CppUTest/MemoryLeakWarningTest.cpp
index 71c020994..d4a6ea6fc 100644
--- a/tests/CppUTest/MemoryLeakWarningTest.cpp
+++ b/tests/CppUTest/MemoryLeakWarningTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -74,7 +74,7 @@ TEST_GROUP(MemoryLeakWarningTest)
DummyMemoryLeakFailure dummy;
TestTestingFixture* fixture;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
fixture = new TestTestingFixture();
detector = new MemoryLeakDetector(&dummy);
@@ -87,7 +87,7 @@ TEST_GROUP(MemoryLeakWarningTest)
leak2 = NULLPTR;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
detector->deallocMemory(allocator, leak1);
detector->deallocMemory(allocator, leak2);
@@ -99,7 +99,7 @@ TEST_GROUP(MemoryLeakWarningTest)
}
};
-static void _testTwoLeaks()
+static void testTwoLeaks_()
{
leak1 = detector->allocMemory(allocator, 10);
leak2 = (long*) (void*) detector->allocMemory(allocator, 4);
@@ -109,7 +109,7 @@ static void _testTwoLeaks()
TEST(MemoryLeakWarningTest, TwoLeaks)
{
- fixture->setTestFunction(_testTwoLeaks);
+ fixture->setTestFunction(testTwoLeaks_);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
@@ -119,7 +119,7 @@ TEST(MemoryLeakWarningTest, TwoLeaks)
TEST(MemoryLeakWarningTest, TwoLeaks)
{
- fixture->setTestFunction(_testTwoLeaks);
+ fixture->setTestFunction(testTwoLeaks_);
fixture->runAllTests();
LONGS_EQUAL(0, fixture->getFailureCount());
@@ -128,7 +128,7 @@ TEST(MemoryLeakWarningTest, TwoLeaks)
#endif
-static void _testLeakWarningWithPluginDisabled()
+static void testLeakWarningWithPluginDisabled_()
{
memPlugin->expectLeaksInTest(1);
leak1 = (char*) cpputest_malloc_location_with_leak_detection(10, __FILE__, __LINE__);
@@ -136,7 +136,7 @@ static void _testLeakWarningWithPluginDisabled()
TEST(MemoryLeakWarningTest, LeakWarningWithPluginDisabled)
{
- fixture->setTestFunction(_testLeakWarningWithPluginDisabled);
+ fixture->setTestFunction(testLeakWarningWithPluginDisabled_);
MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads();
@@ -151,7 +151,7 @@ TEST(MemoryLeakWarningTest, LeakWarningWithPluginDisabled)
MemoryLeakWarningPlugin::restoreNewDeleteOverloads();
}
-static void _testIgnore2()
+static void testIgnore2_()
{
memPlugin->expectLeaksInTest(2);
leak1 = detector->allocMemory(allocator, 10);
@@ -160,12 +160,12 @@ static void _testIgnore2()
TEST(MemoryLeakWarningTest, Ignore2)
{
- fixture->setTestFunction(_testIgnore2);
+ fixture->setTestFunction(testIgnore2_);
fixture->runAllTests();
LONGS_EQUAL(0, fixture->getFailureCount());
}
-static void _failAndLeakMemory()
+static void failAndLeakMemory_()
{
leak1 = detector->allocMemory(allocator, 10);
FAIL("");
@@ -173,7 +173,7 @@ static void _failAndLeakMemory()
TEST(MemoryLeakWarningTest, FailingTestDoesNotReportMemoryLeaks)
{
- fixture->setTestFunction(_failAndLeakMemory);
+ fixture->setTestFunction(failAndLeakMemory_);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
}
@@ -195,7 +195,7 @@ TEST_GROUP(MemoryLeakWarningGlobalDetectorTest)
cpputestHasCrashed = true;
}
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
memoryAllocatorStash.save();
detector = MemoryLeakWarningPlugin::getGlobalDetector();
@@ -210,7 +210,7 @@ TEST_GROUP(MemoryLeakWarningGlobalDetectorTest)
cpputestHasCrashed = false;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
MemoryLeakWarningPlugin::restoreNewDeleteOverloads();
@@ -407,7 +407,7 @@ static void StubMutexUnlock(PlatformSpecificMutex)
TEST_GROUP(MemoryLeakWarningThreadSafe)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
UT_PTR_SET(PlatformSpecificMutexLock, StubMutexLock);
UT_PTR_SET(PlatformSpecificMutexUnlock, StubMutexUnlock);
@@ -416,7 +416,7 @@ TEST_GROUP(MemoryLeakWarningThreadSafe)
mutexUnlockCount = 0;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
}
};
diff --git a/tests/CppUTest/MemoryOperatorOverloadTest.cpp b/tests/CppUTest/MemoryOperatorOverloadTest.cpp
index 399c01f12..df4b212d5 100644
--- a/tests/CppUTest/MemoryOperatorOverloadTest.cpp
+++ b/tests/CppUTest/MemoryOperatorOverloadTest.cpp
@@ -10,6 +10,7 @@
#include "CppUTest/TestHarness_c.h"
#include "AllocationInCFile.h"
+
TEST_GROUP(BasicBehavior)
{
};
@@ -22,34 +23,6 @@ TEST(BasicBehavior, CanDeleteNullPointers)
#if CPPUTEST_USE_MEM_LEAK_DETECTION
-CPPUTEST_DO_NOT_SANITIZE_ADDRESS
-static void deleteArrayInvalidatesMemory()
-{
- unsigned char* memory = new unsigned char[10];
- PlatformSpecificMemset(memory, 0xAB, 10);
- delete [] memory;
- CHECK(memory[5] != 0xCB);
-}
-
-TEST(BasicBehavior, deleteArrayInvalidatesMemory)
-{
- deleteArrayInvalidatesMemory();
-}
-
-CPPUTEST_DO_NOT_SANITIZE_ADDRESS
-static void deleteInvalidatesMemory()
-{
- unsigned char* memory = new unsigned char;
- *memory = 0xAD;
- delete memory;
- CHECK(*memory != 0xAD);
-}
-
-TEST(BasicBehavior, deleteInvalidatesMemory)
-{
- deleteInvalidatesMemory();
-}
-
#if __cplusplus >= 201402L
TEST(BasicBehavior, DeleteWithSizeParameterWorks)
{
@@ -60,27 +33,6 @@ TEST(BasicBehavior, DeleteWithSizeParameterWorks)
}
#endif
-static void deleteUnallocatedMemory()
-{
- delete (char*) 0x1234678;
- FAIL("Should never come here"); // LCOV_EXCL_LINE
-} // LCOV_EXCL_LINE
-
-TEST(BasicBehavior, deleteWillNotThrowAnExceptionWhenDeletingUnallocatedMemoryButCanStillCauseTestFailures)
-{
- /*
- * Test failure might cause an exception. But according to C++ standard, you aren't allowed
- * to throw exceptions in the delete function. If you do that, it will call std::terminate.
- * Therefore, the delete will need to fail without exceptions.
- */
- MemoryLeakFailure* defaultReporter = MemoryLeakWarningPlugin::getGlobalFailureReporter();
- TestTestingFixture fixture;
- fixture.setTestFunction(deleteUnallocatedMemory);
- fixture.runAllTests();
- LONGS_EQUAL(1, fixture.getFailureCount());
- POINTERS_EQUAL(defaultReporter, MemoryLeakWarningPlugin::getGlobalFailureReporter());
-}
-
#endif
#ifdef CPPUTEST_USE_MALLOC_MACROS
@@ -101,32 +53,76 @@ TEST(BasicBehavior, bothMallocAndFreeAreOverloaded)
#endif
+TEST_GROUP(MemoryLeakOverridesToBeUsedInProductionCode)
+{
+ MemoryLeakDetector* memLeakDetector;
+ void setup() CPPUTEST_OVERRIDE
+ {
+ memLeakDetector = MemoryLeakWarningPlugin::getGlobalDetector();
+ }
+
+};
+
#if CPPUTEST_USE_MEM_LEAK_DETECTION
-CPPUTEST_DO_NOT_SANITIZE_ADDRESS
-static void freeInvalidatesMemory()
+#ifdef CPPUTEST_USE_NEW_MACROS
+ #undef new
+#endif
+TEST(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteOverloadsWithIntLineWorks)
+{
+ const int line = 42;
+ char* leak = new("TestFile.cpp", line) char;
+
+ size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking);
+ STRCMP_NOCASE_CONTAINS("Allocated at: TestFile.cpp and line: 42.", memLeakDetector->report(mem_leak_period_checking));
+
+ ::operator delete (leak, "TestFile.cpp", line);
+
+ LONGS_EQUAL(memLeaks-1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking));
+}
+
+TEST(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteOverloadsWithSizeTLineWorks)
{
- unsigned char* memory = (unsigned char*) cpputest_malloc(sizeof(unsigned char));
- *memory = 0xAD;
- cpputest_free(memory);
- CHECK(*memory != 0xAD);
+ const size_t line = 42;
+ char* leak = new("TestFile.cpp", line) char;
+
+ size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking);
+ STRCMP_NOCASE_CONTAINS("Allocated at: TestFile.cpp and line: 42.", memLeakDetector->report(mem_leak_period_checking));
+
+ ::operator delete (leak, "TestFile.cpp", line);
+
+ LONGS_EQUAL(memLeaks-1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking));
}
-TEST(BasicBehavior, freeInvalidatesMemory)
+TEST(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteArrayOverloadsWithIntLineWorks)
{
- freeInvalidatesMemory();
+ const int line = 42;
+ char* leak = new("TestFile.cpp", line) char[10];
+
+ size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking);
+ STRCMP_NOCASE_CONTAINS("Allocated at: TestFile.cpp and line: 42.", memLeakDetector->report(mem_leak_period_checking));
+
+ ::operator delete [] (leak, "TestFile.cpp", line);
+
+ LONGS_EQUAL(memLeaks-1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking));
}
-#endif
-TEST_GROUP(MemoryLeakOverridesToBeUsedInProductionCode)
+TEST(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteArrayOverloadsWithSizeTLineWorks)
{
- MemoryLeakDetector* memLeakDetector;
- void setup()
- {
- memLeakDetector = MemoryLeakWarningPlugin::getGlobalDetector();
- }
+ const size_t line = 42;
+ char* leak = new("TestFile.cpp", line) char[10];
-};
+ size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking);
+ STRCMP_NOCASE_CONTAINS("Allocated at: TestFile.cpp and line: 42.", memLeakDetector->report(mem_leak_period_checking));
+
+ ::operator delete [] (leak, "TestFile.cpp", line);
+
+ LONGS_EQUAL(memLeaks-1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking));
+}
+#ifdef CPPUTEST_USE_NEW_MACROS
+ #include "CppUTest/MemoryLeakDetectorNewMacros.h" // redefine the 'new' macro
+#endif
+#endif
#ifdef CPPUTEST_USE_MALLOC_MACROS
@@ -312,7 +308,7 @@ TEST_GROUP(OutOfMemoryTestsForOperatorNew)
{
TestMemoryAllocator* no_memory_allocator;
GlobalMemoryAllocatorStash memoryAllocatorStash;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
memoryAllocatorStash.save();
no_memory_allocator = new NullUnknownAllocator;
@@ -320,7 +316,7 @@ TEST_GROUP(OutOfMemoryTestsForOperatorNew)
setCurrentNewArrayAllocator(no_memory_allocator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
memoryAllocatorStash.restore();
delete no_memory_allocator;
@@ -329,16 +325,16 @@ TEST_GROUP(OutOfMemoryTestsForOperatorNew)
#if CPPUTEST_USE_MEM_LEAK_DETECTION
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorThrowsAnExceptionWhenUsingStdCppNew)
{
- CHECK_THROWS(std::bad_alloc, new char);
+ CHECK_THROWS(CPPUTEST_BAD_ALLOC, new char);
}
TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorThrowsAnExceptionWhenUsingStdCppNew)
{
- CHECK_THROWS(std::bad_alloc, new char[10]);
+ CHECK_THROWS(CPPUTEST_BAD_ALLOC, new char[10]);
}
TEST_GROUP(TestForExceptionsInConstructor)
@@ -371,7 +367,7 @@ TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorReturnsNull)
#undef new
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
/*
@@ -410,14 +406,15 @@ char* some_memory;
TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorThrowsAnExceptionWhenUsingStdCppNewWithoutOverride)
{
- CHECK_THROWS(std::bad_alloc, some_memory = new char);
+ CHECK_THROWS(CPPUTEST_BAD_ALLOC, some_memory = new char);
}
TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorThrowsAnExceptionWhenUsingStdCppNewWithoutOverride)
{
- CHECK_THROWS(std::bad_alloc, some_memory = new char[10]);
+ CHECK_THROWS(CPPUTEST_BAD_ALLOC, some_memory = new char[10]);
}
+#if CPPUTEST_USE_STD_CPP_LIB
TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorReturnsNullWithoutOverride)
{
POINTERS_EQUAL(NULLPTR, new (std::nothrow) char);
@@ -427,6 +424,7 @@ TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorReturnsNullWithoutOv
{
POINTERS_EQUAL(NULLPTR, new (std::nothrow) char[10]);
}
+#endif
#else
diff --git a/tests/CppUTest/PluginTest.cpp b/tests/CppUTest/PluginTest.cpp
index 1231e7791..c9b74fd07 100644
--- a/tests/CppUTest/PluginTest.cpp
+++ b/tests/CppUTest/PluginTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,13 +44,13 @@ class DummyPlugin: public TestPlugin
{
}
- virtual void preTestAction(UtestShell&, TestResult&)
+ virtual void preTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE
{
preAction++;
preActionSequence = sequenceNumber++;
}
- virtual void postTestAction(UtestShell&, TestResult&)
+ virtual void postTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE
{
postAction++;
postActionSequence = sequenceNumber++;
@@ -70,7 +70,7 @@ class DummyPluginWhichAcceptsParameters: public DummyPlugin
{
}
- virtual bool parseArguments(int ac, const char *const *av, int index)
+ virtual bool parseArguments(int ac, const char *const *av, int index) CPPUTEST_OVERRIDE
{
SimpleString argument (av[index]);
if (argument == "-paccept")
@@ -88,7 +88,7 @@ TEST_GROUP(PluginTest)
TestTestingFixture *genFixture;
TestRegistry* registry;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
firstPlugin = new DummyPlugin(GENERIC_PLUGIN);
secondPlugin = new DummyPluginWhichAcceptsParameters(GENERIC_PLUGIN2);
@@ -99,7 +99,7 @@ TEST_GROUP(PluginTest)
sequenceNumber = 1;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete firstPlugin;
delete secondPlugin;
diff --git a/tests/CppUTest/PreprocessorTest.cpp b/tests/CppUTest/PreprocessorTest.cpp
index 3207972f6..d41c8055a 100644
--- a/tests/CppUTest/PreprocessorTest.cpp
+++ b/tests/CppUTest/PreprocessorTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTest/SetPluginTest.cpp b/tests/CppUTest/SetPluginTest.cpp
index c26a51258..d55b91dfb 100644
--- a/tests/CppUTest/SetPluginTest.cpp
+++ b/tests/CppUTest/SetPluginTest.cpp
@@ -29,7 +29,7 @@ TEST_GROUP(SetPointerPluginTest)
StringBufferTestOutput* output_;
TestResult* result_;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
myRegistry_ = new TestRegistry();
plugin_ = new SetPointerPlugin("TestSetPlugin");
@@ -39,7 +39,7 @@ TEST_GROUP(SetPointerPluginTest)
result_ = new TestResult(*output_);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
myRegistry_->setCurrentRegistry(NULLPTR);
delete myRegistry_;
@@ -52,13 +52,13 @@ TEST_GROUP(SetPointerPluginTest)
class FunctionPointerUtest : public Utest
{
public:
- void setup() _override
+ void setup() CPPUTEST_OVERRIDE
{
UT_PTR_SET(fp1, stub_func1);
UT_PTR_SET(fp2, stub_func2);
UT_PTR_SET(fp2, stub_func2);
}
- void testBody() _override
+ void testBody() CPPUTEST_OVERRIDE
{
CHECK(fp1 == stub_func1);
CHECK(fp2 == stub_func2);
@@ -68,7 +68,7 @@ class FunctionPointerUtest : public Utest
class FunctionPointerUtestShell: public UtestShell
{
public:
- virtual Utest* createTest()
+ virtual Utest* createTest() CPPUTEST_OVERRIDE
{
return new FunctionPointerUtest();
}
@@ -98,7 +98,7 @@ class MaxFunctionPointerUtest : public Utest
{
}
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
for (int i = 0; i < numOfFpSets; ++i)
{
@@ -116,7 +116,7 @@ class MaxFunctionPointerUtestShell: public UtestShell
{
}
- virtual Utest* createTest()
+ virtual Utest* createTest() CPPUTEST_OVERRIDE
{
return new MaxFunctionPointerUtest(numOfFpSets);
}
@@ -140,11 +140,11 @@ static double stub_double = 4.0;
class SetDoublePointerUtest : public Utest
{
public:
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
UT_PTR_SET(orig_double_ptr, &stub_double);
}
- void testBody()
+ void testBody() CPPUTEST_OVERRIDE
{
CHECK(orig_double_ptr == &stub_double);
}
@@ -153,7 +153,7 @@ class SetDoublePointerUtest : public Utest
class SetDoublePointerUtestShell: public UtestShell
{
public:
- Utest * createTest()
+ Utest * createTest() CPPUTEST_OVERRIDE
{
return new SetDoublePointerUtest();
}
diff --git a/tests/CppUTest/SimpleMutexTest.cpp b/tests/CppUTest/SimpleMutexTest.cpp
index 17d86a18d..19eeae935 100644
--- a/tests/CppUTest/SimpleMutexTest.cpp
+++ b/tests/CppUTest/SimpleMutexTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -59,7 +59,7 @@ static void StubMutexDestroy(PlatformSpecificMutex)
TEST_GROUP(SimpleMutexTest)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
UT_PTR_SET(PlatformSpecificMutexCreate, StubMutexCreate);
UT_PTR_SET(PlatformSpecificMutexLock, StubMutexLock);
@@ -72,7 +72,7 @@ TEST_GROUP(SimpleMutexTest)
mutexUnlockCount = 0;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
}
};
diff --git a/tests/CppUTest/SimpleStringCacheTest.cpp b/tests/CppUTest/SimpleStringCacheTest.cpp
index e59406fe1..3fd98ab4f 100644
--- a/tests/CppUTest/SimpleStringCacheTest.cpp
+++ b/tests/CppUTest/SimpleStringCacheTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,7 +36,7 @@ class TestFunctionWithCache : public ExecFunction
SimpleStringInternalCache* parameter;
size_t allocationSize;
- void exec() _override
+ void exec() CPPUTEST_OVERRIDE
{
testFunction(parameter, allocationSize);
}
@@ -52,7 +52,7 @@ TEST_GROUP(SimpleStringInternalCache)
TestFunctionWithCache testFunction;
TestTestingFixture fixture;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
fixture.setTestFunction(&testFunction);
testFunction.parameter = &cache;
@@ -62,7 +62,7 @@ TEST_GROUP(SimpleStringInternalCache)
cache.setAllocator(defaultAllocator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
cache.clearAllIncludingCurrentlyUsedMemory();
accountant.clear();
@@ -188,7 +188,7 @@ TEST(SimpleStringInternalCache, clearCacheWillRemoveAllCachedMemoryButNotAllUsed
char* mem = cache.alloc(10);
cache.dealloc(mem, 10);
- mem = cache.alloc(60);
+ cache.alloc(60);
cache.clearCache();
@@ -251,7 +251,7 @@ TEST(SimpleStringInternalCache, clearAllIncludingCurrentlyUsedMemoryAlsoReleases
LONGS_EQUAL(3, accountant.totalDeallocationsOfSize(1234));
}
-static void _deallocatingStringMemoryThatWasntAllocatedWithCache(SimpleStringInternalCache* cache, size_t allocationSize)
+static void deallocatingStringMemoryThatWasntAllocatedWithCache_(SimpleStringInternalCache* cache, size_t allocationSize)
{
char* mem = defaultMallocAllocator()->alloc_memory(allocationSize, __FILE__, __LINE__);
mem[0] = 'B';
@@ -264,7 +264,7 @@ static void _deallocatingStringMemoryThatWasntAllocatedWithCache(SimpleStringInt
TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarning)
{
- testFunction.testFunction = _deallocatingStringMemoryThatWasntAllocatedWithCache;
+ testFunction.testFunction = deallocatingStringMemoryThatWasntAllocatedWithCache_;
testFunction.allocationSize = 123;
cache.setAllocator(allocator);
@@ -277,7 +277,7 @@ TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWa
}
-static void _deallocatingStringMemoryTwiceThatWasntAllocatedWithCache(SimpleStringInternalCache* cache, size_t allocationSize)
+static void deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_(SimpleStringInternalCache* cache, size_t allocationSize)
{
char* mem = defaultMallocAllocator()->alloc_memory(allocationSize, __FILE__, __LINE__);
mem[0] = '\0';
@@ -288,7 +288,7 @@ static void _deallocatingStringMemoryTwiceThatWasntAllocatedWithCache(SimpleStri
TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarningButOnlyOnce)
{
- testFunction.testFunction = _deallocatingStringMemoryTwiceThatWasntAllocatedWithCache;
+ testFunction.testFunction = deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_;
testFunction.allocationSize = 123;
cache.setAllocator(allocator);
@@ -299,7 +299,7 @@ TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWa
TEST(SimpleStringInternalCache, deallocatingLargeMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarning)
{
- testFunction.testFunction = _deallocatingStringMemoryThatWasntAllocatedWithCache;
+ testFunction.testFunction = deallocatingStringMemoryThatWasntAllocatedWithCache_;
testFunction.allocationSize = 12345;
cache.setAllocator(allocator);
@@ -314,7 +314,7 @@ TEST(SimpleStringInternalCache, deallocatingLargeMemoryThatWasntAllocatedWhileCa
TEST(SimpleStringInternalCache, deallocatingLargeMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarningButOnlyOnce)
{
- testFunction.testFunction = _deallocatingStringMemoryTwiceThatWasntAllocatedWithCache;
+ testFunction.testFunction = deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_;
testFunction.allocationSize = 12345;
cache.setAllocator(allocator);
@@ -330,13 +330,13 @@ TEST_GROUP(SimpleStringCacheAllocator)
MemoryAccountant accountant;
AccountingTestMemoryAllocator* accountingAllocator;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
accountingAllocator = new AccountingTestMemoryAllocator(accountant, defaultMallocAllocator());
allocator = new SimpleStringCacheAllocator(cache, accountingAllocator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
cache.clearCache();
delete allocator;
@@ -387,4 +387,3 @@ TEST(GlobalSimpleStringCache, installsAndRemovedCache)
}
POINTERS_EQUAL(originalStringAllocator, SimpleString::getStringAllocator());
}
-
diff --git a/tests/CppUTest/SimpleStringTest.cpp b/tests/CppUTest/SimpleStringTest.cpp
index a9e7a4289..7a4e7629e 100644
--- a/tests/CppUTest/SimpleStringTest.cpp
+++ b/tests/CppUTest/SimpleStringTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -35,13 +35,13 @@
class JustUseNewStringAllocator : public TestMemoryAllocator
{
public:
- virtual ~JustUseNewStringAllocator() _destructor_override {}
+ virtual ~JustUseNewStringAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- char* alloc_memory(size_t size, const char* file, size_t line) _override
+ char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE
{
return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size, file, line);
}
- void free_memory(char* str, size_t, const char* file, size_t line) _override
+ void free_memory(char* str, size_t, const char* file, size_t line) CPPUTEST_OVERRIDE
{
MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewArrayAllocator(), str, file, line);
}
@@ -54,7 +54,7 @@ class GlobalSimpleStringMemoryAccountantExecFunction
void (*testFunction_)(GlobalSimpleStringMemoryAccountant*);
GlobalSimpleStringMemoryAccountant* parameter_;
- virtual void exec() _override
+ virtual void exec() CPPUTEST_OVERRIDE
{
testFunction_(parameter_);
}
@@ -67,14 +67,14 @@ TEST_GROUP(GlobalSimpleStringMemoryAccountant)
TestTestingFixture fixture;
GlobalSimpleStringMemoryAccountant accountant;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
stash.save();
testFunction.parameter_ = &accountant;
fixture.setTestFunction(&testFunction);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
stash.restore();
}
@@ -105,19 +105,19 @@ TEST(GlobalSimpleStringMemoryAccountant, stop)
POINTERS_EQUAL(originalAllocator, SimpleString::getStringAllocator());
}
-static void _stopAccountant(GlobalSimpleStringMemoryAccountant* accountant)
+static void stopAccountant_(GlobalSimpleStringMemoryAccountant* accountant)
{
accountant->stop();
}
TEST(GlobalSimpleStringMemoryAccountant, stopWithoutStartWillFail)
{
- testFunction.testFunction_ = _stopAccountant;
+ testFunction.testFunction_ = stopAccountant_;
fixture.runAllTests();
fixture.assertPrintContains("Global SimpleString allocator stopped without starting");
}
-static void _changeAllocatorBetweenStartAndStop(GlobalSimpleStringMemoryAccountant* accountant)
+static void changeAllocatorBetweenStartAndStop_(GlobalSimpleStringMemoryAccountant* accountant)
{
TestMemoryAllocator* originalAllocator = SimpleString::getStringAllocator();
accountant->start();
@@ -127,7 +127,7 @@ static void _changeAllocatorBetweenStartAndStop(GlobalSimpleStringMemoryAccounta
TEST(GlobalSimpleStringMemoryAccountant, stopFailsWhenAllocatorWasChangedInBetween)
{
- testFunction.testFunction_ = _changeAllocatorBetweenStartAndStop;
+ testFunction.testFunction_ = changeAllocatorBetweenStartAndStop_;
fixture.runAllTests();
fixture.assertPrintContains("GlobalStrimpleStringMemoryAccountant: allocator has changed between start and stop!");
}
@@ -157,12 +157,12 @@ TEST_GROUP(SimpleString)
{
JustUseNewStringAllocator justNewForSimpleStringTestAllocator;
GlobalSimpleStringAllocatorStash stash;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
stash.save();
SimpleString::setStringAllocator(&justNewForSimpleStringTestAllocator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
stash.restore();
}
@@ -178,10 +178,10 @@ class MyOwnStringAllocator : public TestMemoryAllocator
{
public:
MyOwnStringAllocator() : memoryWasAllocated(false) {}
- virtual ~MyOwnStringAllocator() _destructor_override {}
+ virtual ~MyOwnStringAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE {}
bool memoryWasAllocated;
- char* alloc_memory(size_t size, const char* file, size_t line) _override
+ char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE
{
memoryWasAllocated = true;
return TestMemoryAllocator::alloc_memory(size, file, line);
@@ -294,6 +294,14 @@ TEST(SimpleString, lowerCase)
STRCMP_EQUAL("AbCdEfG1234", s1.asCharString());
}
+TEST(SimpleString, printable)
+{
+ SimpleString s1("ABC\01\06\a\n\r\b\t\v\f\x0E\x1F\x7F""abc");
+ SimpleString s2(s1.printable());
+ STRCMP_EQUAL("ABC\\x01\\x06\\a\\n\\r\\b\\t\\v\\f\\x0E\\x1F\\x7Fabc", s2.asCharString());
+ STRCMP_EQUAL("ABC\01\06\a\n\r\b\t\v\f\x0E\x1F\x7F""abc", s1.asCharString());
+}
+
TEST(SimpleString, Addition)
{
SimpleString s1("hello!");
@@ -578,6 +586,11 @@ TEST(SimpleString, NULLReportsNullString)
STRCMP_EQUAL("(null)", StringFromOrNull((char*) NULLPTR).asCharString());
}
+TEST(SimpleString, NULLReportsNullStringPrintable)
+{
+ STRCMP_EQUAL("(null)", PrintableStringFromOrNull((char*) NULLPTR).asCharString());
+}
+
TEST(SimpleString, Booleans)
{
SimpleString s1(StringFrom(true));
@@ -627,7 +640,7 @@ TEST(SimpleString, UnsignedLongInts)
CHECK(s == s2);
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(SimpleString, LongLongInts)
{
@@ -684,7 +697,7 @@ TEST(SimpleString, Sizes)
TEST(SimpleString, nullptr_type)
{
- SimpleString s(StringFrom(nullptr));
+ SimpleString s(StringFrom(NULLPTR));
STRCMP_EQUAL("(null)", s.asCharString());
}
@@ -697,7 +710,7 @@ TEST(SimpleString, HexStrings)
SimpleString h1 = HexStringFrom(0xffffL);
STRCMP_EQUAL("ffff", h1.asCharString());
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
SimpleString h15 = HexStringFrom(0xffffLL);
STRCMP_EQUAL("ffff", h15.asCharString());
#endif
@@ -834,7 +847,7 @@ TEST(SimpleString, CollectionWritingToEmptyString)
#ifdef CPPUTEST_64BIT
-TEST(SimpleString, _64BitAddressPrintsCorrectly)
+TEST(SimpleString, 64BitAddressPrintsCorrectly)
{
char* p = (char*) 0x0012345678901234;
SimpleString expected("0x12345678901234");
@@ -865,7 +878,7 @@ TEST(SimpleString, BracketsFormattedHexStringFromForLongOnDifferentPlatform)
/*
* This test case cannot pass on 32 bit systems.
*/
-IGNORE_TEST(SimpleString, _64BitAddressPrintsCorrectly)
+IGNORE_TEST(SimpleString, 64BitAddressPrintsCorrectly)
{
}
@@ -1127,7 +1140,7 @@ TEST(SimpleString, MaskedBitsChar)
STRCMP_EQUAL("xxxxxxxx xxxxxxx1", StringFromMaskedBits(0x01, 0x01, 1).asCharString());
STRCMP_EQUAL("xxxxxxxx 11xx11xx", StringFromMaskedBits(0xFF, 0xCC, 1).asCharString());
}
-#else
+#elif (CPPUTEST_CHAR_BIT == 8)
TEST(SimpleString, MaskedBitsChar)
{
STRCMP_EQUAL("xxxxxxxx", StringFromMaskedBits(0x00, 0x00, 1).asCharString());
@@ -1233,7 +1246,7 @@ TEST(SimpleString, BracketsFormattedHexStringFromForLong)
STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString());
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(SimpleString, BracketsFormattedHexStringFromForLongLong)
{
@@ -1250,16 +1263,15 @@ TEST(SimpleString, BracketsFormattedHexStringFromForULongLong)
#else
TEST(SimpleString, BracketsFormattedHexStringFromForLongLong)
{
- cpputest_longlong value = 1;
+ cpputest_longlong value;
STRCMP_EQUAL("", BracketsFormattedHexStringFrom(value).asCharString());
}
TEST(SimpleString, BracketsFormattedHexStringFromForULongLong)
{
- cpputest_ulonglong value = 1;
+ cpputest_ulonglong value;
STRCMP_EQUAL("", BracketsFormattedHexStringFrom(value).asCharString());
}
#endif
-
diff --git a/tests/CppUTest/TeamCityOutputTest.cpp b/tests/CppUTest/TeamCityOutputTest.cpp
index f8cb86db8..36ee135f5 100644
--- a/tests/CppUTest/TeamCityOutputTest.cpp
+++ b/tests/CppUTest/TeamCityOutputTest.cpp
@@ -9,16 +9,16 @@ class TeamCityOutputToBuffer : public TeamCityTestOutput
{
}
- virtual ~TeamCityOutputToBuffer() _destructor_override
+ virtual ~TeamCityOutputToBuffer() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
- void printBuffer(const char* s) _override
+ void printBuffer(const char* s) CPPUTEST_OVERRIDE
{
output += s;
}
- void flush() _override
+ void flush() CPPUTEST_OVERRIDE
{
output = "";
}
@@ -32,11 +32,11 @@ class TeamCityOutputToBuffer : public TeamCityTestOutput
SimpleString output;
};
-static long millisTime;
+static unsigned long millisTime;
extern "C" {
- static long MockGetPlatformSpecificTimeInMillis()
+ static unsigned long MockGetPlatformSpecificTimeInMillis()
{
return millisTime;
}
@@ -51,7 +51,7 @@ TEST_GROUP(TeamCityOutputTest)
TestFailure *f, *f2, *f3;
TestResult* result;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
mock = new TeamCityOutputToBuffer();
tcout = mock;
@@ -64,7 +64,7 @@ TEST_GROUP(TeamCityOutputTest)
millisTime = 0;
UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete tcout;
delete tst;
diff --git a/tests/CppUTest/TestFailureNaNTest.cpp b/tests/CppUTest/TestFailureNaNTest.cpp
index e17e359a2..2f7e2a62f 100644
--- a/tests/CppUTest/TestFailureNaNTest.cpp
+++ b/tests/CppUTest/TestFailureNaNTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -29,50 +29,36 @@
#include "CppUTest/TestOutput.h"
#include "CppUTest/PlatformSpecificFunctions.h"
+#if CPPUTEST_USE_STD_C_LIB
+#include
+#endif
+
+#if defined(NAN) && defined(INFINITY)
+
namespace
{
const int failLineNumber = 2;
const char* failFileName = "fail.cpp";
}
-static double zero = 0.0;
-static double one = 1.0;
-static double not_a_number = zero / zero;
-static double infinity = one / zero;
-
-extern "C" {
- static int IsNanForSystemsWithoutNan(double d) { return ((long)not_a_number == (long)d); }
- static int IsInfForSystemsWithoutInf(double d) { return ((long)infinity == (long)d); }
-}
-
TEST_GROUP(TestFailureNanAndInf)
{
UtestShell* test;
- void setup() _override
+ void setup() CPPUTEST_OVERRIDE
{
test = new UtestShell("groupname", "testname", failFileName, failLineNumber-1);
- if(PlatformSpecificIsNan(not_a_number) == false)
- {
- not_a_number = -1.0;
- UT_PTR_SET(PlatformSpecificIsNan, IsNanForSystemsWithoutNan);
- }
- if(PlatformSpecificIsInf(infinity) == false)
- {
- infinity = -2.0;
- UT_PTR_SET(PlatformSpecificIsInf, IsInfForSystemsWithoutInf);
- }
}
- void teardown() _override
+ void teardown() CPPUTEST_OVERRIDE
{
delete test;
}
};
-#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, b.getMessage().asCharString(), "", __FILE__, __LINE__)
+#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, (b).getMessage().asCharString(), "", __FILE__, __LINE__)
TEST(TestFailureNanAndInf, DoublesEqualExpectedIsNaN)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, not_a_number, 2.0, 3.0, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, (double)NAN, 2.0, 3.0, "");
FAILURE_EQUAL("expected \n"
"\tbut was <2> threshold used was <3>\n"
"\tCannot make comparisons with Nan", f);
@@ -80,7 +66,7 @@ TEST(TestFailureNanAndInf, DoublesEqualExpectedIsNaN)
TEST(TestFailureNanAndInf, DoublesEqualActualIsNaN)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, not_a_number, 3.0, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, (double)NAN, 3.0, "");
FAILURE_EQUAL("expected <1>\n"
"\tbut was threshold used was <3>\n"
"\tCannot make comparisons with Nan", f);
@@ -88,7 +74,7 @@ TEST(TestFailureNanAndInf, DoublesEqualActualIsNaN)
TEST(TestFailureNanAndInf, DoublesEqualThresholdIsNaN)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, 2.0, not_a_number, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, 2.0, (double)NAN, "");
FAILURE_EQUAL("expected <1>\n"
"\tbut was <2> threshold used was \n"
"\tCannot make comparisons with Nan", f);
@@ -96,22 +82,24 @@ TEST(TestFailureNanAndInf, DoublesEqualThresholdIsNaN)
TEST(TestFailureNanAndInf, DoublesEqualExpectedIsInf)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, infinity, 2.0, 3.0, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, (double)INFINITY, 2.0, 3.0, "");
FAILURE_EQUAL("expected \n"
"\tbut was <2> threshold used was <3>", f);
}
TEST(TestFailureNanAndInf, DoublesEqualActualIsInf)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, infinity, 3.0, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, (double)INFINITY, 3.0, "");
FAILURE_EQUAL("expected <1>\n"
"\tbut was threshold used was <3>", f);
}
TEST(TestFailureNanAndInf, DoublesEqualThresholdIsInf)
{
- DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, not_a_number, infinity, "");
+ DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, (double)NAN, (double)INFINITY, "");
FAILURE_EQUAL("expected <1>\n"
"\tbut was threshold used was \n"
"\tCannot make comparisons with Nan", f);
}
+
+#endif
diff --git a/tests/CppUTest/TestFailureTest.cpp b/tests/CppUTest/TestFailureTest.cpp
index 1f8c148f3..6a7cb1516 100644
--- a/tests/CppUTest/TestFailureTest.cpp
+++ b/tests/CppUTest/TestFailureTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,16 +38,16 @@ TEST_GROUP(TestFailure)
{
UtestShell* test;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
test = new UtestShell("groupname", "testname", failFileName, failLineNumber-1);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete test;
}
};
-#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, b.getMessage().asCharString(), "", __FILE__, __LINE__)
+#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, (b).getMessage().asCharString(), "", __FILE__, __LINE__)
TEST(TestFailure, CreateFailure)
{
@@ -141,7 +141,7 @@ TEST(TestFailure, LongsEqualFailure)
TEST(TestFailure, LongLongsEqualFailure)
{
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
LongLongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, "");
FAILURE_EQUAL("expected <1 (0x1)>\n\tbut was <2 (0x2)>", f);
#else
@@ -153,7 +153,7 @@ TEST(TestFailure, LongLongsEqualFailure)
TEST(TestFailure, UnsignedLongLongsEqualFailure)
{
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
UnsignedLongLongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, "");
FAILURE_EQUAL("expected <1 (0x1)>\n\tbut was <2 (0x2)>", f);
#else
@@ -212,10 +212,10 @@ TEST(TestFailure, StringsEqualFailureWithNewLinesAndTabs)
"StringWith\t\nDifferentString",
"StringWith\t\ndifferentString", "");
- FAILURE_EQUAL("expected \n"
- "\tbut was \n"
- "\tdifference starts at position 12 at: \n"
- "\t \t\n^", f);
+ FAILURE_EQUAL("expected \n"
+ "\tbut was \n"
+ "\tdifference starts at position 12 at: \n"
+ "\t ^", f);
}
TEST(TestFailure, StringsEqualFailureInTheMiddle)
@@ -401,7 +401,7 @@ TEST(TestFailure, BitsEqualChar)
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), "");
FAILURE_EQUAL("expected \n\tbut was ", f);
}
-#else
+#elif (CPPUTEST_CHAR_BIT == 8)
TEST(TestFailure, BitsEqualChar)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), "");
@@ -426,3 +426,26 @@ TEST(TestFailure, FeatureUnsupported)
FeatureUnsupportedFailure f(test, failFileName, failLineNumber, "SOME_FEATURE", "");
FAILURE_EQUAL("The feature \"SOME_FEATURE\" is not supported in this environment or with the feature set selected when building the library.", f);
}
+
+#if CPPUTEST_HAVE_EXCEPTIONS
+TEST(TestFailure, UnexpectedExceptionFailure_UnknownException)
+{
+ UnexpectedExceptionFailure f(test);
+ FAILURE_EQUAL("Unexpected exception of unknown type was thrown.", f);
+}
+#endif
+
+#if CPPUTEST_HAVE_EXCEPTIONS && CPPUTEST_USE_STD_CPP_LIB
+TEST(TestFailure, UnexpectedExceptionFailure_StandardException)
+{
+ std::runtime_error e("Some error");
+ UnexpectedExceptionFailure f(test, e);
+#if CPPUTEST_HAVE_RTTI
+ STRCMP_CONTAINS("Unexpected exception of type '", f.getMessage().asCharString());
+ STRCMP_CONTAINS("runtime_error", f.getMessage().asCharString());
+ STRCMP_CONTAINS("' was thrown: Some error", f.getMessage().asCharString());
+#else
+ FAILURE_EQUAL("Unexpected exception of unknown type was thrown.", f);
+#endif
+}
+#endif
diff --git a/tests/CppUTest/TestFilterTest.cpp b/tests/CppUTest/TestFilterTest.cpp
index 1f60e6896..231a01a0a 100644
--- a/tests/CppUTest/TestFilterTest.cpp
+++ b/tests/CppUTest/TestFilterTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTest/TestHarness_cTest.cpp b/tests/CppUTest/TestHarness_cTest.cpp
index 6ceefcaac..fadc66f1d 100644
--- a/tests/CppUTest/TestHarness_cTest.cpp
+++ b/tests/CppUTest/TestHarness_cTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -84,7 +84,7 @@ TEST_GROUP(TestHarness_c)
}
};
-static void _failBoolMethod()
+static void failBoolMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_BOOL(1, 0);
@@ -94,14 +94,14 @@ TEST(TestHarness_c, checkBool)
{
CHECK_EQUAL_C_BOOL(1, 1);
CHECK_EQUAL_C_BOOL(1, 2);
- fixture->setTestFunction(_failBoolMethod);
+ fixture->setTestFunction(failBoolMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected \n but was ");
+ fixture->assertPrintContains("expected \n\tbut was ");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failBoolTextMethod()
+static void failBoolTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_BOOL_TEXT(1, 0, "BoolTestText");
@@ -111,15 +111,15 @@ TEST(TestHarness_c, checkBoolText)
{
CHECK_EQUAL_C_BOOL_TEXT(1, 1, "Text");
CHECK_EQUAL_C_BOOL_TEXT(1, 2, "Text");
- fixture->setTestFunction(_failBoolTextMethod);
+ fixture->setTestFunction(failBoolTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected \n but was ");
+ fixture->assertPrintContains("expected \n\tbut was ");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: BoolTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failIntMethod()
+static void failIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_INT(1, 2);
@@ -128,14 +128,14 @@ static void _failIntMethod()
TEST(TestHarness_c, checkInt)
{
CHECK_EQUAL_C_INT(2, 2);
- fixture->setTestFunction(_failIntMethod);
+ fixture->setTestFunction(failIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failIntTextMethod()
+static void failIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_INT_TEXT(1, 2, "IntTestText");
@@ -144,15 +144,15 @@ static void _failIntTextMethod()
TEST(TestHarness_c, checkIntText)
{
CHECK_EQUAL_C_INT_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failIntTextMethod);
+ fixture->setTestFunction(failIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: IntTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedIntMethod()
+static void failUnsignedIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_UINT(1, 2);
@@ -161,14 +161,14 @@ static void _failUnsignedIntMethod()
TEST(TestHarness_c, checkUnsignedInt)
{
CHECK_EQUAL_C_UINT(2, 2);
- fixture->setTestFunction(_failUnsignedIntMethod);
+ fixture->setTestFunction(failUnsignedIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedIntTextMethod()
+static void failUnsignedIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_UINT_TEXT(1, 2, "UnsignedIntTestText");
@@ -177,15 +177,15 @@ static void _failUnsignedIntTextMethod()
TEST(TestHarness_c, checkUnsignedIntText)
{
CHECK_EQUAL_C_UINT_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failUnsignedIntTextMethod);
+ fixture->setTestFunction(failUnsignedIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: UnsignedIntTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failLongIntMethod()
+static void failLongIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_LONG(1, 2);
@@ -194,14 +194,14 @@ static void _failLongIntMethod()
TEST(TestHarness_c, checkLongInt)
{
CHECK_EQUAL_C_LONG(2, 2);
- fixture->setTestFunction(_failLongIntMethod);
+ fixture->setTestFunction(failLongIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failLongIntTextMethod()
+static void failLongIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_LONG_TEXT(1, 2, "LongIntTestText");
@@ -210,15 +210,15 @@ static void _failLongIntTextMethod()
TEST(TestHarness_c, checkLongIntText)
{
CHECK_EQUAL_C_LONG_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failLongIntTextMethod);
+ fixture->setTestFunction(failLongIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: LongIntTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedLongIntMethod()
+static void failUnsignedLongIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_ULONG(1, 2);
@@ -227,14 +227,14 @@ static void _failUnsignedLongIntMethod()
TEST(TestHarness_c, checkUnsignedLongInt)
{
CHECK_EQUAL_C_ULONG(2, 2);
- fixture->setTestFunction(_failUnsignedLongIntMethod);
+ fixture->setTestFunction(failUnsignedLongIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedLongIntTextMethod()
+static void failUnsignedLongIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_ULONG_TEXT(1, 2, "UnsignedLongIntTestText");
@@ -243,17 +243,17 @@ static void _failUnsignedLongIntTextMethod()
TEST(TestHarness_c, checkUnsignedLongIntText)
{
CHECK_EQUAL_C_ULONG_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failUnsignedLongIntTextMethod);
+ fixture->setTestFunction(failUnsignedLongIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: UnsignedLongIntTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
-static void _failLongLongIntMethod()
+static void failLongLongIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_LONGLONG(1, 2);
@@ -262,14 +262,14 @@ static void _failLongLongIntMethod()
TEST(TestHarness_c, checkLongLongInt)
{
CHECK_EQUAL_C_LONGLONG(2, 2);
- fixture->setTestFunction(_failLongLongIntMethod);
+ fixture->setTestFunction(failLongLongIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failLongLongIntTextMethod()
+static void failLongLongIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_LONGLONG_TEXT(1, 2, "LongLongTestText");
@@ -278,15 +278,15 @@ static void _failLongLongIntTextMethod()
TEST(TestHarness_c, checkLongLongIntText)
{
CHECK_EQUAL_C_LONGLONG_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failLongLongIntTextMethod);
+ fixture->setTestFunction(failLongLongIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: LongLongTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedLongLongIntMethod()
+static void failUnsignedLongLongIntMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_ULONGLONG(1, 2);
@@ -295,14 +295,14 @@ static void _failUnsignedLongLongIntMethod()
TEST(TestHarness_c, checkUnsignedLongLongInt)
{
CHECK_EQUAL_C_ULONGLONG(2, 2);
- fixture->setTestFunction(_failUnsignedLongLongIntMethod);
+ fixture->setTestFunction(failUnsignedLongLongIntMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedLongLongIntTextMethod()
+static void failUnsignedLongLongIntTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_ULONGLONG_TEXT(1, 2, "UnsignedLongLongTestText");
@@ -311,9 +311,9 @@ static void _failUnsignedLongLongIntTextMethod()
TEST(TestHarness_c, checkUnsignedLongLongIntText)
{
CHECK_EQUAL_C_ULONGLONG_TEXT(2, 2, "Text");
- fixture->setTestFunction(_failUnsignedLongLongIntTextMethod);
+ fixture->setTestFunction(failUnsignedLongLongIntTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1 (0x1)>\n but was <2 (0x2)>");
+ fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: UnsignedLongLongTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
@@ -321,7 +321,7 @@ TEST(TestHarness_c, checkUnsignedLongLongIntText)
#else
-static void _failLongLongIntMethod()
+static void failLongLongIntMethod_()
{
cpputest_longlong dummy_longlong;
CHECK_EQUAL_C_LONGLONG(dummy_longlong, dummy_longlong);
@@ -329,13 +329,13 @@ static void _failLongLongIntMethod()
TEST(TestHarness_c, checkLongLongInt)
{
- fixture->setTestFunction(_failLongLongIntMethod);
+ fixture->setTestFunction(failLongLongIntMethod_);
fixture->runAllTests();
fixture->assertPrintContains("is not supported");
fixture->assertPrintContains("arness_c");
}
-static void _failLongLongIntTextMethod()
+static void failLongLongIntTextMethod_()
{
cpputest_longlong dummy_longlong;
CHECK_EQUAL_C_LONGLONG_TEXT(dummy_longlong, dummy_longlong, "Text");
@@ -343,13 +343,13 @@ static void _failLongLongIntTextMethod()
TEST(TestHarness_c, checkLongLongIntText)
{
- fixture->setTestFunction(_failLongLongIntTextMethod);
+ fixture->setTestFunction(failLongLongIntTextMethod_);
fixture->runAllTests();
fixture->assertPrintContains("is not supported");
fixture->assertPrintContains("arness_c");
}
-static void _failUnsignedLongLongIntMethod()
+static void failUnsignedLongLongIntMethod_()
{
cpputest_ulonglong dummy_ulonglong;
CHECK_EQUAL_C_ULONGLONG(dummy_ulonglong, dummy_ulonglong);
@@ -357,13 +357,13 @@ static void _failUnsignedLongLongIntMethod()
TEST(TestHarness_c, checkUnsignedLongLongInt)
{
- fixture->setTestFunction(_failUnsignedLongLongIntMethod);
+ fixture->setTestFunction(failUnsignedLongLongIntMethod_);
fixture->runAllTests();
fixture->assertPrintContains("is not supported");
fixture->assertPrintContains("arness_c");
}
-static void _failUnsignedLongLongIntTextMethod()
+static void failUnsignedLongLongIntTextMethod_()
{
cpputest_ulonglong dummy_ulonglong;
CHECK_EQUAL_C_ULONGLONG_TEXT(dummy_ulonglong, dummy_ulonglong, "Text");
@@ -371,7 +371,7 @@ static void _failUnsignedLongLongIntTextMethod()
TEST(TestHarness_c, checkUnsignedLongLongIntText)
{
- fixture->setTestFunction(_failUnsignedLongLongIntTextMethod);
+ fixture->setTestFunction(failUnsignedLongLongIntTextMethod_);
fixture->runAllTests();
fixture->assertPrintContains("is not supported");
fixture->assertPrintContains("arness_c");
@@ -379,7 +379,7 @@ TEST(TestHarness_c, checkUnsignedLongLongIntText)
#endif
-static void _failRealMethod()
+static void failRealMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_REAL(1.0, 2.0, 0.5);
@@ -388,14 +388,14 @@ static void _failRealMethod()
TEST(TestHarness_c, checkReal)
{
CHECK_EQUAL_C_REAL(1.0, 1.1, 0.5);
- fixture->setTestFunction(_failRealMethod);
+ fixture->setTestFunction(failRealMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1>\n but was <2>");
+ fixture->assertPrintContains("expected <1>\n\tbut was <2>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failRealTextMethod()
+static void failRealTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_REAL_TEXT(1.0, 2.0, 0.5, "RealTestText");
@@ -404,15 +404,15 @@ static void _failRealTextMethod()
TEST(TestHarness_c, checkRealText)
{
CHECK_EQUAL_C_REAL_TEXT(1.0, 1.1, 0.5, "Text");
- fixture->setTestFunction(_failRealTextMethod);
+ fixture->setTestFunction(failRealTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <1>\n but was <2>");
+ fixture->assertPrintContains("expected <1>\n\tbut was <2>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: RealTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failCharMethod()
+static void failCharMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_CHAR('a', 'c');
@@ -421,14 +421,14 @@ static void _failCharMethod()
TEST(TestHarness_c, checkChar)
{
CHECK_EQUAL_C_CHAR('a', 'a');
- fixture->setTestFunction(_failCharMethod);
+ fixture->setTestFunction(failCharMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected \n but was ");
+ fixture->assertPrintContains("expected \n\tbut was ");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failCharTextMethod()
+static void failCharTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_CHAR_TEXT('a', 'c', "CharTestText");
@@ -437,15 +437,15 @@ static void _failCharTextMethod()
TEST(TestHarness_c, checkCharText)
{
CHECK_EQUAL_C_CHAR_TEXT('a', 'a', "Text");
- fixture->setTestFunction(_failCharTextMethod);
+ fixture->setTestFunction(failCharTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected \n but was ");
+ fixture->assertPrintContains("expected \n\tbut was ");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: CharTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedByteMethod()
+static void failUnsignedByteMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_UBYTE(254, 253);
@@ -454,14 +454,14 @@ static void _failUnsignedByteMethod()
TEST(TestHarness_c, checkUnsignedByte)
{
CHECK_EQUAL_C_UBYTE(254, 254);
- fixture->setTestFunction(_failUnsignedByteMethod);
+ fixture->setTestFunction(failUnsignedByteMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <254>\n but was <253>");
+ fixture->assertPrintContains("expected <254>\n\tbut was <253>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failUnsignedByteTextMethod()
+static void failUnsignedByteTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_UBYTE_TEXT(254, 253, "UnsignedByteTestText");
@@ -470,15 +470,15 @@ static void _failUnsignedByteTextMethod()
TEST(TestHarness_c, checkUnsignedByteText)
{
CHECK_EQUAL_C_UBYTE_TEXT(254, 254, "Text");
- fixture->setTestFunction(_failUnsignedByteTextMethod);
+ fixture->setTestFunction(failUnsignedByteTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <254>\n but was <253>");
+ fixture->assertPrintContains("expected <254>\n\tbut was <253>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: UnsignedByteTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failSignedByteMethod()
+static void failSignedByteMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_SBYTE(-3, -5);
@@ -487,14 +487,14 @@ static void _failSignedByteMethod()
TEST(TestHarness_c, checkSignedByte)
{
CHECK_EQUAL_C_SBYTE(-3, -3);
- fixture->setTestFunction(_failSignedByteMethod);
+ fixture->setTestFunction(failSignedByteMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <-3>\n but was <-5>");
+ fixture->assertPrintContains("expected <-3>\n\tbut was <-5>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failSignedByteTextMethod()
+static void failSignedByteTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_SBYTE_TEXT(-3, -5, "SignedByteTestText");
@@ -503,15 +503,15 @@ static void _failSignedByteTextMethod()
TEST(TestHarness_c, checkSignedByteText)
{
CHECK_EQUAL_C_SBYTE_TEXT(-3, -3, "Text");
- fixture->setTestFunction(_failSignedByteTextMethod);
+ fixture->setTestFunction(failSignedByteTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <-3>\n but was <-5>");
+ fixture->assertPrintContains("expected <-3>\n\tbut was <-5>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: SignedByteTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failStringMethod()
+static void failStringMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_STRING("Hello", "Hello World");
@@ -520,7 +520,7 @@ static void _failStringMethod()
TEST(TestHarness_c, checkString)
{
CHECK_EQUAL_C_STRING("Hello", "Hello");
- fixture->setTestFunction(_failStringMethod);
+ fixture->setTestFunction(failStringMethod_);
fixture->runAllTests();
StringEqualFailure failure(UtestShell::getCurrent(), "file", 1, "Hello", "Hello World", "");
@@ -529,7 +529,7 @@ TEST(TestHarness_c, checkString)
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failStringTextMethod()
+static void failStringTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_STRING_TEXT("Hello", "Hello World", "StringTestText");
@@ -538,7 +538,7 @@ static void _failStringTextMethod()
TEST(TestHarness_c, checkStringText)
{
CHECK_EQUAL_C_STRING_TEXT("Hello", "Hello", "Text");
- fixture->setTestFunction(_failStringTextMethod);
+ fixture->setTestFunction(failStringTextMethod_);
fixture->runAllTests();
StringEqualFailure failure(UtestShell::getCurrent(), "file", 1, "Hello", "Hello World", "");
@@ -548,7 +548,7 @@ TEST(TestHarness_c, checkStringText)
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failPointerMethod()
+static void failPointerMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_POINTER(NULLPTR, (void *)0x1);
@@ -557,14 +557,14 @@ static void _failPointerMethod()
TEST(TestHarness_c, checkPointer)
{
CHECK_EQUAL_C_POINTER(NULLPTR, NULLPTR);
- fixture->setTestFunction(_failPointerMethod);
+ fixture->setTestFunction(failPointerMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <0x0>\n but was <0x1>");
+ fixture->assertPrintContains("expected <0x0>\n\tbut was <0x1>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failPointerTextMethod()
+static void failPointerTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_POINTER_TEXT(NULLPTR, (void *)0x1, "PointerTestText");
@@ -573,15 +573,54 @@ static void _failPointerTextMethod()
TEST(TestHarness_c, checkPointerText)
{
CHECK_EQUAL_C_POINTER_TEXT(NULLPTR, NULLPTR, "Text");
- fixture->setTestFunction(_failPointerTextMethod);
+ fixture->setTestFunction(failPointerTextMethod_);
fixture->runAllTests();
- fixture->assertPrintContains("expected <0x0>\n but was <0x1>");
+ fixture->assertPrintContains("expected <0x0>\n\tbut was <0x1>");
fixture->assertPrintContains("arness_c");
fixture->assertPrintContains("Message: PointerTestText");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failBitsMethod()
+static void failMemcmpMethod_()
+{
+ HasTheDestructorBeenCalledChecker checker;
+ unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 };
+ unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 };
+
+ CHECK_EQUAL_C_MEMCMP(expectedData, actualData, sizeof(expectedData));
+}
+
+TEST(TestHarness_c, checkMemcmp)
+{
+ CHECK_EQUAL_C_MEMCMP("TEST", "TEST", 5);
+ fixture->setTestFunction(failMemcmpMethod_);
+ fixture->runAllTests();
+ fixture->assertPrintContains("expected <00 01 02 03>\n\tbut was <00 01 03 03>");
+ fixture->assertPrintContains("arness_c");
+ CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
+}
+
+static void failMemcmpTextMethod_()
+{
+ HasTheDestructorBeenCalledChecker checker;
+ unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 };
+ unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 };
+
+ CHECK_EQUAL_C_MEMCMP_TEXT(expectedData, actualData, sizeof(expectedData), "MemcmpTestText");
+}
+
+TEST(TestHarness_c, checkMemcmpText)
+{
+ CHECK_EQUAL_C_MEMCMP_TEXT("TEST", "TEST", 5, "Text");
+ fixture->setTestFunction(failMemcmpTextMethod_);
+ fixture->runAllTests();
+ fixture->assertPrintContains("expected <00 01 02 03>\n\tbut was <00 01 03 03>");
+ fixture->assertPrintContains("arness_c");
+ fixture->assertPrintContains("Message: MemcmpTestText");
+ CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
+}
+
+static void failBitsMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_BITS(0x0001, (unsigned short)0x0003, 0xFFFF);
@@ -590,14 +629,14 @@ static void _failBitsMethod()
TEST(TestHarness_c, checkBits)
{
CHECK_EQUAL_C_BITS(0xABCD, (unsigned short)0xABCD, 0xFFFF);
- fixture->setTestFunction(_failBitsMethod);
+ fixture->setTestFunction(failBitsMethod_);
fixture->runAllTests();
fixture->assertPrintContains("expected <00000000 00000001>\n\tbut was <00000000 00000011>");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failBitsTextMethod()
+static void failBitsTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_EQUAL_C_BITS_TEXT(0x0001, (unsigned short)0x0003, 0xFFFF, "BitsTestText");
@@ -606,7 +645,7 @@ static void _failBitsTextMethod()
TEST(TestHarness_c, checkBitsText)
{
CHECK_EQUAL_C_BITS_TEXT(0xABCD, (unsigned short)0xABCD, 0xFFFF, "Text");
- fixture->setTestFunction(_failBitsTextMethod);
+ fixture->setTestFunction(failBitsTextMethod_);
fixture->runAllTests();
fixture->assertPrintContains("expected <00000000 00000001>\n\tbut was <00000000 00000011>");
fixture->assertPrintContains("arness_c");
@@ -614,7 +653,7 @@ TEST(TestHarness_c, checkBitsText)
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failTextMethod()
+static void failTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
FAIL_TEXT_C("Booo");
@@ -622,14 +661,14 @@ static void _failTextMethod()
TEST(TestHarness_c, checkFailText)
{
- fixture->setTestFunction(_failTextMethod);
+ fixture->setTestFunction(failTextMethod_);
fixture->runAllTests();
fixture->assertPrintContains("Booo");
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _failMethod()
+static void failMethod_()
{
HasTheDestructorBeenCalledChecker checker;
FAIL_C();
@@ -637,14 +676,52 @@ static void _failMethod()
TEST(TestHarness_c, checkFail)
{
- fixture->setTestFunction(_failMethod);
+ fixture->setTestFunction(failMethod_);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
fixture->assertPrintContains("arness_c");
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _CheckMethod()
+static bool cpputestHasCrashed;
+
+static void crashMethod()
+{
+ cpputestHasCrashed = true;
+}
+
+TEST(TestHarness_c, doesNotCrashIfNotSetToCrash)
+{
+ cpputestHasCrashed = false;
+ UtestShell::setCrashMethod(crashMethod);
+ fixture->setTestFunction(failMethod_);
+
+ fixture->runAllTests();
+
+ CHECK_FALSE(cpputestHasCrashed);
+ LONGS_EQUAL(1, fixture->getFailureCount());
+ CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
+
+ UtestShell::resetCrashMethod();
+}
+
+TEST(TestHarness_c, doesCrashIfSetToCrash)
+{
+ cpputestHasCrashed = false;
+ UtestShell::setCrashOnFail();
+ UtestShell::setCrashMethod(crashMethod);
+ fixture->setTestFunction(failMethod_);
+
+ fixture->runAllTests();
+
+ CHECK(cpputestHasCrashed);
+ CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
+
+ UtestShell::restoreDefaultTestTerminator();
+ UtestShell::resetCrashMethod();
+}
+
+static void CheckMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_C(false);
@@ -653,13 +730,13 @@ static void _CheckMethod()
TEST(TestHarness_c, checkCheck)
{
CHECK_C(true);
- fixture->setTestFunction(_CheckMethod);
+ fixture->setTestFunction(CheckMethod_);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled);
}
-static void _CheckTextMethod()
+static void CheckTextMethod_()
{
HasTheDestructorBeenCalledChecker checker;
CHECK_C_TEXT(false, "CheckTestText");
@@ -668,7 +745,7 @@ static void _CheckTextMethod()
TEST(TestHarness_c, checkCheckText)
{
CHECK_C_TEXT(true, "Text");
- fixture->setTestFunction(_CheckTextMethod);
+ fixture->setTestFunction(CheckTextMethod_);
fixture->runAllTests();
LONGS_EQUAL(1, fixture->getFailureCount());
fixture->assertPrintContains("Message: CheckTestText");
@@ -805,4 +882,3 @@ TEST(TestHarness_c, callocShouldReturnNULLWhenOutOfMemory)
cpputest_malloc_set_not_out_of_memory();
}
#endif
-
diff --git a/tests/CppUTest/TestInstallerTest.cpp b/tests/CppUTest/TestInstallerTest.cpp
index ec646700d..da59f322d 100644
--- a/tests/CppUTest/TestInstallerTest.cpp
+++ b/tests/CppUTest/TestInstallerTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -42,13 +42,13 @@ TEST_GROUP(TestInstaller)
TestInstaller* testInstaller;
TestRegistry* myRegistry;
TestInstallerTestUtestShell shell;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
myRegistry = new TestRegistry();
myRegistry->setCurrentRegistry(myRegistry);
testInstaller = new TestInstaller(shell, "TestInstaller", "test", __FILE__, __LINE__);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
myRegistry->setCurrentRegistry(NULLPTR);
testInstaller->unDo();
@@ -60,4 +60,3 @@ TEST_GROUP(TestInstaller)
TEST(TestInstaller, Create)
{
}
-
diff --git a/tests/CppUTest/TestMemoryAllocatorTest.cpp b/tests/CppUTest/TestMemoryAllocatorTest.cpp
index 9cd9feff2..1f2e86618 100644
--- a/tests/CppUTest/TestMemoryAllocatorTest.cpp
+++ b/tests/CppUTest/TestMemoryAllocatorTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,13 +36,13 @@ TEST_GROUP(TestMemoryAllocatorTest)
TestMemoryAllocator* allocator;
GlobalMemoryAllocatorStash memoryAllocatorStash;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
allocator = NULLPTR;
memoryAllocatorStash.save();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
memoryAllocatorStash.restore();
delete allocator;
@@ -127,7 +127,7 @@ TEST(TestMemoryAllocatorTest, NullUnknownNames)
#if (! CPPUTEST_SANITIZE_ADDRESS)
-#define MAX_SIZE_FOR_ALLOC ((size_t) -1 > (unsigned short)-1) ? (size_t) -97 : (size_t) -1
+#define MAX_SIZE_FOR_ALLOC ((size_t) -1 > (unsigned short)-1) ? (size_t)(-97) : (size_t)(-1)
static void failTryingToAllocateTooMuchMemory(void)
{
@@ -149,12 +149,12 @@ TEST_GROUP(MemoryLeakAllocator)
{
MemoryLeakAllocator* allocator;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
allocator = new MemoryLeakAllocator(defaultMallocAllocator());
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete allocator;
}
@@ -198,13 +198,13 @@ class FailableMemoryAllocatorExecFunction : public ExecFunction
FailableMemoryAllocator* allocator_;
void (*testFunction_)(FailableMemoryAllocator*);
- void exec() _override
+ void exec() CPPUTEST_OVERRIDE
{
testFunction_(allocator_);
}
FailableMemoryAllocatorExecFunction() : allocator_(NULLPTR), testFunction_(NULLPTR) {}
- virtual ~FailableMemoryAllocatorExecFunction() _destructor_override {}
+ virtual ~FailableMemoryAllocatorExecFunction() CPPUTEST_DESTRUCTOR_OVERRIDE {}
};
TEST_GROUP(FailableMemoryAllocator)
@@ -214,14 +214,14 @@ TEST_GROUP(FailableMemoryAllocator)
TestTestingFixture fixture;
GlobalMemoryAllocatorStash stash;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
stash.save();
testFunction.allocator_ = failableMallocAllocator = new FailableMemoryAllocator("Failable Malloc Allocator", "malloc", "free");
fixture.setTestFunction(&testFunction);
setCurrentMallocAllocator(failableMallocAllocator);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
failableMallocAllocator->checkAllFailedAllocsWereDone();
failableMallocAllocator->clearFailedAllocs();
@@ -261,7 +261,7 @@ TEST(FailableMemoryAllocator, FailSecondAndFourthMalloc)
free(memory3);
}
-static void _failingAllocIsNeverDone(FailableMemoryAllocator* failableMallocAllocator)
+static void failingAllocIsNeverDone_(FailableMemoryAllocator* failableMallocAllocator)
{
failableMallocAllocator->failAllocNumber(1);
failableMallocAllocator->failAllocNumber(2);
@@ -273,7 +273,7 @@ static void _failingAllocIsNeverDone(FailableMemoryAllocator* failableMallocAllo
TEST(FailableMemoryAllocator, CheckAllFailingAllocsWereDone)
{
- testFunction.testFunction_ = _failingAllocIsNeverDone;
+ testFunction.testFunction_ = failingAllocIsNeverDone_;
fixture.runAllTests();
@@ -306,7 +306,7 @@ TEST(FailableMemoryAllocator, FailThirdAllocationAtGivenLine)
LONGS_EQUAL(3, allocation);
}
-static void _failingLocationAllocIsNeverDone(FailableMemoryAllocator* failableMallocAllocator)
+static void failingLocationAllocIsNeverDone_(FailableMemoryAllocator* failableMallocAllocator)
{
failableMallocAllocator->failNthAllocAt(1, "TestMemoryAllocatorTest.cpp", __LINE__);
failableMallocAllocator->checkAllFailedAllocsWereDone();
@@ -314,7 +314,7 @@ static void _failingLocationAllocIsNeverDone(FailableMemoryAllocator* failableMa
TEST(FailableMemoryAllocator, CheckAllFailingLocationAllocsWereDone)
{
- testFunction.testFunction_ = _failingLocationAllocIsNeverDone;
+ testFunction.testFunction_ = failingLocationAllocIsNeverDone_;
fixture.runAllTests();
@@ -332,14 +332,14 @@ class MemoryAccountantExecFunction
: public ExecFunction
{
public:
- virtual ~MemoryAccountantExecFunction() _destructor_override
+ virtual ~MemoryAccountantExecFunction() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
void (*testFunction_)(MemoryAccountant*);
MemoryAccountant* parameter_;
- virtual void exec() _override
+ virtual void exec() CPPUTEST_OVERRIDE
{
testFunction_(parameter_);
}
@@ -351,13 +351,13 @@ TEST_GROUP(TestMemoryAccountant)
TestTestingFixture fixture;
MemoryAccountantExecFunction testFunction;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
testFunction.parameter_ = &accountant;
fixture.setTestFunction(&testFunction);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
accountant.clear();
}
@@ -465,7 +465,7 @@ TEST(TestMemoryAccountant, reportAllocationsWithSizeZero)
}
-static void _failUseCacheSizesAfterAllocation(MemoryAccountant* accountant)
+static void failUseCacheSizesAfterAllocation_(MemoryAccountant* accountant)
{
size_t cacheSizes[] = {0};
@@ -475,7 +475,7 @@ static void _failUseCacheSizesAfterAllocation(MemoryAccountant* accountant)
TEST(TestMemoryAccountant, withCacheSizesFailsWhenAlreadyAllocatedMemory)
{
- testFunction.testFunction_ = _failUseCacheSizesAfterAllocation;
+ testFunction.testFunction_ = failUseCacheSizesAfterAllocation_;
fixture.runAllTests();
@@ -545,12 +545,12 @@ TEST_GROUP(AccountingTestMemoryAllocator)
MemoryAccountant accountant;
AccountingTestMemoryAllocator *allocator;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
allocator = new AccountingTestMemoryAllocator(accountant, getCurrentMallocAllocator());
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
accountant.clear();
delete allocator;
@@ -615,7 +615,7 @@ class GlobalMemoryAccountantExecFunction
void (*testFunction_)(GlobalMemoryAccountant*);
GlobalMemoryAccountant* parameter_;
- virtual void exec() _override
+ virtual void exec() CPPUTEST_OVERRIDE
{
testFunction_(parameter_);
}
@@ -628,14 +628,14 @@ TEST_GROUP(GlobalMemoryAccountant)
GlobalMemoryAccountantExecFunction testFunction;
GlobalMemoryAllocatorStash stash;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
testFunction.parameter_ = &accountant;
fixture.setTestFunction(&testFunction);
stash.save();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
stash.restore();
}
@@ -695,19 +695,19 @@ TEST(GlobalMemoryAccountant, reportWithCacheSizes)
#endif
-static void _failStopWithoutStartingWillFail(GlobalMemoryAccountant* accountant)
+static void failStopWithoutStartingWillFail_(GlobalMemoryAccountant* accountant)
{
accountant->stop();
}
TEST(GlobalMemoryAccountant, StopCantBeCalledWithoutStarting)
{
- testFunction.testFunction_ = _failStopWithoutStartingWillFail;
+ testFunction.testFunction_ = failStopWithoutStartingWillFail_;
fixture.runAllTests();
fixture.assertPrintContains("GlobalMemoryAccount: Stop called without starting");
}
-static void _failStartingTwiceWillFail(GlobalMemoryAccountant* accountant)
+static void failStartingTwiceWillFail_(GlobalMemoryAccountant* accountant)
{
accountant->start();
accountant->start();
@@ -715,14 +715,14 @@ static void _failStartingTwiceWillFail(GlobalMemoryAccountant* accountant)
TEST(GlobalMemoryAccountant, startTwiceWillFail)
{
- testFunction.testFunction_ = _failStartingTwiceWillFail;
+ testFunction.testFunction_ = failStartingTwiceWillFail_;
fixture.runAllTests();
accountant.stop();
fixture.assertPrintContains("Global allocator start called twice!");
}
-static void _failChangeMallocMemoryAllocator(GlobalMemoryAccountant* accountant)
+static void failChangeMallocMemoryAllocator_(GlobalMemoryAccountant* accountant)
{
accountant->start();
setCurrentMallocAllocator(defaultMallocAllocator());
@@ -731,12 +731,12 @@ static void _failChangeMallocMemoryAllocator(GlobalMemoryAccountant* accountant)
TEST(GlobalMemoryAccountant, checkWhetherMallocAllocatorIsNotChanged)
{
- testFunction.testFunction_ = _failChangeMallocMemoryAllocator;
+ testFunction.testFunction_ = failChangeMallocMemoryAllocator_;
fixture.runAllTests();
fixture.assertPrintContains("GlobalMemoryAccountant: Malloc memory allocator has been changed while accounting for memory");
}
-static void _failChangeNewMemoryAllocator(GlobalMemoryAccountant* accountant)
+static void failChangeNewMemoryAllocator_(GlobalMemoryAccountant* accountant)
{
accountant->start();
setCurrentNewAllocator(defaultNewAllocator());
@@ -745,12 +745,12 @@ static void _failChangeNewMemoryAllocator(GlobalMemoryAccountant* accountant)
TEST(GlobalMemoryAccountant, checkWhetherNewAllocatorIsNotChanged)
{
- testFunction.testFunction_ = _failChangeNewMemoryAllocator;
+ testFunction.testFunction_ = failChangeNewMemoryAllocator_;
fixture.runAllTests();
fixture.assertPrintContains("GlobalMemoryAccountant: New memory allocator has been changed while accounting for memory");
}
-static void _failChangeNewArrayMemoryAllocator(GlobalMemoryAccountant* accountant)
+static void failChangeNewArrayMemoryAllocator_(GlobalMemoryAccountant* accountant)
{
accountant->start();
setCurrentNewArrayAllocator(defaultNewArrayAllocator());
@@ -759,8 +759,7 @@ static void _failChangeNewArrayMemoryAllocator(GlobalMemoryAccountant* accountan
TEST(GlobalMemoryAccountant, checkWhetherNewArrayAllocatorIsNotChanged)
{
- testFunction.testFunction_ = _failChangeNewArrayMemoryAllocator;
+ testFunction.testFunction_ = failChangeNewArrayMemoryAllocator_;
fixture.runAllTests();
fixture.assertPrintContains("GlobalMemoryAccountant: New Array memory allocator has been changed while accounting for memory");
}
-
diff --git a/tests/CppUTest/TestOutputTest.cpp b/tests/CppUTest/TestOutputTest.cpp
index 034dae73e..bde55df4f 100644
--- a/tests/CppUTest/TestOutputTest.cpp
+++ b/tests/CppUTest/TestOutputTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,11 +30,11 @@
#include "CppUTest/TestResult.h"
#include "CppUTest/PlatformSpecificFunctions.h"
-static long millisTime;
+static unsigned long millisTime;
extern "C" {
- static long MockGetPlatformSpecificTimeInMillis()
+ static unsigned long MockGetPlatformSpecificTimeInMillis()
{
return millisTime;
}
@@ -51,7 +51,7 @@ TEST_GROUP(TestOutput)
TestFailure *f3;
TestResult* result;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
mock = new StringBufferTestOutput();
printer = mock;
@@ -66,7 +66,7 @@ TEST_GROUP(TestOutput)
TestOutput::setWorkingEnvironment(TestOutput::eclipse);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
TestOutput::setWorkingEnvironment(TestOutput::detectEnvironment);
delete printer;
@@ -285,32 +285,32 @@ TEST(TestOutput, printTestsEndedWithNoTestsRunOrIgnored)
class CompositeTestOutputTestStringBufferTestOutput : public StringBufferTestOutput
{
public:
- virtual void printTestsStarted()
+ virtual void printTestsStarted() CPPUTEST_OVERRIDE
{
output += "Test Start\n";
}
- virtual void printTestsEnded(const TestResult& result)
+ virtual void printTestsEnded(const TestResult& result) CPPUTEST_OVERRIDE
{
output += StringFromFormat("Test End %d\n", (int) result.getTestCount());
}
- void printCurrentGroupStarted(const UtestShell& test)
+ void printCurrentGroupStarted(const UtestShell& test) CPPUTEST_OVERRIDE
{
output += StringFromFormat("Group %s Start\n", test.getGroup().asCharString());
}
- void printCurrentGroupEnded(const TestResult& res)
+ void printCurrentGroupEnded(const TestResult& res) CPPUTEST_OVERRIDE
{
output += StringFromFormat("Group End %d\n", (int) res.getTestCount());
}
- virtual void printCurrentTestStarted(const UtestShell&)
+ virtual void printCurrentTestStarted(const UtestShell&) CPPUTEST_OVERRIDE
{
output += "s";
}
- void flush()
+ void flush() CPPUTEST_OVERRIDE
{
output += "flush";
}
@@ -339,7 +339,7 @@ TEST_GROUP(CompositeTestOutput)
TestResult* result;
UtestShell* test;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
output1 = new CompositeTestOutputTestStringBufferTestOutput;
output2 = new CompositeTestOutputTestStringBufferTestOutput;
@@ -349,7 +349,7 @@ TEST_GROUP(CompositeTestOutput)
test = new UtestShell("Group", "Name", "file", 10);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete test;
delete result;
@@ -471,3 +471,10 @@ TEST(CompositeTestOutput, deletePreviousInstanceWhenSettingNew)
// CHECK NO MEMORY LEAKS
}
+TEST(CompositeTestOutput, printVeryVerbose)
+{
+ compositeOutput.verbose(TestOutput::level_veryVerbose);
+ compositeOutput.printVeryVerbose("very-verbose");
+ STRCMP_EQUAL("very-verbose", output1->getOutput().asCharString());
+ STRCMP_EQUAL("very-verbose", output2->getOutput().asCharString());
+}
diff --git a/tests/CppUTest/TestRegistryTest.cpp b/tests/CppUTest/TestRegistryTest.cpp
index b727f8c33..45d3eb309 100644
--- a/tests/CppUTest/TestRegistryTest.cpp
+++ b/tests/CppUTest/TestRegistryTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -42,7 +42,7 @@ class MockTest: public UtestShell
UtestShell(group, "Name", "File", testLineNumber), hasRun_(false)
{
}
- virtual void runOneTest(TestPlugin*, TestResult&)
+ virtual void runOneTest(TestPlugin*, TestResult&) CPPUTEST_OVERRIDE
{
hasRun_ = true;
}
@@ -67,7 +67,7 @@ class MockTestResult: public TestResult
resetCount();
}
- virtual ~MockTestResult() _destructor_override
+ virtual ~MockTestResult() CPPUTEST_DESTRUCTOR_OVERRIDE
{
}
@@ -81,27 +81,27 @@ class MockTestResult: public TestResult
countCurrentGroupEnded = 0;
}
- virtual void testsStarted() _override
+ virtual void testsStarted() CPPUTEST_OVERRIDE
{
countTestsStarted++;
}
- virtual void testsEnded() _override
+ virtual void testsEnded() CPPUTEST_OVERRIDE
{
countTestsEnded++;
}
- virtual void currentTestStarted(UtestShell* /*test*/) _override
+ virtual void currentTestStarted(UtestShell* /*test*/) CPPUTEST_OVERRIDE
{
countCurrentTestStarted++;
}
- virtual void currentTestEnded(UtestShell* /*test*/) _override
+ virtual void currentTestEnded(UtestShell* /*test*/) CPPUTEST_OVERRIDE
{
countCurrentTestEnded++;
}
- virtual void currentGroupStarted(UtestShell* /*test*/) _override
+ virtual void currentGroupStarted(UtestShell* /*test*/) CPPUTEST_OVERRIDE
{
countCurrentGroupStarted++;
}
- virtual void currentGroupEnded(UtestShell* /*test*/) _override
+ virtual void currentGroupEnded(UtestShell* /*test*/) CPPUTEST_OVERRIDE
{
countCurrentGroupEnded++;
}
@@ -118,7 +118,7 @@ TEST_GROUP(TestRegistry)
MockTest* test4;
TestResult *result;
MockTestResult *mockResult;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
output = new StringBufferTestOutput();
mockResult = new MockTestResult(*output);
@@ -131,7 +131,7 @@ TEST_GROUP(TestRegistry)
myRegistry->setCurrentRegistry(myRegistry);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
myRegistry->setCurrentRegistry(NULLPTR);
delete myRegistry;
@@ -312,9 +312,9 @@ class MyTestPluginDummy: public TestPlugin
{
public:
MyTestPluginDummy(const SimpleString& name) : TestPlugin(name) {}
- virtual ~MyTestPluginDummy() _destructor_override {}
- virtual void runAllPreTestAction(UtestShell&, TestResult&) _override {}
- virtual void runAllPostTestAction(UtestShell&, TestResult&) _override {}
+ virtual ~MyTestPluginDummy() CPPUTEST_DESTRUCTOR_OVERRIDE {}
+ virtual void runAllPreTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE {}
+ virtual void runAllPostTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE {}
};
TEST(TestRegistry, ResetPluginsWorks)
@@ -361,6 +361,29 @@ TEST(TestRegistry, listTestGroupAndCaseNames_shouldListBackwardsGroupATestaAfter
STRCMP_EQUAL("GROUP_A.test_aa GROUP_B.test_b GROUP_A.test_a", s.asCharString());
}
+TEST(TestRegistry, listTestLocations_shouldListBackwardsGroupATestaAfterGroupAtestaa)
+{
+ test1->setGroupName("GROUP_A");
+ test1->setTestName("test_a");
+ test1->setFileName("cpptest_simple/my_tests/testa.cpp");
+ test1->setLineNumber(100);
+ myRegistry->addTest(test1);
+ test2->setGroupName("GROUP_B");
+ test2->setTestName("test_b");
+ test2->setFileName("cpptest_simple/my tests/testb.cpp");
+ test2->setLineNumber(200);
+ myRegistry->addTest(test2);
+ test3->setGroupName("GROUP_A");
+ test3->setTestName("test_aa");
+ test3->setFileName("cpptest_simple/my_tests/testaa.cpp");
+ test3->setLineNumber(300);
+ myRegistry->addTest(test3);
+
+ myRegistry->listTestLocations(*result);
+ SimpleString s = output->getOutput();
+ STRCMP_EQUAL("GROUP_A.test_aa.cpptest_simple/my_tests/testaa.cpp.300\nGROUP_B.test_b.cpptest_simple/my tests/testb.cpp.200\nGROUP_A.test_a.cpptest_simple/my_tests/testa.cpp.100\n", s.asCharString());
+}
+
TEST(TestRegistry, shuffleEmptyListIsNoOp)
{
CHECK_TRUE(myRegistry->getFirstTest() == NULLPTR);
diff --git a/tests/CppUTest/TestResultTest.cpp b/tests/CppUTest/TestResultTest.cpp
index c60fff12b..a2bd497ba 100644
--- a/tests/CppUTest/TestResultTest.cpp
+++ b/tests/CppUTest/TestResultTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,7 +31,7 @@
extern "C" {
- static long MockGetPlatformSpecificTimeInMillis()
+ static unsigned long MockGetPlatformSpecificTimeInMillis()
{
return 10;
}
@@ -45,14 +45,14 @@ TEST_GROUP(TestResult)
TestResult* res;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
mock = new StringBufferTestOutput();
printer = mock;
res = new TestResult(*printer);
UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete printer;
delete res;
diff --git a/tests/CppUTest/TestUTestMacro.cpp b/tests/CppUTest/TestUTestMacro.cpp
index 8e955dcaf..ecc07a619 100644
--- a/tests/CppUTest/TestUTestMacro.cpp
+++ b/tests/CppUTest/TestUTestMacro.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -48,7 +48,7 @@ TEST_GROUP(UnitTestMacros)
TestTestingFixture fixture;
};
-static void _failingTestMethodWithFAIL()
+static void failingTestMethodWithFAIL_()
{
FAIL("This test fails");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -56,13 +56,13 @@ static void _failingTestMethodWithFAIL()
TEST(UnitTestMacros, FAILMakesTheTestFailPrintsTheRightResultAndStopsExecuting)
{
- fixture.runTestWithMethod(_failingTestMethodWithFAIL);
+ fixture.runTestWithMethod(failingTestMethodWithFAIL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("This test fails");
}
TEST(UnitTestMacros, FAILWillPrintTheFileThatItFailed)
{
- fixture.runTestWithMethod(_failingTestMethodWithFAIL);
+ fixture.runTestWithMethod(failingTestMethodWithFAIL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT(__FILE__);
}
@@ -80,7 +80,7 @@ IGNORE_TEST(UnitTestMacros, FAILworksInAnIgnoredTest)
FAIL("die!"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _UNSIGNED_LONGS_EQUALTestMethod()
+static void UNSIGNED_LONGS_EQUALTestMethod_()
{
UNSIGNED_LONGS_EQUAL(1, 1);
UNSIGNED_LONGS_EQUAL(1, 0);
@@ -88,7 +88,7 @@ static void _UNSIGNED_LONGS_EQUALTestMethod()
TEST(UnitTestMacros, TestUNSIGNED_LONGS_EQUAL)
{
- fixture.runTestWithMethod(_UNSIGNED_LONGS_EQUALTestMethod);
+ fixture.runTestWithMethod(UNSIGNED_LONGS_EQUALTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
}
@@ -104,14 +104,14 @@ IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGS_EQUALWorksInAnIgnoredTest)
UNSIGNED_LONGS_EQUAL(1, 0); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _UNSIGNED_LONGS_EQUAL_TEXTTestMethod()
+static void UNSIGNED_LONGS_EQUAL_TEXTTestMethod_()
{
UNSIGNED_LONGS_EQUAL_TEXT(1, 0, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestUNSIGNED_LONGS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_UNSIGNED_LONGS_EQUAL_TEXTTestMethod);
+ fixture.runTestWithMethod(UNSIGNED_LONGS_EQUAL_TEXTTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -128,9 +128,9 @@ IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGS_EQUAL_TEXTWorksInAnIgnoredTest)
UNSIGNED_LONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
-static void _LONGLONGS_EQUALTestMethod()
+static void LONGLONGS_EQUALTestMethod_()
{
LONGLONGS_EQUAL(1, 1);
LONGLONGS_EQUAL(1, 0);
@@ -138,7 +138,7 @@ static void _LONGLONGS_EQUALTestMethod()
TEST(UnitTestMacros, TestLONGLONGS_EQUAL)
{
- fixture.runTestWithMethod(_LONGLONGS_EQUALTestMethod);
+ fixture.runTestWithMethod(LONGLONGS_EQUALTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
}
@@ -154,14 +154,14 @@ IGNORE_TEST(UnitTestMacros, LONGLONGS_EQUALWorksInAnIgnoredTest)
LONGLONGS_EQUAL(1, 0); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _LONGLONGS_EQUAL_TEXTTestMethod()
+static void LONGLONGS_EQUAL_TEXTTestMethod_()
{
LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestLONGLONGS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_LONGLONGS_EQUAL_TEXTTestMethod);
+ fixture.runTestWithMethod(LONGLONGS_EQUAL_TEXTTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -178,7 +178,7 @@ IGNORE_TEST(UnitTestMacros, LONGLONGS_EQUAL_TEXTWorksInAnIgnoredTest)
LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _UNSIGNED_LONGLONGS_EQUALTestMethod()
+static void UNSIGNED_LONGLONGS_EQUALTestMethod_()
{
UNSIGNED_LONGLONGS_EQUAL(1, 1);
UNSIGNED_LONGLONGS_EQUAL(1, 0);
@@ -186,7 +186,7 @@ static void _UNSIGNED_LONGLONGS_EQUALTestMethod()
TEST(UnitTestMacros, TestUNSIGNED_LONGLONGS_EQUAL)
{
- fixture.runTestWithMethod(_UNSIGNED_LONGLONGS_EQUALTestMethod);
+ fixture.runTestWithMethod(UNSIGNED_LONGLONGS_EQUALTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
}
@@ -202,14 +202,14 @@ IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUALWorksInAnIgnoredTest)
UNSIGNED_LONGLONGS_EQUAL(1, 0); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _UNSIGNED_LONGLONGS_EQUAL_TEXTTestMethod()
+static void UNSIGNED_LONGLONGS_EQUAL_TEXTTestMethod_()
{
UNSIGNED_LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestUNSIGNED_LONGLONGS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_UNSIGNED_LONGLONGS_EQUAL_TEXTTestMethod);
+ fixture.runTestWithMethod(UNSIGNED_LONGLONGS_EQUAL_TEXTTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -226,33 +226,9 @@ IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUAL_TEXTWorksInAnIgnoredTest)
UNSIGNED_LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-#else
-
-static void _LONGLONGS_EQUALFailsWithUnsupportedFeatureTestMethod()
-{
- LONGLONGS_EQUAL(1, 1);
-} // LCOV_EXCL_LINE
-
-static void _UNSIGNED_LONGLONGS_EQUALFailsWithUnsupportedFeatureTestMethod()
-{
- UNSIGNED_LONGLONGS_EQUAL(1, 1);
-} // LCOV_EXCL_LINE
-
-TEST(UnitTestMacros, LONGLONGS_EQUALFailsWithUnsupportedFeature)
-{
- fixture.runTestWithMethod(_LONGLONGS_EQUALFailsWithUnsupportedFeatureTestMethod);
- CHECK_TEST_FAILS_PROPER_WITH_TEXT("\"CPPUTEST_USE_LONG_LONG\" is not supported");
-}
-
-TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUALFailsWithUnsupportedFeature)
-{
- fixture.runTestWithMethod(_UNSIGNED_LONGLONGS_EQUALFailsWithUnsupportedFeatureTestMethod);
- CHECK_TEST_FAILS_PROPER_WITH_TEXT("\"CPPUTEST_USE_LONG_LONG\" is not supported");
-}
-
#endif /* CPPUTEST_USE_LONG_LONG */
-static void _failingTestMethodWithCHECK()
+static void failingTestMethodWithCHECK_()
{
CHECK(false);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -260,7 +236,7 @@ static void _failingTestMethodWithCHECK()
TEST(UnitTestMacros, FailureWithCHECK)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK(false) failed");
}
@@ -275,7 +251,7 @@ IGNORE_TEST(UnitTestMacros, CHECKWorksInAnIgnoredTest)
CHECK(false); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_TEXT()
+static void failingTestMethodWithCHECK_TEXT_()
{
CHECK_TEXT(false, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -283,7 +259,7 @@ static void _failingTestMethodWithCHECK_TEXT()
TEST(UnitTestMacros, FailureWithCHECK_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK(false) failed");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
}
@@ -299,7 +275,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_TEXTWorksInAnIgnoredTest)
CHECK_TEXT(false, "false"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_TRUE()
+static void failingTestMethodWithCHECK_TRUE_()
{
CHECK_TRUE(false);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -307,7 +283,7 @@ static void _failingTestMethodWithCHECK_TRUE()
TEST(UnitTestMacros, FailureWithCHECK_TRUE)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_TRUE);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_TRUE_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_TRUE(false) failed");
}
@@ -322,7 +298,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_TRUEWorksInAnIgnoredTest)
CHECK_TRUE(false); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_TRUE_TEXT()
+static void failingTestMethodWithCHECK_TRUE_TEXT_()
{
CHECK_TRUE_TEXT(false, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -330,7 +306,7 @@ static void _failingTestMethodWithCHECK_TRUE_TEXT()
TEST(UnitTestMacros, FailureWithCHECK_TRUE_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_TRUE_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_TRUE_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_TRUE(false) failed");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
}
@@ -346,7 +322,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_TRUE_TEXTWorksInAnIgnoredTest)
CHECK_TRUE_TEXT(false, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_FALSE()
+static void failingTestMethodWithCHECK_FALSE_()
{
CHECK_FALSE(true);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -354,7 +330,7 @@ static void _failingTestMethodWithCHECK_FALSE()
TEST(UnitTestMacros, FailureWithCHECK_FALSE)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_FALSE);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_FALSE_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_FALSE(true) failed");
}
@@ -369,7 +345,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_FALSEWorksInAnIgnoredTest)
CHECK_FALSE(true); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_FALSE_TEXT()
+static void failingTestMethodWithCHECK_FALSE_TEXT_()
{
CHECK_FALSE_TEXT(true, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -377,7 +353,7 @@ static void _failingTestMethodWithCHECK_FALSE_TEXT()
TEST(UnitTestMacros, FailureWithCHECK_FALSE_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_FALSE_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_FALSE_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_FALSE(true)");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
}
@@ -393,7 +369,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_FALSE_TEXTWorksInAnIgnoredTest)
CHECK_FALSE_TEXT(true, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_EQUAL()
+static void failingTestMethodWithCHECK_EQUAL_()
{
CHECK_EQUAL(1, 2);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -401,12 +377,12 @@ static void _failingTestMethodWithCHECK_EQUAL()
TEST(UnitTestMacros, FailureWithCHECK_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <2>");
}
-static void _failingTestMethodWithCHECK_COMPARE()
+static void failingTestMethodWithCHECK_COMPARE_()
{
double small = 0.5, big = 0.8;
CHECK_COMPARE(small, >=, big);
@@ -415,7 +391,7 @@ static void _failingTestMethodWithCHECK_COMPARE()
TEST(UnitTestMacros, FailureWithCHECK_COMPARE)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_COMPARE);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_COMPARE_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_COMPARE(0.5 >= 0.8)");
}
@@ -430,7 +406,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_COMPAREWorksInAnIgnoredTest)
CHECK_COMPARE(1, >, 2); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_COMPARE_TEXT()
+static void failingTestMethodWithCHECK_COMPARE_TEXT_()
{
double small = 0.5, big = 0.8;
CHECK_COMPARE_TEXT(small, >=, big, "small bigger than big");
@@ -439,7 +415,7 @@ static void _failingTestMethodWithCHECK_COMPARE_TEXT()
TEST(UnitTestMacros, FailureWithCHECK_COMPARE_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_COMPARE_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_COMPARE_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_COMPARE(0.5 >= 0.8)");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("small bigger than big");
}
@@ -456,7 +432,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_COMPARE_TEXTWorksInAnIgnoredTest)
} // LCOV_EXCL_LINE
static int countInCountingMethod;
-static int _countingMethod()
+static int countingMethod_()
{
return countInCountingMethod++;
}
@@ -480,36 +456,36 @@ TEST(UnitTestMacros, UNSIGNED_LONGS_EQUAL_macroExpressionSafety)
TEST(UnitTestMacros, passingCheckEqualWillNotBeEvaluatedMultipleTimesWithCHECK_EQUAL)
{
countInCountingMethod = 0;
- CHECK_EQUAL(0, _countingMethod());
+ CHECK_EQUAL(0, countingMethod_());
LONGS_EQUAL(1, countInCountingMethod);
}
-static void _failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning()
+static void failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning_()
{
- CHECK_EQUAL(12345, _countingMethod());
+ CHECK_EQUAL(12345, countingMethod_());
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning)
{
- fixture.runTestWithMethod(_failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning);
+ fixture.runTestWithMethod(failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("WARNING:\n\tThe \"Actual Parameter\" parameter is evaluated multiple times resulting in different values.\n\tThus the value in the error message is probably incorrect.");
}
-static void _failing_CHECK_EQUAL_WithExpectedBeingEvaluatesMultipleTimesWillGiveAWarning()
+static void failing_CHECK_EQUAL_WithExpectedBeingEvaluatesMultipleTimesWillGiveAWarning_()
{
- CHECK_EQUAL(_countingMethod(), 12345);
+ CHECK_EQUAL(countingMethod_(), 12345);
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, failing_CHECK_EQUAL_WithExpectedBeingEvaluatesMultipleTimesWillGiveAWarning)
{
- fixture.runTestWithMethod(_failing_CHECK_EQUAL_WithExpectedBeingEvaluatesMultipleTimesWillGiveAWarning);
+ fixture.runTestWithMethod(failing_CHECK_EQUAL_WithExpectedBeingEvaluatesMultipleTimesWillGiveAWarning_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("WARNING:\n\tThe \"Expected Parameter\" parameter is evaluated multiple times resulting in different values.\n\tThus the value in the error message is probably incorrect.");
}
TEST(UnitTestMacros, failing_CHECK_EQUAL_withParamatersThatDontChangeWillNotGiveAnyWarning)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_);
fixture.assertPrintContainsNot("WARNING");
}
@@ -524,7 +500,7 @@ IGNORE_TEST(UnitTestMacros, CHECK_EQUALWorksInAnIgnoredTest)
CHECK_EQUAL(1, 2); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithCHECK_EQUAL_TEXT()
+static void failingTestMethodWithCHECK_EQUAL_TEXT_()
{
CHECK_EQUAL_TEXT(1, 2, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -532,7 +508,7 @@ static void _failingTestMethodWithCHECK_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithCHECK_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithCHECK_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <2>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -549,7 +525,82 @@ IGNORE_TEST(UnitTestMacros, CHECK_EQUAL_TEXTWorksInAnIgnoredTest)
CHECK_EQUAL_TEXT(1, 2, "Failed because it failed"); // LCOV_EXCL_LINE;
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithLONGS_EQUAL()
+static void failingTestMethodWithCHECK_EQUAL_ZERO_()
+{
+ CHECK_EQUAL_ZERO(1);
+ TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
+} // LCOV_EXCL_LINE
+
+TEST(UnitTestMacros, FailureWithCHECK_EQUAL_ZERO)
+{
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_ZERO_);
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0>");
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <1>");
+}
+
+TEST(UnitTestMacros, passingCheckEqualWillNotBeEvaluatedMultipleTimesWithCHECK_EQUAL_ZERO)
+{
+ countInCountingMethod = 0;
+ CHECK_EQUAL_ZERO(countingMethod_());
+
+ LONGS_EQUAL(1, countInCountingMethod);
+}
+
+static void failing_CHECK_EQUAL_ZERO_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning_()
+{
+ countInCountingMethod = 1;
+ CHECK_EQUAL_ZERO(countingMethod_());
+} // LCOV_EXCL_LINE
+
+TEST(UnitTestMacros, failing_CHECK_EQUAL_ZERO_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning)
+{
+ fixture.runTestWithMethod(failing_CHECK_EQUAL_ZERO_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning_);
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("WARNING:\n\tThe \"Actual Parameter\" parameter is evaluated multiple times resulting in different values.\n\tThus the value in the error message is probably incorrect.");
+}
+
+TEST(UnitTestMacros, failing_CHECK_EQUAL_ZERO_withParamatersThatDontChangeWillNotGiveAnyWarning)
+{
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_ZERO_);
+ fixture.assertPrintContainsNot("WARNING");
+}
+
+IGNORE_TEST(UnitTestMacros, CHECK_EQUAL_ZERO_WorksInAnIgnoredTest)
+{
+ CHECK_EQUAL_ZERO(1); // LCOV_EXCL_LINE
+} // LCOV_EXCL_LINE
+
+TEST(UnitTestMacros, CHECK_EQUAL_ZERO_BehavesAsProperMacro)
+{
+ if (false) CHECK_EQUAL_ZERO(1);
+ else CHECK_EQUAL_ZERO(0);
+}
+
+static void failingTestMethodWithCHECK_EQUAL_ZERO_TEXT_()
+{
+ CHECK_EQUAL_ZERO_TEXT(1, "Failed because it failed");
+ TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
+} // LCOV_EXCL_LINE
+
+TEST(UnitTestMacros, FailureWithCHECK_EQUAL_ZERO_TEXT)
+{
+ fixture.runTestWithMethod(failingTestMethodWithCHECK_EQUAL_ZERO_TEXT_);
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0>");
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <1>");
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
+}
+
+TEST(UnitTestMacros, CHECK_EQUAL_ZERO_TEXTBehavesAsProperMacro)
+{
+ if (false) CHECK_EQUAL_ZERO_TEXT(1, "Failed because it failed");
+ else CHECK_EQUAL_ZERO_TEXT(0, "Failed because it failed");
+}
+
+IGNORE_TEST(UnitTestMacros, CHECK_EQUAL_ZERO_TEXTWorksInAnIgnoredTest)
+{
+ CHECK_EQUAL_ZERO_TEXT(1, "Failed because it failed"); // LCOV_EXCL_LINE;
+} // LCOV_EXCL_LINE
+
+static void failingTestMethodWithLONGS_EQUAL_()
{
LONGS_EQUAL(1, 0xff);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -557,23 +608,23 @@ static void _failingTestMethodWithLONGS_EQUAL()
TEST(UnitTestMacros, FailureWithLONGS_EQUALS)
{
- fixture.runTestWithMethod(_failingTestMethodWithLONGS_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithLONGS_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected < 1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <255 (0xff)>");
}
-static void _failingTestMethodWithLONGS_EQUALWithSymbolicParameters()
+static void failingTestMethodWithLONGS_EQUALWithSymbolicParameters_()
{
-#define _MONDAY 1
- int day_of_the_week = _MONDAY+1;
- LONGS_EQUAL(_MONDAY, day_of_the_week);
+#define MONDAY 1
+ int day_of_the_week = MONDAY+1;
+ LONGS_EQUAL(MONDAY, day_of_the_week);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, FailureWithLONGS_EQUALShowsSymbolicParameters)
{
- fixture.runTestWithMethod(_failingTestMethodWithLONGS_EQUALWithSymbolicParameters);
- CHECK_TEST_FAILS_PROPER_WITH_TEXT("LONGS_EQUAL(_MONDAY, day_of_the_week) failed");
+ fixture.runTestWithMethod(failingTestMethodWithLONGS_EQUALWithSymbolicParameters_);
+ CHECK_TEST_FAILS_PROPER_WITH_TEXT("LONGS_EQUAL(MONDAY, day_of_the_week) failed");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <2 (0x2)>");
CHECK_FALSE(fixture.getOutput().contains("Message: "));
@@ -590,7 +641,7 @@ IGNORE_TEST(UnitTestMacros, LONGS_EQUALWorksInAnIgnoredTest)
LONGS_EQUAL(11, 22); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithLONGS_EQUAL_TEXT()
+static void failingTestMethodWithLONGS_EQUAL_TEXT_()
{
LONGS_EQUAL_TEXT(1, 0xff, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -598,7 +649,7 @@ static void _failingTestMethodWithLONGS_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithLONGS_EQUALS_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithLONGS_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithLONGS_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected < 1 (0x1)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <255 (0xff)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -615,7 +666,7 @@ IGNORE_TEST(UnitTestMacros, LONGS_EQUAL_TEXTWorksInAnIgnoredTest)
LONGS_EQUAL_TEXT(11, 22, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithBYTES_EQUAL()
+static void failingTestMethodWithBYTES_EQUAL_()
{
BYTES_EQUAL('a', 'b');
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -623,7 +674,7 @@ static void _failingTestMethodWithBYTES_EQUAL()
TEST(UnitTestMacros, FailureWithBYTES_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithBYTES_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithBYTES_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <97 (0x61)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <98 (0x62)>");
}
@@ -639,7 +690,7 @@ IGNORE_TEST(UnitTestMacros, BYTES_EQUALWorksInAnIgnoredTest)
BYTES_EQUAL('q', 'w'); // LCOV_EXCL_LINE;
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithBYTES_EQUAL_TEXT()
+static void failingTestMethodWithBYTES_EQUAL_TEXT_()
{
BYTES_EQUAL_TEXT('a', 'b', "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -647,7 +698,7 @@ static void _failingTestMethodWithBYTES_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithBYTES_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithBYTES_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithBYTES_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <97 (0x61)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <98 (0x62)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -664,7 +715,7 @@ IGNORE_TEST(UnitTestMacros, BYTES_EQUAL_TEXTWorksInAnIgnoredTest)
BYTES_EQUAL_TEXT('q', 'w', "Failed because it failed"); // LCOV_EXCL_LINE;
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSIGNED_BYTES_EQUAL()
+static void failingTestMethodWithSIGNED_BYTES_EQUAL_()
{
SIGNED_BYTES_EQUAL(-1, -2);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -672,11 +723,11 @@ static void _failingTestMethodWithSIGNED_BYTES_EQUAL()
TEST(UnitTestMacros, FailureWithSIGNED_BYTES_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithSIGNED_BYTES_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithSIGNED_BYTES_EQUAL_);
#if CPPUTEST_CHAR_BIT == 16
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <-1 (0xffff)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <-2 (0xfffe)>");
-#else
+#elif CPPUTEST_CHAR_BIT == 8
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <-1 (0xff)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <-2 (0xfe)>");
#endif
@@ -693,7 +744,7 @@ IGNORE_TEST(UnitTestMacros, CHARS_EQUALWorksInAnIgnoredTest)
SIGNED_BYTES_EQUAL(-7, 19); // LCOV_EXCL_LINE;
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT()
+static void failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT_()
{
SIGNED_BYTES_EQUAL_TEXT(-127, -126, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -701,7 +752,7 @@ static void _failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithSIGNED_BYTES_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <-127 (0x81)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <-126 (0x82)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -718,7 +769,7 @@ IGNORE_TEST(UnitTestMacros, SIGNED_BYTES_EQUAL_TEXTWorksInAnIgnoredTest)
SIGNED_BYTES_EQUAL_TEXT(-7, 19, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithPOINTERS_EQUAL()
+static void failingTestMethodWithPOINTERS_EQUAL_()
{
POINTERS_EQUAL((void*)0xa5a5, (void*)0xf0f0);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -726,7 +777,7 @@ static void _failingTestMethodWithPOINTERS_EQUAL()
TEST(UnitTestMacros, FailureWithPOINTERS_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithPOINTERS_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithPOINTERS_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>");
}
@@ -742,7 +793,7 @@ IGNORE_TEST(UnitTestMacros, POINTERS_EQUALWorksInAnIgnoredTest)
POINTERS_EQUAL((void*) 0xbeef, (void*) 0xdead); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithPOINTERS_EQUAL_TEXT()
+static void failingTestMethodWithPOINTERS_EQUAL_TEXT_()
{
POINTERS_EQUAL_TEXT((void*)0xa5a5, (void*)0xf0f0, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -750,7 +801,7 @@ static void _failingTestMethodWithPOINTERS_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithPOINTERS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithPOINTERS_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithPOINTERS_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -768,7 +819,7 @@ IGNORE_TEST(UnitTestMacros, POINTERS_EQUAL_TEXTWorksInAnIgnoredTest)
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithFUNCTIONPOINTERS_EQUAL()
+static void failingTestMethodWithFUNCTIONPOINTERS_EQUAL_()
{
FUNCTIONPOINTERS_EQUAL((void (*)())0xa5a5, (void (*)())0xf0f0);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -776,7 +827,7 @@ static void _failingTestMethodWithFUNCTIONPOINTERS_EQUAL()
TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithFUNCTIONPOINTERS_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithFUNCTIONPOINTERS_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>");
}
@@ -792,7 +843,7 @@ IGNORE_TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUALWorksInAnIgnoredTest)
FUNCTIONPOINTERS_EQUAL((void (*)())0xbeef, (void (*)())0xdead); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT()
+static void failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT_()
{
FUNCTIONPOINTERS_EQUAL_TEXT((void (*)())0xa5a5, (void (*)())0xf0f0, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -800,7 +851,7 @@ static void _failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -820,7 +871,7 @@ IGNORE_TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUAL_TEXTWorksInAnIgnoredTest)
-static void _failingTestMethodWithDOUBLES_EQUAL()
+static void failingTestMethodWithDOUBLES_EQUAL_()
{
DOUBLES_EQUAL(0.12, 44.1, 0.3);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -828,7 +879,7 @@ static void _failingTestMethodWithDOUBLES_EQUAL()
TEST(UnitTestMacros, FailureWithDOUBLES_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithDOUBLES_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithDOUBLES_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0.12>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <44.1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("threshold used was <0.3>");
@@ -845,7 +896,7 @@ IGNORE_TEST(UnitTestMacros, DOUBLES_EQUALWorksInAnIgnoredTest)
DOUBLES_EQUAL(100.0, 0.0, 0.2); // LCOV_EXCL_LINE;
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithDOUBLES_EQUAL_TEXT()
+static void failingTestMethodWithDOUBLES_EQUAL_TEXT_()
{
DOUBLES_EQUAL_TEXT(0.12, 44.1, 0.3, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -853,7 +904,7 @@ static void _failingTestMethodWithDOUBLES_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithDOUBLES_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithDOUBLES_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithDOUBLES_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0.12>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <44.1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("threshold used was <0.3>");
@@ -873,7 +924,7 @@ IGNORE_TEST(UnitTestMacros, DOUBLES_EQUAL_TEXTWorksInAnIgnoredTest)
static bool lineOfCodeExecutedAfterCheck = false;
-static void _passingTestMethod()
+static void passingTestMethod_()
{
CHECK(true);
lineOfCodeExecutedAfterCheck = true;
@@ -881,35 +932,35 @@ static void _passingTestMethod()
TEST(UnitTestMacros, SuccessPrintsNothing)
{
- fixture.runTestWithMethod(_passingTestMethod);
+ fixture.runTestWithMethod(passingTestMethod_);
LONGS_EQUAL(0, fixture.getFailureCount());
fixture.assertPrintContains(".\nOK (1 tests");
CHECK(lineOfCodeExecutedAfterCheck);
}
-static void _methodThatOnlyPrints()
+static void methodThatOnlyPrints_()
{
UT_PRINT("Hello World!");
}
TEST(UnitTestMacros, PrintPrintsWhateverPrintPrints)
{
- fixture.runTestWithMethod(_methodThatOnlyPrints);
+ fixture.runTestWithMethod(methodThatOnlyPrints_);
LONGS_EQUAL(0, fixture.getFailureCount());
fixture.assertPrintContains("Hello World!");
fixture.assertPrintContains(__FILE__);
}
-static void _methodThatOnlyPrintsUsingSimpleStringFromFormat()
+static void methodThatOnlyPrintsUsingSimpleStringFromFormat_()
{
UT_PRINT(StringFromFormat("Hello %s %d", "World!", 2009));
}
TEST(UnitTestMacros, PrintPrintsSimpleStringsForExampleThoseReturnedByFromString)
{
- fixture.runTestWithMethod(_methodThatOnlyPrintsUsingSimpleStringFromFormat);
+ fixture.runTestWithMethod(methodThatOnlyPrintsUsingSimpleStringFromFormat_);
fixture.assertPrintContains("Hello World! 2009");
}
@@ -927,6 +978,8 @@ static int functionThatReturnsAValue()
BYTES_EQUAL_TEXT(0xab, 0xab, "Shouldn't fail");
CHECK_EQUAL(100,100);
CHECK_EQUAL_TEXT(100, 100, "Shouldn't fail");
+ CHECK_EQUAL_ZERO(0);
+ CHECK_EQUAL_ZERO_TEXT(0, "Shouldn't fail");
STRCMP_EQUAL("THIS", "THIS");
STRCMP_EQUAL_TEXT("THIS", "THIS", "Shouldn't fail");
DOUBLES_EQUAL(1.0, 1.0, .01);
@@ -958,7 +1011,7 @@ IGNORE_TEST(UnitTestMacros, MEMCMP_EQUALWorksInAnIgnoredTest)
MEMCMP_EQUAL("TEST", "test", 5); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _MEMCMP_EQUALFailingTestMethodWithUnequalInput()
+static void MEMCMP_EQUALFailingTestMethodWithUnequalInput_()
{
unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 };
unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 };
@@ -969,13 +1022,13 @@ static void _MEMCMP_EQUALFailingTestMethodWithUnequalInput()
TEST(UnitTestMacros, MEMCMP_EQUALFailureWithUnequalInput)
{
- fixture.runTestWithMethod(_MEMCMP_EQUALFailingTestMethodWithUnequalInput);
+ fixture.runTestWithMethod(MEMCMP_EQUALFailingTestMethodWithUnequalInput_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <00 01 02 03>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <00 01 03 03>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 2");
}
-static void _MEMCMP_EQUALFailingTestMethodWithNullExpected()
+static void MEMCMP_EQUALFailingTestMethodWithNullExpected_()
{
unsigned char actualData[] = { 0x00, 0x01, 0x02, 0x03 };
@@ -985,12 +1038,12 @@ static void _MEMCMP_EQUALFailingTestMethodWithNullExpected()
TEST(UnitTestMacros, MEMCMP_EQUALFailureWithNullExpected)
{
- fixture.runTestWithMethod(_MEMCMP_EQUALFailingTestMethodWithNullExpected);
+ fixture.runTestWithMethod(MEMCMP_EQUALFailingTestMethodWithNullExpected_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <00 01 02 03>");
}
-static void _MEMCMP_EQUALFailingTestMethodWithNullActual()
+static void MEMCMP_EQUALFailingTestMethodWithNullActual_()
{
unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 };
@@ -1000,7 +1053,7 @@ static void _MEMCMP_EQUALFailingTestMethodWithNullActual()
TEST(UnitTestMacros, MEMCMP_EQUALFailureWithNullActual)
{
- fixture.runTestWithMethod(_MEMCMP_EQUALFailingTestMethodWithNullActual);
+ fixture.runTestWithMethod(MEMCMP_EQUALFailingTestMethodWithNullActual_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <00 01 02 03>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>");
}
@@ -1023,7 +1076,7 @@ TEST(UnitTestMacros, MEMCMP_EQUALNullPointerIgnoredInActualWhenSize0)
MEMCMP_EQUAL(expectedData, NULLPTR, 0);
}
-static void _failingTestMethodWithMEMCMP_EQUAL_TEXT()
+static void failingTestMethodWithMEMCMP_EQUAL_TEXT_()
{
unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 };
unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 };
@@ -1034,7 +1087,7 @@ static void _failingTestMethodWithMEMCMP_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithMEMCMP_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithMEMCMP_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithMEMCMP_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <00 01 02 03>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <00 01 03 03>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 2");
@@ -1063,7 +1116,7 @@ IGNORE_TEST(UnitTestMacros, BITS_EQUALWorksInAnIgnoredTest)
BITS_EQUAL(0x00, 0xFF, 0xFF); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _BITS_EQUALFailingTestMethodWithUnequalInput()
+static void BITS_EQUALFailingTestMethodWithUnequalInput_()
{
BITS_EQUAL(0x00, 0xFF, 0xFF);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -1071,7 +1124,7 @@ static void _BITS_EQUALFailingTestMethodWithUnequalInput()
TEST(UnitTestMacros, BITS_EQUALFailureWithUnequalInput)
{
- fixture.runTestWithMethod(_BITS_EQUALFailingTestMethodWithUnequalInput);
+ fixture.runTestWithMethod(BITS_EQUALFailingTestMethodWithUnequalInput_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("00000000>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("11111111>");
}
@@ -1081,7 +1134,7 @@ TEST(UnitTestMacros, BITS_EQUALZeroMaskEqual)
BITS_EQUAL(0x00, 0xFF, 0x00);
}
-static void _failingTestMethodWithBITS_EQUAL_TEXT()
+static void failingTestMethodWithBITS_EQUAL_TEXT_()
{
BITS_EQUAL_TEXT(0x00, 0xFFFFFFFF, 0xFF, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -1089,7 +1142,7 @@ static void _failingTestMethodWithBITS_EQUAL_TEXT()
TEST(UnitTestMacros, FailureWithBITS_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithBITS_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithBITS_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -1111,7 +1164,7 @@ enum class ScopedIntEnum {
A, B
};
-static void _ENUMS_EQUAL_INTWithScopedIntEnumTestMethod()
+static void ENUMS_EQUAL_INTWithScopedIntEnumTestMethod_()
{
ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::B);
ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::A);
@@ -1119,7 +1172,7 @@ static void _ENUMS_EQUAL_INTWithScopedIntEnumTestMethod()
TEST(UnitTestMacros, TestENUMS_EQUAL_INTWithScopedIntEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_INTWithScopedIntEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_INTWithScopedIntEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
}
@@ -1135,14 +1188,14 @@ IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_INTWithScopedIntEnumWorksInAnIgnoredTest
ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::A); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _ENUMS_EQUAL_INT_TEXTWithScopedIntEnumTestMethod()
+static void ENUMS_EQUAL_INT_TEXTWithScopedIntEnumTestMethod_()
{
ENUMS_EQUAL_INT_TEXT(ScopedIntEnum::B, ScopedIntEnum::A, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestENUMS_EQUAL_INT_TEXTWithScopedIntEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_INT_TEXTWithScopedIntEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_INT_TEXTWithScopedIntEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -1163,7 +1216,7 @@ enum class ScopedLongEnum : long {
A, B
};
-static void _ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod()
+static void ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod_()
{
ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::B);
ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::A);
@@ -1171,7 +1224,7 @@ static void _ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod()
TEST(UnitTestMacros, TestENUMS_EQUAL_TYPEWithScopedLongEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
}
@@ -1187,14 +1240,14 @@ IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_TYPEWithScopedLongEnumWorksInAnIgnoredTe
ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::A); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _ENUMS_EQUAL_TYPE_TEXTWithScopedLongEnumTestMethod()
+static void ENUMS_EQUAL_TYPE_TEXTWithScopedLongEnumTestMethod_()
{
ENUMS_EQUAL_TYPE_TEXT(long, ScopedLongEnum::B, ScopedLongEnum::A, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestENUMS_EQUAL_TYPE_TEXTWithScopedLongEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_TYPE_TEXTWithScopedLongEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_TYPE_TEXTWithScopedLongEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -1217,7 +1270,7 @@ enum UnscopedEnum {
UNSCOPED_ENUM_A, UNSCOPED_ENUM_B
};
-static void _ENUMS_EQUAL_INTWithUnscopedEnumTestMethod()
+static void ENUMS_EQUAL_INTWithUnscopedEnumTestMethod_()
{
ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_B);
ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A);
@@ -1225,7 +1278,7 @@ static void _ENUMS_EQUAL_INTWithUnscopedEnumTestMethod()
TEST(UnitTestMacros, TestENUMS_EQUAL_INTWithUnscopedEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_INTWithUnscopedEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_INTWithUnscopedEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
}
@@ -1241,14 +1294,14 @@ IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_INTWithUnscopedEnumWorksInAnIgnoredTest)
ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _ENUMS_EQUAL_INT_TEXTWithUnscopedEnumTestMethod()
+static void ENUMS_EQUAL_INT_TEXTWithUnscopedEnumTestMethod_()
{
ENUMS_EQUAL_INT_TEXT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A, "Failed because it failed");
} // LCOV_EXCL_LINE
TEST(UnitTestMacros, TestENUMS_EQUAL_INT_TEXTWithUnscopedEnum)
{
- fixture.runTestWithMethod(_ENUMS_EQUAL_INT_TEXTWithUnscopedEnumTestMethod);
+ fixture.runTestWithMethod(ENUMS_EQUAL_INT_TEXTWithUnscopedEnumTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -1265,8 +1318,8 @@ IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_EQUAL_INT_TEXTWithUnscopedEnumWorksInAnI
ENUMS_EQUAL_INT_TEXT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-#if CPPUTEST_USE_STD_CPP_LIB
-static void _failingTestMethod_NoThrowWithCHECK_THROWS()
+#if CPPUTEST_HAVE_EXCEPTIONS
+static void failingTestMethod_NoThrowWithCHECK_THROWS_()
{
CHECK_THROWS(int, (void) (1+2));
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -1274,13 +1327,13 @@ static void _failingTestMethod_NoThrowWithCHECK_THROWS()
TEST(UnitTestMacros, FailureWithCHECK_THROWS_whenDoesntThrow)
{
- fixture.runTestWithMethod(_failingTestMethod_NoThrowWithCHECK_THROWS);
+ fixture.runTestWithMethod(failingTestMethod_NoThrowWithCHECK_THROWS_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected to throw int");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but threw nothing");
LONGS_EQUAL(1, fixture.getCheckCount());
}
-static void _succeedingTestMethod_CorrectThrowWithCHECK_THROWS()
+static void succeedingTestMethod_CorrectThrowWithCHECK_THROWS_()
{
CHECK_THROWS(int, throw 4);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -1288,11 +1341,11 @@ static void _succeedingTestMethod_CorrectThrowWithCHECK_THROWS()
TEST(UnitTestMacros, SuccessWithCHECK_THROWS)
{
- fixture.runTestWithMethod(_succeedingTestMethod_CorrectThrowWithCHECK_THROWS);
+ fixture.runTestWithMethod(succeedingTestMethod_CorrectThrowWithCHECK_THROWS_);
LONGS_EQUAL(1, fixture.getCheckCount());
}
-static void _failingTestMethod_WrongThrowWithCHECK_THROWS()
+static void failingTestMethod_WrongThrowWithCHECK_THROWS_()
{
CHECK_THROWS(int, throw 4.3);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -1300,7 +1353,7 @@ static void _failingTestMethod_WrongThrowWithCHECK_THROWS()
TEST(UnitTestMacros, FailureWithCHECK_THROWS_whenWrongThrow)
{
- fixture.runTestWithMethod(_failingTestMethod_WrongThrowWithCHECK_THROWS);
+ fixture.runTestWithMethod(failingTestMethod_WrongThrowWithCHECK_THROWS_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected to throw int");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but threw a different type");
LONGS_EQUAL(1, fixture.getCheckCount());
diff --git a/tests/CppUTest/TestUTestStringMacro.cpp b/tests/CppUTest/TestUTestStringMacro.cpp
index 5d558bb08..e51f18c67 100644
--- a/tests/CppUTest/TestUTestStringMacro.cpp
+++ b/tests/CppUTest/TestUTestStringMacro.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -36,128 +36,128 @@ TEST_GROUP(UnitTestStringMacros)
TestTestingFixture fixture;
};
-static void _STRCMP_EQUALWithActualIsNULLTestMethod()
+static void STRCMP_EQUALWithActualIsNULLTestMethod_()
{
STRCMP_EQUAL("ok", NULLPTR);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUALAndActualIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_EQUALWithActualIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_EQUALWithActualIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>");
}
-static void _STRCMP_EQUALWithExpectedIsNULLTestMethod()
+static void STRCMP_EQUALWithExpectedIsNULLTestMethod_()
{
STRCMP_EQUAL(NULLPTR, "ok");
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUALAndExpectedIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_EQUALWithExpectedIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_EQUALWithExpectedIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>");
}
-static void _STRCMP_CONTAINSWithActualIsNULLTestMethod()
+static void STRCMP_CONTAINSWithActualIsNULLTestMethod_()
{
STRCMP_CONTAINS("ok", NULLPTR);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINSAndActualIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_CONTAINSWithActualIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_CONTAINSWithActualIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
}
-static void _STRCMP_CONTAINSWithExpectedIsNULLTestMethod()
+static void STRCMP_CONTAINSWithExpectedIsNULLTestMethod_()
{
STRCMP_CONTAINS(NULLPTR, "ok");
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINSAndExpectedIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_CONTAINSWithExpectedIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_CONTAINSWithExpectedIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain <>");
}
-static void _STRNCMP_EQUALWithActualIsNULLTestMethod()
+static void STRNCMP_EQUALWithActualIsNULLTestMethod_()
{
STRNCMP_EQUAL("ok", NULLPTR, 2);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUALAndActualIsNULL)
{
- fixture.runTestWithMethod(_STRNCMP_EQUALWithActualIsNULLTestMethod);
+ fixture.runTestWithMethod(STRNCMP_EQUALWithActualIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>");
}
-static void _STRNCMP_EQUALWithExpectedIsNULLTestMethod()
+static void STRNCMP_EQUALWithExpectedIsNULLTestMethod_()
{
STRNCMP_EQUAL(NULLPTR, "ok", 2);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUALAndExpectedIsNULL)
{
- fixture.runTestWithMethod(_STRNCMP_EQUALWithExpectedIsNULLTestMethod);
+ fixture.runTestWithMethod(STRNCMP_EQUALWithExpectedIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>");
}
-static void _STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod()
+static void STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod_()
{
STRCMP_NOCASE_EQUAL("ok", NULLPTR);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndActualIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>");
}
-static void _STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod()
+static void STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod_()
{
STRCMP_NOCASE_EQUAL(NULLPTR, "ok");
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndExpectedIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>");
}
-static void _STRCMP_NOCASE_EQUALWithUnequalInputTestMethod()
+static void STRCMP_NOCASE_EQUALWithUnequalInputTestMethod_()
{
STRCMP_NOCASE_EQUAL("no", "ok");
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndUnequalInput)
{
- fixture.runTestWithMethod(_STRCMP_NOCASE_EQUALWithUnequalInputTestMethod);
+ fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithUnequalInputTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
}
-static void _STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod()
+static void STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod_()
{
STRCMP_NOCASE_CONTAINS("ok", NULLPTR);
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINSAndActualIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
}
-static void _STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod()
+static void STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod_()
{
STRCMP_NOCASE_CONTAINS(NULLPTR, "ok");
} // LCOV_EXCL_LINE
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINSAndExpectedIsNULL)
{
- fixture.runTestWithMethod(_STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod);
+ fixture.runTestWithMethod(STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain <>");
}
-static void _failingTestMethodWithSTRCMP_EQUAL()
+static void failingTestMethodWithSTRCMP_EQUAL_()
{
STRCMP_EQUAL("hello", "hell");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -165,7 +165,7 @@ static void _failingTestMethodWithSTRCMP_EQUAL()
TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
}
@@ -181,7 +181,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_EQUALWorksInAnIgnoredTest)
STRCMP_EQUAL("Hello", "World"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_EQUAL_TEXT()
+static void failingTestMethodWithSTRCMP_EQUAL_TEXT_()
{
STRCMP_EQUAL_TEXT("hello", "hell", "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -189,7 +189,7 @@ static void _failingTestMethodWithSTRCMP_EQUAL_TEXT()
TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -206,7 +206,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_EQUAL_TEXTWorksInAnIgnoredTest)
STRCMP_EQUAL_TEXT("Hello", "World", "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRNCMP_EQUAL()
+static void failingTestMethodWithSTRNCMP_EQUAL_()
{
STRNCMP_EQUAL("hello", "hallo", 5);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -214,7 +214,7 @@ static void _failingTestMethodWithSTRNCMP_EQUAL()
TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRNCMP_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithSTRNCMP_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
}
@@ -230,7 +230,7 @@ IGNORE_TEST(UnitTestStringMacros, STRNCMP_EQUALWorksInAnIgnoredTest)
STRNCMP_EQUAL("Hello", "World", 3); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRNCMP_EQUAL_TEXT()
+static void failingTestMethodWithSTRNCMP_EQUAL_TEXT_()
{
STRNCMP_EQUAL_TEXT("hello", "hallo", 5, "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -238,7 +238,7 @@ static void _failingTestMethodWithSTRNCMP_EQUAL_TEXT()
TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRNCMP_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSTRNCMP_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -255,7 +255,7 @@ IGNORE_TEST(UnitTestStringMacros, STRNCMP_EQUAL_TEXTWorksInAnIgnoredTest)
STRNCMP_EQUAL_TEXT("Hello", "World", 3, "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_NOCASE_EQUAL()
+static void failingTestMethodWithSTRCMP_NOCASE_EQUAL_()
{
STRCMP_NOCASE_EQUAL("hello", "Hell");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -263,7 +263,7 @@ static void _failingTestMethodWithSTRCMP_NOCASE_EQUAL()
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUAL)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_NOCASE_EQUAL);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_EQUAL_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
}
@@ -279,7 +279,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_NOCASE_EQUALWorksInAnIgnoredTest)
STRCMP_NOCASE_EQUAL("Hello", "World"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT()
+static void failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT_()
{
STRCMP_NOCASE_EQUAL_TEXT("hello", "hell", "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -287,7 +287,7 @@ static void _failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT()
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUAL_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -304,7 +304,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_NOCASE_EQUAL_TEXTWorksInAnIgnoredTest)
STRCMP_NOCASE_EQUAL_TEXT("Hello", "World", "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_CONTAINS()
+static void failingTestMethodWithSTRCMP_CONTAINS_()
{
STRCMP_CONTAINS("hello", "world");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -312,7 +312,7 @@ static void _failingTestMethodWithSTRCMP_CONTAINS()
TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINS)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_CONTAINS);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_CONTAINS_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
}
@@ -328,7 +328,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_CONTAINSWorksInAnIgnoredTest)
STRCMP_CONTAINS("Hello", "World"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_CONTAINS_TEXT()
+static void failingTestMethodWithSTRCMP_CONTAINS_TEXT_()
{
STRCMP_CONTAINS_TEXT("hello", "world", "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -336,7 +336,7 @@ static void _failingTestMethodWithSTRCMP_CONTAINS_TEXT()
TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINS_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_CONTAINS_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_CONTAINS_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -353,7 +353,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_CONTAINS_TEXTWorksInAnIgnoredTest)
STRCMP_CONTAINS_TEXT("Hello", "World", "Failed because it failed"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_NOCASE_CONTAINS()
+static void failingTestMethodWithSTRCMP_NOCASE_CONTAINS_()
{
STRCMP_NOCASE_CONTAINS("hello", "WORLD");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -361,7 +361,7 @@ static void _failingTestMethodWithSTRCMP_NOCASE_CONTAINS()
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINS)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_NOCASE_CONTAINS);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_CONTAINS_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
}
@@ -377,7 +377,7 @@ IGNORE_TEST(UnitTestStringMacros, STRCMP_NO_CASE_CONTAINSWorksInAnIgnoredTest)
STRCMP_NOCASE_CONTAINS("Hello", "World"); // LCOV_EXCL_LINE
} // LCOV_EXCL_LINE
-static void _failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT()
+static void failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT_()
{
STRCMP_NOCASE_CONTAINS_TEXT("hello", "WORLD", "Failed because it failed");
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -385,7 +385,7 @@ static void _failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT()
TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINS_TEXT)
{
- fixture.runTestWithMethod(_failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT);
+ fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed");
@@ -410,7 +410,7 @@ TEST(UnitTestStringMacros, NFirstCharsComparison)
STRNCMP_EQUAL("Hello World!", "Hello", 5);
}
-static void _compareNFirstCharsWithUpperAndLowercase()
+static void compareNFirstCharsWithUpperAndLowercase_()
{
STRNCMP_EQUAL("hello world!", "HELLO WORLD!", 12);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -418,13 +418,13 @@ static void _compareNFirstCharsWithUpperAndLowercase()
TEST(UnitTestStringMacros, CompareNFirstCharsWithUpperAndLowercase)
{
- fixture.runTestWithMethod(_compareNFirstCharsWithUpperAndLowercase);
+ fixture.runTestWithMethod(compareNFirstCharsWithUpperAndLowercase_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 0");
}
-static void _compareNFirstCharsWithDifferenceInTheMiddle()
+static void compareNFirstCharsWithDifferenceInTheMiddle_()
{
STRNCMP_EQUAL("Hello World!", "Hello Peter!", 12);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -432,13 +432,13 @@ static void _compareNFirstCharsWithDifferenceInTheMiddle()
TEST(UnitTestStringMacros, CompareNFirstCharsWithDifferenceInTheMiddle)
{
- fixture.runTestWithMethod(_compareNFirstCharsWithDifferenceInTheMiddle);
+ fixture.runTestWithMethod(compareNFirstCharsWithDifferenceInTheMiddle_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 6");
}
-static void _compareNFirstCharsWithEmptyString()
+static void compareNFirstCharsWithEmptyString_()
{
STRNCMP_EQUAL("", "Not empty string", 5);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -446,13 +446,13 @@ static void _compareNFirstCharsWithEmptyString()
TEST(UnitTestStringMacros, CompareNFirstCharsWithEmptyString)
{
- fixture.runTestWithMethod(_compareNFirstCharsWithEmptyString);
+ fixture.runTestWithMethod(compareNFirstCharsWithEmptyString_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <>");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 0");
}
-static void _compareNFirstCharsWithLastCharDifferent()
+static void compareNFirstCharsWithLastCharDifferent_()
{
STRNCMP_EQUAL("Not empty string?", "Not empty string!", 17);
TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE
@@ -460,9 +460,8 @@ static void _compareNFirstCharsWithLastCharDifferent()
TEST(UnitTestStringMacros, CompareNFirstCharsWithLastCharDifferent)
{
- fixture.runTestWithMethod(_compareNFirstCharsWithLastCharDifferent);
+ fixture.runTestWithMethod(compareNFirstCharsWithLastCharDifferent_);
CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was ");
CHECK_TEST_FAILS_PROPER_WITH_TEXT("difference starts at position 16");
}
-
diff --git a/tests/CppUTest/UtestPlatformTest.cpp b/tests/CppUTest/UtestPlatformTest.cpp
index bba56e9e7..4faf52695 100644
--- a/tests/CppUTest/UtestPlatformTest.cpp
+++ b/tests/CppUTest/UtestPlatformTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,7 +44,8 @@ TEST_GROUP(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess)
TestTestingFixture fixture;
};
-#ifndef CPPUTEST_HAVE_FORK
+// There is a possibility that a compiler provides fork but not waitpid.
+#if !defined(CPPUTEST_HAVE_FORK) || !defined(CPPUTEST_HAVE_WAITPID) || !defined(CPPUTEST_HAVE_KILL)
TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, DummyFailsWithMessage)
{
@@ -55,13 +56,13 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, DummyFailsWit
#else
-static void _failFunction()
+static void failFunction_()
{
FAIL("This test fails");
}
-static void _exitNonZeroFunction() _no_return_;
-static void _exitNonZeroFunction()
+CPPUTEST_NORETURN static void exitNonZeroFunction_();
+static void exitNonZeroFunction_()
{
/* destructor of static objects will be called. If StringCache was there then the allocator will report invalid deallocations of static SimpleString */
SimpleString::setStringAllocator(SimpleString::getStringAllocator()->actualAllocator());
@@ -100,7 +101,7 @@ extern "C" {
#include
#include
-static void _stoppedTestFunction()
+static void stoppedTestFunction_()
{
kill(getpid(), SIGSTOP);
}
@@ -115,7 +116,7 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, TestInSeparat
TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, FailureInSeparateProcessWorks)
{
fixture.setRunTestsInSeperateProcess();
- fixture.setTestFunction(_failFunction);
+ fixture.setTestFunction(failFunction_);
fixture.runAllTests();
fixture.assertPrintContains("Failed in separate process");
fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out");
@@ -123,15 +124,15 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, FailureInSepa
#if (! CPPUTEST_SANITIZE_ADDRESS)
-static int _accessViolationTestFunction()
+static int accessViolationTestFunction_()
{
- return *(volatile int*) NULLPTR;
+ return *(volatile int*) NULLPTR; // NOLINT(clang-analyzer-core.NullDereference)
}
TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, AccessViolationInSeparateProcessWorks)
{
fixture.setRunTestsInSeperateProcess();
- fixture.setTestFunction((void(*)())_accessViolationTestFunction);
+ fixture.setTestFunction((void(*)())accessViolationTestFunction_);
fixture.runAllTests();
fixture.assertPrintContains("Failed in separate process - killed by signal 11");
fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran");
@@ -142,7 +143,7 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, AccessViolati
TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, StoppedInSeparateProcessWorks)
{
fixture.setRunTestsInSeperateProcess();
- fixture.setTestFunction(_stoppedTestFunction);
+ fixture.setTestFunction(stoppedTestFunction_);
fixture.runAllTests();
fixture.assertPrintContains("Stopped in separate process - continuing");
fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran");
@@ -197,9 +198,9 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, MultipleTests
{
fixture.setRunTestsInSeperateProcess();
fixture.runTestWithMethod(NULLPTR);
- fixture.runTestWithMethod(_stoppedTestFunction);
+ fixture.runTestWithMethod(stoppedTestFunction_);
fixture.runTestWithMethod(NULLPTR);
- fixture.runTestWithMethod(_exitNonZeroFunction);
+ fixture.runTestWithMethod(exitNonZeroFunction_);
fixture.runTestWithMethod(NULLPTR);
fixture.assertPrintContains("Failed in separate process");
fixture.assertPrintContains("Stopped in separate process");
@@ -208,4 +209,3 @@ TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, MultipleTests
#endif
#endif
-
diff --git a/tests/CppUTest/UtestTest.cpp b/tests/CppUTest/UtestTest.cpp
index cf6ad1c16..b1e2fb421 100644
--- a/tests/CppUTest/UtestTest.cpp
+++ b/tests/CppUTest/UtestTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,62 +30,74 @@
#include "CppUTest/TestTestingFixture.h"
#include "CppUTest/PlatformSpecificFunctions.h"
+#if CPPUTEST_USE_STD_C_LIB
+#include
+#endif
+
TEST_GROUP(UtestShell)
{
TestTestingFixture fixture;
};
-static void _failMethod()
+static void failMethod_()
{
FAIL("This test fails");
}
-static void _passingTestMethod()
+static void passingTestMethod_()
{
CHECK(true);
}
-static void _passingCheckEqualTestMethod()
+static void passingCheckEqualTestMethod_()
{
CHECK_EQUAL(1, 1);
}
-static void _exitTestMethod()
+static void exitTestMethod_()
{
TEST_EXIT;
FAIL("Should not get here");
}
-static volatile double zero = 0.0;
-
TEST(UtestShell, compareDoubles)
{
- double not_a_number = zero / zero;
- double infinity = 1 / zero;
CHECK(doubles_equal(1.0, 1.001, 0.01));
- CHECK(!doubles_equal(not_a_number, 1.001, 0.01));
- CHECK(!doubles_equal(1.0, not_a_number, 0.01));
- CHECK(!doubles_equal(1.0, 1.001, not_a_number));
CHECK(!doubles_equal(1.0, 1.1, 0.05));
- CHECK(!doubles_equal(infinity, 1.0, 0.01));
- CHECK(!doubles_equal(1.0, infinity, 0.01));
- CHECK(doubles_equal(1.0, -1.0, infinity));
- CHECK(doubles_equal(infinity, infinity, 0.01));
- CHECK(doubles_equal(infinity, infinity, infinity));
double a = 1.2345678;
CHECK(doubles_equal(a, a, 0.000000001));
}
+#ifdef NAN
+TEST(UtestShell, compareDoublesNaN)
+{
+ CHECK(!doubles_equal((double)NAN, 1.001, 0.01));
+ CHECK(!doubles_equal(1.0, (double)NAN, 0.01));
+ CHECK(!doubles_equal(1.0, 1.001, (double)NAN));
+}
+#endif
+
+#ifdef INFINITY
+TEST(UtestShell, compareDoublesInf)
+{
+ CHECK(!doubles_equal((double)INFINITY, 1.0, 0.01));
+ CHECK(!doubles_equal(1.0, (double)INFINITY, 0.01));
+ CHECK(doubles_equal(1.0, -1.0, (double)INFINITY));
+ CHECK(doubles_equal((double)INFINITY, (double)INFINITY, 0.01));
+ CHECK(doubles_equal((double)INFINITY, (double)INFINITY, (double)INFINITY));
+}
+#endif
+
TEST(UtestShell, FailWillIncreaseTheAmountOfChecks)
{
- fixture.setTestFunction(_failMethod);
+ fixture.setTestFunction(failMethod_);
fixture.runAllTests();
LONGS_EQUAL(1, fixture.getCheckCount());
}
TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks)
{
- fixture.setTestFunction(_passingCheckEqualTestMethod);
+ fixture.setTestFunction(passingCheckEqualTestMethod_);
fixture.runAllTests();
LONGS_EQUAL(1, fixture.getCheckCount());
}
@@ -98,8 +110,8 @@ IGNORE_TEST(UtestShell, IgnoreTestAccessingFixture)
TEST(UtestShell, MacrosUsedInSetup)
{
IGNORE_ALL_LEAKS_IN_TEST();
- fixture.setSetup(_failMethod);
- fixture.setTestFunction(_passingTestMethod);
+ fixture.setSetup(failMethod_);
+ fixture.setTestFunction(passingTestMethod_);
fixture.runAllTests();
LONGS_EQUAL(1, fixture.getFailureCount());
}
@@ -107,24 +119,60 @@ TEST(UtestShell, MacrosUsedInSetup)
TEST(UtestShell, MacrosUsedInTearDown)
{
IGNORE_ALL_LEAKS_IN_TEST();
- fixture.setTeardown(_failMethod);
- fixture.setTestFunction(_passingTestMethod);
+ fixture.setTeardown(failMethod_);
+ fixture.setTestFunction(passingTestMethod_);
fixture.runAllTests();
LONGS_EQUAL(1, fixture.getFailureCount());
}
TEST(UtestShell, ExitLeavesQuietly)
{
- fixture.setTestFunction(_exitTestMethod);
+ fixture.setTestFunction(exitTestMethod_);
fixture.runAllTests();
LONGS_EQUAL(0, fixture.getFailureCount());
}
+static bool cpputestHasCrashed;
+
+static void crashMethod()
+{
+ cpputestHasCrashed = true;
+}
+
+TEST(UtestShell, FailWillNotCrashIfNotEnabled)
+{
+ cpputestHasCrashed = false;
+ UtestShell::setCrashMethod(crashMethod);
+
+ fixture.setTestFunction(failMethod_);
+ fixture.runAllTests();
+
+ CHECK_FALSE(cpputestHasCrashed);
+ LONGS_EQUAL(1, fixture.getFailureCount());
+
+ UtestShell::resetCrashMethod();
+}
+
+TEST(UtestShell, FailWillCrashIfEnabled)
+{
+ cpputestHasCrashed = false;
+ UtestShell::setCrashOnFail();
+ UtestShell::setCrashMethod(crashMethod);
+
+ fixture.setTestFunction(failMethod_);
+ fixture.runAllTests();
+
+ CHECK(cpputestHasCrashed);
+
+ UtestShell::restoreDefaultTestTerminator();
+ UtestShell::resetCrashMethod();
+}
+
static int teardownCalled = 0;
-static void _teardownMethod()
+static void teardownMethod_()
{
teardownCalled++;
}
@@ -133,15 +181,15 @@ TEST(UtestShell, TeardownCalledAfterTestFailure)
{
teardownCalled = 0;
IGNORE_ALL_LEAKS_IN_TEST();
- fixture.setTeardown(_teardownMethod);
- fixture.setTestFunction(_failMethod);
+ fixture.setTeardown(teardownMethod_);
+ fixture.setTestFunction(failMethod_);
fixture.runAllTests();
LONGS_EQUAL(1, fixture.getFailureCount());
LONGS_EQUAL(1, teardownCalled);
}
static int stopAfterFailure = 0;
-static void _stopAfterFailureMethod()
+static void stopAfterFailureMethod_()
{
FAIL("fail");
stopAfterFailure++;
@@ -151,7 +199,7 @@ TEST(UtestShell, TestStopsAfterTestFailure)
{
IGNORE_ALL_LEAKS_IN_TEST();
stopAfterFailure = 0;
- fixture.setTestFunction(_stopAfterFailureMethod);
+ fixture.setTestFunction(stopAfterFailureMethod_);
fixture.runAllTests();
CHECK(fixture.hasTestFailed());
LONGS_EQUAL(1, fixture.getFailureCount());
@@ -161,14 +209,146 @@ TEST(UtestShell, TestStopsAfterTestFailure)
TEST(UtestShell, TestStopsAfterSetupFailure)
{
stopAfterFailure = 0;
- fixture.setSetup(_stopAfterFailureMethod);
- fixture.setTeardown(_stopAfterFailureMethod);
- fixture.setTestFunction(_failMethod);
+ fixture.setSetup(stopAfterFailureMethod_);
+ fixture.setTeardown(stopAfterFailureMethod_);
+ fixture.setTestFunction(failMethod_);
fixture.runAllTests();
LONGS_EQUAL(2, fixture.getFailureCount());
LONGS_EQUAL(0, stopAfterFailure);
}
+#if CPPUTEST_HAVE_EXCEPTIONS
+
+// Prevents -Wunreachable-code; should always be 'true'
+static bool shouldThrowException = true;
+
+static void thrownUnknownExceptionMethod_()
+{
+ if (shouldThrowException)
+ {
+ throw 33;
+ }
+ stopAfterFailure++;
+}
+
+TEST(UtestShell, TestStopsAfterUnknownExceptionIsThrown)
+{
+ bool initialRethrowExceptions = UtestShell::isRethrowingExceptions();
+ UtestShell::setRethrowExceptions(false);
+ stopAfterFailure = 0;
+ shouldThrowException = true;
+ fixture.setTestFunction(thrownUnknownExceptionMethod_);
+ fixture.runAllTests();
+ LONGS_EQUAL(1, fixture.getFailureCount());
+ fixture.assertPrintContains("Unexpected exception of unknown type was thrown");
+ LONGS_EQUAL(0, stopAfterFailure);
+ UtestShell::setRethrowExceptions(initialRethrowExceptions);
+}
+
+TEST(UtestShell, NoExceptionIsRethrownIfEnabledButNotThrown)
+{
+ bool initialRethrowExceptions = UtestShell::isRethrowingExceptions();
+ bool exceptionRethrown = false;
+ stopAfterFailure = 0;
+ UtestShell::setRethrowExceptions(true);
+ shouldThrowException = false;
+ fixture.setTestFunction(thrownUnknownExceptionMethod_);
+ try
+ {
+ fixture.runAllTests();
+ }
+ catch(...)
+ {
+ exceptionRethrown = true;
+ }
+ CHECK_FALSE(exceptionRethrown);
+ LONGS_EQUAL(0, fixture.getFailureCount());
+ LONGS_EQUAL(1, stopAfterFailure);
+ UtestShell::setRethrowExceptions(initialRethrowExceptions);
+}
+
+TEST(UtestShell, UnknownExceptionIsRethrownIfEnabled)
+{
+ bool initialRethrowExceptions = UtestShell::isRethrowingExceptions();
+ bool exceptionRethrown = false;
+ stopAfterFailure = 0;
+ UtestShell::setRethrowExceptions(true);
+ shouldThrowException = true;
+ fixture.setTestFunction(thrownUnknownExceptionMethod_);
+ try
+ {
+ fixture.runAllTests();
+ stopAfterFailure++;
+ }
+ catch(...)
+ {
+ exceptionRethrown = true;
+ }
+ CHECK_TRUE(exceptionRethrown);
+ LONGS_EQUAL(1, fixture.getFailureCount());
+ fixture.assertPrintContains("Unexpected exception of unknown type was thrown");
+ LONGS_EQUAL(0, stopAfterFailure);
+ UtestShell::setRethrowExceptions(initialRethrowExceptions);
+}
+
+#if CPPUTEST_USE_STD_CPP_LIB
+static void thrownStandardExceptionMethod_()
+{
+ if (shouldThrowException)
+ {
+ throw std::runtime_error("exception text");
+ }
+ stopAfterFailure++;
+}
+
+TEST(UtestShell, TestStopsAfterStandardExceptionIsThrown)
+{
+ bool initialRethrowExceptions = UtestShell::isRethrowingExceptions();
+ UtestShell::setRethrowExceptions(false);
+ stopAfterFailure = 0;
+ shouldThrowException = true;
+ fixture.setTestFunction(thrownStandardExceptionMethod_);
+ fixture.runAllTests();
+ LONGS_EQUAL(1, fixture.getFailureCount());
+#if CPPUTEST_HAVE_RTTI
+ fixture.assertPrintContains("Unexpected exception of type '");
+ fixture.assertPrintContains("runtime_error");
+ fixture.assertPrintContains("' was thrown: exception text");
+#else
+ fixture.assertPrintContains("Unexpected exception of unknown type was thrown");
+#endif
+ LONGS_EQUAL(0, stopAfterFailure);
+ UtestShell::setRethrowExceptions(initialRethrowExceptions);
+}
+
+TEST(UtestShell, StandardExceptionIsRethrownIfEnabled)
+{
+ bool initialRethrowExceptions = UtestShell::isRethrowingExceptions();
+ bool exceptionRethrown = false;
+ stopAfterFailure = 0;
+ UtestShell::setRethrowExceptions(true);
+ shouldThrowException = true;
+ fixture.setTestFunction(thrownStandardExceptionMethod_);
+ try
+ {
+ fixture.runAllTests();
+ stopAfterFailure++;
+ }
+ catch(const std::exception &)
+ {
+ exceptionRethrown = true;
+ }
+ CHECK_TRUE(exceptionRethrown);
+ LONGS_EQUAL(1, fixture.getFailureCount());
+ fixture.assertPrintContains("Unexpected exception of type '");
+ fixture.assertPrintContains("runtime_error");
+ fixture.assertPrintContains("' was thrown: exception text");
+ LONGS_EQUAL(0, stopAfterFailure);
+ UtestShell::setRethrowExceptions(initialRethrowExceptions);
+}
+#endif // CPPUTEST_USE_STD_CPP_LIB
+#endif // CPPUTEST_HAVE_EXCEPTIONS
+
TEST(UtestShell, veryVebose)
{
UtestShell shell("Group", "name", __FILE__, __LINE__);
@@ -207,34 +387,28 @@ TEST(UtestShell, RunInSeparateProcessTest)
fixture.assertPrintContains("Failed in separate process");
}
-#ifndef CPPUTEST_HAVE_FORK
+// There is a possibility that a compiler provides fork but not waitpid.
+#if !defined(CPPUTEST_HAVE_FORK) || !defined(CPPUTEST_HAVE_WAITPID) || !defined(CPPUTEST_HAVE_KILL)
IGNORE_TEST(UtestShell, TestDefaultCrashMethodInSeparateProcessTest) {}
#else
-#if !CPPUTEST_SANITIZE_ADDRESS
-
TEST(UtestShell, TestDefaultCrashMethodInSeparateProcessTest)
{
fixture.setTestFunction(UtestShell::crash);
fixture.setRunTestsInSeperateProcess();
fixture.runAllTests();
fixture.assertPrintContains("Failed in separate process - killed by signal");
-
- /* Signal 11 usually happens, but with clang3.7 on Linux, it produced signal 4 */
- CHECK(fixture.getOutput().contains("signal 11") || fixture.getOutput().contains("signal 4"));
}
#endif
-#endif
-
-#if CPPUTEST_USE_STD_CPP_LIB
+#if CPPUTEST_HAVE_EXCEPTIONS
static bool destructorWasCalledOnFailedTest = false;
-static void _destructorCalledForLocalObjects()
+static void destructorCalledForLocalObjects_()
{
SetBooleanOnDestructorCall pleaseCallTheDestructor(destructorWasCalledOnFailedTest);
destructorWasCalledOnFailedTest = false;
@@ -243,7 +417,7 @@ static void _destructorCalledForLocalObjects()
TEST(UtestShell, DestructorIsCalledForLocalObjectsWhenTheTestFails)
{
- fixture.setTestFunction(_destructorCalledForLocalObjects);
+ fixture.setTestFunction(destructorCalledForLocalObjects_);
fixture.runAllTests();
CHECK(destructorWasCalledOnFailedTest);
}
@@ -256,7 +430,7 @@ TEST_GROUP(IgnoredUtestShell)
IgnoredUtestShell ignoredTest;
ExecFunctionTestShell normalUtestShell;
- void setup() _override
+ void setup() CPPUTEST_OVERRIDE
{
fixture.addTest(&ignoredTest);
fixture.addTest(&normalUtestShell);
@@ -335,12 +509,12 @@ TEST_BASE(MyOwnTest)
}
bool inTest;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
CHECK(!inTest);
inTest = true;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
CHECK(inTest);
inTest = false;
@@ -415,7 +589,7 @@ TEST_GROUP(UtestShellPointerArrayTest)
UtestShell* test1;
UtestShell* test2;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
test0 = new IgnoredUtestShell();
test1 = new IgnoredUtestShell();
@@ -425,7 +599,7 @@ TEST_GROUP(UtestShellPointerArrayTest)
test1->addTest(test2);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete test0;
delete test1;
diff --git a/tests/CppUTestExt/AllTests.cpp b/tests/CppUTestExt/AllTests.cpp
index d593b7604..6b4ca8666 100644
--- a/tests/CppUTestExt/AllTests.cpp
+++ b/tests/CppUTestExt/AllTests.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTestExt/CMakeLists.txt b/tests/CppUTestExt/CMakeLists.txt
index 304b23759..c50179852 100644
--- a/tests/CppUTestExt/CMakeLists.txt
+++ b/tests/CppUTestExt/CMakeLists.txt
@@ -1,43 +1,139 @@
-set(CppUTestExtTests_src
+add_library(CppUTestExtTests_main OBJECT
AllTests.cpp
- CodeMemoryReporterTest.cpp
+)
+
+if(CPPUTEST_STD_C_LIB_DISABLED)
+ target_sources(CppUTestExtTests_main
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/../DummyUTestPlatform/DummyUTestPlatform.cpp
+ )
+endif()
+
+if(CPPUTEST_TEST_GTEST)
+ find_package(GTest)
+ if(NOT GTest_FOUND)
+ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.11")
+ include(FetchContent)
+ FetchContent_Declare(googletest
+ URL https://github.com/google/googletest/archive/release-1.8.0.zip
+ )
+ if(NOT googletest_POPULATED)
+ FetchContent_Populate(googletest)
+ add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
+ endif()
+ set(GTEST_LIBRARIES gmock gtest)
+ else()
+ # FetchContent is not supported.
+ message(FATAL_ERROR
+ "GTest not found"
+ )
+ endif()
+ endif()
+ target_link_libraries(CppUTestExtTests_main PUBLIC ${GTEST_LIBRARIES})
+ target_compile_definitions(CppUTestExtTests_main PUBLIC CPPUTEST_INCLUDE_GTEST_TESTS)
+endif()
+
+target_link_libraries(CppUTestExtTests_main
+ PUBLIC
+ CppUTest
+ CppUTestExt
+)
+
+if(NOT CPPUTEST_SPLIT_TESTS)
+ add_executable(CppUTestExtTests)
+
+ add_mapfile(CppUTestExtTests)
+
+ include(CppUTest)
+ cpputest_discover_tests(CppUTestExtTests
+ DETAILED FALSE
+ )
+endif()
+
+function(add_cpputestext_test number)
+ set(name CppUTestExtTests)
+
+ if(CPPUTEST_SPLIT_TESTS)
+ string(APPEND name ${number})
+ add_executable(${name})
+ add_mapfile(${name})
+ cpputest_discover_tests(${name})
+ endif()
+
+ target_sources(${name}
+ PRIVATE ${ARGN}
+ )
+ target_link_libraries(${name}
+ PRIVATE CppUTestExtTests_main
+ )
+endfunction()
+
+add_cpputestext_test(1
+ MockFailureReporterForTest.cpp
+ ExpectedFunctionsListTest.cpp
GMockTest.cpp
GTest1Test.cpp
- IEEE754PluginTest.cpp
- IEEE754PluginTest_c.c
+ GTest2ConvertorTest.cpp
+)
+
+add_cpputestext_test(2
+ MockFailureReporterForTest.cpp
MemoryReportAllocatorTest.cpp
- MemoryReporterPluginTest.cpp
MemoryReportFormatterTest.cpp
+ MemoryReporterPluginTest.cpp
MockActualCallTest.cpp
MockCheatSheetTest.cpp
- MockCallTest.cpp
MockComparatorCopierTest.cpp
MockExpectedCallTest.cpp
- ExpectedFunctionsListTest.cpp
- MockFailureReporterForTest.cpp
- MockFailureTest.cpp
MockHierarchyTest.cpp
+)
+
+add_cpputestext_test(3
+ MockFailureReporterForTest.cpp
+ CodeMemoryReporterTest.cpp
+ OrderedTestTest.cpp
+ OrderedTestTest_c.c
+)
+
+add_cpputestext_test(4
+ MockFailureReporterForTest.cpp
+ MockReturnValueTest.cpp
MockNamedValueTest.cpp
- MockParameterTest.cpp
+)
+
+add_cpputestext_test(5
+ MockFailureReporterForTest.cpp
MockPluginTest.cpp
- MockSupportTest.cpp
- MockSupport_cTestCFile.c
MockSupport_cTest.cpp
- MockStrictOrderTest.cpp
- MockReturnValueTest.cpp
- OrderedTestTest_c.c
- OrderedTestTest.cpp
+ MockSupport_cTestCFile.c
)
-if (MINGW)
- find_package (Threads REQUIRED)
- set(THREAD_LIB "pthread")
-endif (MINGW)
+add_cpputestext_test(6
+ MockFailureReporterForTest.cpp
+ ExpectedFunctionsListTest.cpp
+ MockCallTest.cpp
+)
-add_executable(CppUTestExtTests ${CppUTestExtTests_src})
-cpputest_normalize_test_output_location(CppUTestExtTests)
-target_link_libraries(CppUTestExtTests CppUTest CppUTestExt ${THREAD_LIB} ${CPPUNIT_EXTERNAL_LIBRARIES})
+add_cpputestext_test(7
+ MockFailureReporterForTest.cpp
+ MockComparatorCopierTest.cpp
+ MockHierarchyTest.cpp
+ MockParameterTest.cpp
+)
-if (TESTS_BUILD_DISCOVER)
- cpputest_buildtime_discover_tests(CppUTestExtTests)
-endif()
+add_cpputestext_test(8
+ MockFailureReporterForTest.cpp
+ IEEE754PluginTest.cpp
+ IEEE754PluginTest_c.c
+ MockComparatorCopierTest.cpp
+)
+
+add_cpputestext_test(9
+ MockFailureReporterForTest.cpp
+ MockFailureTest.cpp
+ MockHierarchyTest.cpp
+ MockPluginTest.cpp
+ MockReturnValueTest.cpp
+ MockStrictOrderTest.cpp
+ MockSupportTest.cpp
+)
diff --git a/tests/CppUTestExt/CodeMemoryReporterTest.cpp b/tests/CppUTestExt/CodeMemoryReporterTest.cpp
index a17a50160..c2b390504 100644
--- a/tests/CppUTestExt/CodeMemoryReporterTest.cpp
+++ b/tests/CppUTestExt/CodeMemoryReporterTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -45,7 +45,7 @@ TEST_GROUP(CodeMemoryReportFormatter)
TestResult* testResult;
CodeMemoryReportFormatter* formatter;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
cAllocator = defaultMallocAllocator();
newAllocator = defaultNewAllocator();
@@ -57,7 +57,7 @@ TEST_GROUP(CodeMemoryReportFormatter)
testResult = new TestResult(testOutput);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete testResult;
delete formatter;
diff --git a/tests/CppUTestExt/ExpectedFunctionsListTest.cpp b/tests/CppUTestExt/ExpectedFunctionsListTest.cpp
index 61cd42a7c..526db2393 100644
--- a/tests/CppUTestExt/ExpectedFunctionsListTest.cpp
+++ b/tests/CppUTestExt/ExpectedFunctionsListTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,7 +38,7 @@ TEST_GROUP(MockExpectedCallsList)
MockCheckedExpectedCall* call2;
MockCheckedExpectedCall* call3;
MockCheckedExpectedCall* call4;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
list = new MockExpectedCallsList;
call1 = new MockCheckedExpectedCall;
@@ -49,7 +49,7 @@ TEST_GROUP(MockExpectedCallsList)
call2->withName("bar");
call3->withName("boo");
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete call1;
delete call2;
@@ -253,6 +253,24 @@ TEST(MockExpectedCallsList, callToStringForUnfulfilledFunctions)
STRCMP_EQUAL(expectedString.asCharString(), list->unfulfilledCallsToString().asCharString());
}
+TEST(MockExpectedCallsList, callsWithMissingParametersToString)
+{
+ call1->withName("foo").withParameter("boo", 0);
+ call2->withName("bar").withParameter("baa", 10).withParameter("baz", "blah");
+ call2->inputParameterWasPassed("baa");
+
+ list->addExpectedCall(call1);
+ list->addExpectedCall(call2);
+
+ SimpleString expectedString;
+ expectedString = StringFromFormat("-%s\n-#%s\n-%s\n-#%s",
+ call1->callToString().asCharString(),
+ call1->missingParametersToString().asCharString(),
+ call2->callToString().asCharString(),
+ call2->missingParametersToString().asCharString());
+ STRCMP_EQUAL(expectedString.asCharString(), list->callsWithMissingParametersToString("-", "#").asCharString());
+}
+
TEST(MockExpectedCallsList, callToStringForFulfilledFunctions)
{
call1->withName("foo");
diff --git a/tests/CppUTestExt/GMockTest.cpp b/tests/CppUTestExt/GMockTest.cpp
index a3698ef2d..88b00e93d 100644
--- a/tests/CppUTestExt/GMockTest.cpp
+++ b/tests/CppUTestExt/GMockTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,12 +37,12 @@
TEST_GROUP(GMock)
{
TestTestingFixture *fixture;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
fixture = new TestTestingFixture;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete fixture;
@@ -90,5 +90,3 @@ TEST(GMock, GMockNiceMocksWorkFine)
}
#endif
-
-
diff --git a/tests/CppUTestExt/GTest1Test.cpp b/tests/CppUTestExt/GTest1Test.cpp
index 77e037fe2..8f23d3482 100644
--- a/tests/CppUTestExt/GTest1Test.cpp
+++ b/tests/CppUTestExt/GTest1Test.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -117,37 +117,37 @@ TEST(gtest, SimpleGoogleTestGetCalled)
static bool afterCheck;
-static void _failMethodEXPECT_EQ()
+static void failMethodEXPECT_EQ_()
{
EXPECT_EQ(1, 2);
afterCheck = true;
}
-static void _failMethodASSERT_EQ()
+static void failMethodASSERT_EQ_()
{
ASSERT_EQ(1, 2);
afterCheck = true;
}
-static void _failMethodEXPECT_TRUE()
+static void failMethodEXPECT_TRUE_()
{
EXPECT_TRUE(false);
afterCheck = true;
}
-static void _failMethodASSERT_TRUE()
+static void failMethodASSERT_TRUE_()
{
ASSERT_TRUE(false);
afterCheck = true;
}
-static void _failMethodEXPECT_FALSE()
+static void failMethodEXPECT_FALSE_()
{
EXPECT_FALSE(true);
afterCheck = true;
}
-static void _failMethodEXPECT_STREQ()
+static void failMethodEXPECT_STREQ_()
{
EXPECT_STREQ("hello", "world");
afterCheck = true;
@@ -156,12 +156,12 @@ static void _failMethodEXPECT_STREQ()
TEST_GROUP(gtestMacros)
{
TestTestingFixture* fixture;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
fixture = new TestTestingFixture();
afterCheck = false;
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete fixture;
}
@@ -178,32 +178,32 @@ TEST_GROUP(gtestMacros)
TEST(gtestMacros, EXPECT_EQFails)
{
- testFailureWith(_failMethodEXPECT_EQ);
+ testFailureWith(failMethodEXPECT_EQ_);
}
TEST(gtestMacros, EXPECT_TRUEFails)
{
- testFailureWith(_failMethodEXPECT_TRUE);
+ testFailureWith(failMethodEXPECT_TRUE_);
}
TEST(gtestMacros, EXPECT_FALSEFails)
{
- testFailureWith(_failMethodEXPECT_FALSE);
+ testFailureWith(failMethodEXPECT_FALSE_);
}
TEST(gtestMacros, EXPECT_STREQFails)
{
- testFailureWith(_failMethodEXPECT_STREQ);
+ testFailureWith(failMethodEXPECT_STREQ_);
}
TEST(gtestMacros, ASSERT_EQFails)
{
- testFailureWith(_failMethodASSERT_EQ);
+ testFailureWith(failMethodASSERT_EQ_);
}
TEST(gtestMacros, ASSERT_TRUEFails)
{
- testFailureWith(_failMethodASSERT_TRUE);
+ testFailureWith(failMethodASSERT_TRUE_);
}
#endif
diff --git a/tests/CppUTestExt/GTest2ConvertorTest.cpp b/tests/CppUTestExt/GTest2ConvertorTest.cpp
index f65e5ea1e..f8c390fb7 100644
--- a/tests/CppUTestExt/GTest2ConvertorTest.cpp
+++ b/tests/CppUTestExt/GTest2ConvertorTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -34,13 +34,13 @@ class GTestTestingFixtureTest : public testing::Test {
bool setup_was_called;
char* freed_during_teardown;
- void SetUp()
+ void SetUp() CPPUTEST_OVERRIDE
{
setup_was_called = true;
freed_during_teardown = NULL;
}
- void TearDown()
+ void TearDown() CPPUTEST_OVERRIDE
{
delete [] freed_during_teardown;
}
diff --git a/tests/CppUTestExt/IEEE754PluginTest.cpp b/tests/CppUTestExt/IEEE754PluginTest.cpp
index 133f4d0b1..e37e309cb 100644
--- a/tests/CppUTestExt/IEEE754PluginTest.cpp
+++ b/tests/CppUTestExt/IEEE754PluginTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,46 +31,42 @@
#include "CppUTest/TestTestingFixture.h"
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
-#ifdef CPPUTEST_HAVE_FENV
-#if CPPUTEST_FENV_IS_WORKING_PROPERLY
+#if CPPUTEST_HAVE_FENV
-extern "C"
-{
- #include "IEEE754PluginTest_c.h"
-}
+#include "IEEE754PluginTest_c.h"
-TEST_GROUP(FE__with_Plugin)
+TEST_GROUP(FE_with_Plugin)
{
TestTestingFixture fixture;
IEEE754ExceptionsPlugin ieee754Plugin;
- void setup(void) _override
+ void setup(void) CPPUTEST_OVERRIDE
{
fixture.installPlugin(&ieee754Plugin);
}
};
-TEST(FE__with_Plugin, should_fail____when__FE_DIVBYZERO__is_set)
+TEST(FE_with_Plugin, should_fail_when_FE_DIVBYZERO_is_set)
{
fixture.setTestFunction(set_divisionbyzero_c);
fixture.runAllTests();
fixture.assertPrintContains("IEEE754_CHECK_CLEAR(FE_DIVBYZERO) failed");
}
-TEST(FE__with_Plugin, should_fail____when__FE_OVERFLOW___is_set)
+TEST(FE_with_Plugin, should_fail_when_FE_OVERFLOW_is_set)
{
fixture.setTestFunction(set_overflow_c);
fixture.runAllTests();
fixture.assertPrintContains("IEEE754_CHECK_CLEAR(FE_OVERFLOW) failed");
}
-TEST(FE__with_Plugin, should_fail____when__FE_UNDERFLOW__is_set)
+TEST(FE_with_Plugin, should_fail_when_FE_UNDERFLOW_is_set)
{
fixture.setTestFunction(set_underflow_c);
fixture.runAllTests();
fixture.assertPrintContains("IEEE754_CHECK_CLEAR(FE_UNDERFLOW) failed");
}
-TEST(FE__with_Plugin, should_fail____when__FE_INEXACT____is_set_and_enabled)
+TEST(FE_with_Plugin, should_fail_when_FE_INEXACT_is_set_and_enabled)
{
IEEE754ExceptionsPlugin::enableInexact();
fixture.setTestFunction(set_inexact_c);
@@ -78,7 +74,7 @@ TEST(FE__with_Plugin, should_fail____when__FE_INEXACT____is_set_and_enabled)
fixture.assertPrintContains("IEEE754_CHECK_CLEAR(FE_INEXACT) failed");
}
-TEST(FE__with_Plugin, should_succeed_when__FE_INEXACT____is_set_and_disabled)
+TEST(FE_with_Plugin, should_succeed_when_FE_INEXACT_is_set_and_disabled)
{
IEEE754ExceptionsPlugin::enableInexact();
IEEE754ExceptionsPlugin::disableInexact();
@@ -87,7 +83,7 @@ TEST(FE__with_Plugin, should_succeed_when__FE_INEXACT____is_set_and_disabled)
fixture.assertPrintContains("OK");
}
-TEST(FE__with_Plugin, should_succeed_with_5_checks_when_no_flags_are_set)
+TEST(FE_with_Plugin, should_succeed_with_5_checks_when_no_flags_are_set)
{
IEEE754ExceptionsPlugin::enableInexact();
fixture.setTestFunction(set_nothing_c);
@@ -96,14 +92,14 @@ TEST(FE__with_Plugin, should_succeed_with_5_checks_when_no_flags_are_set)
IEEE754ExceptionsPlugin::disableInexact();
}
-TEST(FE__with_Plugin, should_check_five_times_when_all_flags_are_set)
+TEST(FE_with_Plugin, should_check_five_times_when_all_flags_are_set)
{
fixture.setTestFunction(set_everything_c);
fixture.runAllTests();
LONGS_EQUAL(5, fixture.getCheckCount());
}
-TEST(FE__with_Plugin, should_fail_only_once_when_all_flags_are_set)
+TEST(FE_with_Plugin, should_fail_only_once_when_all_flags_are_set)
{
fixture.setTestFunction(set_everything_c);
fixture.runAllTests();
@@ -116,7 +112,7 @@ static void set_everything_but_already_failed(void)
CHECK(1 == 2);
}
-TEST(FE__with_Plugin, should_not_fail_again_when_test_has_already_failed)
+TEST(FE_with_Plugin, should_not_fail_again_when_test_has_already_failed)
{
fixture.setTestFunction(set_everything_but_already_failed);
fixture.runAllTests();
@@ -132,7 +128,7 @@ static IEEE754ExceptionsPlugin ip;
TEST_GROUP(IEEE754ExceptionsPlugin2)
{
- void setup(void) _override
+ void setup(void) CPPUTEST_OVERRIDE
{
TestRegistry::getCurrentRegistry()->installPlugin(&ip);
}
@@ -144,4 +140,3 @@ IGNORE_TEST(IEEE754ExceptionsPlugin2, should_not_fail_in_ignored_test)
}
#endif
-#endif
diff --git a/tests/CppUTestExt/IEEE754PluginTest_c.c b/tests/CppUTestExt/IEEE754PluginTest_c.c
index 1cce8bde3..644ea6462 100644
--- a/tests/CppUTestExt/IEEE754PluginTest_c.c
+++ b/tests/CppUTestExt/IEEE754PluginTest_c.c
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -58,7 +58,7 @@ void set_nothing_c(void)
{
}
-void set_everything_c()
+void set_everything_c(void)
{
set_divisionbyzero_c();
set_overflow_c();
diff --git a/tests/CppUTestExt/IEEE754PluginTest_c.h b/tests/CppUTestExt/IEEE754PluginTest_c.h
index 2f65ba7a5..6f1f02e91 100644
--- a/tests/CppUTestExt/IEEE754PluginTest_c.h
+++ b/tests/CppUTestExt/IEEE754PluginTest_c.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -25,9 +25,22 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef IEEE754PLUGINTEST_C_H
+#define IEEE754PLUGINTEST_C_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void set_divisionbyzero_c(void);
void set_overflow_c(void);
void set_underflow_c(void);
void set_inexact_c(void);
void set_nothing_c(void);
void set_everything_c(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IEEE754PLUGINTEST_C_H */
diff --git a/tests/CppUTestExt/MemoryReportAllocatorTest.cpp b/tests/CppUTestExt/MemoryReportAllocatorTest.cpp
index 3cc990511..13500be4c 100644
--- a/tests/CppUTestExt/MemoryReportAllocatorTest.cpp
+++ b/tests/CppUTestExt/MemoryReportAllocatorTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTestExt/MemoryReportFormatterTest.cpp b/tests/CppUTestExt/MemoryReportFormatterTest.cpp
index 7a32b1a89..13b0b190d 100644
--- a/tests/CppUTestExt/MemoryReportFormatterTest.cpp
+++ b/tests/CppUTestExt/MemoryReportFormatterTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -40,13 +40,13 @@ TEST_GROUP(NormalMemoryReportFormatter)
TestResult* testResult;
NormalMemoryReportFormatter formatter;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
memory01 = (char*) 0x01;
testResult = new TestResult(testOutput);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete testResult;
}
diff --git a/tests/CppUTestExt/MemoryReporterPluginTest.cpp b/tests/CppUTestExt/MemoryReporterPluginTest.cpp
index 72bcb69b2..2a94646d4 100644
--- a/tests/CppUTestExt/MemoryReporterPluginTest.cpp
+++ b/tests/CppUTestExt/MemoryReporterPluginTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -52,37 +52,37 @@ class TemporaryDefaultNewAllocator
class MockMemoryReportFormatter : public MemoryReportFormatter
{
public:
- virtual void report_testgroup_start(TestResult* result, UtestShell& test)
+ virtual void report_testgroup_start(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_testgroup_start").withParameter("result", result).withParameter("test", &test);
}
- virtual void report_testgroup_end(TestResult* result, UtestShell& test)
+ virtual void report_testgroup_end(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_testgroup_end").withParameter("result", result).withParameter("test", &test);
}
- virtual void report_test_start(TestResult* result, UtestShell& test)
+ virtual void report_test_start(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_test_start").withParameter("result", result).withParameter("test", &test);
}
- virtual void report_test_end(TestResult* result, UtestShell& test)
+ virtual void report_test_end(TestResult* result, UtestShell& test) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_test_end").withParameter("result", result).withParameter("test", &test);
}
- virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t, char* , const char* , size_t )
+ virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t, char* , const char* , size_t ) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_alloc_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", allocator);
}
- virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* , const char* , size_t )
+ virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* , const char* , size_t ) CPPUTEST_OVERRIDE
{
TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator);
mock("formatter").actualCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", allocator);
@@ -94,21 +94,21 @@ static MockMemoryReportFormatter formatterForPluginTest;
class MemoryReporterPluginUnderTest : public MemoryReporterPlugin
{
public:
- MemoryReportFormatter* createMemoryFormatter(const SimpleString& type)
+ MemoryReportFormatter* createMemoryFormatter(const SimpleString& type) CPPUTEST_OVERRIDE
{
- mock("reporter").actualCall("createMemoryFormatter").onObject(this).withParameter("type", type.asCharString());
- return new MockMemoryReportFormatter;
+ mock("reporter").actualCall("createMemoryFormatter").onObject(this).withParameter("type", type.asCharString());
+ return new MockMemoryReportFormatter;
}
};
class TestMemoryAllocatorComparator : public MockNamedValueComparator
{
public:
- bool isEqual(const void* object1, const void* object2)
+ bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return ((const TestMemoryAllocator*)object1)->name() == ((const TestMemoryAllocator*)object2)->name();
}
- SimpleString valueToString(const void* object)
+ SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
return ((const TestMemoryAllocator*)object)->name();
}
@@ -124,7 +124,7 @@ TEST_GROUP(MemoryReporterPlugin)
TestResult* result;
UtestShell* test;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
previousNewAllocator = getCurrentNewAllocator();
result = new TestResult(output);
@@ -138,7 +138,7 @@ TEST_GROUP(MemoryReporterPlugin)
reporter->parseArguments(1, cmd_line, 0);
mock("reporter").enable();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
setCurrentNewAllocator(previousNewAllocator);
mock().clear();
@@ -314,4 +314,3 @@ TEST(MemoryReporterPlugin, shouldntCrashCreateInvalidMemoryReportFormatterWithou
realReporter.preTestAction(*test, *result);
realReporter.postTestAction(*test, *result);
}
-
diff --git a/tests/CppUTestExt/MockActualCallTest.cpp b/tests/CppUTestExt/MockActualCallTest.cpp
index e8f398fcc..a38b85200 100644
--- a/tests/CppUTestExt/MockActualCallTest.cpp
+++ b/tests/CppUTestExt/MockActualCallTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,14 +38,14 @@ TEST_GROUP(MockCheckedActualCall)
MockExpectedCallsList* list;
MockFailureReporter* reporter;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
emptyList = new MockExpectedCallsList;
list = new MockExpectedCallsList;
reporter = MockFailureReporterForTest::getReporter();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
CHECK_NO_MOCK_FAILURE();
@@ -164,7 +164,7 @@ TEST(MockCheckedActualCall, MockIgnoredActualCallWorksAsItShould)
CHECK(1l == actual.returnLongIntValueOrDefault(1l));
CHECK(0 == actual.returnUnsignedIntValue());
CHECK(1u == actual.returnUnsignedIntValueOrDefault(1u));
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
CHECK(0 == actual.returnLongLongIntValue());
CHECK(1ll == actual.returnLongLongIntValueOrDefault(1ll));
CHECK(0 == actual.returnUnsignedLongLongIntValue());
@@ -199,7 +199,7 @@ TEST(MockCheckedActualCall, remainderOfMockActualCallTraceWorksAsItShould)
actual.withUnsignedIntParameter("unsigned_int", (unsigned int) 1);
actual.withUnsignedLongIntParameter("unsigned_long", (unsigned long)1);
actual.withLongIntParameter("long_int", (long int) 1);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
actual.withLongLongIntParameter("long_long_int", (long long int) 1);
actual.withUnsignedLongLongIntParameter("unsigned_long_long_int", (unsigned long long int) 1);
#endif
@@ -217,7 +217,7 @@ TEST(MockCheckedActualCall, remainderOfMockActualCallTraceWorksAsItShould)
expectedString += " unsigned_int:1 (0x1)";
expectedString += " unsigned_long:1 (0x1)";
expectedString += " long_int:1 (0x1)";
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
expectedString += " long_long_int:1 (0x1)";
expectedString += " unsigned_long_long_int:1 (0x1)";
#endif
@@ -243,7 +243,7 @@ TEST(MockCheckedActualCall, remainderOfMockActualCallTraceWorksAsItShould)
CHECK(0 == actual.returnIntValueOrDefault(1));
CHECK(0 == actual.returnLongIntValue());
CHECK(0 == actual.returnLongIntValueOrDefault(1l));
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
CHECK(0 == actual.returnLongLongIntValue());
CHECK(0 == actual.returnLongLongIntValueOrDefault(1ll));
CHECK(0 == actual.returnUnsignedLongLongIntValue());
diff --git a/tests/CppUTestExt/MockCallTest.cpp b/tests/CppUTestExt/MockCallTest.cpp
index 4bfc372f1..2e36c9aa6 100644
--- a/tests/CppUTestExt/MockCallTest.cpp
+++ b/tests/CppUTestExt/MockCallTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,7 +31,7 @@
TEST_GROUP(MockCallTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().checkExpectations();
mock().clear();
@@ -501,3 +501,13 @@ TEST(MockCallTest, mockExpectationShouldIncreaseNumberOfChecks)
LONGS_EQUAL(3, fixture.getCheckCount());
}
+TEST(MockCallTest, expectationsLeftBeforCheckExpectations)
+{
+ CHECK(!mock().expectedCallsLeft());
+ mock().expectOneCall("boo");
+ CHECK(mock().expectedCallsLeft());
+ mock().actualCall("boo");
+ CHECK(!mock().expectedCallsLeft());
+ mock().checkExpectations();
+ CHECK(!mock().expectedCallsLeft());
+}
diff --git a/tests/CppUTestExt/MockCheatSheetTest.cpp b/tests/CppUTestExt/MockCheatSheetTest.cpp
index f5a97df85..ec74a22ce 100644
--- a/tests/CppUTestExt/MockCheatSheetTest.cpp
+++ b/tests/CppUTestExt/MockCheatSheetTest.cpp
@@ -39,7 +39,7 @@ static void productionCodeBarCalls()
/* Actual test */
TEST_GROUP(MockCheatSheet)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
/* Check expectations. Alternatively use MockSupportPlugin */
mock().checkExpectations();
@@ -73,4 +73,3 @@ TEST(MockCheatSheet, bar)
/* And the production code call */
productionCodeBarCalls();
}
-
diff --git a/tests/CppUTestExt/MockComparatorCopierTest.cpp b/tests/CppUTestExt/MockComparatorCopierTest.cpp
index 5c3ba60d6..5cad7a4a5 100644
--- a/tests/CppUTestExt/MockComparatorCopierTest.cpp
+++ b/tests/CppUTestExt/MockComparatorCopierTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,7 +30,7 @@
TEST_GROUP(MockComparatorCopierTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().checkExpectations();
mock().clear();
@@ -55,13 +55,13 @@ class MyTypeForTesting
class MyTypeForTestingComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void* object1, const void* object2)
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
const MyTypeForTesting* obj1 = (const MyTypeForTesting*) object1;
const MyTypeForTesting* obj2 = (const MyTypeForTesting*) object2;
return *(obj1->value) == *(obj2->value);
}
- virtual SimpleString valueToString(const void* object)
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
const MyTypeForTesting* obj = (const MyTypeForTesting*) object;
return StringFrom(*(obj->value));
@@ -71,7 +71,7 @@ class MyTypeForTestingComparator : public MockNamedValueComparator
class MyTypeForTestingCopier : public MockNamedValueCopier
{
public:
- virtual void copy(void* dst_, const void* src_)
+ virtual void copy(void* dst_, const void* src_) CPPUTEST_OVERRIDE
{
MyTypeForTesting* dst = (MyTypeForTesting*) dst_;
const MyTypeForTesting* src = (const MyTypeForTesting*) src_;
@@ -229,7 +229,7 @@ TEST(MockComparatorCopierTest, customTypeOutputParameterMissing)
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations);
mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject);
mock().actualCall("foo");
@@ -567,11 +567,11 @@ TEST(MockComparatorCopierTest, installCopiersWorksHierarchically)
class StubComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void*, const void*)
+ virtual bool isEqual(const void*, const void*) CPPUTEST_OVERRIDE
{
return true;
}
- virtual SimpleString valueToString(const void*)
+ virtual SimpleString valueToString(const void*) CPPUTEST_OVERRIDE
{
return "";
}
@@ -598,4 +598,3 @@ TEST(MockComparatorCopierTest, shouldSupportConstParameters)
mock().checkExpectations();
}
-
diff --git a/tests/CppUTestExt/MockExpectedCallTest.cpp b/tests/CppUTestExt/MockExpectedCallTest.cpp
index c953d1b39..7bd76aa73 100644
--- a/tests/CppUTestExt/MockExpectedCallTest.cpp
+++ b/tests/CppUTestExt/MockExpectedCallTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -47,13 +47,13 @@ class TypeForTestingExpectedFunctionCall
class TypeForTestingExpectedFunctionCallComparator : public MockNamedValueComparator
{
public:
- virtual bool isEqual(const void* object1, const void* object2)
+ virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
const TypeForTestingExpectedFunctionCall* obj1 = (const TypeForTestingExpectedFunctionCall*) object1;
const TypeForTestingExpectedFunctionCall* obj2 = (const TypeForTestingExpectedFunctionCall*) object2;
return *(obj1->value) == *(obj2->value);
}
- virtual SimpleString valueToString(const void* object)
+ virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
{
const TypeForTestingExpectedFunctionCall* obj = (const TypeForTestingExpectedFunctionCall*) object;
return StringFrom(*(obj->value));
@@ -63,7 +63,7 @@ class TypeForTestingExpectedFunctionCallComparator : public MockNamedValueCompar
class TypeForTestingExpectedFunctionCallCopier : public MockNamedValueCopier
{
public:
- virtual void copy(void* dst_, const void* src_)
+ virtual void copy(void* dst_, const void* src_) CPPUTEST_OVERRIDE
{
TypeForTestingExpectedFunctionCall* dst = (TypeForTestingExpectedFunctionCall*) dst_;
const TypeForTestingExpectedFunctionCall* src = (const TypeForTestingExpectedFunctionCall*) src_;
@@ -73,7 +73,7 @@ class TypeForTestingExpectedFunctionCallCopier : public MockNamedValueCopier
TEST_GROUP(MockNamedValueHandlerRepository)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
CHECK_NO_MOCK_FAILURE();
MockFailureReporterForTest::clearReporter();
@@ -155,13 +155,13 @@ TEST_GROUP(MockExpectedCall)
{
MockCheckedExpectedCall* call;
MockNamedValueComparatorsAndCopiersRepository* originalComparatorRepository;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
originalComparatorRepository = MockNamedValue::getDefaultComparatorsAndCopiersRepository();
call = new MockCheckedExpectedCall(1);
call->withName("funcName");
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
MockNamedValue::setDefaultComparatorsAndCopiersRepository(originalComparatorRepository);
delete call;
@@ -232,7 +232,7 @@ TEST(MockExpectedCall, callWithLongIntegerParameter)
STRCMP_CONTAINS("funcName -> long int paramName: <777 (0x309)>", call->callToString().asCharString());
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockExpectedCall, callWithUnsignedLongLongIntegerParameter)
{
@@ -326,7 +326,7 @@ TEST(MockExpectedCall, callWithMemoryBuffer)
const unsigned char value[] = { 0x12, 0xFE, 0xA1 };
call->withParameter(paramName, value, sizeof(value));
STRCMP_EQUAL("const unsigned char*", call->getInputParameterType(paramName).asCharString());
- POINTERS_EQUAL( (void*) value, (void*) call->getInputParameter(paramName).getMemoryBuffer() );
+ POINTERS_EQUAL(value, call->getInputParameter(paramName).getMemoryBuffer());
LONGS_EQUAL(sizeof(value), call->getInputParameter(paramName).getSize());
STRCMP_CONTAINS("funcName -> const unsigned char* paramName: ", call->callToString().asCharString());
}
@@ -780,7 +780,7 @@ TEST(MockIgnoredExpectedCall, worksAsItShould)
ignored.withUnsignedIntParameter("foo", (unsigned int) 1);
ignored.withLongIntParameter("hey", (long int) 1);
ignored.withUnsignedLongIntParameter("bah", (unsigned long int) 1);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
ignored.withLongLongIntParameter("yo", (long long int) 1);
ignored.withUnsignedLongLongIntParameter("grr", (unsigned long long int) 1);
#endif
@@ -802,7 +802,7 @@ TEST(MockIgnoredExpectedCall, worksAsItShould)
ignored.andReturnValue((int) 1);
ignored.andReturnValue((unsigned long int) 1);
ignored.andReturnValue((long int) 1);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
ignored.andReturnValue((unsigned long long int) 1);
ignored.andReturnValue((long long int) 1);
#endif
diff --git a/tests/CppUTestExt/MockFailureReporterForTest.cpp b/tests/CppUTestExt/MockFailureReporterForTest.cpp
index b8437b8b7..5330b7472 100644
--- a/tests/CppUTestExt/MockFailureReporterForTest.cpp
+++ b/tests/CppUTestExt/MockFailureReporterForTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTestExt/MockFailureReporterForTest.h b/tests/CppUTestExt/MockFailureReporterForTest.h
index 387f22b4f..f1b599f60 100644
--- a/tests/CppUTestExt/MockFailureReporterForTest.h
+++ b/tests/CppUTestExt/MockFailureReporterForTest.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -38,7 +38,7 @@ class MockFailureReporterForTest : public MockFailureReporter
public:
SimpleString mockFailureString;
- virtual void failTest(const MockFailure& failure);
+ virtual void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE;
static MockFailureReporterForTest* getReporter();
static void clearReporter();
private:
@@ -61,11 +61,10 @@ void CHECK_NO_MOCK_FAILURE_LOCATION(const char* file, size_t line);
class MockExpectedCallsListForTest : public MockExpectedCallsList
{
public:
- ~MockExpectedCallsListForTest() _destructor_override;
+ ~MockExpectedCallsListForTest() CPPUTEST_DESTRUCTOR_OVERRIDE;
MockCheckedExpectedCall* addFunction(const SimpleString& name);
MockCheckedExpectedCall* addFunction(unsigned int numCalls, const SimpleString& name);
MockCheckedExpectedCall* addFunctionOrdered(const SimpleString& name, unsigned int order);
};
#endif
-
diff --git a/tests/CppUTestExt/MockFailureTest.cpp b/tests/CppUTestExt/MockFailureTest.cpp
index 1582c3fcb..0e1aea2b5 100644
--- a/tests/CppUTestExt/MockFailureTest.cpp
+++ b/tests/CppUTestExt/MockFailureTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -39,31 +39,46 @@ TEST_GROUP(MockFailureTest)
MockCheckedExpectedCall* call1;
MockCheckedExpectedCall* call2;
MockCheckedExpectedCall* call3;
+ MockCheckedExpectedCall* call4;
+ MockCheckedExpectedCall* call5;
- void setup ()
+ void setup () CPPUTEST_OVERRIDE
{
list = new MockExpectedCallsList;
call1 = new MockCheckedExpectedCall;
call2 = new MockCheckedExpectedCall;
call3 = new MockCheckedExpectedCall;
+ call4 = new MockCheckedExpectedCall;
+ call5 = new MockCheckedExpectedCall;
}
- void teardown ()
+ void teardown () CPPUTEST_OVERRIDE
{
delete list;
delete call1;
delete call2;
delete call3;
+ delete call4;
+ delete call5;
CHECK_NO_MOCK_FAILURE();
MockFailureReporterForTest::clearReporter();
}
- void addAllToList()
+ void addThreeCallsToList()
{
list->addExpectedCall(call1);
list->addExpectedCall(call2);
list->addExpectedCall(call3);
}
+ void addFiveCallsToList()
+ {
+ list->addExpectedCall(call1);
+ list->addExpectedCall(call2);
+ list->addExpectedCall(call3);
+ list->addExpectedCall(call4);
+ list->addExpectedCall(call5);
+ }
+
void checkUnexpectedNthCallMessage(unsigned int count, const char* expectedOrdinal)
{
MockExpectedCallsList callList;
@@ -114,7 +129,7 @@ TEST(MockFailureTest, expectedCallDidNotHappen)
call2->withName("world").withParameter("boo", 2).withParameter("hello", "world");
call3->withName("haphaphap");
call3->callWasMade(1);
- addAllToList();
+ addThreeCallsToList();
MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), *list);
STRCMP_EQUAL("Mock Failure: Expected call WAS NOT fulfilled.\n"
@@ -144,7 +159,7 @@ TEST(MockFailureTest, MockUnexpectedInputParameterFailure)
call1->withName("foo").withParameter("boo", 2);
call2->withName("foo").withParameter("boo", 3.3);
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockNamedValue actualParameter("bar");
actualParameter.setValue(2);
@@ -167,7 +182,7 @@ TEST(MockFailureTest, MockUnexpectedOutputParameterFailure)
call1->withName("foo").withOutputParameterReturning("boo", &out1, sizeof(out1));
call2->withName("foo").withOutputParameterReturning("boo", &out2, sizeof(out2));
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockNamedValue actualParameter("bar");
actualParameter.setValue((void *)0x123);
@@ -189,7 +204,7 @@ TEST(MockFailureTest, MockUnexpectedUnmodifiedOutputParameterFailure)
call1->withName("foo").withOutputParameterReturning("boo", &out1, sizeof(out1));
call2->withName("foo").withUnmodifiedOutputParameter("boo");
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockNamedValue actualParameter("bar");
actualParameter.setValue((void *)0x123);
@@ -210,7 +225,7 @@ TEST(MockFailureTest, MockUnexpectedParameterValueFailure)
call1->withName("foo").withParameter("boo", 2);
call2->withName("foo").withParameter("boo", 10);
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockNamedValue actualParameter("boo");
actualParameter.setValue(20);
@@ -229,21 +244,35 @@ TEST(MockFailureTest, MockUnexpectedParameterValueFailure)
TEST(MockFailureTest, MockExpectedParameterDidntHappenFailure)
{
call1->withName("foo").withParameter("bar", 2).withParameter("boo", "str");
+ call1->inputParameterWasPassed("bar");
call2->withName("foo").withParameter("bar", 10).withParameter("boo", "bleh");
call2->callWasMade(1);
call2->inputParameterWasPassed("bar");
call2->inputParameterWasPassed("boo");
- call3->withName("unrelated");
- addAllToList();
+ call3->withName("foo").withParameter("bar", 2).withParameter("boo", "blah").withParameter("baa", 0u);
+ call3->inputParameterWasPassed("bar");
+ call4->withName("foo").withParameter("bar", 20);
+ call5->withName("unrelated");
+ addFiveCallsToList();
- MockExpectedParameterDidntHappenFailure failure(UtestShell::getCurrent(), "foo", *list);
+ MockExpectedCallsList matchingCalls;
+ matchingCalls.addExpectedCall(call1);
+ matchingCalls.addExpectedCall(call3);
+
+ MockExpectedParameterDidntHappenFailure failure(UtestShell::getCurrent(), "foo", *list, matchingCalls);
STRCMP_EQUAL("Mock Failure: Expected parameter for function \"foo\" did not happen.\n"
+ "\tEXPECTED calls with MISSING parameters related to function: foo\n"
+ "\t\tfoo -> int bar: <2 (0x2)>, const char* boo: (expected 1 call, called 0 times)\n"
+ "\t\t\tMISSING parameters: const char* boo\n"
+ "\t\tfoo -> int bar: <2 (0x2)>, const char* boo: , unsigned int baa: <0 (0x0)> (expected 1 call, called 0 times)\n"
+ "\t\t\tMISSING parameters: const char* boo, unsigned int baa\n"
"\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n"
"\t\tfoo -> int bar: <2 (0x2)>, const char* boo: (expected 1 call, called 0 times)\n"
+ "\t\tfoo -> int bar: <2 (0x2)>, const char* boo: , unsigned int baa: <0 (0x0)> (expected 1 call, called 0 times)\n"
+ "\t\tfoo -> int bar: <20 (0x14)> (expected 1 call, called 0 times)\n"
"\tEXPECTED calls that WERE fulfilled related to function: foo\n"
- "\t\tfoo -> int bar: <10 (0xa)>, const char* boo: (expected 1 call, called 1 time)\n"
- "\tMISSING parameters that didn't happen:\n"
- "\t\tint bar, const char* boo", failure.getMessage().asCharString());
+ "\t\tfoo -> int bar: <10 (0xa)>, const char* boo: (expected 1 call, called 1 time)",
+ failure.getMessage().asCharString());
}
TEST(MockFailureTest, MockNoWayToCompareCustomTypeFailure)
@@ -259,7 +288,7 @@ TEST(MockFailureTest, MockUnexpectedObjectFailure)
call2->callWasMade(1);
call2->wasPassedToObject();
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockUnexpectedObjectFailure failure(UtestShell::getCurrent(), "foo", (void*)0x1, *list);
STRCMP_EQUAL(StringFromFormat (
@@ -279,7 +308,7 @@ TEST(MockFailureTest, MockExpectedObjectDidntHappenFailure)
call2->callWasMade(1);
call2->wasPassedToObject();
call3->withName("unrelated");
- addAllToList();
+ addThreeCallsToList();
MockExpectedObjectDidntHappenFailure failure(UtestShell::getCurrent(), "foo", *list);
STRCMP_EQUAL(StringFromFormat(
diff --git a/tests/CppUTestExt/MockFakeLongLong.cpp b/tests/CppUTestExt/MockFakeLongLong.cpp
index cc6b3462e..e0cd1a61b 100644
--- a/tests/CppUTestExt/MockFakeLongLong.cpp
+++ b/tests/CppUTestExt/MockFakeLongLong.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,7 +44,7 @@ TEST_GROUP(FakeLongLongs)
#define CHECK_TEST_FAILS_PROPER_WITH_TEXT(text) fixture.checkTestFailsWithProperTestLocation(text, __FILE__, __LINE__)
-static void _actualCallWithFakeLongLongParameter()
+static void actualCallWithFakeLongLongParameter_()
{
cpputest_longlong value = {0};
@@ -55,12 +55,12 @@ static void _actualCallWithFakeLongLongParameter()
TEST(FakeLongLongs, ActualCallWithFakeLongLongParameterFAILS)
{
- fixture.runTestWithMethod(_actualCallWithFakeLongLongParameter);
+ fixture.runTestWithMethod(actualCallWithFakeLongLongParameter);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported");
}
-static void _actualCallWithFakeUnsignedLongLongParameter()
+static void actualCallWithFakeUnsignedLongLongParameter_()
{
cpputest_ulonglong value = {0};
@@ -71,12 +71,12 @@ static void _actualCallWithFakeUnsignedLongLongParameter()
TEST(FakeLongLongs, ActualCallWithFakeUnsignedLongLongParameterFAILS)
{
- fixture.runTestWithMethod(_actualCallWithFakeUnsignedLongLongParameter);
+ fixture.runTestWithMethod(actualCallWithFakeUnsignedLongLongParameter_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported");
}
-static void _actualCallWithFakeLongLongReturn()
+static void actualCallWithFakeLongLongReturn_()
{
mock().expectOneCall("foo").andReturnValue(0);
mock().actualCall("foo").returnLongLongIntValue();
@@ -85,12 +85,12 @@ static void _actualCallWithFakeLongLongReturn()
TEST(FakeLongLongs, ActualCallWithFakeLongLongReturnFAILS)
{
- fixture.runTestWithMethod(_actualCallWithFakeLongLongReturn);
+ fixture.runTestWithMethod(actualCallWithFakeLongLongReturn_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported");
}
-static void _actualCallWithFakeUnsignedLongLongReturn()
+static void actualCallWithFakeUnsignedLongLongReturn_()
{
mock().expectOneCall("foo").andReturnValue(0);
mock().actualCall("foo").returnUnsignedLongLongIntValue();
@@ -99,12 +99,12 @@ static void _actualCallWithFakeUnsignedLongLongReturn()
TEST(FakeLongLongs, ActualCallWithFakeUnsignedLongLongReturnFAILS)
{
- fixture.runTestWithMethod(_actualCallWithFakeUnsignedLongLongReturn);
+ fixture.runTestWithMethod(actualCallWithFakeUnsignedLongLongReturn_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported");
}
-static void _expectOneCallWithFakeLongLongParameter()
+static void expectOneCallWithFakeLongLongParameter_()
{
cpputest_longlong value = {0};
@@ -115,12 +115,12 @@ static void _expectOneCallWithFakeLongLongParameter()
TEST(FakeLongLongs, ExpectedCallWithFakeLongLongParameterFAILS)
{
- fixture.runTestWithMethod(_expectOneCallWithFakeLongLongParameter);
+ fixture.runTestWithMethod(expectOneCallWithFakeLongLongParameter_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported");
}
-static void _expectOneCallWithFakeUnsignedLongLongParameter()
+static void expectOneCallWithFakeUnsignedLongLongParameter_()
{
cpputest_ulonglong value = {0};
@@ -131,12 +131,12 @@ static void _expectOneCallWithFakeUnsignedLongLongParameter()
TEST(FakeLongLongs, ExpectedCallWithFakeUnsignedLongLongParameterFAILS)
{
- fixture.runTestWithMethod(_expectOneCallWithFakeUnsignedLongLongParameter);
+ fixture.runTestWithMethod(expectOneCallWithFakeUnsignedLongLongParameter_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported");
}
-static void _expectOneCallWithFakeLongLongReturn()
+static void expectOneCallWithFakeLongLongReturn_()
{
cpputest_longlong value = {0};
@@ -147,12 +147,12 @@ static void _expectOneCallWithFakeLongLongReturn()
TEST(FakeLongLongs, ExpectedCallWithFakeLongLongReturnFAILS)
{
- fixture.runTestWithMethod(_expectOneCallWithFakeLongLongReturn);
+ fixture.runTestWithMethod(expectOneCallWithFakeLongLongReturn_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported");
}
-static void _expectOneCallWithFakeUnsignedLongLongReturn()
+static void expectOneCallWithFakeUnsignedLongLongReturn_()
{
cpputest_ulonglong value = {0};
@@ -163,7 +163,7 @@ static void _expectOneCallWithFakeUnsignedLongLongReturn()
TEST(FakeLongLongs, ExpectedCallWithFakeUnsignedLongLongReturnFAILS)
{
- fixture.runTestWithMethod(_expectOneCallWithFakeUnsignedLongLongReturn);
+ fixture.runTestWithMethod(expectOneCallWithFakeUnsignedLongLongReturn_);
mock().clear();
CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported");
}
diff --git a/tests/CppUTestExt/MockHierarchyTest.cpp b/tests/CppUTestExt/MockHierarchyTest.cpp
index 962ae7981..8ee5901df 100644
--- a/tests/CppUTestExt/MockHierarchyTest.cpp
+++ b/tests/CppUTestExt/MockHierarchyTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,7 +30,7 @@
TEST_GROUP(MockHierarchyTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().clear();
}
@@ -132,7 +132,7 @@ TEST(MockHierarchyTest, checkExpectationsWorksHierarchicallyForLastCallNotFinish
MockExpectedCallsListForTest expectations;
expectations.addFunction("first::foobar")->withParameter("boo", 1);
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "first::foobar", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "first::foobar", expectations, expectations);
mock("first").expectOneCall("foobar").withParameter("boo", 1);
mock("first").actualCall("foobar");
@@ -151,4 +151,3 @@ TEST(MockHierarchyTest, reporterIsInheritedInHierarchicalMocks)
MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "differentScope::foobar", expectations);
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
}
-
diff --git a/tests/CppUTestExt/MockNamedValueTest.cpp b/tests/CppUTestExt/MockNamedValueTest.cpp
index ef739c39a..0a0286f8f 100644
--- a/tests/CppUTestExt/MockNamedValueTest.cpp
+++ b/tests/CppUTestExt/MockNamedValueTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,10 +37,10 @@ class MyComparator : public MockNamedValueComparator
public:
MyComparator() {}
- virtual ~MyComparator() _destructor_override {}
+ virtual ~MyComparator() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- virtual bool isEqual(const void*, const void*) _override { return false; }
- virtual SimpleString valueToString(const void*) _override { return ""; }
+ virtual bool isEqual(const void*, const void*) CPPUTEST_OVERRIDE { return false; }
+ virtual SimpleString valueToString(const void*) CPPUTEST_OVERRIDE { return ""; }
};
class MyCopier : public MockNamedValueCopier
@@ -48,9 +48,9 @@ class MyCopier : public MockNamedValueCopier
public:
MyCopier() {}
- virtual ~MyCopier() _destructor_override {}
+ virtual ~MyCopier() CPPUTEST_DESTRUCTOR_OVERRIDE {}
- virtual void copy(void*, const void*) _override {}
+ virtual void copy(void*, const void*) CPPUTEST_OVERRIDE {}
};
TEST(ComparatorsAndCopiersRepository, InstallCopierAndRetrieveIt)
@@ -83,12 +83,12 @@ TEST(ComparatorsAndCopiersRepository, InstallComparatorsAndCopiersFromRepository
source.installCopier("MyType", copier);
source.installComparator("MyType", comparator);
-
+
target.installComparatorsAndCopiers(source);
-
+
POINTERS_EQUAL(&comparator, target.getComparatorForType("MyType"));
POINTERS_EQUAL(&copier, target.getCopierForType("MyType"));
-
+
source.clear();
target.clear();
}
@@ -96,12 +96,12 @@ TEST(ComparatorsAndCopiersRepository, InstallComparatorsAndCopiersFromRepository
TEST_GROUP(MockNamedValue)
{
MockNamedValue * value;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
value = new MockNamedValue("param");
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete value;
}
diff --git a/tests/CppUTestExt/MockParameterTest.cpp b/tests/CppUTestExt/MockParameterTest.cpp
index 7373fe0bc..54f719662 100644
--- a/tests/CppUTestExt/MockParameterTest.cpp
+++ b/tests/CppUTestExt/MockParameterTest.cpp
@@ -14,7 +14,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -31,7 +31,7 @@
TEST_GROUP(MockParameterTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().checkExpectations();
mock().clear();
@@ -63,11 +63,11 @@ TEST(MockParameterTest, expectOneIntegerParameterAndValue)
mock().checkExpectations();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockParameterTest, expectOneUnsignedLongLongIntegerParameterAndValue)
{
- unsigned long long value = 0xFFFFAAAAFFFFAAAA;
+ unsigned long long value = 0xFFFFAAAAFFFFAAAAULL;
mock().expectOneCall("foo").withParameter("parameter", value);
mock().actualCall("foo").withParameter("parameter", value);
@@ -76,7 +76,7 @@ TEST(MockParameterTest, expectOneUnsignedLongLongIntegerParameterAndValue)
TEST(MockParameterTest, expectOneLongLongIntegerParameterAndValue)
{
- long long value = 0x7FFFAAAAFFFFAAAA;
+ long long value = 0x7FFFAAAAFFFFAAAAULL;
mock().expectOneCall("foo").withParameter("parameter", value);
mock().actualCall("foo").withParameter("parameter", value);
@@ -152,7 +152,7 @@ TEST(MockParameterTest, mismatchedIntegerTypesLongAndUnsignedLongAreAllowed)
mock().checkExpectations();
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockParameterTest, mismatchedIntegerTypesIntAndLongLongAreAllowed)
{
@@ -535,7 +535,7 @@ TEST(MockParameterTest, calledWithoutParameters)
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withParameter("p1", 1);
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations);
mock().expectOneCall("foo").withParameter("p1", 1);
mock().actualCall("foo");
@@ -566,7 +566,7 @@ TEST(MockParameterTest, ignoreOtherParametersButExpectedParameterDidntHappen)
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withParameter("p1", 1).ignoreOtherParameters();
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations);
mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters();
mock().actualCall("foo").withParameter("p2", 2).withParameter("p3", 3).withParameter("p4", 4);
@@ -613,7 +613,7 @@ TEST(MockParameterTest, newCallStartsWhileNotAllParametersWerePassed)
MockExpectedCallsListForTest expectations;
expectations.addFunction("foo")->withParameter("p1", 1);
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations);
mock().expectOneCall("foo").withParameter("p1", 1);
mock().actualCall("foo");
@@ -703,7 +703,7 @@ TEST(MockParameterTest, outputParameterMissing)
mock().actualCall("foo");
expectations.addFunction("foo")->withOutputParameterReturning("output", &output, sizeof(output));
- MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations);
+ MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations);
mock().checkExpectations();
CHECK_EXPECTED_MOCK_FAILURE(expectedFailure);
@@ -889,7 +889,7 @@ TEST(MockParameterTest, ignoreOtherCallsIgnoresWithAllKindsOfParameters)
.withParameter("bar", 1u)
.withParameter("foo", 1l)
.withParameter("hey", 1ul)
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
.withParameter("ick", 1ll)
.withParameter("grr", 1ull)
#endif
@@ -930,4 +930,3 @@ TEST(MockParameterTest, expectMultipleMultipleCallsWithParameters)
mock().checkExpectations();
}
-
diff --git a/tests/CppUTestExt/MockPluginTest.cpp b/tests/CppUTestExt/MockPluginTest.cpp
index a9f947367..e3c13a20b 100644
--- a/tests/CppUTestExt/MockPluginTest.cpp
+++ b/tests/CppUTestExt/MockPluginTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -40,13 +40,13 @@ TEST_GROUP(MockPlugin)
MockSupportPlugin plugin;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
test = new UtestShell("group", "name", "file", 1);
result = new TestResult(output);
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete test;
delete result;
@@ -92,11 +92,11 @@ TEST(MockPlugin, checkExpectationsWorksAlsoWithHierachicalObjects)
class DummyComparator : public MockNamedValueComparator
{
public:
- bool isEqual(const void* object1, const void* object2)
+ bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
{
return object1 == object2;
}
- SimpleString valueToString(const void*)
+ SimpleString valueToString(const void*) CPPUTEST_OVERRIDE
{
return "string";
}
@@ -120,7 +120,7 @@ TEST(MockPlugin, installComparatorRecordsTheComparatorButNotInstallsItYet)
class DummyCopier : public MockNamedValueCopier
{
public:
- void copy(void* dst, const void* src)
+ void copy(void* dst, const void* src) CPPUTEST_OVERRIDE
{
*(int*)dst = *(const int*)src;
}
@@ -160,7 +160,7 @@ TEST(MockPlugin, preTestActionWillEnableMultipleComparatorsToTheGlobalMockSuppor
plugin.clear();
}
-static void _failTwiceFunction()
+static void failTwiceFunction_()
{
mock().expectOneCall("foobar");
FAIL("This failed");
@@ -170,8 +170,7 @@ TEST(MockPlugin, shouldNotFailAgainWhenTestAlreadyFailed)
{
TestTestingFixture fixture;
fixture.installPlugin(&plugin);
- fixture.setTestFunction(_failTwiceFunction);
+ fixture.setTestFunction(failTwiceFunction_);
fixture.runAllTests();
fixture.assertPrintContains("1 failures, 1 tests, 1 ran, 2 checks,");
}
-
diff --git a/tests/CppUTestExt/MockReturnValueTest.cpp b/tests/CppUTestExt/MockReturnValueTest.cpp
index da412830a..e99890605 100644
--- a/tests/CppUTestExt/MockReturnValueTest.cpp
+++ b/tests/CppUTestExt/MockReturnValueTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,7 +30,7 @@
TEST_GROUP(MockReturnValueTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().checkExpectations();
mock().clear();
@@ -106,7 +106,7 @@ TEST(MockReturnValueTest, UnsignedIntReturnValueCanBeRetrievedAsUnsignedLongInt)
UNSIGNED_LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue());
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockReturnValueTest, PositiveIntReturnValueCanBeRetrievedAsUnsignedLongLongInt)
{
@@ -145,7 +145,7 @@ TEST(MockReturnValueTest, UnsignedLongIntReturnValueCanBeRetrievedAsUnsignedLong
TEST(MockReturnValueTest, UnsignedLongLongIntReturnValueCanBeRetrieved)
{
- unsigned long long int expected_value = ULLONG_MAX;
+ unsigned long long int expected_value = 2ULL;
mock().expectOneCall("foo").andReturnValue(expected_value);
UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue());
}
@@ -180,7 +180,7 @@ TEST(MockReturnValueTest, UnsignedLongIntReturnValueCanBeRetrievedAsLongLongInt)
TEST(MockReturnValueTest, LongLongIntReturnValueCanBeRetrieved)
{
- long long int expected_value = LLONG_MAX;
+ long long int expected_value = 2LL;
mock().expectOneCall("foo").andReturnValue(expected_value);
LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue());
}
@@ -284,11 +284,11 @@ TEST(MockReturnValueTest, WhenNoLongIntegerReturnValueIsExpectedButThereIsADefau
LONGS_EQUAL(default_return_value, mock().returnLongIntValueOrDefault(default_return_value));
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockReturnValueTest, WhenAUnsignedLongLongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault)
{
- unsigned long long int default_return_value = ULLONG_MAX;
+ unsigned long long int default_return_value = 2ULL;
unsigned long long int expected_return_value = default_return_value - 1;
mock().expectOneCall("foo").andReturnValue(expected_return_value);
LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnUnsignedLongLongIntValueOrDefault(default_return_value));
@@ -297,7 +297,7 @@ TEST(MockReturnValueTest, WhenAUnsignedLongLongIntegerReturnValueIsExpectedAndAl
TEST(MockReturnValueTest, WhenNoUnsignedLongLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue)
{
- unsigned long long int default_return_value = ULLONG_MAX;
+ unsigned long long int default_return_value = 2ULL;
mock().expectOneCall("foo");
LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnUnsignedLongLongIntValueOrDefault(default_return_value));
LONGS_EQUAL(default_return_value, mock().returnUnsignedLongLongIntValueOrDefault(default_return_value));
@@ -305,7 +305,7 @@ TEST(MockReturnValueTest, WhenNoUnsignedLongLongIntegerReturnValueIsExpectedButT
TEST(MockReturnValueTest, WhenALongLongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault)
{
- long long int default_return_value = LLONG_MAX;
+ long long int default_return_value = 2LL;
long long int expected_return_value = default_return_value - 1;
mock().expectOneCall("foo").andReturnValue(expected_return_value);
LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnLongLongIntValueOrDefault(default_return_value));
@@ -314,7 +314,7 @@ TEST(MockReturnValueTest, WhenALongLongIntegerReturnValueIsExpectedAndAlsoThereI
TEST(MockReturnValueTest, WhenNoLongLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue)
{
- long long int default_return_value = LLONG_MAX;
+ long long int default_return_value = 2LL;
mock().expectOneCall("foo");
LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnLongLongIntValueOrDefault(default_return_value));
LONGS_EQUAL(default_return_value, mock().returnLongLongIntValueOrDefault(default_return_value));
@@ -518,7 +518,7 @@ TEST(MockReturnValueTest, UnsignedLongIntegerReturnValueSetsDifferentValuesWhile
LONGS_EQUAL(another_ret_value, mock().returnValue().getUnsignedLongIntValue());
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockReturnValueTest, LongLongIntegerReturnValue)
{
@@ -745,4 +745,3 @@ TEST(MockReturnValueTest, whenCallingDisabledOrIgnoredActualCallsThenTheyDontRet
CHECK(!mock().hasReturnValue());
}
-
diff --git a/tests/CppUTestExt/MockStrictOrderTest.cpp b/tests/CppUTestExt/MockStrictOrderTest.cpp
index 400471d21..9151ffa5e 100644
--- a/tests/CppUTestExt/MockStrictOrderTest.cpp
+++ b/tests/CppUTestExt/MockStrictOrderTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -30,7 +30,7 @@
TEST_GROUP(MockStrictOrderTest)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().clear();
}
diff --git a/tests/CppUTestExt/MockSupportTest.cpp b/tests/CppUTestExt/MockSupportTest.cpp
index 09083afd6..bf6d3a000 100644
--- a/tests/CppUTestExt/MockSupportTest.cpp
+++ b/tests/CppUTestExt/MockSupportTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -37,7 +37,7 @@ TEST_GROUP(MockSupportTest)
MockExpectedCallsListForTest expectations;
MockFailureReporterInstaller failureReporterInstaller;
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().checkExpectations();
CHECK_NO_MOCK_FAILURE();
@@ -173,7 +173,7 @@ TEST_GROUP(MockSupportTestWithFixture)
{
TestTestingFixture fixture;
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock().clear();
MockFailureReporterForTest::clearReporter();
@@ -231,6 +231,7 @@ static void unexpectedCallTestFunction_(void)
TEST(MockSupportTestWithFixture, shouldCrashOnFailure)
{
+ cpputestHasCrashed = false;
mock().crashOnFailure(true);
UtestShell::setCrashMethod(crashMethod);
fixture.setTestFunction(unexpectedCallTestFunction_);
@@ -256,6 +257,21 @@ TEST(MockSupportTestWithFixture, ShouldNotCrashOnFailureAfterCrashMethodWasReset
CHECK_FALSE(cpputestHasCrashed);
}
+TEST(MockSupportTestWithFixture, shouldCrashOnFailureWithCppUTestSetting)
+{
+ cpputestHasCrashed = false;
+ UtestShell::setCrashOnFail();
+ UtestShell::setCrashMethod(crashMethod);
+ fixture.setTestFunction(unexpectedCallTestFunction_);
+
+ fixture.runAllTests();
+
+ CHECK(cpputestHasCrashed);
+
+ UtestShell::restoreDefaultTestTerminator();
+ UtestShell::resetCrashMethod();
+}
+
TEST(MockSupportTestWithFixture, failedMockShouldFailAgainWhenRepeated)
{
fixture.setTestFunction(unexpectedCallTestFunction_);
@@ -268,4 +284,3 @@ TEST(MockSupportTestWithFixture, failedMockShouldFailAgainWhenRepeated)
fixture.flushOutputAndResetResult();
}
}
-
diff --git a/tests/CppUTestExt/MockSupport_cTest.cpp b/tests/CppUTestExt/MockSupport_cTest.cpp
index 3aff93d7d..f35855299 100644
--- a/tests/CppUTestExt/MockSupport_cTest.cpp
+++ b/tests/CppUTestExt/MockSupport_cTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -43,7 +43,7 @@ extern "C" {
TEST_GROUP(MockSupport_c)
{
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
mock_c()->clear();
}
@@ -164,7 +164,7 @@ TEST(MockSupport_c, doubleParameterWithTolerance)
mock_c( )->actualCall("foo")->withDoubleParameters("p", 1.9);
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockSupport_c, longLongIntParameter)
{
@@ -369,7 +369,7 @@ TEST(MockSupport_c, whenNoReturnValueIsGivenReturnUnsignedLongIntValueOrDefaultS
LONGS_EQUAL(defaultValue, mock_c()->returnUnsignedLongIntValueOrDefault(defaultValue));
}
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
TEST(MockSupport_c, returnLongLongIntValue)
{
@@ -686,6 +686,40 @@ TEST_ORDERED(MockSupport_c, nextTestShouldNotCrashOnFailure, 22)
UtestShell::resetCrashMethod();
}
+TEST(MockSupport_c, FailWillNotCrashIfNotEnabled)
+{
+ cpputestHasCrashed = false;
+ TestTestingFixture fixture;
+ UtestShell::setCrashMethod(crashMethod);
+
+ fixture.setTestFunction(failedCallToMockC);
+
+ fixture.runAllTests();
+
+ CHECK_FALSE(cpputestHasCrashed);
+ LONGS_EQUAL(1, fixture.getFailureCount());
+
+ UtestShell::resetCrashMethod();
+}
+
+TEST(MockSupport_c, FailWillCrashIfEnabled)
+{
+ cpputestHasCrashed = false;
+ TestTestingFixture fixture;
+ UtestShell::setCrashOnFail();
+ UtestShell::setCrashMethod(crashMethod);
+
+ fixture.setTestFunction(failedCallToMockC);
+
+ fixture.runAllTests();
+
+ CHECK(cpputestHasCrashed);
+ LONGS_EQUAL(1, fixture.getFailureCount());
+
+ UtestShell::restoreDefaultTestTerminator();
+ UtestShell::resetCrashMethod();
+}
+
static void failingCallToMockCWithParameterOfType_()
{
mock_c()->expectOneCall("bar")->withParameterOfType("typeName", "name", (const void*) 1);
diff --git a/tests/CppUTestExt/MockSupport_cTestCFile.c b/tests/CppUTestExt/MockSupport_cTestCFile.c
index 77e4bdabd..e3ad5fb1a 100644
--- a/tests/CppUTestExt/MockSupport_cTestCFile.c
+++ b/tests/CppUTestExt/MockSupport_cTestCFile.c
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -53,7 +53,7 @@ void all_mock_support_c_calls(void)
withUnsignedIntParameters("unsigned", 1)->
withLongIntParameters("long int", (long int) -1)->
withUnsignedLongIntParameters("unsigned long int", (unsigned long int) 1)->
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
withLongLongIntParameters("long long int", (long long int) -1)->
withUnsignedLongLongIntParameters("unsigned long long int", (unsigned long long int) 1)->
#endif
@@ -72,7 +72,7 @@ void all_mock_support_c_calls(void)
withUnsignedIntParameters("unsigned", 1)->
withLongIntParameters("long int", (long int) -1)->
withUnsignedLongIntParameters("unsigned long int", (unsigned long int) 1)->
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
withLongLongIntParameters("long long int", (long long int) -1)->
withUnsignedLongLongIntParameters("unsigned long long int", (unsigned long long int) 1)->
#endif
@@ -123,7 +123,7 @@ void all_mock_support_c_calls(void)
mock_c()->actualCall("boo3")->unsignedLongIntReturnValue();
mock_c()->unsignedLongIntReturnValue();
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
mock_c()->expectOneCall("mgrgrgr1")->andReturnLongLongIntValue(1);
mock_c()->actualCall("mgrgrgr1")->longLongIntReturnValue();
mock_c()->longLongIntReturnValue();
@@ -189,7 +189,7 @@ void all_mock_support_c_calls(void)
mock_c()->returnUnsignedIntValueOrDefault(1);
mock_c()->returnLongIntValueOrDefault(-1L);
mock_c()->returnUnsignedLongIntValueOrDefault(1L);
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
mock_c()->returnLongLongIntValueOrDefault(-1LL);
mock_c()->returnUnsignedLongLongIntValueOrDefault(1ULL);
#endif
diff --git a/tests/CppUTestExt/MockSupport_cTestCFile.h b/tests/CppUTestExt/MockSupport_cTestCFile.h
index 686c75eee..245247494 100644
--- a/tests/CppUTestExt/MockSupport_cTestCFile.h
+++ b/tests/CppUTestExt/MockSupport_cTestCFile.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/CppUTestExt/OrderedTestTest.cpp b/tests/CppUTestExt/OrderedTestTest.cpp
index 31fa74084..0273cf587 100644
--- a/tests/CppUTestExt/OrderedTestTest.cpp
+++ b/tests/CppUTestExt/OrderedTestTest.cpp
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
@@ -44,7 +44,7 @@ TEST_GROUP(TestOrderedTest)
ExecFunctionTestShell normalTest3;
OrderedTestShell* orderedTestCache;
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
orderedTestCache = OrderedTestShell::getOrderedTestHead();
OrderedTestShell::setOrderedTestHead(NULLPTR);
@@ -53,7 +53,7 @@ TEST_GROUP(TestOrderedTest)
fixture->getRegistry()->unDoLastAddTest();
}
- void teardown()
+ void teardown() CPPUTEST_OVERRIDE
{
delete fixture;
OrderedTestShell::setOrderedTestHead(orderedTestCache);
@@ -82,7 +82,7 @@ TEST_GROUP(TestOrderedTest)
TEST(TestOrderedTest, TestInstallerSetsFields)
{
- OrderedTestInstaller(orderedTest, "testgroup", "testname", "this.cpp", 10, 5);
+ OrderedTestInstaller installer(orderedTest, "testgroup", "testname", "this.cpp", 10, 5);
STRCMP_EQUAL("testgroup", orderedTest.getGroup().asCharString());
STRCMP_EQUAL("testname", orderedTest.getName().asCharString());
STRCMP_EQUAL("this.cpp", orderedTest.getFile().asCharString());
@@ -169,7 +169,7 @@ int OrderedTestTestingFixture::count_ = 0;
TEST_GROUP(TestOrderedTestMacros)
{
- void setup()
+ void setup() CPPUTEST_OVERRIDE
{
OrderedTestTestingFixture::checkRun(TestRegistry::getCurrentRegistry()->getCurrentRepetition());
}
diff --git a/tests/CppUTestExt/OrderedTestTest.h b/tests/CppUTestExt/OrderedTestTest.h
index 088115191..4d6afbac4 100644
--- a/tests/CppUTestExt/OrderedTestTest.h
+++ b/tests/CppUTestExt/OrderedTestTest.h
@@ -13,7 +13,7 @@
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
diff --git a/tests/DummyUTestPlatform/DummyUTestPlatform.cpp b/tests/DummyUTestPlatform/DummyUTestPlatform.cpp
new file mode 100644
index 000000000..948c85dbe
--- /dev/null
+++ b/tests/DummyUTestPlatform/DummyUTestPlatform.cpp
@@ -0,0 +1,140 @@
+#include
+
+typedef char jmp_buf[200];
+
+TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment()
+{
+ return TestOutput::eclipse;
+}
+
+void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) = NULLPTR;
+int (*PlatformSpecificFork)(void) = NULLPTR;
+int (*PlatformSpecificWaitPid)(int pid, int* status, int options) = NULLPTR;
+
+static jmp_buf test_exit_jmp_buf[10];
+static int jmp_buf_index = 0;
+
+extern "C" int setjmp(jmp_buf);
+static int fakeSetJmp(void (*function)(void* data), void* data)
+{
+ if (0 == setjmp(test_exit_jmp_buf[jmp_buf_index])) {
+ jmp_buf_index++;
+ function(data);
+ jmp_buf_index--;
+ return 1;
+ }
+ return 0;
+}
+int (*PlatformSpecificSetJmp)(void (*function)(void*), void* data) = fakeSetJmp;
+
+extern "C" void longjmp(jmp_buf, int);
+static void fakeLongJmp(void)
+{
+ jmp_buf_index--;
+ longjmp(test_exit_jmp_buf[jmp_buf_index], 1);
+}
+void (*PlatformSpecificLongJmp)(void) = fakeLongJmp;
+
+static void fakeRestoreJumpBuffer()
+{
+ jmp_buf_index--;
+}
+void (*PlatformSpecificRestoreJumpBuffer)(void) = fakeRestoreJumpBuffer;
+
+static unsigned long fakeTimeInMillis(void)
+{
+ return 0;
+}
+unsigned long (*GetPlatformSpecificTimeInMillis)(void) = fakeTimeInMillis;
+
+static const char* fakeTimeString(void)
+{
+ return "";
+}
+const char* (*GetPlatformSpecificTimeString)() = fakeTimeString;
+
+extern "C" int vsnprintf(char*, size_t, const char*, va_list);
+int (*PlatformSpecificVSNprintf)(char* str, size_t size, const char* format, va_list va_args_list) = vsnprintf;
+
+extern "C" double fabs(double);
+double (*PlatformSpecificFabs)(double d) = fabs;
+
+static int fakeIsNan(double d)
+{
+ return d != d;
+}
+int (*PlatformSpecificIsNan)(double d) = fakeIsNan;
+
+static int fakeIsInf(double d)
+{
+ return !fakeIsNan(d) && fakeIsNan(d - d);
+}
+int (*PlatformSpecificIsInf)(double d) = fakeIsInf;
+
+extern "C" int atexit(void (*func)(void));
+int (*PlatformSpecificAtExit)(void (*func)(void)) = atexit;
+
+extern "C" void* stdout;
+PlatformSpecificFile PlatformSpecificStdOut = stdout;
+
+extern "C" void* fopen(const char*, const char*);
+PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = fopen;
+
+extern "C" int fputs(const char*, void*);
+static void fakeFPuts(const char* str, PlatformSpecificFile file)
+{
+ fputs(str, file);
+}
+void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = fakeFPuts;
+
+extern "C" int fclose(void* stream);
+static void fakeFClose(PlatformSpecificFile file)
+{
+ fclose(file);
+}
+void (*PlatformSpecificFClose)(PlatformSpecificFile file) = fakeFClose;
+
+extern "C" int fflush(void* stream);
+static void fakeFlush(void)
+{
+ fflush(stdout);
+}
+void (*PlatformSpecificFlush)(void) = fakeFlush;
+
+static void fakeSrand(unsigned int){};
+void (*PlatformSpecificSrand)(unsigned int) = fakeSrand;
+
+static int fakeRand(void)
+{
+ return 0;
+}
+int (*PlatformSpecificRand)(void) = fakeRand;
+
+extern "C" void* malloc(size_t);
+void* (*PlatformSpecificMalloc)(size_t) = malloc;
+
+extern "C" void* realloc(void* ptr, size_t new_size);
+void* (*PlatformSpecificRealloc)(void* memory, size_t size) = realloc;
+
+extern "C" void free(void*);
+void (*PlatformSpecificFree)(void* memory) = free;
+
+extern "C" void* memcpy(void* dest, const void* src, size_t count);
+void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size) = memcpy;
+
+extern "C" void* memset(void* dest, int ch, size_t count);
+void* (*PlatformSpecificMemset)(void* mem, int c, size_t size) = memset;
+
+static PlatformSpecificMutex fakeMutexCreate(void)
+{
+ return 0;
+}
+PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = fakeMutexCreate;
+
+static void fakeMutexFunc(PlatformSpecificMutex) {}
+void (*PlatformSpecificMutexLock)(PlatformSpecificMutex mtx) = fakeMutexFunc;
+void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex mtx) = fakeMutexFunc;
+void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex mtx) = fakeMutexFunc;
+
+extern "C" void abort(void);
+void (*PlatformSpecificAbort)(void) = abort;