diff --git a/.clang-format b/.clang-format deleted file mode 100644 index a586a94d3..000000000 --- a/.clang-format +++ /dev/null @@ -1,41 +0,0 @@ ---- -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 deleted file mode 100644 index 6a48af4f9..000000000 --- a/.clang-tidy +++ /dev/null @@ -1,11 +0,0 @@ ---- -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/.git-blame-ignore-revs b/.git-blame-ignore-revs deleted file mode 100644 index 30c51b94f..000000000 --- a/.git-blame-ignore-revs +++ /dev/null @@ -1,7 +0,0 @@ -# Enable via `git config blame.ignoreRevsFile .git-blame-ignore-revs` - -# Fix line endings -e674cfe759b20c6b78becbc50d8f9f644d32ea8a - -# clang-format -2a4942eb93b823c9723d4797222d6d3315f3bef2 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 2bdb94418..000000000 --- a/.gitattributes +++ /dev/null @@ -1,20 +0,0 @@ -* text=auto - -*.c text -*.h text -*.cpp text - -# Windows files -*.sln text eol=crlf -*.bat text eol=crlf -*.dsp text eol=crlf -*.dsw text eol=crlf -*.dep text eol=crlf -*.mak text eol=crlf -*.vcproj text eol=crlf -*.vcxproj text eol=crlf - - -*.sh text -*.ac text -*.am text diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml deleted file mode 100644 index f89f04cb8..000000000 --- a/.github/workflows/basic.yml +++ /dev/null @@ -1,432 +0,0 @@ ---- -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@v3 - 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@v3 - - 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: - TERM: linux - steps: - - name: Checkout - uses: actions/checkout@main - - name: Install tools - run: | - sudo apt-get update - sudo apt-get install -y dosbox - - name: Build & Test - run: ./scripts/dos_build_test.sh - - 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: Build - uses: docker/build-push-action@v3 - with: - file: docker/Dockerfile.${{ matrix.image }} - tags: cpputest/${{ matrix.image }}:latest - push: false - - name: Test - run: | - docker run --rm cpputest/${{ matrix.image }}:latest diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml deleted file mode 100644 index d44746601..000000000 --- a/.github/workflows/test-report.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -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 deleted file mode 100644 index fa41116a8..000000000 --- a/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -.DS_Store -*.swp -*.*~ -.*~ -*.d -*.o -*.a -.settings -*doxygen* -*.gcov -*.gcno -*.gcda -*_tests -*_cslim -*a.out -*.zip -tmp -pdfs -*.map -gcov -objs -lib -*_tests.txt -gcov*.html -ErrorLogs -testResults -.metadata -/ipch -Debug -Release -*/Debug/* -*/Release/* -*.exe -*.obj -*.ncb -*.opt -*.plg -*.idb -*.pdb -*.suo -*.sdf -*.opensdf -*.lib -*.log -*.tlog -*.cache -*.user -*.VC.db -*.VC.opendb -_build_ -_build -builds/*gcc* -cpputest_build/Makefile -cpputest_build/generated -cpputest_build/src -cpputest_build/tests -/.deps -CppUTestExtTests -CppUTestTests -/Makefile -config.h -config.h.in -config.status -cpputest.pc -filename.map.txt -libtool -stamp-h1 -INSTALL -Makefile.in -aclocal.m4 -compile -config.guess -config.sub -configure -depcomp -install-sh -ltmain.sh -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 -missing -test-driver -platforms/iar/settings -cpputest_*.xml -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/AUTHORS b/AUTHORS deleted file mode 100644 index e3d619e32..000000000 --- a/AUTHORS +++ /dev/null @@ -1,5 +0,0 @@ - -The current main authors of CppUTest are James Grenning and Bas Vodde. - -Thanks for all the other contributions. You can find them on github at: -https://github.com/cpputest/cpputest/graphs/contributors \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 0b6a4eeaf..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,154 +0,0 @@ -# 2.6.3 is needed for ctest support -# 3.1 is needed for target_sources -# 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 -############### -if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") - include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) - message(STATUS "conan_basic_setup()") - conan_basic_setup() -endif() - -include(CTest) - -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() - - -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() - -if(PROJECT_IS_TOP_LEVEL) - include(cmake/warnings.cmake) -endif() -include(GNUInstallDirs) - -# 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" -) - -add_subdirectory(src) - -target_include_directories(CppUTest - PUBLIC - $ -) -target_compile_definitions(CppUTest - PUBLIC - HAVE_CONFIG_H -) - -if (CPPUTEST_BUILD_TESTING) - add_subdirectory(tests) -endif () - -if (CPPUTEST_EXAMPLES) - add_subdirectory(examples) -endif() - -if(PROJECT_IS_TOP_LEVEL) - include(cmake/install.cmake) -endif() diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index a4a3f8327..000000000 --- a/CMakePresets.json +++ /dev/null @@ -1,183 +0,0 @@ -{ - "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/COPYING b/COPYING deleted file mode 100644 index a93bf596e..000000000 --- a/COPYING +++ /dev/null @@ -1,10 +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 COPYRIGHT HOLDERS AND CONTRIBUTORS "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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. \ No newline at end of file diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index 399179154..000000000 --- a/ChangeLog +++ /dev/null @@ -1,4 +0,0 @@ - -For changelog check the github page: -https://github.com/cpputest/cpputest - diff --git a/CppUTest.sln b/CppUTest.sln deleted file mode 100644 index dfae564c3..000000000 --- a/CppUTest.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C++ Express 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllTests", "tests\AllTests.vcproj", "{E66A12BB-1E17-4CFE-A358-9E0FA85E0F15}" - ProjectSection(ProjectDependencies) = postProject - {EC28C821-4AB8-458F-A821-C6E65607B781} = {EC28C821-4AB8-458F-A821-C6E65607B781} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppUTest", "CppUTest.vcproj", "{EC28C821-4AB8-458F-A821-C6E65607B781}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E66A12BB-1E17-4CFE-A358-9E0FA85E0F15}.Debug|Win32.ActiveCfg = Debug|Win32 - {E66A12BB-1E17-4CFE-A358-9E0FA85E0F15}.Debug|Win32.Build.0 = Debug|Win32 - {E66A12BB-1E17-4CFE-A358-9E0FA85E0F15}.Release|Win32.ActiveCfg = Release|Win32 - {E66A12BB-1E17-4CFE-A358-9E0FA85E0F15}.Release|Win32.Build.0 = Release|Win32 - {EC28C821-4AB8-458F-A821-C6E65607B781}.Debug|Win32.ActiveCfg = Debug|Win32 - {EC28C821-4AB8-458F-A821-C6E65607B781}.Debug|Win32.Build.0 = Debug|Win32 - {EC28C821-4AB8-458F-A821-C6E65607B781}.Release|Win32.ActiveCfg = Release|Win32 - {EC28C821-4AB8-458F-A821-C6E65607B781}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/CppUTest.vcproj b/CppUTest.vcproj deleted file mode 100644 index 9a8bfdcc2..000000000 --- a/CppUTest.vcproj +++ /dev/null @@ -1,1102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/CppUTest.vcxproj b/CppUTest.vcxproj deleted file mode 100644 index 4a2f18e61..000000000 --- a/CppUTest.vcxproj +++ /dev/null @@ -1,299 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F468F539-27BD-468E-BE64-DDE641400B51} - - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - 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;%(AdditionalIncludeDirectories) - _LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - winmm.lib;%(AdditionalDependencies) - - - true - .\Debug/CppUTestd.bsc - - - - - - - - true - - - - - Disabled - .\include;%(AdditionalIncludeDirectories) - _LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - winmm.lib;%(AdditionalDependencies) - - - true - .\Debug/CppUTestd.bsc - - - - - - - - true - - - - - Disabled - .\include;%(AdditionalIncludeDirectories) - OnlyExplicitInline - WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - Level3 - true - OldStyle - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - winmm.lib;%(AdditionalDependencies) - - - true - .\Release/CppUTest.bsc - - - - - - - - true - - - - - Disabled - .\include;%(AdditionalIncludeDirectories) - OnlyExplicitInline - WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - Level3 - true - OldStyle - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - winmm.lib;%(AdditionalDependencies) - - - true - .\Release/CppUTest.bsc - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CppUTestConfig.cmake.build.in b/CppUTestConfig.cmake.build.in deleted file mode 100644 index f8931224a..000000000 --- a/CppUTestConfig.cmake.build.in +++ /dev/null @@ -1,9 +0,0 @@ -@PACKAGE_INIT@ - -set_and_check(CppUTest_INCLUDE_DIRS "@PACKAGE_INCLUDE_DIR@") -if(NOT TARGET CppUTest) - include("${CMAKE_CURRENT_LIST_DIR}/CppUTestTargets.cmake") -endif() -set(CppUTest_LIBRARIES CppUTest CppUTestExt) - -check_required_components(CppUTest) diff --git a/CppUTestConfig.cmake.install.in b/CppUTestConfig.cmake.install.in deleted file mode 100644 index 3c79ea3aa..000000000 --- a/CppUTestConfig.cmake.install.in +++ /dev/null @@ -1,9 +0,0 @@ -@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") - -check_required_components(CppUTest) diff --git a/CppUTest_VS201x.sln b/CppUTest_VS201x.sln deleted file mode 100644 index d794568ba..000000000 --- a/CppUTest_VS201x.sln +++ /dev/null @@ -1,36 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllTests", "tests\AllTests.vcxproj", "{913088F6-37C0-4195-80E9-548C7C5303CB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppUTest", "CppUTest.vcxproj", "{F468F539-27BD-468E-BE64-DDE641400B51}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {913088F6-37C0-4195-80E9-548C7C5303CB}.Debug|Win32.ActiveCfg = Debug|Win32 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Debug|Win32.Build.0 = Debug|Win32 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Debug|x64.ActiveCfg = Debug|x64 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Debug|x64.Build.0 = Debug|x64 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Release|Win32.ActiveCfg = Release|Win32 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Release|Win32.Build.0 = Release|Win32 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Release|x64.ActiveCfg = Release|x64 - {913088F6-37C0-4195-80E9-548C7C5303CB}.Release|x64.Build.0 = Release|x64 - {F468F539-27BD-468E-BE64-DDE641400B51}.Debug|Win32.ActiveCfg = Debug|Win32 - {F468F539-27BD-468E-BE64-DDE641400B51}.Debug|Win32.Build.0 = Debug|Win32 - {F468F539-27BD-468E-BE64-DDE641400B51}.Debug|x64.ActiveCfg = Debug|x64 - {F468F539-27BD-468E-BE64-DDE641400B51}.Debug|x64.Build.0 = Debug|x64 - {F468F539-27BD-468E-BE64-DDE641400B51}.Release|Win32.ActiveCfg = Release|Win32 - {F468F539-27BD-468E-BE64-DDE641400B51}.Release|Win32.Build.0 = Release|Win32 - {F468F539-27BD-468E-BE64-DDE641400B51}.Release|x64.ActiveCfg = Release|x64 - {F468F539-27BD-468E-BE64-DDE641400B51}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 09547e330..000000000 --- a/Doxyfile +++ /dev/null @@ -1,1294 +0,0 @@ -# Doxyfile 1.5.3 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = CppUTest - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = cpputest_doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be extracted -# and appear in the documentation as a namespace called 'anonymous_namespace{file}', -# where file will be replaced with the base name of the file that contains the anonymous -# namespace. By default anonymous namespace are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH -# then you must also enable this option. If you don't then doxygen will produce -# a warning and turn it on anyway - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). - -HTML_DYNAMIC_SECTIONS = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the number -# of direct children of the root node in a graph is already larger than -# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 3406079c7..000000000 --- a/Makefile.am +++ /dev/null @@ -1,482 +0,0 @@ - -ACLOCAL_AMFLAGS = -I m4 - -CPPUTEST_TESTS = CppUTestTests -CPPUTESTEXT_TESTS = CppUTestExtTests - -EXTRA_LIBRARIES = lib/libCppUTestExt.a -EXTRA_PROGRAMS = CppUTestExtTests - -lib_LIBRARIES = lib/libCppUTest.a -check_PROGRAMS = $(CPPUTEST_TESTS) - -if INCLUDE_CPPUTEST_EXT -lib_LIBRARIES+= lib/libCppUTestExt.a -check_PROGRAMS += $(CPPUTESTEXT_TESTS) -endif - -if INCLUDE_GMOCKTESTS -# check_PROGRAMS += GTestTests -endif - -TESTS = $(check_PROGRAMS) - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = cpputest.pc - -cmakemodulesdir = $(libdir)/CppUTest/cmake/Modules -cmakemodules_DATA = \ - cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake - -cmakescriptsdir = $(libdir)/CppUTest/cmake/Scripts -cmakescripts_DATA = \ - cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake - -cmakedir = $(libdir)/CppUTest/cmake -cmake_DATA = \ - build/cmake_package_files/CppUTestConfig.cmake \ - build/cmake_package_files/CppUTestConfigVersion.cmake \ - build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake \ - build/cmake_package_files/CppUTestTargets.cmake - -EXTRA_DIST = \ - cpputest.pc.in \ - $(ALL_FILES_IN_GIT) - -lib_libCppUTest_a_CPPFLAGS = $(AM_CPPFLAGS) $(CPPUTEST_CPPFLAGS) $(CPPUTEST_ADDITIONAL_CPPFLAGS) -lib_libCppUTest_a_CFLAGS = $(AM_CFLAGS) $(CPPUTEST_CFLAGS) $(CPPUTEST_ADDITIONAL_CFLAGS) -lib_libCppUTest_a_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUTEST_CXXFLAGS) $(CPPUTEST_ADDITIONAL_CXXFLAGS) - -lib_libCppUTest_a_SOURCES = \ - src/CppUTest/CommandLineArguments.cpp \ - src/CppUTest/CommandLineTestRunner.cpp \ - src/CppUTest/JUnitTestOutput.cpp \ - src/CppUTest/MemoryLeakDetector.cpp \ - src/CppUTest/MemoryLeakWarningPlugin.cpp \ - src/CppUTest/SimpleString.cpp \ - src/CppUTest/SimpleStringInternalCache.cpp \ - src/CppUTest/SimpleMutex.cpp \ - src/CppUTest/TeamCityTestOutput.cpp \ - src/CppUTest/TestFailure.cpp \ - src/CppUTest/TestFilter.cpp \ - src/CppUTest/TestHarness_c.cpp \ - src/CppUTest/TestMemoryAllocator.cpp \ - src/CppUTest/TestOutput.cpp \ - src/CppUTest/TestPlugin.cpp \ - src/CppUTest/TestRegistry.cpp \ - src/CppUTest/TestResult.cpp \ - src/CppUTest/TestTestingFixture.cpp \ - src/CppUTest/Utest.cpp \ - src/Platforms/@CPP_PLATFORM@/UtestPlatform.cpp - -include_cpputestdir = $(includedir)/CppUTest - -include_cpputest_HEADERS = \ - include/CppUTest/CommandLineArguments.h \ - include/CppUTest/CommandLineTestRunner.h \ - 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 \ - include/CppUTest/PlatformSpecificFunctions.h \ - include/CppUTest/PlatformSpecificFunctions_c.h \ - include/CppUTest/SimpleString.h \ - include/CppUTest/SimpleStringInternalCache.h \ - include/CppUTest/SimpleMutex.h \ - include/CppUTest/StandardCLibrary.h \ - include/CppUTest/TeamCityTestOutput.h \ - include/CppUTest/TestFailure.h \ - include/CppUTest/TestFilter.h \ - include/CppUTest/TestHarness.h \ - include/CppUTest/TestHarness_c.h \ - include/CppUTest/TestMemoryAllocator.h \ - include/CppUTest/TestOutput.h \ - include/CppUTest/TestPlugin.h \ - include/CppUTest/TestRegistry.h \ - include/CppUTest/TestResult.h \ - include/CppUTest/TestTestingFixture.h \ - include/CppUTest/Utest.h \ - include/CppUTest/UtestMacros.h \ - generated/CppUTestGeneratedConfig.h - -lib_libCppUTestExt_a_CPPFLAGS = $(lib_libCppUTest_a_CPPFLAGS) -lib_libCppUTestExt_a_CFLAGS = $(lib_libCppUTest_a_CFLAGS) -lib_libCppUTestExt_a_CXXFLAGS = $(lib_libCppUTest_a_CXXFLAGS) - -lib_libCppUTestExt_a_SOURCES = \ - src/CppUTestExt/CodeMemoryReportFormatter.cpp \ - src/CppUTestExt/GTest.cpp \ - src/CppUTestExt/IEEE754ExceptionsPlugin.cpp \ - src/CppUTestExt/MemoryReportAllocator.cpp \ - src/CppUTestExt/MemoryReporterPlugin.cpp \ - src/CppUTestExt/MemoryReportFormatter.cpp \ - src/CppUTestExt/MockActualCall.cpp \ - src/CppUTestExt/MockExpectedCall.cpp \ - src/CppUTestExt/MockExpectedCallsList.cpp \ - src/CppUTestExt/MockFailure.cpp \ - src/CppUTestExt/MockNamedValue.cpp \ - src/CppUTestExt/MockSupport.cpp \ - src/CppUTestExt/MockSupportPlugin.cpp \ - src/CppUTestExt/MockSupport_c.cpp \ - src/CppUTestExt/OrderedTest.cpp - -if INCLUDE_CPPUTEST_EXT -include_cpputestextdir = $(includedir)/CppUTestExt - -include_cpputestext_HEADERS = \ - include/CppUTestExt/CodeMemoryReportFormatter.h \ - include/CppUTestExt/GMock.h \ - include/CppUTestExt/GTest.h \ - include/CppUTestExt/GTestSupport.h \ - include/CppUTestExt/GTestConvertor.h \ - include/CppUTestExt/IEEE754ExceptionsPlugin.h \ - include/CppUTestExt/MemoryReportAllocator.h \ - include/CppUTestExt/MemoryReporterPlugin.h \ - include/CppUTestExt/MemoryReportFormatter.h \ - include/CppUTestExt/MockActualCall.h \ - include/CppUTestExt/MockCheckedActualCall.h \ - include/CppUTestExt/MockCheckedExpectedCall.h \ - include/CppUTestExt/MockExpectedCall.h \ - include/CppUTestExt/MockExpectedCallsList.h \ - include/CppUTestExt/MockFailure.h \ - include/CppUTestExt/MockNamedValue.h \ - include/CppUTestExt/MockSupport.h \ - include/CppUTestExt/MockSupportPlugin.h \ - include/CppUTestExt/MockSupport_c.h \ - include/CppUTestExt/OrderedTest.h - -endif - -CppUTestTests_CPPFLAGS = $(lib_libCppUTest_a_CPPFLAGS) -CppUTestTests_CFLAGS = $(lib_libCppUTest_a_CFLAGS) -CppUTestTests_CXXFLAGS = $(lib_libCppUTest_a_CXXFLAGS) -CppUTestTests_LDADD = lib/libCppUTest.a $(CPPUTEST_LDADD) -CppUTestTests_LDFLAGS = $(AM_LDFLAGS) $(CPPUTEST_LDFLAGS) $(CPPUTEST_ADDITIONAL_LDFLAGS) - -CppUTestTests_SOURCES = \ - tests/CppUTest/AllocationInCFile.c \ - tests/CppUTest/AllocationInCppFile.cpp \ - tests/CppUTest/AllocLetTestFree.c \ - tests/CppUTest/AllocLetTestFreeTest.cpp \ - tests/CppUTest/AllTests.cpp \ - tests/CppUTest/CheatSheetTest.cpp \ - tests/CppUTest/CompatabilityTests.cpp \ - tests/CppUTest/CommandLineArgumentsTest.cpp \ - tests/CppUTest/CommandLineTestRunnerTest.cpp \ - tests/CppUTest/DummyMemoryLeakDetector.cpp \ - tests/CppUTest/JUnitOutputTest.cpp \ - tests/CppUTest/MemoryLeakDetectorTest.cpp \ - tests/CppUTest/MemoryOperatorOverloadTest.cpp \ - tests/CppUTest/MemoryLeakWarningTest.cpp \ - tests/CppUTest/PluginTest.cpp \ - tests/CppUTest/PreprocessorTest.cpp \ - tests/CppUTest/SetPluginTest.cpp \ - tests/CppUTest/SimpleStringTest.cpp \ - tests/CppUTest/SimpleStringCacheTest.cpp \ - tests/CppUTest/SimpleMutexTest.cpp \ - tests/CppUTest/TeamCityOutputTest.cpp \ - tests/CppUTest/TestFailureNaNTest.cpp \ - tests/CppUTest/TestFailureTest.cpp \ - tests/CppUTest/TestFilterTest.cpp \ - tests/CppUTest/TestHarness_cTest.cpp \ - tests/CppUTest/TestHarness_cTestCFile.c \ - tests/CppUTest/TestInstallerTest.cpp \ - tests/CppUTest/TestMemoryAllocatorTest.cpp \ - tests/CppUTest/TestOutputTest.cpp \ - tests/CppUTest/TestRegistryTest.cpp \ - tests/CppUTest/TestResultTest.cpp \ - tests/CppUTest/TestUTestMacro.cpp \ - tests/CppUTest/TestUTestStringMacro.cpp \ - tests/CppUTest/UtestTest.cpp \ - tests/CppUTest/UtestPlatformTest.cpp - -CppUTestExtTests_CPPFLAGS = $(lib_libCppUTestExt_a_CPPFLAGS) -CppUTestExtTests_CFLAGS = $(lib_libCppUTestExt_a_CFLAGS) -CppUTestExtTests_CXXFLAGS = $(lib_libCppUTestExt_a_CXXFLAGS) -CppUTestExtTests_LDADD = lib/libCppUTestExt.a lib/libCppUTest.a $(CPPUTEST_LDADD) -CppUTestExtTests_LDFLAGS = $(CppUTestTests_LDFLAGS) - -CppUTestExtTests_SOURCES = \ - tests/CppUTestExt/AllTests.cpp \ - tests/CppUTestExt/CodeMemoryReporterTest.cpp \ - tests/CppUTestExt/GMockTest.cpp \ - tests/CppUTestExt/GTest1Test.cpp \ - tests/CppUTestExt/GTest2ConvertorTest.cpp \ - tests/CppUTestExt/IEEE754PluginTest.cpp \ - tests/CppUTestExt/IEEE754PluginTest_c.c \ - tests/CppUTestExt/MemoryReportAllocatorTest.cpp \ - tests/CppUTestExt/MemoryReporterPluginTest.cpp \ - tests/CppUTestExt/MemoryReportFormatterTest.cpp \ - tests/CppUTestExt/MockActualCallTest.cpp \ - tests/CppUTestExt/MockCheatSheetTest.cpp \ - tests/CppUTestExt/MockCallTest.cpp \ - tests/CppUTestExt/MockComparatorCopierTest.cpp \ - tests/CppUTestExt/MockExpectedCallTest.cpp \ - tests/CppUTestExt/ExpectedFunctionsListTest.cpp \ - tests/CppUTestExt/MockFailureReporterForTest.cpp \ - tests/CppUTestExt/MockFailureTest.cpp \ - tests/CppUTestExt/MockHierarchyTest.cpp \ - tests/CppUTestExt/MockNamedValueTest.cpp \ - tests/CppUTestExt/MockParameterTest.cpp \ - tests/CppUTestExt/MockPluginTest.cpp \ - tests/CppUTestExt/MockSupportTest.cpp \ - tests/CppUTestExt/MockSupport_cTest.cpp \ - tests/CppUTestExt/MockSupport_cTestCFile.c \ - tests/CppUTestExt/MockStrictOrderTest.cpp \ - tests/CppUTestExt/MockReturnValueTest.cpp \ - tests/CppUTestExt/OrderedTestTest.cpp \ - tests/CppUTestExt/OrderedTestTest_c.c \ - tests/CppUTestExt/MockFakeLongLong.cpp - -DISTCLEANFILES = \ - filename.map.txt \ - generated/CppUTestGeneratedConfig.h - -if INCLUDE_GMOCKTESTS - -#GTestTests_CPPFLAGS = $(lib_libCppUTestExt_a_CPPFLAGS) -#GTestTests_CFLAGS = $(lib_libCppUTestExt_a_CFLAGS) -#GTestTests_CXXFLAGS = $(lib_libCppUTestExt_a_CXXFLAGS) -DCPPUTEST_USE_MEM_LEAK_DETECTION=0 -DGMOCK_RENAME_MAIN=1 -D_THREAD_SAFE -DGTEST_HAS_PTHREAD=1 -#GTestTests_LDADD = lib/libCppUTestExt.a lib/libCppUTest.a $(CPPUTEST_LDADD) -#GTestTests_LDFLAGS = $(CppUTestTests_LDFLAGS) - -#GTestTests_SOURCES = \ - $(GMOCK_HOME)/test/gmock-spec-builders_test.cc \ - tests/CppUTestExt/AllTests.cpp -endif - -RUN_CPPUTEST_TESTS = ./$(CPPUTEST_TESTS) -RUN_CPPUTESTEXT_TESTS = ./$(CPPUTESTEXT_TESTS) - -valgrind: check - @if test "x$(CPPUTEST_HAS_VALGRIND)" = xno; then echo "Running the valgrind target without having valgrind. Perhaps install it first?"; exit 1; fi - valgrind --dsymutil=yes --suppressions=$(srcdir)/valgrind.suppressions --gen-suppressions=all --error-exitcode=1 ./$(CPPUTEST_TESTS) - -tdd: $(CPPUTEST_TESTS)$(EXEEXT) $(CPPUTESTEXT_TESTS)$(EXEEXT) - ./$(CPPUTEST_TESTS) -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; \ - wget https://github.com/google/googletest/archive/release-1.8.0.zip -O gtest-1.8.0.zip && unzip gtest-1.8.0.zip; \ - cd googletest-release-1.8.0; cmake .; make - -cpputest_build_gtest17: - mkdir -p cpputest_build_gtest17 - cd cpputest_build_gtest17; \ - wget https://github.com/google/googletest/archive/release-1.7.0.zip -O gtest-1.7.0.zip && unzip gtest-1.7.0.zip; \ - wget https://github.com/google/googlemock/archive/release-1.7.0.zip -O gmock-1.7.0.zip && unzip gmock-1.7.0.zip; \ - mv googletest-release-1.7.0 googlemock-release-1.7.0/gtest; \ - cd googlemock-release-1.7.0; autoreconf -i; ./configure && make - -cpputest_build_gtest16: - mkdir -p cpputest_build_gtest16 - cd cpputest_build_gtest16; \ - wget https://github.com/google/googletest/archive/release-1.6.0.zip -O gtest-1.6.0.zip && unzip gtest-1.6.0.zip; \ - wget https://github.com/google/googlemock/archive/release-1.6.0.zip -O gmock-1.6.0.zip && unzip gmock-1.6.0.zip; \ - mv googletest-release-1.6.0 googlemock-release-1.6.0/gtest; \ - cd googlemock-release-1.6.0; autoreconf -i; ./configure CXXFLAGS=-DGTEST_USE_OWN_TR1_TUPLE=1 && make - -cpputest_build_gtest15: - mkdir -p cpputest_build_gtest15 - cd cpputest_build_gtest15; \ - wget https://github.com/google/googletest/archive/release-1.5.0.zip -O gtest-1.5.0.zip && unzip gtest-1.5.0.zip; \ - wget https://github.com/google/googlemock/archive/release-1.5.0.zip -O gmock-1.5.0.zip && unzip gmock-1.5.0.zip; \ - mv googletest-release-1.5.0 googlemock-release-1.5.0/gtest; \ - cd googlemock-release-1.5.0; autoreconf -i; ./configure CXXFLAGS=-DGTEST_USE_OWN_TR1_TUPLE=1 && make - -check_gtest15: cpputest_build_gtest15 - @echo "Build using gmock 1.5"; - export GMOCK_HOME=`pwd`/cpputest_build_gtest15/googlemock-release-1.5.0; \ - make distclean; $(srcdir)/configure --enable-std-cpp98; make check - -check_gtest16: cpputest_build_gtest16 - @echo "Build using gmock 1.6"; - export GMOCK_HOME=`pwd`/cpputest_build_gtest16/googlemock-release-1.6.0; \ - make distclean; $(srcdir)/configure --enable-std-cpp98; make check - -check_gtest17: cpputest_build_gtest17 - @echo "Build using gmock 1.7" - export GMOCK_HOME=`pwd`/cpputest_build_gtest17/googlemock-release-1.7.0; \ - make distclean; $(srcdir)/configure --enable-std-cpp98; make check - -check_gtest18: cpputest_build_gtest18 - @echo "Build using gmock 1.8" - export GMOCK_HOME=`pwd`/cpputest_build_gtest18/googletest-release-1.8.0/googlemock; \ - 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_gtest110 check_gtest111 check_gtest112 - -check_basic: - @echo "If dash is available, run the configure with dash to find bash-isms and increase portability" - make distclean; if test "x$(CPPUTEST_HAS_DASH)" = xyes; then CONFIG_SHELL=dash $(srcdir)/configure; fi - - @echo "Building and valgrinding (skipping this on MacOS due to buggy Valgrind" - if test "x$(CPPUTEST_ON_MACOSX)" = xno; then \ - make distclean; $(srcdir)/configure; make valgrind; \ - fi - - @echo "Building without extensions" - make distclean; $(srcdir)/configure --disable-extensions; make check - - @echo "Building with the Std C++ 98 turned on. Compiler acts differently then." - make distclean; $(srcdir)/configure --enable-std-cpp98; make - - @echo "Building with the Std C++ 11 turned on. Compiler acts differently then." - make distclean; $(srcdir)/configure --enable-std-cpp11; make - - @echo "Building with the Std C++ 14 turned on. Compiler acts differently then." - make distclean; $(srcdir)/configure --enable-std-cpp14; make - - @echo "Building with the Std C++ 17 turned on. Compiler acts differently then." - make distclean; $(srcdir)/configure --enable-std-cpp17; make - - @echo "Building with the Std C++ 20 turned on. Compiler acts differently then." - make distclean; $(srcdir)/configure --enable-std-cpp20; make - - @echo "Building without the Standard C library" - make distclean; $(srcdir)/configure --disable-std-c; make - - @echo "Building without the Standard C++ library and without long long" - make distclean; $(srcdir)/configure --disable-std-cpp --disable-long-long; make check - - @echo "Building without memory leak detection" - make distclean; $(srcdir)/configure --disable-memory-leak-detection; make check - - @echo "Building with address sanitizer" - make distclean; $(srcdir)/configure --enable-sanitize-address; make check - - @echo "Building without memory leak detection and without Standard C++" - make distclean; $(srcdir)/configure --disable-memory-leak-detection --disable-std-cpp; make check - - @echo "Generate a map file while building" - make distclean; $(srcdir)/configure -enable-generate-map-file; make check - if [ -s CppUTest.o.map.txt ]; then echo "Generating map file failed. Build failed!"; exit 1; fi - -check_special_situations: - @echo "Does the system have gcc? $(CPPUTEST_HAS_GCC)" - if test "x$(CPPUTEST_HAS_GCC)" = xyes; then echo "Compiling with gcc"; make distclean; $(srcdir)/configure CC="gcc" CXX="g++"; make check; fi - - @echo "Does the system have clang and is a Mac? $(CPPUTEST_HAS_CLANG)" - if test "x$(CPPUTEST_HAS_CLANG)" = xyes && test "x$(CPPUTEST_ON_MACOSX)" = xyes; then \ - echo "Compiling with clang"; make distclean; $(srcdir)/configure CC="clang" CXX="clang++"; make check; \ - fi - - @echo Testing JUnit output - make distclean; $(srcdir)/configure; make check - ./$(CPPUTEST_TESTS) -ojunit > junit_run_output - if [ -s junit_run_output ]; then echo "JUnit run has output. Build failed!"; exit 1; fi - rm junit_run_output; rm cpputest_*.xml - - @echo "Building with all flags turned off" - make distclean; $(srcdir)/configure --disable-cpputest-flags CFLAGS="" CXXFLAGS="" CPPFLAGS="-I $(srcdir)/include -I$(srcdir)/include/CppUTestExt/CppUTestGTest -I$(srcdir)/include/CppUTestExt/CppUTestGMock" --disable-dependency-tracking; make check - -check_coverage: - @echo "Compile with coverage (switch to clang for Mac OSX)" - if test "x$(CPPUTEST_HAS_CLANG)" = xyes && test "x$(CPPUTEST_ON_MACOSX)" = xyes; then \ - echo "Compiling with clang"; make distclean; $(srcdir)/configure CC="clang" CXX="clang++" --enable-coverage CFLAGS="-O0" CXXFLAGS="-O0"; \ - else \ - make distclean; $(srcdir)/configure -enable-coverage CFLAGS="-O0" CXXFLAGS="-O0"; \ - fi - - make check - - ./$(CPPUTEST_TESTS) >> test_output.txt; ./$(CPPUTESTEXT_TESTS) >> test_output.txt - $(SILENCE)for f in `ls *.gcno` ; do \ - gcov $(CppUTestExtTests_SOURCES) $(CppUTestTests_SOURCES) $(lib_libCppUTest_a_SOURCES) $(lib_libCppUTestExt_a_SOURCES) -o $$f 1>>gcov_output.txt 2>>gcov_error.txt; \ - done - $(srcdir)/scripts/filterGcov.sh gcov_output.txt gcov_error.txt gcov_report.txt test_output.txt - cat gcov_report.txt - if test "x$(CPPUTEST_HAS_LCOV)" = xyes; then lcov -c -d . -o temp.info; lcov -r temp.info /usr\* -o coverage.info; genhtml -o test_coverage coverage.info; fi - -remove_coverage_output: - rm -f gcov_output.txt gcov_error.txt gcov_report.txt test_output.txt gcov_report.txt.html temp.info coverage.info - rm -rf test_coverage - -check_examples: - @echo "Using the old Makefile and examples" - make distclean - $(MAKE) -C $(srcdir) -f Makefile_using_MakefileWorker extensions - $(MAKE) -C $(srcdir)/examples all clean - - @echo "Compiling and running the examples. This will use the old Makefile" - make distclean; $(srcdir)/configure; make; $(MAKE) -C $(srcdir)/examples all clean CPPUTEST_LIB_LINK_DIR="`pwd`/lib" - -check_all: check_basic check_special_situations check_coverage remove_coverage_output check_examples check_gtest - @echo "Last... one normal build and test" - make distclean; $(srcdir)/configure; make check; - @echo "Check running tests repeatedly" - $(RUN_CPPUTEST_TESTS) - r; $(RUN_CPPUTESTEXT_TESTS) -r - @echo "Check running tests in separate process (CppUTestExtTests TEST_GROUP(TestOrderedTestMacro) would have to fail)" - $(RUN_CPPUTEST_TESTS) -p; - -# Mac OSX adds an annoying directory when packaging. This can be prevented by setting COPYFILE_DISABLE=1 -# However, I've not figured out how to set it automatically and neither google nor stackoverflow knew the answer. -# The automake mailing list is still thinking about it, and thus, I've added this check so that I don't forget to do it :) -# More info: http://superuser.com/questions/61185/why-do-i-get-files-like-foo-in-my-tarball-on-os-x -dist-hook: - if test "x$(CPPUTEST_ON_MACOSX)" = "xyes"; then \ - if test ! "x$(COPYFILE_DISABLE)" = "x1"; then \ - echo ""; \ - echo 'ERROR: When packaging on MacOSX, please run "COPYFILE_DISABLE=1 make dist"'; \ - echo ""; \ - exit 1; \ - fi \ - fi - -distclean-local: - test -z "generated" || rmdir generated - diff --git a/Makefile_CppUTestExt b/Makefile_CppUTestExt deleted file mode 100644 index 563dec08d..000000000 --- a/Makefile_CppUTestExt +++ /dev/null @@ -1,25 +0,0 @@ - -#Set this to @ to keep the makefile quiet -ifndef SILENCE - SILENCE = @ -endif - -#---- Outputs ----# -COMPONENT_NAME = CppUTestExt - -#--- Inputs ----# -CPPUTEST_HOME = . -CPP_PLATFORM = Gcc - -WARNINGFLAGS = -pedantic-errors -Wall -Wextra -Werror -Wshadow -Wswitch-default -Wswitch-enum -Wconversion - -SRC_DIRS = src/CppUTestExt - -TEST_SRC_DIRS = tests/CppUTestExt - -INCLUDE_DIRS = $(CPPUTEST_HOME)/include - -LD_LIBRARIES += -lstdc++ -L$(CPPUTEST_LIB_DIR)/$(TARGET_PLATFORM) -lCppUTest - -include $(CPPUTEST_HOME)/build/MakefileWorker.mk - diff --git a/Makefile_using_MakefileWorker b/Makefile_using_MakefileWorker deleted file mode 100644 index 66ec53932..000000000 --- a/Makefile_using_MakefileWorker +++ /dev/null @@ -1,163 +0,0 @@ -#Set this to @ to keep the makefile quiet -SILENCE = @ - -#--- Inputs ----# -COMPONENT_NAME = CppUTest -ifeq ($(CPPUTEST_USE_STD_C_LIB), N) - CPP_PLATFORM = GccNoStdC -else - CPP_PLATFORM = Gcc -endif -CPPUTEST_HOME = . -OLD_MAKE = oldmake - -MAKE_CMD = make -f $(CPPUTEST_HOME)/Makefile_using_MakefileWorker -CPPUTEST_ENABLE_DEBUG = Y - -SRC_DIRS = \ - src/CppUTest \ - src/Platforms/$(CPP_PLATFORM) - -TEST_SRC_DIRS = \ - tests/CppUTest - -INCLUDE_DIRS =\ - include - -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=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) 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 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) 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 - $(SILENCE)if [ -s junit_run_output ]; then echo "JUnit run has output. Build failed!"; exit 1; fi - $(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 - $(MAKE_CMD) flags - $(MAKE_CMD) debug - -.PHONY: examples -examples: $(TEST_TARGET) extensions - +$(TIME) $(MAKE) -C examples all CPPUTEST_USE_STD_CPP_LIB=$(CPPUTEST_USE_STD_CPP_LIB) CPPUTEST_USE_MEM_LEAK_DETECTION=$(CPPUTEST_USE_MEM_LEAK_DETECTION) - -extensions: $(TEST_TARGET) - +$(TIME) $(MAKE) -f Makefile_CppUTestExt all CPPUTEST_USE_STD_CPP_LIB=$(CPPUTEST_USE_STD_CPP_LIB) CPPUTEST_USE_MEM_LEAK_DETECTION=$(CPPUTEST_USE_MEM_LEAK_DETECTION) TARGET_PLATFORM=$(TARGET_PLATFORM) - -cleanExtensions: clean - +$(TIME) $(MAKE) -f Makefile_CppUTestExt clean CPPUTEST_USE_STD_CPP_LIB=$(CPPUTEST_USE_STD_CPP_LIB) CPPUTEST_USE_MEM_LEAK_DETECTION=$(CPPUTEST_USE_MEM_LEAK_DETECTION) TARGET_PLATFORM=$(TARGET_PLATFORM) - -cleanExamples: clean cleanExtensions - +$(TIME) $(MAKE) -C examples clean CPPUTEST_USE_STD_CPP_LIB=$(CPPUTEST_USE_STD_CPP_LIB) CPPUTEST_USE_MEM_LEAK_DETECTION=$(CPPUTEST_USE_MEM_LEAK_DETECTION) - -.PHONY: everythingInstall -everythingInstall: all extensions examples - -.PHONY: cleanEverythingInstall -cleanEverythingInstall: clean cleanExtensions cleanExamples - diff --git a/NEWS b/NEWS deleted file mode 100644 index 8cd3c4209..000000000 --- a/NEWS +++ /dev/null @@ -1,3 +0,0 @@ - -You can find the main NEWS at: -https://github.com/cpputest/cpputest \ No newline at end of file diff --git a/README b/README deleted file mode 100644 index 3b3d0089e..000000000 --- a/README +++ /dev/null @@ -1,3 +0,0 @@ - -Please see the README.md. This file exists to be compliant to GNU coding standards. - diff --git a/README.md b/README.md deleted file mode 100644 index 8d6ae3727..000000000 --- a/README.md +++ /dev/null @@ -1,264 +0,0 @@ -# CppUTest - -[![GitHub Actions](https://github.com/cpputest/cpputest/actions/workflows/basic.yml/badge.svg)](https://github.com/cpputest/cpputest/actions/workflows/basic.yml) -[![AppveyorBuild status](https://ci.appveyor.com/api/projects/status/irh38i4wblsb5tew?svg=true)](https://ci.appveyor.com/project/basvodde/cpputest) -[![Coverage Status](https://coveralls.io/repos/cpputest/cpputest/badge.svg?branch=master&service=github)](https://coveralls.io/github/cpputest/cpputest?branch=master) -[![ConanCenter package](https://repology.org/badge/version-for-repo/conancenter/cpputest.svg)](https://conan.io/center/cpputest) - -CppUTest unit testing and mocking framework for C/C++ - -[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-epq97u9h-6yBQHHl2cvUADjEENtdASw) - -## Getting Started - -You'll need to do the following to get started: - -Building from source (Unix-based, Cygwin, MacOS): - -```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 also use CMake, which also works for Windows Visual Studio. - -```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` -* 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` -* Add the library linking to your Makefile. Something like: - * `LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt` - -After this, you can write your first test: - -```cpp -TEST_GROUP(FirstTestGroup) -{ -}; - -TEST(FirstTestGroup, FirstTest) -{ - FAIL("Fail me!"); -} -``` - -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 -* `-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`. - -## 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. - -## 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) - -Customize `CHECK_EQUAL` to work with your types that support `operator==()` - -- Create the function: `SimpleString StringFrom(const yourType&)` - -The Extensions directory has a few of these. - -## Building default checks with TestPlugin - -* CppUTest can support extra checking functionality by inserting TestPlugins -* TestPlugin is derived from the TestPlugin class and can be inserted in the TestRegistry via the installPlugin method. -* TestPlugins can be used for, for example, system stability and resource handling like files, memory or network connection clean-up. -* In CppUTest, the memory leak detection is done via a default enabled TestPlugin - -Example of a main with a TestPlugin: - -```cpp -int main(int ac, char** av) -{ - LogPlugin logPlugin; - TestRegistry::getCurrentRegistry()->installPlugin(&logPlugin); - int result = CommandLineTestRunner::RunAllTests(ac, av); - TestRegistry::getCurrentRegistry()->resetPlugins(); - return result; -} -``` - -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. - -## 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 -* 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[]` - -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: - -```cpp -TEST(MemoryLeakWarningTest, Ignore1) -{ - EXPECT_N_LEAKS(1); - char* arrayToLeak1 = new char[100]; -} -``` - -## Example Main - -```cpp -#include "CppUTest/CommandLineTestRunner.h" - -int main(int ac, char** av) -{ - return RUN_ALL_TESTS(ac, av); -} -``` - -## Example Test - -```cpp -#include "CppUTest/TestHarness.h" -#include "ClassName.h" - -TEST_GROUP(ClassName) -{ - ClassName* className; - - void setup() - { - className = new ClassName(); - } - void teardown() - { - delete className; - } -}; - -TEST(ClassName, Create) -{ - CHECK(0 != className); - CHECK(true); - CHECK_EQUAL(1,1); - LONGS_EQUAL(1,1); - DOUBLES_EQUAL(1.000, 1.001, .01); - STRCMP_EQUAL("hello", "hello"); - FAIL("The prior tests pass, but this one doesn't"); -} -``` - -There are some scripts that are helpful in creating your initial h, cpp, and -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. - -```cmake -# CppUTest -include(FetchContent) -FetchContent_Declare( - CppUTest - GIT_REPOSITORY https://github.com/cpputest/cpputest.git - GIT_TAG master # or use release tag, eg. v4.0 -) -FetchContent_MakeAvailable(CppUTest) -``` - -It can be used then like so: - -```cmake -add_executable(run_tests UnitTest1.cpp UnitTest2.cpp) - -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 deleted file mode 100644 index 8674364ce..000000000 --- a/README_CppUTest_for_C.txt +++ /dev/null @@ -1,66 +0,0 @@ - -CPPUTest can and has been used for testing C code also. When testing -C code there are a couple of things to keep in mind and a couple of -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 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: - -extern "C" { - #include "hello.h" - - extern HelloWorldApi theRealHelloWorldApi; -} - ----++ CppUTest support for 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 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 -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 -including it. - - ----++ C++ keywords used - -It sometimes happens that a C file uses a C++ keyword as a type or something -else. The most common one is the bool-type. This can typically be solved by -#defining the bool to something else. For example: - -extern "C" { -#define bool helloBool -#include "hello.h" -#undef bool -} - -The #undef is optional. It is possible that this solution leads to problems in -some situation (never happened to me). The same solution works for other C++ -key-words - ----++ Other - - * In C, sometimes people use empty structs. The sizeof(empty struct) would be - 0. In C++, the sizeof(empty struct) would be something. The best way to fix - this is to not use empty structs in C. - According to http://www.glenmccl.com/bett.htm an empty struct in C is illegal - anyway. - ----++ References - - * http://www.glenmccl.com/bett.htm - Describes some differences between C and C++ - * http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B - Wikipedia entry on the compatibility between C and C++ diff --git a/README_InstallCppUTest.txt b/README_InstallCppUTest.txt deleted file mode 100644 index bb67cc2a8..000000000 --- a/README_InstallCppUTest.txt +++ /dev/null @@ -1,60 +0,0 @@ -1. Unzip into , resulting in - /CppUTest/ - - MAKE SURE DOES NOT HAVE SPACES IN IT - MAKE SURE DOES NOT HAVE SPACES IN IT - MAKE SURE DOES NOT HAVE SPACES IN IT - -2. Build CppUTest and examples - -2a. For unix/gcc (including cygwin) - > cd /CppUTest/cpputest_build - > ../configure - > make - > make tdd # This is to run the CppUTest unit tests - -2b. For Microsoft Visual C++ V6 - We couldn't install the compiler anymore. We removed the project files. - You will need to make your own - -2c. For ARMCC from Keil MDK-ARM (building CppUTest library only) - > make all -C platforms/armcc - Please see README and Makefile in platforms/armcc to adjust options, default - CPU architecture is ARM7TDMI and default CPU execution mode is THUMB. - -3c. For Microsoft Visual Studio 2008 - Double click /CppUTest/CppUTest.sln - - If Visual studio reports that the solution file was created with a - newer version of Visual Studio, then try 3d - - Then press control-F5 to "Start without debugging" - - See CppUTest build and run its tests. - -3d. For Older Microsoft Visual Studio .NET - Double click /CppUTest/CppUTest.dsw - Allow VS.NET to convert the files by clicking "yes to all" - Run without debugging, see the test results in the command window - Exit MS VS.NET - - Allow VS.NET to convert the files by clicking "yes to all" - Run without debugging, see the test results in the command window - - NOTE: To create your own project, you need to have CppUTest and your project - compiled with the same compile and link settings - -4. to setup the support scripts. These scripts work in various unix systems -and cygwin. (these are quite handy) If you are using windows -install some tool like cygwin, msys or MKSToolkit to run these scripts. - > cd /CppUTest - > ./scripts/InstallScripts.sh - -This command adds some symbolic links to /usr/local/bin, so you have -to run it as root. - - sudo ./InstallScripts.sh - -MSYS - http://www.mingw.org/msys.shtml -CYGWIN - http://www.cygwin.com/ -MKSToolkit - http://mkstoolkit.com/ diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 6ed3b31b8..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,51 +0,0 @@ -version: 3.7.0-ci{build} - -image: Visual Studio 2015 - -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml - - C:\Tools\MinGW32 -> appveyor.yml - - C:\Tools\MinGW64 -> appveyor.yml - -environment: - Configuration: Release - matrix: - - Platform: Cygwin32 - - Platform: MinGW32 - PlatformToolset: 4.8.5 - - Platform: MinGW64 - PlatformToolset: 4.8.5 - - Platform: MinGW32 - PlatformToolset: 5.3.0 - - Platform: MinGW64 - PlatformToolset: 5.3.0 - - Platform: MinGWClang64 - PlatformToolset: 5.3.0 - - Platform: MinGWClang32 - PlatformToolset: 5.3.0 - - Platform: Win32 - PlatformToolset: v90 - - Platform: Win32 - PlatformToolset: v100 - - Platform: Win32 - PlatformToolset: v110 - - Platform: Win32 - PlatformToolset: v120 - - Platform: Win32 - PlatformToolset: v140 - - Platform: x64 - PlatformToolset: v140 - -install: -- ps: if ($env:Platform -like 'MinGW*') { choco install mingw --version $env:PlatformToolset $( if ($env:Platform -like '*32') { Write-Output --forcex86 --params /exception:dwarf } ) } - -build_script: -- ps: scripts\appveyor_ci_build.ps1 - -test_script: -- ps: scripts\appveyor_ci_test.ps1 - -artifacts: -- path: lib\CppUTest.lib - name: CppUTest diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index b81e557cd..000000000 --- a/autogen.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# -# cpputest autogen.sh -# -# Run this to generate all the initial makefiles, etc. - -autoreconf -i diff --git a/build/ComponentMakefile b/build/ComponentMakefile deleted file mode 100644 index 37e7807f2..000000000 --- a/build/ComponentMakefile +++ /dev/null @@ -1,226 +0,0 @@ -#--------- -# -# ComponentMakefile -# -# Include this file in your makefile -# It makes -# A static library -# A test executable -# -# The necessary parameters are shown in -# ComponentMakefileExampleParameters -# -# Inputs -# SRC_FILES - Specific source files to build into library -# SRC_DIRS - Directories of source files to build into the library -# TEST_SRC - unit test code build into the unit test runner -# MOCKS_SRC - mock objects built into the test runner -# INCLUDES - List of -I files -# CPPUTEST_CXXFLAGS - flags for the C++ compiler -# CPPUTEST_CPPFLAGS - flags for the C++ AND C compiler -# CPPUTEST_CFLAGS - C complier -# CPPUTEST_LDFLAGS - Linker flags -# LIB_DIR - the directory for the created library -# COMPONENT_NAME - the name of the thing being created -# OTHER_MAKEFILE_TO_INCLUDE - a hook to use this makefile to make -# other targets. Like CSlim, which is part of fitnesse -#---------- -ifeq ("$(COMPONENT_NAME)", "") - COMPONENT_NAME = name_this_in_the_makefile -endif - -ifeq ("$(OBJS_DIR)", "") - OBJS_DIR = objs -endif - -ifeq ("$(LIB_DIR)", "") - LIB_DIR = lib -endif - -ifeq ("$CPPUTEST_USE_MALLOC_LEAK_DETECTION","") - CPPUTEST_USE_MALLOC_LEAK_DETECTION = Y - echo "leak on by default" -endif - -#CPPUTEST_USE_OPERATOR_NEW_LEAK_DETECTION = Y -#CXXFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h -#CFLAGS += -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h - -TARGET_LIB = \ - $(LIB_DIR)/lib$(COMPONENT_NAME).a - -TEST_TARGET = \ - $(COMPONENT_NAME)_tests - -#Helper Functions -get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.c) -get_dirs_from_dirspec = $(wildcard $1) -get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir))) -src_to_o = $(subst .c,.o, $(subst .cpp,.o,$1)) -src_to_d = $(subst .c,.d, $(subst .cpp,.d,$1)) -change_o_file_location = $(patsubst %.o,$(OBJS_DIR)/%.o, $1) -change_d_file_location = $(patsubst %.d,$(OBJS_DIR)/%.d, $1) -src_to = $(subst .c,$1, $(subst .cpp,$1,$2)) - -#Derived -STUFF_TO_CLEAN += $(TEST_TARGET) $(TEST_TARGET).exe $(TARGET_LIB) - -SRC += $(call get_src_from_dir_list, $(SRC_DIRS)) $(SRC_FILES) -#OBJ = $(call src_to_o,$(SRC)) -OBJ = $(call change_o_file_location, $(call src_to_o,$(SRC))) -STUFF_TO_CLEAN += $(OBJ) - -TEST_SRC = $(call get_src_from_dir_list, $(TEST_SRC_DIRS)) -#TEST_OBJS = $(call src_to_o,$(TEST_SRC)) -TEST_OBJS = $(call change_o_file_location, $(call src_to_o,$(TEST_SRC))) -STUFF_TO_CLEAN += $(TEST_OBJS) - - -MOCKS_SRC = $(call get_src_from_dir_list, $(MOCKS_SRC_DIRS)) -#MOCKS_OBJS = $(call src_to_o,$(MOCKS_SRC)) -MOCKS_OBJS = $(call change_o_file_location, $(call src_to_o,$(MOCKS_SRC))) -STUFF_TO_CLEAN += $(MOCKS_OBJS) - -ALL_SRC = $(SRC) $(TEST_SRC) $(MOCKS_SRC) - -#Test coverage with gcov -GCOV_OUTPUT = gcov_output.txt -GCOV_REPORT = gcov_report.txt -GCOV_ERROR = gcov_error.txt -GCOV_GCDA_FILES = $(call src_to,.gcda, $(ALL_SRC)) -GCOV_GCNO_FILES = $(call src_to,.gcno, $(ALL_SRC)) -TEST_OUTPUT = $(TEST_TARGET).txt -STUFF_TO_CLEAN += \ - $(GCOV_OUTPUT)\ - $(GCOV_REPORT)\ - $(GCOV_ERROR)\ - $(GCOV_GCDA_FILES)\ - $(GCOV_GCNO_FILES)\ - $(TEST_OUTPUT) - - -#Other stuff needed -CPPUTEST_LIB = $(CPPUTEST_HOME)/lib/libCppUTest.a - -ifdef CPPUTEST_USE_EXTENSIONS -CPPUTEST_LIB += $(CPPUTEST_HOME)/lib/libCppUTestExt.a -endif - -CPPUTEST_CPPFLAGS += $(INCLUDES) $(GCOVFLAGS) - -#The gcda files for gcov need to be deleted before each run -#To avoid annoying messages. -GCOV_CLEAN = $(SILENCE)rm -f $(GCOV_GCDA_FILES) $(GCOV_OUTPUT) $(GCOV_REPORT) $(GCOV_ERROR) -RUN_TEST_TARGET = $(SILENCE) $(GCOV_CLEAN) ; echo "Running $(TEST_TARGET)"; ./$(TEST_TARGET) $(CPPUTEST_EXE_FLAGS) - -ifneq "$(OTHER_MAKEFILE_TO_INCLUDE)" "" --include $(OTHER_MAKEFILE_TO_INCLUDE) -endif - -ifneq "$(MAP_FILE)" "" - CPPUTEST_LDFLAGS += -Wl,-map,$(MAP_FILE) -endif - -INCLUDES_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(INCLUDE_DIRS)) -INCLUDES += $(foreach dir, $(INCLUDES_DIRS_EXPANDED), -I$(dir)) -MOCK_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(MOCKS_SRC_DIRS)) -INCLUDES += $(foreach dir, $(MOCK_DIRS_EXPANDED), -I$(dir)) - - -DEP_FILES = $(call src_to_d, $(ALL_SRC)) -STUFF_TO_CLEAN += $(DEP_FILES) + $(PRODUCTION_CODE_START) + $(PRODUCTION_CODE_END) -STUFF_TO_CLEAN += $(STDLIB_CODE_START) + $(MAP_FILE) + cpputest_*.xml junit_run_output - -# We'll use the CPPUTEST_CFLAGS etc so that you can override AND add to the CppUTest flags -CFLAGS = $(CPPUTEST_CFLAGS) $(CPPUTEST_ADDITIONAL_CFLAGS) -CPPFLAGS = $(CPPUTEST_CPPFLAGS) $(CPPUTEST_ADDITIONAL_CPPFLAGS) -CXXFLAGS = $(CPPUTEST_CXXFLAGS) $(CPPUTEST_ADDITIONAL_CXXFLAGS) -LDFLAGS = $(CPPUTEST_LDFLAGS) $(CPPUTEST_ADDITIONAL_LDFLAGS) - -# Targets -.PHONY: all -all: $(TEST_TARGET) - $(RUN_TEST_TARGET) - @echo "Component makefile is no longer supported, convert to MakefileInclude.mk" - -.PHONY: all_no_tests -all_no_tests: $(TEST_TARGET) - -.PHONY: flags -flags: - $(SILENCE)echo Compile with these flags: - $(SILENCE)for f in $(CPPFLAGS) ; do \ - echo " C++ $$f" ; \ - done - $(SILENCE)for f in $(CFLAGS) ; do \ - echo " C $$f" ; \ - done - $(SILENCE)for f in $(LDFLAGS) ; do \ - echo " LD $$f" ; \ - done - $(SILENCE)for f in $(ARFLAGS) ; do \ - echo " AR $$f" ; \ - done - - -$(TEST_TARGET): $(TEST_OBJS) $(MOCKS_OBJS) $(PRODUCTION_CODE_START) $(TARGET_LIB) $(USER_LIBS) $(PRODUCTION_CODE_END) $(CPPUTEST_LIB) $(STDLIB_CODE_START) - $(SILENCE)echo Linking $@ - $(SILENCE)$(LINK.o) -o $@ $^ $(LD_LIBRARIES) - -$(TARGET_LIB): $(OBJ) - $(SILENCE)echo Building archive $@ - $(SILENCE)mkdir -p lib - $(SILENCE)$(AR) $(ARFLAGS) $@ $^ - $(SILENCE)$(RANLIB) $@ - -test: $(TEST_TARGET) - $(RUN_TEST_TARGET) | tee $(TEST_OUTPUT) - -vtest: $(TEST_TARGET) - $(RUN_TEST_TARGET) -v | tee $(TEST_OUTPUT) - -$(OBJS_DIR)/%.o: %.cpp - @echo compiling $(notdir $<) - $(SILENCE)mkdir -p $(dir $@) - $(SILENCE)$(COMPILE.cpp) -M -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $< - $(SILENCE)$(COMPILE.cpp) $(OUTPUT_OPTION) $< - -$(OBJS_DIR)/%.o: %.c - @echo compiling $(notdir $<) - $(SILENCE)mkdir -p $(dir $@) - $(SILENCE)$(COMPILE.c) -M -MF $(subst .o,.d,$@) -MT "$@ $(subst .o,.d,$@)" $< - $(SILENCE)$(COMPILE.c) $(OUTPUT_OPTION) $< - -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEP_FILES) -endif - -.PHONY: clean -clean: - $(SILENCE)echo Making clean - $(SILENCE)$(RM) $(STUFF_TO_CLEAN) - $(SILENCE)find . -name "*.gcov" | xargs rm -f - $(SILENCE)find . -name "*.[do]" | xargs rm -f - - -gcov: test - $(SILENCE)for d in $(SRC_DIRS) ; do \ - gcov -o $$d $$d/*.c $$d/*.cpp >> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \ - done - $(CPPUTEST_HOME)/scripts/filterGcov.sh $(GCOV_OUTPUT) $(GCOV_ERROR) $(GCOV_REPORT) $(TEST_OUTPUT) - cat $(GCOV_REPORT) - -.PHONY: format -format: - $(CPPUTEST_HOME)/scripts/reformat.sh $(PROJECT_HOME_DIR) - -debug: - echo Stuff to clean - $(SILENCE)for f in $(STUFF_TO_CLEAN) ; do \ - echo "$$f" ; \ - done - echo Includes - $(SILENCE)for i in $(INCLUDES) ; do \ - echo "$$i" ; \ - done - diff --git a/build/ComponentMakefileExampleParameters b/build/ComponentMakefileExampleParameters deleted file mode 100644 index 00c9dece7..000000000 --- a/build/ComponentMakefileExampleParameters +++ /dev/null @@ -1,46 +0,0 @@ -#Set this to @ to keep the makefile quiet -SILENCE = @ - -#---- Outputs ----# -COMPONENT_NAME = ProjectName -TARGET_LIB = \ - lib/lib$(COMPONENT_NAME).a - -TEST_TARGET = \ - $(COMPONENT_NAME)_tests - -#--- Inputs ----# -PROJECT_HOME_DIR = . -CPPUTEST_HOME = ../CppUTest -CPP_PLATFORM = Gcc - -#CFLAGS are set to override malloc and free to get memory leak detection in C programs -CFLAGS = -Dmalloc=cpputest_malloc -Dfree=cpputest_free -CPPFLAGS = -GCOVFLAGS = -fprofile-arcs -ftest-coverage - -#SRC_DIRS is a list of source directories that make up the target library -#If test files are in these directories, their IMPORT_TEST_GROUPs need -#to be included in main to force them to be linked in. By convention -#put them into an AllTests.h file in each directory -SRC_DIRS = \ - src - -#TEST_SRC_DIRS is a list of directories including -# - A test main (AllTests.cpp by conventin) -# - OBJ files in these directories are included in the TEST_TARGET -# - Consequently - AllTests.h containing the IMPORT_TEST_GROUPS is not needed -# - -TEST_SRC_DIRS = \ - tests - -#includes for all compiles -INCLUDES =\ - -I.\ - -I$(CPPUTEST_HOME)/include\ - -#Flags to pass to ld -LDFLAGS += -USER_LIBS = - -include $(CPPUTEST_HOME)/build/ComponentMakefile diff --git a/build/MakefileWorker.mk b/build/MakefileWorker.mk deleted file mode 100644 index 46852df8d..000000000 --- a/build/MakefileWorker.mk +++ /dev/null @@ -1,630 +0,0 @@ -#--------- -# -# MakefileWorker.mk -# -# Include this helper file in your makefile -# It makes -# A static library -# A test executable -# -# See this example for parameter settings -# examples/Makefile -# -#---------- -# Inputs - these variables describe what to build -# -# INCLUDE_DIRS - Directories used to search for include files. -# This generates a -I for each directory -# SRC_DIRS - Directories containing source files to build into the library -# SRC_FILES - Specific source files to build into library. Helpful when not all code -# in a directory can be built for test (hopefully a temporary situation) -# TEST_SRC_DIRS - Directories containing unit test code build into the unit test runner -# These do not go in a library. They are explicitly included in the test runner -# TEST_SRC_FILES - Specific source files to build into the unit test runner -# 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 -# See below to determine defaults -# COMPONENT_NAME - the name of the thing being built -# TEST_TARGET - name of the test executable. By default it is -# $(COMPONENT_NAME)_tests -# Helpful if you want 1 > make files in the same directory with different -# executables as output. -# CPPUTEST_HOME - where CppUTest home dir found -# TARGET_PLATFORM - Influences how the outputs are generated by modifying the -# CPPUTEST_OBJS_DIR and CPPUTEST_LIB_DIR to use a sub-directory under the -# normal objs and lib directories. Also modifies where to search for the -# CPPUTEST_LIB to link against. -# CPPUTEST_OBJS_DIR - a directory where o and d files go -# CPPUTEST_LIB_DIR - a directory where libs go -# CPPUTEST_ENABLE_DEBUG - build for debug -# CPPUTEST_USE_MEM_LEAK_DETECTION - Links with overridden new and delete -# CPPUTEST_USE_STD_CPP_LIB - Set to N to keep the standard C++ library out -# 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 -# other targets. Like CSlim, which is part of fitnesse -# CPPUTEST_USE_VPATH - Use Make's VPATH functionality to support user -# specification of source files and directories that aren't below -# the user's Makefile in the directory tree, like: -# SRC_DIRS += ../../lib/foo -# It defaults to N, and shouldn't be necessary except in the above case. -#---------- -# -# Other flags users can initialize to sneak in their settings -# CPPUTEST_CXXFLAGS - flags for the C++ compiler -# 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. - -# Platforms -UNAME_OUTPUT = "$(shell uname -a)" -MACOSX_STR = Darwin -MINGW_STR = MINGW -CYGWIN_STR = CYGWIN -LINUX_STR = Linux -SUNOS_STR = SunOS -UNKNOWN_OS_STR = Unknown - -# Compilers -CC_VERSION_OUTPUT ="$(shell $(CXX) -v 2>&1)" -CLANG_STR = clang -SUNSTUDIO_CXX_STR = SunStudio - -UNAME_OS = $(UNKNOWN_OS_STR) - -ifeq ($(findstring $(MINGW_STR),$(UNAME_OUTPUT)),$(MINGW_STR)) - UNAME_OS = $(MINGW_STR) -endif - -ifeq ($(findstring $(CYGWIN_STR),$(UNAME_OUTPUT)),$(CYGWIN_STR)) - UNAME_OS = $(CYGWIN_STR) -endif - -ifeq ($(findstring $(LINUX_STR),$(UNAME_OUTPUT)),$(LINUX_STR)) - UNAME_OS = $(LINUX_STR) -endif - -ifeq ($(findstring $(MACOSX_STR),$(UNAME_OUTPUT)),$(MACOSX_STR)) - UNAME_OS = $(MACOSX_STR) -#lion has a problem with the 'v' part of -a - UNAME_OUTPUT = "$(shell uname -pmnrs)" -endif - -ifeq ($(findstring $(SUNOS_STR),$(UNAME_OUTPUT)),$(SUNOS_STR)) - UNAME_OS = $(SUNOS_STR) - - SUNSTUDIO_CXX_ERR_STR = CC -flags -ifeq ($(findstring $(SUNSTUDIO_CXX_ERR_STR),$(CC_VERSION_OUTPUT)),$(SUNSTUDIO_CXX_ERR_STR)) - CC_VERSION_OUTPUT ="$(shell $(CXX) -V 2>&1)" - COMPILER_NAME = $(SUNSTUDIO_CXX_STR) -endif -endif - -ifeq ($(findstring $(CLANG_STR),$(CC_VERSION_OUTPUT)),$(CLANG_STR)) - COMPILER_NAME = $(CLANG_STR) -endif - -#Kludge for mingw, it does not have cc.exe, but gcc.exe will do -ifeq ($(UNAME_OS),$(MINGW_STR)) - CC := gcc -endif - -#And another kludge. Exception handling in gcc 4.6.2 is broken when linking the -# Standard C++ library as a shared library. Unbelievable. -ifeq ($(UNAME_OS),$(MINGW_STR)) - CPPUTEST_LDFLAGS += -static -endif -ifeq ($(UNAME_OS),$(CYGWIN_STR)) - CPPUTEST_LDFLAGS += -static -endif - - -#Kludge for MacOsX gcc compiler on Darwin9 who can't handle pendantic -ifeq ($(UNAME_OS),$(MACOSX_STR)) -ifeq ($(findstring Version 9,$(UNAME_OUTPUT)),Version 9) - CPPUTEST_PEDANTIC_ERRORS = N -endif -endif - -ifndef COMPONENT_NAME - COMPONENT_NAME = name_this_in_the_makefile -endif - -# Debug on by default -ifndef CPPUTEST_ENABLE_DEBUG - CPPUTEST_ENABLE_DEBUG = Y -endif - -# new and delete for memory leak detection on by default -ifndef CPPUTEST_USE_MEM_LEAK_DETECTION - CPPUTEST_USE_MEM_LEAK_DETECTION = Y -endif - -# Use the standard C library -ifndef CPPUTEST_USE_STD_C_LIB - CPPUTEST_USE_STD_C_LIB = Y -endif - -# Use the standard C++ library -ifndef CPPUTEST_USE_STD_CPP_LIB - CPPUTEST_USE_STD_CPP_LIB = Y -endif - -# Use long long, off by default -ifndef CPPUTEST_USE_LONG_LONG - CPPUTEST_USE_LONG_LONG = N -endif - -# Use gcov, off by default -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 - -# Default warnings -ifndef CPPUTEST_WARNINGFLAGS - CPPUTEST_WARNINGFLAGS = -Wall -Wextra -Werror -Wshadow -Wswitch-default -Wswitch-enum -Wconversion -Wno-long-long -ifeq ($(CPPUTEST_PEDANTIC_ERRORS), Y) - CPPUTEST_WARNINGFLAGS += -pedantic-errors -endif -ifeq ($(UNAME_OS),$(LINUX_STR)) - CPPUTEST_WARNINGFLAGS += -Wsign-conversion -endif - CPPUTEST_CXX_WARNINGFLAGS = -Woverloaded-virtual - CPPUTEST_C_WARNINGFLAGS = -Wstrict-prototypes -endif - -#Wonderful extra compiler warnings with clang -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. 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. - 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 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) - 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 - -# Uhm. Maybe put some warning flags for SunStudio here? -ifeq ($(COMPILER_NAME),$(SUNSTUDIO_CXX_STR)) - CPPUTEST_CXX_WARNINGFLAGS = - CPPUTEST_C_WARNINGFLAGS = -endif - -# Default dir for temporary files (d, o) -ifndef CPPUTEST_OBJS_DIR -ifndef TARGET_PLATFORM - CPPUTEST_OBJS_DIR = objs -else - CPPUTEST_OBJS_DIR = objs/$(TARGET_PLATFORM) -endif -endif - -# Default dir for the output library -ifndef CPPUTEST_LIB_DIR -ifndef TARGET_PLATFORM - CPPUTEST_LIB_DIR = lib -else - CPPUTEST_LIB_DIR = lib/$(TARGET_PLATFORM) -endif -endif - -# No map by default -ifndef CPPUTEST_MAP_FILE - CPPUTEST_MAP_FILE = N -endif - -# No extensions is default -ifndef CPPUTEST_USE_EXTENSIONS - CPPUTEST_USE_EXTENSIONS = N -endif - -# No VPATH is default -ifndef CPPUTEST_USE_VPATH - CPPUTEST_USE_VPATH := N -endif -# Make empty, instead of 'N', for usage in $(if ) conditionals -ifneq ($(CPPUTEST_USE_VPATH), Y) - CPPUTEST_USE_VPATH := -endif - -ifndef TARGET_PLATFORM -CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib -else -CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM) -endif - -# -------------------------------------- -# derived flags in the following area -# -------------------------------------- - -# Without the C library, we'll need to disable the C++ library and ... -ifeq ($(CPPUTEST_USE_STD_C_LIB), N) - CPPUTEST_USE_STD_CPP_LIB = N - CPPUTEST_USE_MEM_LEAK_DETECTION = N - CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED - CPPUTEST_CPPFLAGS += -nostdinc -endif - -ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N) - CPPUTEST_CPPFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED -else - ifndef CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE - CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h - endif - ifndef CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE - CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h - endif -endif - -ifeq ($(CPPUTEST_USE_LONG_LONG), Y) - CPPUTEST_CPPFLAGS += -DCPPUTEST_USE_LONG_LONG -endif - -ifeq ($(CPPUTEST_ENABLE_DEBUG), Y) - CPPUTEST_CXXFLAGS += -g - CPPUTEST_CFLAGS += -g - CPPUTEST_LDFLAGS += -g -endif - -ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N) - CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED -ifeq ($(CPPUTEST_USE_STD_C_LIB), Y) - CPPUTEST_CXXFLAGS += -nostdinc++ -endif -endif - -ifdef $(GMOCK_HOME) - GTEST_HOME = $(GMOCK_HOME)/gtest - CPPUTEST_CPPFLAGS += -I$(GMOCK_HOME)/include - GMOCK_LIBRARY = $(GMOCK_HOME)/lib/.libs/libgmock.a - LD_LIBRARIES += $(GMOCK_LIBRARY) - CPPUTEST_CPPFLAGS += -DCPPUTEST_INCLUDE_GTEST_TESTS - CPPUTEST_WARNINGFLAGS = - CPPUTEST_CPPFLAGS += -I$(GTEST_HOME)/include -I$(GTEST_HOME) - GTEST_LIBRARY = $(GTEST_HOME)/lib/.libs/libgtest.a - LD_LIBRARIES += $(GTEST_LIBRARY) -endif - - -ifeq ($(CPPUTEST_USE_GCOV), Y) - 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) -CPPUTEST_CPPFLAGS += $(CPPUTEST_WARNINGFLAGS) -CPPUTEST_CXXFLAGS += $(CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE) -CPPUTEST_CPPFLAGS += $(CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE) -CPPUTEST_CFLAGS += $(CPPUTEST_C_WARNINGFLAGS) - -TARGET_MAP = $(COMPONENT_NAME).map.txt -ifeq ($(CPPUTEST_MAP_FILE), Y) - CPPUTEST_LDFLAGS += -Wl,-map,$(TARGET_MAP) -endif - -# Link with CppUTest lib -CPPUTEST_LIB = $(CPPUTEST_LIB_LINK_DIR)/libCppUTest.a - -ifeq ($(CPPUTEST_USE_EXTENSIONS), Y) -CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libCppUTestExt.a -endif - -ifdef CPPUTEST_STATIC_REALTIME - LD_LIBRARIES += -lrt -endif - -TARGET_LIB = \ - $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a - -ifndef TEST_TARGET - ifndef TARGET_PLATFORM - TEST_TARGET = $(COMPONENT_NAME)_tests - else - TEST_TARGET = $(COMPONENT_NAME)_$(TARGET_PLATFORM)_tests - endif -endif - -#Helper Functions -get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c) -get_dirs_from_dirspec = $(wildcard $1) -get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir))) -__src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1,$(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2)))) -src_to = $(addprefix $(CPPUTEST_OBJS_DIR)/,$(call __src_to,$1,$2)) -src_to_o = $(call src_to,.o,$1) -src_to_d = $(call src_to,.d,$1) -src_to_gcda = $(call src_to,.gcda,$1) -src_to_gcno = $(call src_to,.gcno,$1) -time = $(shell date +%s) -delta_t = $(eval minus, $1, $2) -debug_print_list = $(foreach word,$1,echo " $(word)";) echo; - -#Derived -STUFF_TO_CLEAN += $(TEST_TARGET) $(TEST_TARGET).exe $(TARGET_LIB) $(TARGET_MAP) - -SRC += $(call get_src_from_dir_list, $(SRC_DIRS)) $(SRC_FILES) -OBJ = $(call src_to_o,$(SRC)) - -STUFF_TO_CLEAN += $(OBJ) - -TEST_SRC += $(call get_src_from_dir_list, $(TEST_SRC_DIRS)) $(TEST_SRC_FILES) -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_FILES) -MOCKS_OBJS = $(call src_to_o,$(MOCKS_SRC)) -STUFF_TO_CLEAN += $(MOCKS_OBJS) - -ALL_SRC = $(SRC) $(TEST_SRC) $(MOCKS_SRC) - -# If we're using VPATH -ifeq ($(CPPUTEST_USE_VPATH), Y) -# gather all the source directories and add them - VPATH += $(sort $(dir $(ALL_SRC))) -# Add the component name to the objs dir path, to differentiate between same-name objects - CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR)) -endif - -#Test coverage with gcov -GCOV_OUTPUT = gcov_output.txt -GCOV_REPORT = gcov_report.txt -GCOV_ERROR = gcov_error.txt -GCOV_GCDA_FILES = $(call src_to_gcda, $(ALL_SRC)) -GCOV_GCNO_FILES = $(call src_to_gcno, $(ALL_SRC)) -TEST_OUTPUT = $(TEST_TARGET).txt -STUFF_TO_CLEAN += \ - $(GCOV_OUTPUT)\ - $(GCOV_REPORT)\ - $(GCOV_REPORT).html\ - $(GCOV_ERROR)\ - $(GCOV_GCDA_FILES)\ - $(GCOV_GCNO_FILES)\ - $(TEST_OUTPUT) - -#The gcda files for gcov need to be deleted before each run -#To avoid annoying messages. -GCOV_CLEAN = $(SILENCE)rm -f $(GCOV_GCDA_FILES) $(GCOV_OUTPUT) $(GCOV_REPORT) $(GCOV_ERROR) -RUN_TEST_TARGET = $(SILENCE) $(GCOV_CLEAN) ; echo "Running $(TEST_TARGET)"; ./$(TEST_TARGET) $(CPPUTEST_EXE_FLAGS) - -ifeq ($(CPPUTEST_USE_GCOV), Y) - - ifeq ($(COMPILER_NAME),$(CLANG_STR)) - LD_LIBRARIES += --coverage - else - LD_LIBRARIES += -lgcov - endif -endif - - -INCLUDES_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(INCLUDE_DIRS)) -INCLUDES += $(foreach dir, $(INCLUDES_DIRS_EXPANDED), -I$(dir)) -MOCK_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(MOCKS_SRC_DIRS)) -INCLUDES += $(foreach dir, $(MOCK_DIRS_EXPANDED), -I$(dir)) - -CPPUTEST_CPPFLAGS += $(INCLUDES) - -DEP_FILES = $(call src_to_d, $(ALL_SRC)) -STUFF_TO_CLEAN += $(DEP_FILES) $(PRODUCTION_CODE_START) $(PRODUCTION_CODE_END) -STUFF_TO_CLEAN += $(STDLIB_CODE_START) $(MAP_FILE) cpputest_*.xml junit_run_output - -# We'll use the CPPUTEST_CFLAGS etc so that you can override AND add to the CppUTest flags -CFLAGS = $(CPPUTEST_CFLAGS) $(CPPUTEST_ADDITIONAL_CFLAGS) -CPPFLAGS = $(CPPUTEST_CPPFLAGS) $(CPPUTEST_ADDITIONAL_CPPFLAGS) -CXXFLAGS = $(CPPUTEST_CXXFLAGS) $(CPPUTEST_ADDITIONAL_CXXFLAGS) -LDFLAGS = $(CPPUTEST_LDFLAGS) $(CPPUTEST_ADDITIONAL_LDFLAGS) - -# Don't consider creating the archive a warning condition that does STDERR output -ARFLAGS := $(ARFLAGS)c - -DEP_FLAGS=-MMD -MP - -# Some macros for programs to be overridden. For some reason, these are not in Make defaults -RANLIB = ranlib - -# Targets - -.PHONY: all -all: start $(TEST_TARGET) - $(RUN_TEST_TARGET) - -.PHONY: start -start: $(TEST_TARGET) - $(SILENCE)START_TIME=$(call time) - -.PHONY: all_no_tests -all_no_tests: $(TEST_TARGET) - -.PHONY: flags -flags: - @echo - @echo "OS ${UNAME_OS}" - @echo "Compile C and C++ source with CPPFLAGS:" - @$(call debug_print_list,$(CPPFLAGS)) - @echo "Compile C++ source with CXXFLAGS:" - @$(call debug_print_list,$(CXXFLAGS)) - @echo "Compile C source with CFLAGS:" - @$(call debug_print_list,$(CFLAGS)) - @echo "Link with LDFLAGS:" - @$(call debug_print_list,$(LDFLAGS)) - @echo "Link with LD_LIBRARIES:" - @$(call debug_print_list,$(LD_LIBRARIES)) - @echo "Create libraries with ARFLAGS:" - @$(call debug_print_list,$(ARFLAGS)) - -TEST_DEPS = $(TEST_OBJS) $(MOCKS_OBJS) $(PRODUCTION_CODE_START) $(TARGET_LIB) $(USER_LIBS) $(PRODUCTION_CODE_END) $(CPPUTEST_LIB) $(STDLIB_CODE_START) -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) - @$(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) - @$(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)$(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)$(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)$(CPPUTEST_CC_PREFIX)$(COMPILE.c) $(DEP_FLAGS) $(OUTPUT_OPTION) $< - -ifneq "$(MAKECMDGOALS)" "clean" --include $(DEP_FILES) -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 - $(SILENCE)find . -name "*.gcda" | xargs rm -f - -#realclean gets rid of all gcov, o and d files in the directory tree -#not just the ones made by this makefile -.PHONY: realclean -realclean: clean - $(SILENCE)rm -rf gcov - $(SILENCE)find . -name "*.gdcno" | xargs rm -f - $(SILENCE)find . -name "*.[do]" | xargs rm -f - -gcov: test -ifeq ($(CPPUTEST_USE_VPATH), Y) - $(SILENCE)gcov $(GCOV_ARGS) --object-directory $(CPPUTEST_OBJS_DIR) $(SRC) >> $(GCOV_OUTPUT) 2>> $(GCOV_ERROR) -else - $(SILENCE)for d in $(SRC_DIRS) ; do \ - FILES=`ls $$d/*.c $$d/*.cc $$d/*.cpp 2> /dev/null` ; \ - gcov $(GCOV_ARGS) --object-directory $(CPPUTEST_OBJS_DIR)/$$d $$FILES >> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \ - done - $(SILENCE)for f in $(SRC_FILES) ; do \ - gcov $(GCOV_ARGS) --object-directory $(CPPUTEST_OBJS_DIR)/$$f $$f >> $(GCOV_OUTPUT) 2>>$(GCOV_ERROR) ; \ - done -endif - $(CPPUTEST_HOME)/scripts/filterGcov.sh $(GCOV_OUTPUT) $(GCOV_ERROR) $(GCOV_REPORT) $(TEST_OUTPUT) - $(SILENCE)cat $(GCOV_REPORT) - $(SILENCE)mkdir -p gcov - $(SILENCE)mv *.gcov gcov - $(SILENCE)mv gcov_* gcov - @echo "See gcov directory for details" - -.PHONY: format -format: - $(CPPUTEST_HOME)/scripts/reformat.sh $(PROJECT_HOME_DIR) - -.PHONY: debug -debug: - @echo - @echo "Target Source files:" - @$(call debug_print_list,$(SRC)) - @echo "Target Object files:" - @$(call debug_print_list,$(OBJ)) - @echo "Test Source files:" - @$(call debug_print_list,$(TEST_SRC)) - @echo "Test Object files:" - @$(call debug_print_list,$(TEST_OBJS)) - @echo "Mock Source files:" - @$(call debug_print_list,$(MOCKS_SRC)) - @echo "Mock Object files:" - @$(call debug_print_list,$(MOCKS_OBJS)) - @echo "All Input Dependency files:" - @$(call debug_print_list,$(DEP_FILES)) - @echo Stuff to clean: - @$(call debug_print_list,$(STUFF_TO_CLEAN)) - @echo Includes: - @$(call debug_print_list,$(INCLUDES)) - --include $(OTHER_MAKEFILE_TO_INCLUDE) diff --git a/build/StaticLibMakefile b/build/StaticLibMakefile deleted file mode 100644 index cb4ff0b9c..000000000 --- a/build/StaticLibMakefile +++ /dev/null @@ -1,10 +0,0 @@ - -$(CPPUTEST_TARGET) : $(OBJS) - ar -rc $@ $(OBJS) - $(RANLIB) $@ - if [ "$(LIBDIR)" != "." ]; then\ - mv $@ $(LIBDIR) ; \ - fi - -all: $(CPPUTEST_TARGET) - diff --git a/build/alltests.mmp b/build/alltests.mmp deleted file mode 100644 index 40c1dc86a..000000000 --- a/build/alltests.mmp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde and Timo Puronen - * 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. - */ - -TARGET cpputest.exe -TARGETTYPE exe -UID 0x00000000 0x03A6305A - -USERINCLUDE ..\include ..\include\CppUTest ..\tests -SYSTEMINCLUDE \epoc32\include \epoc32\include\stdapis - -STATICLIBRARY libcrt0.lib -STATICLIBRARY cpputest.lib - -LIBRARY euser.lib libc.lib libm.lib libpthread.lib - - -SOURCEPATH ..\tests -SOURCE FailureTest.cpp MemoryLeakWarningTest.cpp NullTestTest.cpp -SOURCE SimpleStringTest.cpp TestInstallerTest.cpp -SOURCE TestOutputTest.cpp TestRegistryTest.cpp UtestTest.cpp CommandLineTestRunnerTest.cpp JUnitOutputTest.cpp TeamCityOutputTest.cpp -SOURCE TestHarness_cTest.cpp - -SOURCEPATH ..\tests -SOURCE AllTests.cpp TestResultTest.cpp PluginTest.cpp SetPluginTest.cpp - -MACRO UT_NEW_MACROS_DISABLED -MACRO UT_NEW_OVERRIDES_DISABLED diff --git a/build/bld.inf b/build/bld.inf deleted file mode 100644 index c2305acfe..000000000 --- a/build/bld.inf +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde and Timo Puronen - * 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. - */ - -PRJ_PLATFORMS -DEFAULT - -PRJ_EXPORTS -..\include\CppUTest\TestHarness.h \epoc32\include\CppUTest\TestHarness.h -..\include\CppUTest\Utest.h \epoc32\include\CppUTest\Utest.h -..\include\CppUTest\UtestMacros.h \epoc32\include\CppUTest\UtestMacros.h -..\include\CppUTest\TestResult.h \epoc32\include\CppUTest\TestResult.h -..\include\CppUTest\Failure.h \epoc32\include\CppUTest\Failure.h -..\include\CppUTest\TestRegistry.h \epoc32\include\CppUTest\TestRegistry.h -..\include\CppUTest\SimpleString.h \epoc32\include\CppUTest\SimpleString.h -..\include\CppUTest\SimpleStringInternalCache.h \epoc32\include\CppUTest\SimpleStringInternalCache.h -..\include\CppUTest\MemoryLeakWarning.h \epoc32\include\CppUTest\MemoryLeakWarning.h -..\include\CppUTest\CommandLineTestRunner.h \epoc32\include\CppuTest\CommandLineTestRunner.h -..\include\CppUTest\TestOutput.h \epoc32\include\CppuTest\TestOutput.h -..\include\CppUTest\TestPlugin.h \epoc32\include\CppUTest\TestPlugin.h -..\include\CppUTest\PlatformSpecificFunctions.h \epoc32\include\CppUTest\PlatformSpecificFunctions.h - -PRJ_MMPFILES -cpputest.mmp - -PRJ_TESTMMPFILES -alltests.mmp diff --git a/build/cmake_package_files/CppUTestConfig.cmake b/build/cmake_package_files/CppUTestConfig.cmake deleted file mode 100644 index cce1985ae..000000000 --- a/build/cmake_package_files/CppUTestConfig.cmake +++ /dev/null @@ -1,32 +0,0 @@ - -####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ####### -####### Any changes to this file will be overwritten by the next CMake run #### -####### The input file was CppUTestConfig.cmake.install.in ######## - -get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) - -macro(set_and_check _var _file) - set(${_var} "${_file}") - if(NOT EXISTS "${_file}") - message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !") - endif() -endmacro() - -macro(check_required_components _NAME) - foreach(comp ${${_NAME}_FIND_COMPONENTS}) - if(NOT ${_NAME}_${comp}_FOUND) - if(${_NAME}_FIND_REQUIRED_${comp}) - set(${_NAME}_FOUND FALSE) - endif() - endif() - endforeach() -endmacro() - -#################################################################################### - -set_and_check(CppUTest_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include") -include("${CMAKE_CURRENT_LIST_DIR}/CppUTestTargets.cmake") -set(CppUTest_LIBRARIES CppUTest CppUTestExt) -include("${CMAKE_CURRENT_LIST_DIR}/Modules/CppUTestBuildTimeDiscoverTests.cmake") - -check_required_components(CppUTest) diff --git a/build/cmake_package_files/CppUTestConfigVersion.cmake b/build/cmake_package_files/CppUTestConfigVersion.cmake deleted file mode 100644 index 69a28a705..000000000 --- a/build/cmake_package_files/CppUTestConfigVersion.cmake +++ /dev/null @@ -1,37 +0,0 @@ -# This is a basic version file for the Config-mode of find_package(). -# It is used by write_basic_package_version_file() as input file for configure_file() -# to create a version-file which can be installed along a config.cmake file. -# -# The created file sets PACKAGE_VERSION_EXACT if the current version string and -# the requested version string are exactly the same and it sets -# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, -# but only if the requested major version is the same as the current one. -# The variable CVF_VERSION must be set before calling configure_file(). -set(PACKAGE_VERSION "4.0") -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - if("4.0" MATCHES "^([0-9]+)\\.") - set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") - else() - set(CVF_VERSION_MAJOR "4.0") - endif() - if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() -# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "") - return() -endif() -# check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8") - math(EXPR installedBits "8 * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_UNSUITABLE TRUE) -endif() diff --git a/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake b/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake deleted file mode 100644 index 31ffbf4ba..000000000 --- a/build/cmake_package_files/CppUTestTargets-relwithdebinfo.cmake +++ /dev/null @@ -1,29 +0,0 @@ -#---------------------------------------------------------------- -# Generated CMake target import file for configuration "RelWithDebInfo". -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Import target "CppUTest" for configuration "RelWithDebInfo" -set_property(TARGET CppUTest APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) -set_target_properties(CppUTest PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "CXX" - IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/libCppUTest.a" - ) - -list(APPEND _IMPORT_CHECK_TARGETS CppUTest ) -list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTest "${_IMPORT_PREFIX}/lib/libCppUTest.a" ) - -# Import target "CppUTestExt" for configuration "RelWithDebInfo" -set_property(TARGET CppUTestExt APPEND PROPERTY IMPORTED_CONFIGURATIONS RELWITHDEBINFO) -set_target_properties(CppUTestExt PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_RELWITHDEBINFO "CXX" - IMPORTED_LOCATION_RELWITHDEBINFO "${_IMPORT_PREFIX}/lib/libCppUTestExt.a" - ) - -list(APPEND _IMPORT_CHECK_TARGETS CppUTestExt ) -list(APPEND _IMPORT_CHECK_FILES_FOR_CppUTestExt "${_IMPORT_PREFIX}/lib/libCppUTestExt.a" ) - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) diff --git a/build/cmake_package_files/CppUTestTargets.cmake b/build/cmake_package_files/CppUTestTargets.cmake deleted file mode 100644 index e1d587696..000000000 --- a/build/cmake_package_files/CppUTestTargets.cmake +++ /dev/null @@ -1,101 +0,0 @@ -# Generated by CMake - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget CppUTest CppUTestExt) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - unset(_targetsDefined) - unset(_targetsNotDefined) - unset(_expectedTargets) - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - - -# Compute the installation prefix relative to this file. -get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -if(_IMPORT_PREFIX STREQUAL "/") - set(_IMPORT_PREFIX "") -endif() - -# Create imported target CppUTest -add_library(CppUTest STATIC IMPORTED) - -set_target_properties(CppUTest PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/CppUTest" -) - -# Create imported target CppUTestExt -add_library(CppUTestExt STATIC IMPORTED) - -set_target_properties(CppUTestExt PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/include/CppUTestExt" -) - -# Load information for each installed configuration. -get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -file(GLOB CONFIG_FILES "${_DIR}/CppUTestTargets-*.cmake") -foreach(f ${CONFIG_FILES}) - include(${f}) -endforeach() - -# Cleanup temporary variables. -set(_IMPORT_PREFIX) - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) diff --git a/build/cpputest.mmp b/build/cpputest.mmp deleted file mode 100644 index 103063507..000000000 --- a/build/cpputest.mmp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde and Timo Puronen - * 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. - */ - -TARGET cpputest.lib -TARGETTYPE LIB -UID 0x00000000 0x03A6305A - -USERINCLUDE ..\include ..\include\CppUTest -SYSTEMINCLUDE \epoc32\include \epoc32\include\stdapis - -SOURCEPATH ..\src\CppUTest -SOURCE CommandLineTestRunner.cpp Failure.cpp MemoryLeakWarningPlugin.cpp SimpleString.cpp TestOutput.cpp TestPlugin.cpp TestRegistry.cpp TestResult.cpp Utest.cpp JUnitTestOutput.cpp TestHarness_c.cpp - -SOURCEPATH ..\src\Platforms\Symbian -SOURCE SymbianMemoryLeakWarning.cpp UtestPlatform.cpp - -MACRO UT_NEW_MACROS_DISABLED -MACRO UT_NEW_OVERRIDES_DISABLED - -SOURCEPATH ..\src\CppUTest -SOURCE MemoryLeakDetector.cpp CommandLineArguments.cpp diff --git a/builds/make-gcc-macport.sh b/builds/make-gcc-macport.sh deleted file mode 100755 index 7e97b8572..000000000 --- a/builds/make-gcc-macport.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# run from the builds directory - -listGccMacVersions() -{ - port select --list gcc -} - -if [ -z "$1" ]; then - echo "usage: $0 gcc-version\navailable versions:" 1>&2 - listGccMacVersions - exit 1 -fi - -gcc_v=$1 - -setGccMac() -{ - sudo port select --set gcc $1 -} - -setGccLinux() -{ - echo "Not implemented for Linux" - exit 1 -# if [ ! -f "/usr/bin/gcc-$1" ] || [ ! -f "/usr/bin/g++-$1" ]; then -# echo "no such version gcc/g++ installed" 1>&2 -# exit 1 -# fi - -# update-alternatives --set gcc "/usr/bin/gcc-$1" -# update-alternatives --set g++ "/usr/bin/g++-$1" -} - -if [ "$(uname)" == "Darwin" ]; then - setGccMac $gcc_v -elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - setGccLinux $gcc_v -else - echo "can't determine OS" - exit 1 -fi - -pushd .. -cpputest_home=$(pwd) -popd - -mkdir -p $gcc_v -cd $gcc_v -../../configure -make -make check -#these links keep compatibility with makefile worker -ln -s $cpputest_home/include include -ln -s $cpputest_home/build build -ln -s $cpputest_home/scripts scripts diff --git a/cmake/Modules/CppUTest.cmake b/cmake/Modules/CppUTest.cmake deleted file mode 100644 index 160959a5e..000000000 --- a/cmake/Modules/CppUTest.cmake +++ /dev/null @@ -1,117 +0,0 @@ -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 deleted file mode 100644 index cfffad56c..000000000 --- a/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake +++ /dev/null @@ -1,55 +0,0 @@ -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 tgt) - message(DEPRECATION - "Use cpputest_discover_tests from the CppUTest module instead" - ) - - 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 ${tgt}" - VERBATIM - ) -endfunction () diff --git a/cmake/Modules/_CppUTestDiscovery.cmake b/cmake/Modules/_CppUTestDiscovery.cmake deleted file mode 100644 index a970fbc37..000000000 --- a/cmake/Modules/_CppUTestDiscovery.cmake +++ /dev/null @@ -1,98 +0,0 @@ -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 deleted file mode 100644 index c5d96c031..000000000 --- a/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake +++ /dev/null @@ -1,94 +0,0 @@ -# Create CTest entries for EXECUTABLE in CTestTestfile.cmake -# Overwrite CTestTestfile.cmake with update version. - -# Usage: -# -# This script is to be called from ../Modules/CppUTestBuildTimeDiscoverTests.cmake -# -# Notes on invocation and used variables: -# ${CMAKE_COMMAND} -DTESTS_DETAILED:BOOL= -DEXECUTABLE= -P -# -# TESTS_DETAILED c.f. top-level CMakeLists.txt -# FULLPATH-TO-EXECUTABLE - use $ or explicit -# The overwritten CTestTestfile.cmake is located in ${CMAKE_CURRENT_BINARY_DIR} -# -# Steps to generate ADD_TEST() commands build time -# - Read CTestTestfile.cmake -# - Create update entries -# - Remove duplicate entries -# - Write new CTestTestfile.cmake - -###################################################################### -# helpers -###################################################################### -function (buildtime_add_test) - # Create ADD_TEST() command string - # - Extract and remove testname from ARGV - # - Add inner quotes to test arguments - # - Add "ADD_TEST()", and first and last quote - # Append result to CTESTTESTS - list(GET ARGV 0 testname) - list(REMOVE_AT ARGV 0) - string (REPLACE ";" "\" \"" TEST_ARGS "${ARGV}") - set(test_to_add "ADD_TEST(${testname} \"${TEST_ARGS}\")") - list(APPEND CTESTTESTS ${test_to_add}) - SET(CTESTTESTS ${CTESTTESTS} PARENT_SCOPE) -endfunction() - -function (JOIN VALUES GLUE OUTPUT) - string (REPLACE ";" "${GLUE}" _TMP_STR "${VALUES}") - set (${OUTPUT} "${_TMP_STR}" PARENT_SCOPE) -endfunction() - -function (buildtime_discover_tests EXECUTABLE DISCOVER_ARG OUTPUT) - execute_process(COMMAND ${EMULATOR} ${EXECUTABLE} ${DISCOVER_ARG} - OUTPUT_VARIABLE _TMP_OUTPUT - ERROR_VARIABLE DISCOVER_ERR - RESULT_VARIABLE DISCOVER_ERR) - if(NOT ${DISCOVER_ERR} EQUAL 0) - message(SEND_ERROR "Executable \"${EXECUTABLE} ${DISCOVER_ARG}\" failed with output:\n" - "${DISCOVER_ERR}\n" - "Please check that the excutable was added.") - endif(NOT ${DISCOVER_ERR} EQUAL 0) - separate_arguments(_TMP_OUTPUT) - set(${OUTPUT} "${_TMP_OUTPUT}" PARENT_SCOPE) -endfunction() - - -###################################################################### -# Implementation -###################################################################### - -set(CTESTFNAME "${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile.cmake") -file(STRINGS ${CTESTFNAME} CTESTTESTS) -get_filename_component(EXECUTABLE_SHORT_NAME ${EXECUTABLE} NAME_WE) - -if (TESTS_DETAILED) - set(DISCOVER_ARG "-ln") - buildtime_discover_tests("${EXECUTABLE}" "${DISCOVER_ARG}" TestList_GroupsAndNames) - set(lastgroup "") - foreach(testfullname ${TestList_GroupsAndNames}) - string(REGEX MATCH "^([^/.]+)" groupname ${testfullname}) - string(REGEX MATCH "([^/.]+)$" testname ${testfullname}) - if (NOT ("${groupname}" STREQUAL "${lastgroup}")) - message("TestGroup: ${groupname}:") - set(lastgroup "${groupname}") - endif (NOT ("${groupname}" STREQUAL "${lastgroup}")) - message("... ${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} ${EMULATOR} "${EXECUTABLE}" -sg ${group}) - endforeach() -endif (TESTS_DETAILED) - - -# create separate CTest test for each CppUTestTests test - -list(REMOVE_DUPLICATES CTESTTESTS) -JOIN("${CTESTTESTS}" "\n" CTESTTESTS) -file(WRITE ${CTESTFNAME} "${CTESTTESTS}\n") diff --git a/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake b/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake deleted file mode 100644 index b9ab5030e..000000000 --- a/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake +++ /dev/null @@ -1,8 +0,0 @@ -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/Toolchains/clang+mingw-win32.toolchain.cmake b/cmake/Toolchains/clang+mingw-win32.toolchain.cmake deleted file mode 100644 index 53711d5a8..000000000 --- a/cmake/Toolchains/clang+mingw-win32.toolchain.cmake +++ /dev/null @@ -1,6 +0,0 @@ -# Toolchain to use Clang compiler with MinGW binutils (e.g. linker) in Windows to generate 32-bits executables - -set(CMAKE_C_COMPILER clang) -set(CMAKE_C_FLAGS "-target i686-w64-mingw32 -m32" CACHE STRING "" FORCE) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_CXX_FLAGS "-target i686-w64-mingw32 -m32" CACHE STRING "" FORCE) \ No newline at end of file diff --git a/cmake/Toolchains/clang+mingw-win64.toolchain.cmake b/cmake/Toolchains/clang+mingw-win64.toolchain.cmake deleted file mode 100644 index 8a2d26501..000000000 --- a/cmake/Toolchains/clang+mingw-win64.toolchain.cmake +++ /dev/null @@ -1,6 +0,0 @@ -# Toolchain to use Clang compiler with MinGW binutils (e.g. linker) in Windows to generate 64-bits executables - -set(CMAKE_C_COMPILER clang) -set(CMAKE_C_FLAGS "-target x86_64-w64-mingw32" CACHE STRING "" FORCE) -set(CMAKE_CXX_COMPILER clang++) -set(CMAKE_CXX_FLAGS "-target x86_64-w64-mingw32" CACHE STRING "" FORCE) \ No newline at end of file diff --git a/cmake/Toolchains/ewarm-linux.toolchain.cmake b/cmake/Toolchains/ewarm-linux.toolchain.cmake deleted file mode 100644 index e0053a7bf..000000000 --- a/cmake/Toolchains/ewarm-linux.toolchain.cmake +++ /dev/null @@ -1,21 +0,0 @@ -### 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 deleted file mode 100644 index ab28b445f..000000000 --- a/cmake/Toolchains/ewarm-win.toolchain.cmake +++ /dev/null @@ -1,21 +0,0 @@ -### 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 deleted file mode 100644 index f58ba31b9..000000000 --- a/cmake/install.cmake +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index 4b763f684..000000000 --- a/cmake/warnings.cmake +++ /dev/null @@ -1,68 +0,0 @@ -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 deleted file mode 100644 index 037a695fb..000000000 --- a/config.h.cmake +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONFIG_H_ -#define CONFIG_H_ - -#cmakedefine CPPUTEST_MEM_LEAK_DETECTION_DISABLED -#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 - -#endif diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 0c105e29b..000000000 --- a/configure.ac +++ /dev/null @@ -1,635 +0,0 @@ - -AC_PREREQ([2.68]) -AC_INIT([CppUTest], [4.0], [https://github.com/cpputest/cpputest]) -AC_CONFIG_AUX_DIR([.]) -AM_INIT_AUTOMAKE([subdir-objects]) -AC_CONFIG_SRCDIR([src/CppUTest/Utest.cpp]) -AC_CONFIG_HEADERS([config.h]) -AX_PREFIX_CONFIG_H(generated/CppUTestGeneratedConfig.h) -AC_CONFIG_FILES([cpputest.pc]) -AC_CONFIG_MACRO_DIR([m4]) -AC_LIBTOOL_DLOPEN -AC_PROG_LIBTOOL - -AC_CANONICAL_HOST - -default_use_std_cpp=yes - -case "x$build_os" in - *darwin*) - AC_SUBST([CPPUTEST_ON_MACOSX], [yes]) - ;; - *mingw*) - default_use_std_cpp=no - ;; -esac - -AC_PROG_CC -AC_PROG_CPP -AC_PROG_CXX -AC_PROG_LN_S -AC_PROG_MAKE_SET -AM_PROG_CC_C_O -AM_SILENT_RULES - -ACX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS"]) - -AX_COMPILER_VERSION -# This additional -lpthread was added due to a bug on gcc for MacOSX: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42159 -# According to the bug report, a workaround is to link -lpthread. Even the ACX_PTHREAD doesn't do that, so we add an -# additional check if that it possible, and if it is, then we link pthread - -saved_libs="$LIBS" -LIBS=-lpthread -AC_MSG_CHECKING([if we can link -lpthread to work around a gcc bug (on MacOSX)]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); HACK_TO_USE_PTHREAD_LIBS=" -lpthread"], [AC_MSG_RESULT([no])]) -LIBS="$saved_libs $HACK_TO_USE_PTHREAD_LIBS" - -AC_CHECK_HEADERS([stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h]) - -AC_C_INLINE -AC_TYPE_INT16_T -AC_TYPE_INT32_T -AC_TYPE_INT64_T -AC_TYPE_INT8_T -AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_TYPE_UINT16_T -AC_TYPE_UINT32_T -AC_TYPE_UINT64_T -AC_TYPE_UINT8_T -AC_TYPE_LONG_LONG_INT - -# Checks for library functions. -AC_FUNC_FORK -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]) -AC_CHECK_PROG([CPPUTEST_HAS_LCOV], [lcov], [yes], [no]) -AC_CHECK_PROG([CPPUTEST_HAS_VALGRIND], [valgrind], [yes], [no]) -AC_CHECK_PROG([CPPUTEST_HAS_DASH], [dash], [yes], [no]) - -# Checking for warning flags on the compiler -saved_cflags="$CFLAGS" -saved_cxxflags="$CXXFLAGS" -saved_ldflags="$LDFLAGS" - -if test "x$USE_MAINTAINER_MODE" = "xyes"; then -# 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])]) -CFLAGS="$saved_cflags" -fi - -AC_LANG_PUSH([C++]) -##################################################################################### -##### C++ checks - -# 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 -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 -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 -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 -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])]) -CXXFLAGS="$saved_cxxflags" - -##################################################################################### -##### C++ version checks - -### Checking for C++ version compiler flags - -# 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 -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])]) -CXXFLAGS="$saved_cxxflags" - -CXXFLAGS="-Werror -std=c++11" -AC_MSG_CHECKING([whether CXX supports -std=c++11]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP11FLAG="-std=c++11" ], [AC_MSG_RESULT([no])]) -CXXFLAGS="$saved_cxxflags" - -CXXFLAGS="-Werror -stdlib=libc++" -AC_MSG_CHECKING([whether CXX supports -stdlib=libc++]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]])], [AC_MSG_RESULT([yes]); CPPUTEST_CPP11FLAG="${CPPUTEST_CPP11FLAG} -stdlib=libc++" ], [AC_MSG_RESULT([no])]) -CXXFLAGS="$saved_cxxflags" - -# Flag -Wno-c++98-compat -CXXFLAGS="-Werror -Wno-c++98-compat" -AC_MSG_CHECKING([whether CXX supports -Wno-c++98-compat]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-c++98-compat" ], [AC_MSG_RESULT([no])]) -CXXFLAGS="$saved_cxxflags" - -# Flag -Wno-c++98-compat-pedantic -CXXFLAGS="-Werror -Wno-c++98-compat-pedantic" -AC_MSG_CHECKING([whether CXX supports -Wno-c++98-compat-pedantic]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-c++98-compat-pedantic" ], [AC_MSG_RESULT([no])]) -CXXFLAGS="$saved_cxxflags" - -# Flag -Wno-c++14-compat -CXXFLAGS="-Werror -Wno-c++14-compat" -AC_MSG_CHECKING([whether CXX supports -Wno-c++14-compat]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} -Wno-c++14-compat" ], [AC_MSG_RESULT([no])]) -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. -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. -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])]) -CFLAGS="$saved_cflags" - - -##################################################################################### -# 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. -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. -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 -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 -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 -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 -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 -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) -AC_LANG_PUSH([C++]) - -CXXFLAGS="-Werror -Wsign-conversion" -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 -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])]) -CXXFLAGS="$saved_cxxflags" - -AC_LANG_POP - -# 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])]) -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. -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. -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" - -AC_LANG_PUSH([C++]) -# 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. -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. -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. -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 -AC_LANG_PUSH([C++]) -CXXFLAGS="-Werror --coverage" -AC_MSG_CHECKING([whether CXX and the linker supports --coverage (broken in clang 3.3)]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); coverage_flag_supported="yes" ], [AC_MSG_RESULT([no])]) -CXXFLAGS="$saved_cxxflags" -AC_LANG_POP - -###################################################### -# Exception Handling -# -# Checking for strange exception handling behavior, related to bugs in compilers... -AC_LANG_PUSH([C++]) - -# Can we use operator delete without exception handling specifier? (clang warns on this!) -CXXFLAGS="-Werror" -AC_MSG_CHECKING([whether CXX supports operator delete without exception handling specifier]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -void operator delete(void* mem);]])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); UT_DELETE_MUST_HAVE_EXCEPTION_SPECIFIER="yes"]) -CXXFLAGS="$saved_cxxflags" - -# Can we use operator new with exception specifier (g++4.7 on MacOSX is broken here) -CXXFLAGS="-Werror" -AC_MSG_CHECKING([whether CXX supports operator new with exception handling specifier]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include -#include -void* operator new(std::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 -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])]) -CXXFLAGS="$saved_cxxflags" - -AC_LANG_POP - -##### Linker checking. -# -# TBD! -# Things that need to be fixed! -# -# The below code is checking for the -Qunused-arguments which is a linker flag. However, it says gcc supports it, while in fact, it doesn't. -# As a workaround, we'll just check whether it is clang hardcoded, this is not in the automake spirit and will need to be fixed. -# -# LDFLAGS= -# AC_MSG_CHECKING([whether LD supports -Qunused-arguments]) -# AC_LINK_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_NO_UNUSED_ARGUMENT_WARNING=" -Qunused-arguments" ], [AC_MSG_RESULT([no])]) -# LDFLAGS="$saved_ldflags" - -AC_MSG_CHECKING([whether CXXLD supports -Qunused-arguments linker option]) -OUTPUT_WHEN_CLANG_COMPILER=`${CXX} --version | grep clang` -AM_CONDITIONAL([TEST_COMPILER_IS_CLANG], [ ! test -z "$OUTPUT_WHEN_CLANG_COMPILER]") -AM_COND_IF([TEST_COMPILER_IS_CLANG], - [AC_MSG_RESULT([yes]); CPPUTEST_NO_UNUSED_ARGUMENT_WARNING=" ${CPPUTEST_NO_UNUSED_ARGUMENT_WARNING} -Qunused-arguments"], - [AC_MSG_RESULT([no])]; CPPUTEST_NO_UNUSED_ARGUMENT_WARNING="${CPPUTEST_NO_UNUSED_ARGUMENT_WARNING} ") - -# Checking for options for creating map files -LDFLAGS=" -Wl,-map,filename.map.txt" -AC_MSG_CHECKING([whether LD supports -Wl,-map]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([])], [AC_MSG_RESULT([yes]); CPPUTEST_LD_MAP_GENERATION=" -Wl,-map,filename.map.txt" ], [AC_MSG_RESULT([no])]) -LDFLAGS="$saved_ldflags" - -# Different features -AC_ARG_ENABLE([std-c], [AC_HELP_STRING([--disable-std-c], [disable the use of Standard C Library (warning: requires implementing Platforms/GccNoStdC) ])], - [use_std_c=${enableval}], [use_std_c=yes]) - -AC_ARG_ENABLE([std-cpp], [AC_HELP_STRING([--disable-std-cpp], [disable the use of Standard C++ Library])], - [use_std_cpp=${enableval}], [use_std_cpp=${default_use_std_cpp}]) - -AC_ARG_ENABLE([std-cpp98], [AC_HELP_STRING([--enable-std-cpp98], [enable the use of Standard C++ 98 (if the compiler supports that)])], - [use_std_cpp98=${enableval}], [use_std_cpp98=no]) - -AC_ARG_ENABLE([std-cpp11], [AC_HELP_STRING([--enable-std-cpp11], [enable the use of Standard C++ 11 (if the compiler supports that)])], - [use_std_cpp11=${enableval}], [use_std_cpp11=no]) - -AC_ARG_ENABLE([std-cpp14], [AC_HELP_STRING([--enable-std-cpp14], [enable the use of Standard C++ 14 (if the compiler supports that)])], - [use_std_cpp14=${enableval}], [use_std_cpp14=no]) - -AC_ARG_ENABLE([std-cpp17], [AC_HELP_STRING([--enable-std-cpp17], [enable the use of Standard C++ 17 (if the compiler supports that)])], - [use_std_cpp17=${enableval}], [use_std_cpp17=no]) - -AC_ARG_ENABLE([std-cpp20], [AC_HELP_STRING([--enable-std-cpp20], [enable the use of Standard C++ 20 (if the compiler supports that)])], - [use_std_cpp20=${enableval}], [use_std_cpp20=no]) - -AC_ARG_ENABLE([cpputest-flags], [AC_HELP_STRING([--disable-cpputest-flags], [disable CFLAGS/CPPFLAGS/CXXFLAGS set by CppUTest])], - [cpputest_flags=${enableval}], [cpputest_flags=yes]) - -AC_ARG_ENABLE([memory-leak-detection], [AC_HELP_STRING([--disable-memory-leak-detection], [disable memory leak detection])], - [memory_leak_detection=${enableval}], [memory_leak_detection=yes]) - -AC_ARG_ENABLE([extensions], [AC_HELP_STRING([--disable-extensions], [disable CppUTest extension library])], - [cpputest_ext=${enableval}], [cpputest_ext=yes]) - -AC_ARG_ENABLE([longlong], [AC_HELP_STRING([--disable-longlong], [disable support for long long type])], - [use_longlong=${enableval}], [use_longlong=yes]) - -AC_ARG_ENABLE([generate-map-file], [AC_HELP_STRING([--enable-generate-map-file], [enable the creation of a map file])], - [generate_map_file=${enableval}], [generate_map_file=no]) - -AC_ARG_ENABLE([coverage], [AC_HELP_STRING([--enable-coverage], [enable running with coverage])], - [coverage=${enableval}], [coverage=no]) - -AC_ARG_ENABLE([sanitize-address], [AC_HELP_STRING([--enable-sanitize-address], [enable running with address sanitizer])], - [sanitize_address=${enableval}], [sanitize_address=no]) - -############################## Setting options ############################### - -AM_CONDITIONAL([INCLUDE_CPPUTEST_EXT], [test "x${cpputest_ext}" = xyes]) - -# Dealing with not having a Standard C library... (usually for Kernel development) -if test "x${use_std_c}" = xno; then - use_std_cpp=no - memory_leak_detection=no - CPPUTEST_CPPFLAGS="${CPPUTEST_CPPFLAGS} -nostdinc" - CPPUTEST_LDFLAGS="${CPPUTEST_LDFLAGS} -nostdlib" - AC_DEFINE([STD_C_LIB_DISABLED], [1], [Standard C library disabled]) - CPP_PLATFORM="GccNoStdC" -else - CPP_PLATFORM="Gcc" -fi - -# Using standard C++ -if test "x${use_std_cpp}" = xno; then - AC_DEFINE([STD_CPP_LIB_DISABLED], 1, [Standard C++ library disabled]) - if test "x${use_std_c}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} -nostdinc++ ${CPPUTEST_CXX_NO_INC_WARNINGFLAGS}" - - # Since automake passes the CXXFLAGS to the linker, this will cause warnings with clang 3.2 (which become errors) - CPPUTEST_LDFLAGS="${CPPUTEST_LDFLAGS} ${CPPUTEST_NO_UNUSED_ARGUMENT_WARNING}" - - fi -fi -cpp_standard_used="default" - -# Using the C++98 standard? -if test "x${use_std_cpp98}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CPP98FLAG}" - cpp_standard_used="C++98" -fi - -# Using the C++11 standard? -if test "x${use_std_cpp11}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CPP11FLAG}" - cpp_standard_used="C++11" -fi - -# Using the C++14 standard? -if test "x${use_std_cpp14}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CPP14FLAG}" - cpp_standard_used="C++14" -fi - -# Using the C++17 standard? -if test "x${use_std_cpp17}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CPP17FLAG}" - cpp_standard_used="C++17" -fi - -# Using the C++20 standard? -if test "x${use_std_cpp20}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CPP20FLAG}" - cpp_standard_used="C++20" -fi - -# Dealing with memory leak detection -if test "x${memory_leak_detection}" = xno; then - AC_DEFINE([MEM_LEAK_DETECTION_DISABLED], 1, [memory leak detection disabled]) -else - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} -include ${srcdir}/include/CppUTest/MemoryLeakDetectorNewMacros.h" - CPPUTEST_CPPFLAGS="${CPPUTEST_CPPFLAGS} -include ${srcdir}/include/CppUTest/MemoryLeakDetectorMallocMacros.h" -fi - -# Disabling long long support -if test "x${use_longlong}" = xno; then - AC_DEFINE([LONG_LONG_DISABLED], 1, [disable long long]) -fi - -# Dealing with address sanitizer -if test "x${sanitize_address}" = xyes; then - CPPUTEST_CFLAGS="${CPPUTEST_CFLAGS} -fsanitize=address -fno-omit-frame-pointer" - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} -fsanitize=address -fno-omit-frame-pointer" - CPPUTEST_LDFLAGS="${CPPUTEST_CXXFLAGS} -fsanitize=address -fno-omit-frame-pointer" -fi - -# Generating map files. -if test "x${generate_map_file}" = xyes; then - CPPUTEST_LDFLAGS="${CPPUTEST_LDFLAGS} ${CPPUTEST_LD_MAP_GENERATION}" - MOSTLYCLEANFILES="${MOSTLYCLEANFILES} *.map.txt" -fi - -if test "x${coverage_flag_supported}" = xyes; then -if test "x${coverage}" = xyes; then - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} --coverage" - CPPUTEST_CFLAGS="${CPPUTEST_CFLAGS} --coverage" - MOSTLYCLEANFILES="${MOSTLYCLEANFILES} *.gcda *.gcno" -fi -fi - -# GMock, check whether we can compile the GMock tests. - -AC_ARG_VAR([GMOCK_HOME], Directory where gmock is installed so the gmock tests can run) -AC_MSG_CHECKING([for the availability of gmock via the GMOCK_HOME variable]) - -AM_CONDITIONAL([INCLUDE_GMOCKTESTS], [test -n "${GMOCK_HOME}"]) -if test -n "${GMOCK_HOME}"; then - - AC_DEFINE([INCLUDE_GTEST_TESTS], 1, [Include the GTest-related tests in the build]) - AC_ARG_VAR([GMOCK_HOME], [Location of the GMock]) - - if test -z "${GTEST_HOME}"; then - GTEST_HOME=${GMOCK_HOME}/gtest - fi - - CPPUTEST_CPPFLAGS="${CPPUTEST_CPPFLAGS} -I${GMOCK_HOME}/include -I${GTEST_HOME}/include -I${GTEST_HOME}" - CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1 -DGMOCK_RENAME_MAIN=1" - if test -e ${GMOCK_HOME}/lib/libgmock.la && test -e ${GTEST_HOME}/lib/libgtest.la; then \ - CPPUTEST_LDADD="${CPPUTEST_LDADD} ${GMOCK_HOME}/lib/libgmock.la ${GTEST_HOME}/lib/libgtest.la"; \ - elif test -e ${GMOCK_HOME}/libgmock.a && test -e ${GTEST_HOME}/libgtest.a; then \ - CPPUTEST_LDADD="${CPPUTEST_LDADD} ${GMOCK_HOME}/libgmock.a ${GTEST_HOME}/libgtest.a"; \ - elif test -e ${GMOCK_HOME}/libgmock.a && test -e ${GMOCK_HOME}/gtest/libgtest.a; then \ - CPPUTEST_LDADD="${CPPUTEST_LDADD} ${GMOCK_HOME}/libgmock.a ${GMOCK_HOME}/gtest/libgtest.a"; \ - else \ - AC_MSG_ERROR([ -------------------------------------- -GMOCK_HOME was set, but couldn't find the compiled library. -Did you compile it? --------------------------------------]); - fi - -else - # When we don't compile with GMock, we can be a bit stricter on warnings. - CPPUTEST_CWARNINGFLAGS="${CPPUTEST_CWARNINGFLAGS} ${CPPUTEST_CWARNINGFLAGS_STRICT}" - CPPUTEST_CXXWARNINGFLAGS="${CPPUTEST_CXXWARNINGFLAGS} ${CPPUTEST_CXXWARNINGFLAGS_STRICT}" - -fi - - -CPPUTEST_CFLAGS="${CPPUTEST_CFLAGS} ${CPPUTEST_CWARNINGFLAGS}" -CPPUTEST_CXXFLAGS="${CPPUTEST_CXXFLAGS} ${CPPUTEST_CXXWARNINGFLAGS}" -CPPUTEST_CPPFLAGS="${CPPUTEST_CPPFLAGS} -I ${srcdir}/include ${CPPUTEST_CPPWARNINGFLAGS}" - -if test "x${cpputest_flags}" = xno; then - CPPUTEST_CFLAGS="" - CPPUTEST_CXXFLAGS="" - CPPUTEST_CPPFLAGS="" -fi - - -############################## Values ######################################## - -### All files in git -if test -e "${srcdir}/.git"; then - ALL_FILES_IN_GIT="`git --git-dir=${srcdir}/.git ls-files | tr '[ \n]' ' '`" -fi - -# Variables to substitute - -AC_SUBST([CPP_PLATFORM]) - -AC_SUBST([INCLUDE_CPPUTEST_EXT]) - -# Replacement of tool flags -AC_SUBST([CPPUTEST_CFLAGS]) -AC_SUBST([CPPUTEST_ADDITIONAL_CFLAGS]) -AC_SUBST([CPPUTEST_CXXFLAGS]) -AC_SUBST([CPPUTEST_ADDITIONAL_CXXFLAGS]) -AC_SUBST([CPPUTEST_CPPFLAGS]) -AC_SUBST([CPPUTEST_ADDITIONAL_CPPFLAGS]) -AC_SUBST([CPPUTEST_LDADD]) -AC_SUBST([CPPUTEST_LDFLAGS]) - -AC_SUBST([MOSTLYCLEANFILES]) -AC_SUBST([CPPUTEST_HAS_GCC]) -AC_SUBST([CPPUTEST_HAS_CLANG]) -AC_SUBST([ALL_FILES_IN_GIT]) - -LT_INIT -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT - - -echo \ -"---------------------------------------------------------------- - -${PACKAGE_NAME} Version ${PACKAGE_VERSION} - -Current compiler options: - CC: ${CC} - CXX: ${CXX} - CC version: ${ax_cv_c_compiler_version} - CXX version: ${ax_cv_cxx_compiler_version} - LD: ${LD} - Default CFLAGS: ${CFLAGS} - Default CXXFLAGS: ${CXXFLAGS} - CppUTest CFLAGS: ${CPPUTEST_CFLAGS} - CppUTest CXXFLAGS: ${CPPUTEST_CXXFLAGS} - CppUTest CPPFLAGS: ${CPPUTEST_CPPFLAGS} - CppUTest LDFLAGS: ${CPPUTEST_LDFLAGS} - CppUTest LIB: ${LIBS} - -Features configured in ${PACKAGE_NAME}: - C++ standard used: ${cpp_standard_used} - Memory Leak Detection: ${memory_leak_detection} - Compiling extensions: ${cpputest_ext} - Use Long Long (if available): ${use_longlong} - Disable CppUTest compile/link flags: ${cpputest_flags} - Address sanitizer: ${sanitize_address} - - Using Standard C++ Library: ${use_std_cpp} - Using Standard C Library: ${use_std_c} - - Generating map file: ${generate_map_file} - Compiling w coverage info: ${coverage} - -----------------------------------------------------------------" diff --git a/cpputest.pc.in b/cpputest.pc.in deleted file mode 100644 index 9a2f0e615..000000000 --- a/cpputest.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: CppUtest -URL: https://github.com/cpputest/cpputest -Description: Easy to use unit test framework for C/C++ -Version: @PACKAGE_VERSION@ -Cflags: -I${includedir} -Libs: -L${libdir} -lstdc++ -lCppUTest -lCppUTestExt diff --git a/cpputest_doxy_gen.conf b/cpputest_doxy_gen.conf deleted file mode 100644 index 63b26bcd1..000000000 --- a/cpputest_doxy_gen.conf +++ /dev/null @@ -1,1869 +0,0 @@ -# Doxyfile 1.8.3.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project. -# -# All text after a hash (#) is considered a comment and will be ignored. -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" "). - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or sequence of words) that should -# identify the project. Note that if you do not use Doxywizard you need -# to put quotes around the project name if it contains spaces. - -PROJECT_NAME = "CppUTest Documentation" - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# Using the PROJECT_BRIEF tag one can provide an optional one line description -# for a project that appears at the top of each page and should give viewer -# a quick idea about the purpose of the project. Keep the description short. - -PROJECT_BRIEF = - -# With the PROJECT_LOGO tag one can specify an logo or icon that is -# included in the documentation. The maximum height of the logo should not -# exceed 55 pixels and the maximum width should not exceed 200 pixels. -# Doxygen will copy the logo to the output directory. - -PROJECT_LOGO = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, -# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English -# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, -# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, -# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. Note that you specify absolute paths here, but also -# relative paths, which will be relative from the directory where doxygen is -# started. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful if your file system -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments -# (thus requiring an explicit @brief command for a brief description.) - -JAVADOC_AUTOBRIEF = NO - -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring -# an explicit \brief command for a brief description.) - -QT_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified -# scopes will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for -# Fortran. - -OPTIMIZE_FOR_FORTRAN = NO - -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for -# VHDL. - -OPTIMIZE_OUTPUT_VHDL = NO - -# Doxygen selects the parser to use depending on the extension of the files it -# parses. With this tag you can assign which parser to use for a given -# extension. Doxygen has a built-in mapping, but you can override or extend it -# using this tag. The format is ext=language, where ext is a file extension, -# and language is one of the parsers supported by doxygen: IDL, Java, -# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, -# C++. For instance to make doxygen treat .inc files as Fortran files (default -# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note -# that for custom extensions you also need to set FILE_PATTERNS otherwise the -# files are not read by doxygen. - -EXTENSION_MAPPING = - -# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all -# comments according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. -# The output of markdown processing is further processed by doxygen, so you -# can mix doxygen, HTML, and XML commands with Markdown formatting. -# Disable only in case of backward compatibilities issues. - -MARKDOWN_SUPPORT = YES - -# When enabled doxygen tries to link words that correspond to documented classes, -# or namespaces to their corresponding documentation. Such a link can be -# prevented in individual cases by by putting a % sign in front of the word or -# globally by setting AUTOLINK_SUPPORT to NO. - -AUTOLINK_SUPPORT = YES - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also makes the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public -# instead of private inheritance when no explicit protection keyword is present. - -SIP_SUPPORT = NO - -# For Microsoft's IDL there are propget and propput attributes to indicate -# getter and setter methods for a property. Setting this option to YES (the -# default) will make doxygen replace the get and set methods by a property in -# the documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the -# methods anyway, you should set this option to NO. - -IDL_PROPERTY_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and -# unions are shown inside the group in which they are included (e.g. using -# @ingroup) instead of on a separate page (for HTML and Man pages) or -# section (for LaTeX and RTF). - -INLINE_GROUPED_CLASSES = NO - -# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and -# unions with only public data fields will be shown inline in the documentation -# of the scope in which they are defined (i.e. file, namespace, or group -# documentation), provided this scope is documented. If set to NO (the default), -# structs, classes, and unions are shown on a separate page (for HTML and Man -# pages) or section (for LaTeX and RTF). - -INLINE_SIMPLE_STRUCTS = NO - -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound -# types are typedef'ed and only the typedef is referenced, never the tag name. - -TYPEDEF_HIDES_STRUCT = NO - -# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to -# determine which symbols to keep in memory and which to flush to disk. -# When the cache is full, less often used symbols will be written to disk. -# For small to medium size projects (<1000 input files) the default value is -# probably good enough. For larger projects a too small cache size can cause -# doxygen to be busy swapping symbols to and from disk most of the time -# causing a significant performance penalty. -# If the system has enough physical memory increasing the cache will improve the -# performance by keeping more symbols in memory. Note that the value works on -# a logarithmic scale so increasing the size by one will roughly double the -# memory usage. The cache size is given by this formula: -# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -SYMBOL_CACHE_SIZE = 0 - -# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be -# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given -# their name and scope. Since this can be an expensive process and often the -# same symbol appear multiple times in the code, doxygen keeps a cache of -# pre-resolved symbols. If the cache is too small doxygen will become slower. -# If the cache is too large, memory is wasted. The cache size is given by this -# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols. - -LOOKUP_CACHE_SIZE = 0 - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal -# scope will be included in the documentation. - -EXTRACT_PACKAGE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default -# anonymous namespaces are hidden. - -EXTRACT_ANON_NSPACES = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen -# will list include files with double quotes in the documentation -# rather than with sharp brackets. - -FORCE_LOCAL_INCLUDES = NO - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen -# will sort the (brief and detailed) documentation of class members so that -# constructors and destructors are listed first. If set to NO (the default) -# the constructors will appear in the respective orders defined by -# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. -# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO -# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. - -SORT_MEMBERS_CTORS_1ST = NO - -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) -# the group names will appear in their defined order. - -SORT_GROUP_NAMES = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to -# do proper type resolution of all parameters of a function it will reject a -# match between the prototype and the implementation of a member function even -# if there is only one candidate or it is obvious which candidate to choose -# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen -# will still accept a match between prototype and implementation in such cases. - -STRICT_PROTO_MATCHING = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if section-label ... \endif -# and \cond section-label ... \endcond blocks. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or macro consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and macros in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the -# Folder Tree View (if specified). The default is YES. - -SHOW_FILES = YES - -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the -# Namespaces page. -# This will remove the Namespaces entry from the Quick Index -# and from the Folder Tree View (if specified). The default is YES. - -SHOW_NAMESPACES = YES - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed -# by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. To create the layout file -# that represents doxygen's defaults, run doxygen with the -l option. -# You can optionally specify a file name after the option, if omitted -# DoxygenLayout.xml will be used as the name of the layout file. - -LAYOUT_FILE = - -# The CITE_BIB_FILES tag can be used to specify one or more bib files -# containing the references data. This must be a list of .bib files. The -# .bib extension is automatically appended if omitted. Using this command -# requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style -# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this -# feature you need bibtex and perl available in the search path. Do not use -# file names with spaces, bibtex cannot handle them. - -CITE_BIB_FILES = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_NO_PARAMDOC option can be enabled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = include/CppUTest - -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for -# the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh -# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py -# *.f90 *.f *.for *.vhd *.vhdl - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should be -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. -# Note that relative paths are relative to the directory from which doxygen is -# run. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or -# directories that are symbolic links (a Unix file system feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. -# If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. -# Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. -# The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty or if -# non of the patterns match the file name, INPUT_FILTER is applied. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file -# pattern. A pattern will override the setting for FILTER_PATTERN (if any) -# and it is also possible to disable source filtering for a specific pattern -# using *.ext= (so without naming a filter). This option only has effect when -# FILTER_SOURCE_FILES is enabled. - -FILTER_SOURCE_PATTERNS = - -# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that -# is part of the input, its contents will be placed on the main page (index.html). -# This can be useful if you have a project on for instance GitHub and want reuse -# the introduction page also for the doxygen output. - -USE_MDFILE_AS_MAINPAGE = - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C, C++ and Fortran comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = NO - -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = NO - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. -# Otherwise they will link to the documentation. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible -# for the proper inclusion of any scripts and style sheets that doxygen -# needs, which is dependent on the configuration options used. -# It is advised to generate a default header using "doxygen -w html -# header.html footer.html stylesheet.css YourConfigFile" and then modify -# that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when -# changing the value of configuration settings such as GENERATE_TREEVIEW! - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If left blank doxygen will -# generate a default style sheet. Note that it is recommended to use -# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this -# tag will in the future become obsolete. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional -# user-defined cascading style sheet that is included after the standard -# style sheets created by doxygen. Using this option one can overrule -# certain style aspects. This is preferred over using HTML_STYLESHEET -# since it does not replace the standard style sheet and is therefor more -# robust against future updates. Doxygen will copy the style sheet file to -# the output directory. - -HTML_EXTRA_STYLESHEET = - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that -# the files will be copied as-is; there are no commands or markers available. - -HTML_EXTRA_FILES = - -# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the style sheet and background images -# according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. -# For instance the value 0 represents red, 60 is yellow, 120 is green, -# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. -# The allowed range is 0 to 359. - -HTML_COLORSTYLE_HUE = 220 - -# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of -# the colors in the HTML output. For a value of 0 the output will use -# grayscales only. A value of 255 will produce the most vivid colors. - -HTML_COLORSTYLE_SAT = 100 - -# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to -# the luminance component of the colors in the HTML output. Values below -# 100 gradually make the output lighter, whereas values above 100 make -# the output darker. The value divided by 100 is the actual gamma applied, -# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, -# and 100 does not change the gamma. - -HTML_COLORSTYLE_GAMMA = 80 - -# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML -# page will contain the date and time when the page was generated. Setting -# this to NO can help when comparing the output of multiple runs. - -HTML_TIMESTAMP = YES - -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. - -HTML_DYNAMIC_SECTIONS = NO - -# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of -# entries shown in the various tree structured indices initially; the user -# can expand and collapse entries dynamically later on. Doxygen will expand -# the tree to such a level that at most the specified number of entries are -# visible (unless a fully collapsed tree already exceeds this amount). -# So setting the number of entries 1 will produce a full collapsed tree by -# default. 0 is a special value representing an infinite number of entries -# and will result in a full expanded tree by default. - -HTML_INDEX_NUM_ENTRIES = 100 - -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find -# it at startup. -# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. - -GENERATE_DOCSET = NO - -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) -# can be grouped. - -DOCSET_FEEDNAME = "Doxygen generated docs" - -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen -# will append .docset to the name. - -DOCSET_BUNDLE_ID = org.doxygen.Project - -# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely -# identify the documentation publisher. This should be a reverse domain-name -# style string, e.g. com.mycompany.MyDocSet.documentation. - -DOCSET_PUBLISHER_ID = org.doxygen.Publisher - -# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. - -DOCSET_PUBLISHER_NAME = Publisher - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING -# is used to encode HtmlHelp index (hhk), content (hhc) and project file -# content. - -CHM_INDEX_ENCODING = - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and -# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated -# that can be used as input for Qt's qhelpgenerator to generate a -# Qt Compressed Help (.qch) of the generated HTML documentation. - -GENERATE_QHP = NO - -# If the QHG_LOCATION tag is specified, the QCH_FILE tag can -# be used to specify the file name of the resulting .qch file. -# The path specified is relative to the HTML output folder. - -QCH_FILE = - -# The QHP_NAMESPACE tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#namespace - -QHP_NAMESPACE = org.doxygen.Project - -# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating -# Qt Help Project output. For more information please see -# http://doc.trolltech.com/qthelpproject.html#virtual-folders - -QHP_VIRTUAL_FOLDER = doc - -# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to -# add. For more information please see -# http://doc.trolltech.com/qthelpproject.html#custom-filters - -QHP_CUST_FILTER_NAME = - -# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the -# custom filter to add. For more information please see -# -# Qt Help Project / Custom Filters. - -QHP_CUST_FILTER_ATTRS = - -# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this -# project's -# filter section matches. -# -# Qt Help Project / Filter Attributes. - -QHP_SECT_FILTER_ATTRS = - -# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can -# be used to specify the location of Qt's qhelpgenerator. -# If non-empty doxygen will try to run qhelpgenerator on the generated -# .qhp file. - -QHG_LOCATION = - -# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files -# will be generated, which together with the HTML files, form an Eclipse help -# plugin. To install this plugin and make it available under the help contents -# menu in Eclipse, the contents of the directory containing the HTML and XML -# files needs to be copied into the plugins directory of eclipse. The name of -# the directory within the plugins directory should be the same as -# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before -# the help appears. - -GENERATE_ECLIPSEHELP = NO - -# A unique identifier for the eclipse help plugin. When installing the plugin -# the directory name containing the HTML and XML files should also have -# this name. - -ECLIPSE_DOC_ID = org.doxygen.Project - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) -# at top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. Since the tabs have the same information as the -# navigation tree you can set this option to NO if you already set -# GENERATE_TREEVIEW to YES. - -DISABLE_INDEX = NO - -# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index -# structure should be generated to display hierarchical information. -# If the tag value is set to YES, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. -# Since the tree basically has the same information as the tab index you -# could consider to set DISABLE_INDEX to NO when enabling this option. - -GENERATE_TREEVIEW = NO - -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open -# links to external symbols imported via tag files in a separate window. - -EXT_LINKS_IN_WINDOW = NO - -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory -# to force them to be regenerated. - -FORMULA_FONTSIZE = 10 - -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are -# not supported properly for IE 6.0, but are supported on all modern browsers. -# Note that when changing this option you need to delete any form_*.png files -# in the HTML output before the changes have effect. - -FORMULA_TRANSPARENT = YES - -# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax -# (see http://www.mathjax.org) which uses client side Javascript for the -# rendering instead of using prerendered bitmaps. Use this if you do not -# have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you may also need to install MathJax separately and -# configure the path to it using the MATHJAX_RELPATH option. - -USE_MATHJAX = NO - -# When MathJax is enabled you can set the default output format to be used for -# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and -# SVG. The default value is HTML-CSS, which is slower, but has the best -# compatibility. - -MATHJAX_FORMAT = HTML-CSS - -# When MathJax is enabled you need to specify the location relative to the -# HTML output directory using the MATHJAX_RELPATH option. The destination -# directory should contain the MathJax.js script. For instance, if the mathjax -# directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to -# the MathJax Content Delivery Network so you can quickly see the result without -# installing MathJax. -# However, it is strongly recommended to install a local -# copy of MathJax from http://www.mathjax.org before deployment. - -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest - -# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension -# names that should be enabled during MathJax rendering. - -MATHJAX_EXTENSIONS = - -# When the SEARCHENGINE tag is enabled doxygen will generate a search box -# for the HTML output. The underlying search engine uses javascript -# and DHTML and should work on any modern browser. Note that when using -# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets -# (GENERATE_DOCSET) there is already a search function so this one should -# typically be disabled. For large projects the javascript based search engine -# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. - -SEARCHENGINE = YES - -# When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. -# There are two flavours of web server based search depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. -# See the manual for details. - -SERVER_BASED_SEARCH = NO - -# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP -# script for searching. Instead the search results are written to an XML file -# which needs to be processed by an external indexer. Doxygen will invoke an -# external search engine pointed to by the SEARCHENGINE_URL option to obtain -# the search results. Doxygen ships with an example indexer (doxyindexer) and -# search engine (doxysearch.cgi) which are based on the open source search engine -# library Xapian. See the manual for configuration details. - -EXTERNAL_SEARCH = NO - -# The SEARCHENGINE_URL should point to a search engine hosted by a web server -# which will returned the search results when EXTERNAL_SEARCH is enabled. -# Doxygen ships with an example search engine (doxysearch) which is based on -# the open source search engine library Xapian. See the manual for configuration -# details. - -SEARCHENGINE_URL = - -# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed -# search data is written to a file for indexing by an external tool. With the -# SEARCHDATA_FILE tag the name of this file can be specified. - -SEARCHDATA_FILE = searchdata.xml - -# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the -# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is -# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple -# projects and redirect the results back to the right project. - -EXTERNAL_SEARCH_ID = - -# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen -# projects other than the one defined by this configuration file, but that are -# all added to the same external search index. Each project needs to have a -# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id -# of to a relative location where the documentation can be found. -# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... - -EXTRA_SEARCH_MAPPINGS = - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. -# Note that when enabling USE_PDFLATEX this option is only used for -# generating bitmaps for formulas in the HTML output, but not in the -# Makefile that is written to the output directory. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for -# the generated latex document. The footer should contain everything after -# the last chapter. If it is left blank doxygen will generate a -# standard footer. Notice: only use this tag if you know what you are doing! - -LATEX_FOOTER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -# If LATEX_SOURCE_CODE is set to YES then doxygen will include -# source code with syntax highlighting in the LaTeX output. -# Note that which sources are shown also depends on other settings -# such as SOURCE_BROWSER. - -LATEX_SOURCE_CODE = NO - -# The LATEX_BIB_STYLE tag can be used to specify the style to use for the -# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. - -LATEX_BIB_STYLE = plain - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load style sheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. -# This is useful -# if you want to understand what is going on. -# On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# pointed to by INCLUDE_PATH will be searched when a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition that -# overrules the definition found in the source code. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all references to function-like macros -# that are alone on a line, have an all uppercase name, and do not end with a -# semicolon, because these will confuse the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. For each -# tag file the location of the external documentation should be added. The -# format of a tag file without this location is as follows: -# -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths -# or URLs. Note that each tag file must have a unique name (where the name does -# NOT include the path). If a tag file is not located in the directory in which -# doxygen is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option also works with HAVE_DOT disabled, but it is recommended to -# install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is -# allowed to run in parallel. When set to 0 (the default) doxygen will -# base this on the number of processors available in the system. You can set it -# explicitly to a value larger than 0 to get control over the balance -# between CPU load and processing speed. - -DOT_NUM_THREADS = 0 - -# By default doxygen will use the Helvetica font for all dot files that -# doxygen generates. When you want a differently looking font you can specify -# the font name using DOT_FONTNAME. You need to make sure dot is able to find -# the font, which can be done by putting it in a standard location or by setting -# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the -# directory containing the font. - -DOT_FONTNAME = Helvetica - -# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. -# The default size is 10pt. - -DOT_FONTSIZE = 10 - -# By default doxygen will tell dot to use the Helvetica font. -# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to -# set the path where dot can find it. - -DOT_FONTPATH = - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If the UML_LOOK tag is enabled, the fields and methods are shown inside -# the class node. If there are many fields or methods and many nodes the -# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS -# threshold limits the number of items for each type to make the size more -# managable. Set this to 0 for no limit. Note that the threshold may be -# exceeded by 50% before the limit is enforced. - -UML_LIMIT_NUM_FIELDS = 10 - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs -# for selected functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller -# graphs for selected functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will generate a graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. If you choose svg you need to set -# HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible in IE 9+ (other browsers do not have this requirement). - -DOT_IMAGE_FORMAT = png - -# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to -# enable generation of interactive SVG images that allow zooming and panning. -# Note that this requires a modern browser other than Internet Explorer. -# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you -# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files -# visible. Older versions of IE do not have SVG support. - -INTERACTIVE_SVG = NO - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MSCFILE_DIRS tag can be used to specify one or more directories that -# contain msc files that are included in the documentation (see the -# \mscfile command). - -MSCFILE_DIRS = - -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note -# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. - -DOT_GRAPH_MAX_NODES = 50 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by -# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not -# seem to support this out of the box. Warning: Depending on the platform used, -# enabling this option may lead to badly anti-aliased labels on the edges of -# a graph (i.e. they become hard to read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES diff --git a/docker/Dockerfile.dos b/docker/Dockerfile.dos deleted file mode 100644 index c09f28fd9..000000000 --- a/docker/Dockerfile.dos +++ /dev/null @@ -1,9 +0,0 @@ -FROM ubuntu - -RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends dosbox make openssl ca-certificates git - -WORKDIR /cpputest_build - -COPY ../ /cpputest - -CMD ["/cpputest/scripts/dos_build_test.sh"] diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu deleted file mode 100644 index b6bbf152c..000000000 --- a/docker/Dockerfile.ubuntu +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu - -RUN apt-get update && \ - apt-get install -y -q --no-install-recommends file git gcc g++ make automake autoconf libtool - -WORKDIR /cpputest_build - -COPY ../ /cpputest - -CMD ["bash", "-c", "autoreconf -i /cpputest && /cpputest/configure && make tdd"] diff --git a/examples/.cdtproject b/examples/.cdtproject deleted file mode 100644 index 7756c06e3..000000000 --- a/examples/.cdtproject +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/.project b/examples/.project deleted file mode 100644 index 3432fd0b4..000000000 --- a/examples/.project +++ /dev/null @@ -1,85 +0,0 @@ - - - CppUTestExample - - - - - - org.eclipse.cdt.make.core.makeBuilder - - - org.eclipse.cdt.make.core.build.arguments - - - - org.eclipse.cdt.core.errorOutputParser - org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser; - - - org.eclipse.cdt.make.core.environment - - - - org.eclipse.cdt.make.core.enableAutoBuild - true - - - org.eclipse.cdt.make.core.build.target.inc - all - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.enabledIncrementalBuild - true - - - org.eclipse.cdt.make.core.build.location - - - - org.eclipse.cdt.make.core.build.command - make - - - org.eclipse.cdt.make.core.build.target.clean - clean depend - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - org.eclipse.cdt.make.core.build.target.auto - all - - - org.eclipse.cdt.make.core.stopOnError - false - - - - - org.eclipse.cdt.make.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.make.core.makeNature - org.eclipse.cdt.make.core.ScannerConfigNature - org.eclipse.cdt.core.ccnature - - diff --git a/examples/.settings/org.eclipse.cdt.core.prefs b/examples/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index a0b16e21b..000000000 --- a/examples/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Thu Apr 19 15:52:43 CDT 2007 -eclipse.preferences.version=1 -indexerId=org.eclipse.cdt.core.fastIndexer diff --git a/examples/AllTests/AllTests.cpp b/examples/AllTests/AllTests.cpp deleted file mode 100644 index 7d17d6f3d..000000000 --- a/examples/AllTests/AllTests.cpp +++ /dev/null @@ -1,60 +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/TestPlugin.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTestExt/IEEE754ExceptionsPlugin.h" -#include "CppUTestExt/MockSupportPlugin.h" - -class MyDummyComparator : public MockNamedValueComparator -{ -public: - virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE - { - return object1 == object2; - } - - virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE - { - return StringFrom(object); - } -}; - -int main(int ac, char** av) -{ - MyDummyComparator dummyComparator; - MockSupportPlugin mockPlugin; - IEEE754ExceptionsPlugin ieee754Plugin; - - mockPlugin.installComparator("MyDummyType", dummyComparator); - TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin); - TestRegistry::getCurrentRegistry()->installPlugin(&ieee754Plugin); - return CommandLineTestRunner::RunAllTests(ac, av); -} - -#include "AllTests.h" diff --git a/examples/AllTests/AllTests.h b/examples/AllTests/AllTests.h deleted file mode 100644 index 9902c6f17..000000000 --- a/examples/AllTests/AllTests.h +++ /dev/null @@ -1,32 +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. - */ - -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 deleted file mode 100644 index ad9ab2b72..000000000 --- a/examples/AllTests/AllTests.vcproj +++ /dev/null @@ -1,252 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/AllTests/AllTests.vcxproj b/examples/AllTests/AllTests.vcxproj deleted file mode 100644 index dc4b9b814..000000000 --- a/examples/AllTests/AllTests.vcxproj +++ /dev/null @@ -1,168 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {95A5F8D0-12C0-4AC1-B46B-292DD3886108} - - - - Application - false - MultiByte - - - Application - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ./$(Configuration)/\ - ./$(Configuration)/\ - true - .\Debug\ - .\Debug\ - true - - - - $(IntDir)BuildLog.htm - - - .\Debug/AllTests.tlb - - - - - MaxSpeed - ../../include;../ApplicationLib;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - ./$(Configuration)/AllTests.pch - ./$(Configuration)/ - ./$(Configuration)/ - ./$(Configuration)/ - ./$(Configuration)/ - Level3 - true - - - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD %(AdditionalOptions) - ../../lib/CppUTest.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies) - ./$(Configuration)/AllTests.exe - true - ./$(Configuration)/$(TargetFileName).intermediate.manifest - false - false - - - Console - false - - - MachineX86 - - - true - .\$(Configuration)/AllTests.bsc - - - "$(TargetPath)" - - - - - .\Debug/AllTests.tlb - - - - - Disabled - ../../include;../ApplicationLib;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - ./$(Configuration)/AllTests.pch - ./$(Configuration)/ - ./$(Configuration)/ - ./$(Configuration)/ - $(Configuration)/ - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - ../../lib/CppUTestd.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies) - ./$(Configuration)/AllTests.exe - true - ./$(Configuration)/$(TargetFileName).intermediate.manifest - true - ./$(Configuration)/AllTests.pdb - Console - false - - - MachineX86 - - - true - .\Debug/AllTests.bsc - - - "$(TargetPath)" - - - - - - - - - - - - - {348076b9-303c-4fe0-9380-17cdf11134a9} - false - - - - - - - - - - \ No newline at end of file diff --git a/examples/AllTests/CMakeLists.txt b/examples/AllTests/CMakeLists.txt deleted file mode 100644 index 403718bb4..000000000 --- a/examples/AllTests/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -add_executable(ExampleTests - AllTests.cpp - CircularBufferTest.cpp - EventDispatcherTest.cpp - FEDemoTest.cpp - HelloTest.cpp - MockDocumentationTest.cpp - PrinterTest.cpp -) - -target_include_directories(ExampleTests - PRIVATE - . -) - -target_compile_options(ExampleTests - PRIVATE $<$:/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 deleted file mode 100644 index 4602e5ab9..000000000 --- a/examples/AllTests/CircularBufferTest.cpp +++ /dev/null @@ -1,262 +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/TestHarness.h" -#include "MockPrinter.h" -#include "CircularBuffer.h" - -TEST_GROUP(CircularBuffer) -{ - 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) -{ - CHECK(buffer->IsEmpty()); -} - -TEST(CircularBuffer, NotEmpty) -{ - buffer->Put(10046); - CHECK(!buffer->IsEmpty()); -} - -TEST(CircularBuffer, NotEmptyThenEmpty) -{ - buffer->Put(4567); - CHECK(!buffer->IsEmpty()); - buffer->Get(); - CHECK(buffer->IsEmpty()); -} - -TEST(CircularBuffer, GetPutOneValue) -{ - buffer->Put(4567); - LONGS_EQUAL(4567, buffer->Get()); -} - -TEST(CircularBuffer, GetPutAFew) -{ - buffer->Put(1); - buffer->Put(2); - buffer->Put(3); - LONGS_EQUAL(1, buffer->Get()); - LONGS_EQUAL(2, buffer->Get()); - LONGS_EQUAL(3, buffer->Get()); -} - -TEST(CircularBuffer, Capacity) -{ - CircularBuffer b(2); - LONGS_EQUAL(2, b.Capacity()); -} - -TEST(CircularBuffer, IsFull) -{ - fillTheQueue(0, buffer->Capacity()); - CHECK(buffer->IsFull()); -} - -TEST(CircularBuffer, EmptyToFullToEmpty) -{ - fillTheQueue(100, buffer->Capacity()); - - CHECK(buffer->IsFull()); - - removeFromQueue(buffer->Capacity()); - - CHECK(buffer->IsEmpty()); -} - -TEST(CircularBuffer, WrapAround) -{ - fillTheQueue(100, buffer->Capacity()); - - CHECK(buffer->IsFull()); - LONGS_EQUAL(100, buffer->Get()); - CHECK(!buffer->IsFull()); - buffer->Put(1000); - CHECK(buffer->IsFull()); - - removeFromQueue(buffer->Capacity() - 1); - - LONGS_EQUAL(1000, buffer->Get()); - CHECK(buffer->IsEmpty()); -} - -TEST(CircularBuffer, PutToFull) -{ - int capacity = buffer->Capacity(); - fillTheQueue(900, capacity); - buffer->Put(9999); - - for (int i = 0; i < buffer->Capacity() - 1; i++) - 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 - -TEST(CircularBuffer, GetFromEmpty) -{ - LONGS_EQUAL(-1, buffer->Get()); - CHECK(buffer->IsEmpty()); -} - -/* - * the next tests demonstrate using a mock object for - * capturing output - * - */ - -TEST(CircularBuffer, PrintEmpty) -{ - MockPrinter mock; - Printer* p = &mock; - - buffer->Print(p); - STRCMP_EQUAL("Circular buffer content:\n<>\n", mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintAfterOnePut) -{ - MockPrinter mock; - - buffer->Put(1); - buffer->Print(&mock); - STRCMP_EQUAL("Circular buffer content:\n<1>\n", mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintNotYetWrappedOrFull) -{ - MockPrinter mock; - - buffer->Put(1); - buffer->Put(2); - buffer->Put(3); - buffer->Print(&mock); - STRCMP_EQUAL("Circular buffer content:\n<1, 2, 3>\n", mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintNotYetWrappedAndIsFull) -{ - MockPrinter mock; - - fillTheQueue(200, buffer->Capacity()); - - buffer->Print(&mock); - const char* expected = - "Circular buffer content:\n" - "<200, 201, 202, 203, 204>\n"; - - STRCMP_EQUAL(expected, mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintWrappedAndIsFullOldestToNewest) -{ - MockPrinter mock; - - fillTheQueue(200, buffer->Capacity()); - buffer->Get(); - buffer->Put(999); - - buffer->Print(&mock); - const char* expected = - "Circular buffer content:\n" - "<201, 202, 203, 204, 999>\n"; - - STRCMP_EQUAL(expected, mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintWrappedAndFullOverwriteOldest) -{ - MockPrinter mock; - - fillTheQueue(200, buffer->Capacity()); - buffer->Put(9999); - - buffer->Print(&mock); - const char* expected = - "Circular buffer content:\n" - "<201, 202, 203, 204, 9999>\n"; - - STRCMP_EQUAL(expected, mock.getOutput().c_str()); -} - -TEST(CircularBuffer, PrintBoundary) -{ - MockPrinter mock; - - fillTheQueue(200, buffer->Capacity()); - removeFromQueue(buffer->Capacity() - 2); - buffer->Put(888); - fillTheQueue(300, buffer->Capacity() - 1); - - buffer->Print(&mock); - const char* expected = - "Circular buffer content:\n" - "<888, 300, 301, 302, 303>\n"; - - STRCMP_EQUAL(expected, mock.getOutput().c_str()); -} - -TEST(CircularBuffer, FillEmptyThenPrint) -{ - MockPrinter mock; - - fillTheQueue(200, buffer->Capacity()); - removeFromQueue(buffer->Capacity()); - buffer->Print(&mock); - 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 deleted file mode 100644 index 7ea4b52a4..000000000 --- a/examples/AllTests/EventDispatcherTest.cpp +++ /dev/null @@ -1,135 +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. - */ - -#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" - -class ObserverMock : public EventObserver -{ -public: - virtual void notify(const Event& event, int timeOutInSeconds) CPPUTEST_OVERRIDE - { - mock() - .actualCall("notify") - .onObject(this) - .withParameterOfType("Event", "event", (void*)&event) - .withParameter("timeOutInSeconds", timeOutInSeconds); - } - virtual void notifyRegistration(EventObserver* newObserver) CPPUTEST_OVERRIDE - { - mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver); - } -}; - -class EventComparator : public MockNamedValueComparator -{ -public: - 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) CPPUTEST_OVERRIDE - { - return StringFrom(((const Event*)object)->type); - } -}; - -TEST_GROUP(EventDispatcher) -{ - Event event; - EventDispatcher* dispatcher; - ObserverMock observer; - ObserverMock observer2; - EventComparator eventComparator; - - void setup() CPPUTEST_OVERRIDE - { - dispatcher = new EventDispatcher; - mock().installComparator("Event", eventComparator); - } - void teardown() CPPUTEST_OVERRIDE - { - delete dispatcher; - mock().removeAllComparatorsAndCopiers(); - } -}; - -TEST(EventDispatcher, EventWithoutRegistrationsResultsIntoNoCalls) -{ - dispatcher->dispatchEvent(event, 10); -} - -TEST(EventDispatcher, EventWithRegistrationForEventResultsIntoCallback) -{ - mock() - .expectOneCall("notify") - .onObject(&observer) - .withParameterOfType("Event", "event", &event) - .withParameter("timeOutInSeconds", 10); - event.type = IMPORTANT_EVENT; - - dispatcher->registerObserver(IMPORTANT_EVENT, &observer); - dispatcher->dispatchEvent(event, 10); -} - -TEST(EventDispatcher, DifferentEventWithRegistrationDoesNotResultIntoCallback) -{ - event.type = LESS_IMPORTANT_EVENT; - dispatcher->registerObserver(IMPORTANT_EVENT, &observer); - dispatcher->dispatchEvent(event, 10); -} - -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("notifyRegistration").onObject(&observer).withParameter("newObserver", &observer2); - - event.type = IMPORTANT_EVENT; - dispatcher->registerObserver(IMPORTANT_EVENT, &observer); - dispatcher->registerObserver(IMPORTANT_EVENT, &observer2); - dispatcher->dispatchEvent(event, 10); -} diff --git a/examples/AllTests/FEDemoTest.cpp b/examples/AllTests/FEDemoTest.cpp deleted file mode 100644 index c2f6c17f2..000000000 --- a/examples/AllTests/FEDemoTest.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2016, Michael Feathers, James Grenning, Bas Vodde - * and Arnd Strube. 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/TestHarness.h" -#include "CppUTest/TestRegistry.h" - -#if CPPUTEST_HAVE_FENV - #include "CppUTestExt/IEEE754ExceptionsPlugin.h" - -/* - * To see a demonstration of tests failing as a result of IEEE754ExceptionsPlugin - * picking up floating point errors, run the test executable with the -ri option. - * - */ - -extern "C" { - #include -} - - #include - -TEST_GROUP(FE_Demo) -{ - void setup() CPPUTEST_OVERRIDE - { - IEEE754ExceptionsPlugin::disableInexact(); - } -}; - -IGNORE_TEST(FE_Demo, should_fail_when_FE_DIVBYZERO_is_set) -{ - float f = 1.0f; - CHECK((f /= 0.0f) >= std::numeric_limits::infinity()); -} - -IGNORE_TEST(FE_Demo, should_fail_when_FE_UNDERFLOW_is_set) -{ - 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) -{ - 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) -{ - IEEE754ExceptionsPlugin::enableInexact(); - 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) -{ - CHECK(5.0f == 15.0f / 3.0f); -} - -#endif diff --git a/examples/AllTests/HelloTest.cpp b/examples/AllTests/HelloTest.cpp deleted file mode 100644 index 7bc644e0e..000000000 --- a/examples/AllTests/HelloTest.cpp +++ /dev/null @@ -1,61 +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 "hello.h" - -#include -#include -#include "CppUTest/TestHarness.h" - -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() CPPUTEST_OVERRIDE - { - buffer = new SimpleString(); - UT_PTR_SET(PrintFormated, &output_method); - } - void teardown() CPPUTEST_OVERRIDE - { - delete buffer; - } -}; - -TEST(HelloWorld, PrintOk) -{ - printHelloWorld(); - STRCMP_EQUAL("Hello World!\n", buffer->asCharString()); -} diff --git a/examples/AllTests/MockDocumentationTest.cpp b/examples/AllTests/MockDocumentationTest.cpp deleted file mode 100644 index 0bd578ea8..000000000 --- a/examples/AllTests/MockDocumentationTest.cpp +++ /dev/null @@ -1,234 +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/TestHarness.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockSupport_c.h" - -TEST_GROUP(FirstTestGroup) -{ -}; - -TEST(FirstTestGroup, FirsTest) -{ - // FAIL("Fail me!"); -} - -TEST(FirstTestGroup, SecondTest) -{ - // STRCMP_EQUAL("hello", "world"); -} - -TEST_GROUP(MockDocumentation) -{ -}; - -static void productionCode() -{ - mock().actualCall("productionCode"); -} - -TEST(MockDocumentation, SimpleScenario) -{ - mock().expectOneCall("productionCode"); - productionCode(); - mock().checkExpectations(); -} - -class ClassFromProductionCode -{ -public: - virtual void importantFunction() {} - virtual ~ClassFromProductionCode() {} -}; - -class ClassFromProductionCodeMock : public ClassFromProductionCode -{ -public: - virtual void importantFunction() CPPUTEST_OVERRIDE - { - mock().actualCall("importantFunction").onObject(this); - } -}; - -TEST(MockDocumentation, SimpleScenarioObject) -{ - ClassFromProductionCode* object = new ClassFromProductionCodeMock; /* create mock instead of real thing */ - - mock().expectOneCall("importantFunction").onObject(object); - object->importantFunction(); - mock().checkExpectations(); - - delete object; -} - -static void parameters_function(int p1, const char* p2) -{ - void* object = (void*)1; - mock().actualCall("function").onObject(object).withParameter("p1", p1).withParameter("p2", p2); -} - -TEST(MockDocumentation, parameters) -{ - void* object = (void*)1; - mock().expectOneCall("function").onObject(object).withParameter("p1", 2).withParameter("p2", "hah"); - parameters_function(2, "hah"); -} - -class MyTypeComparator : public MockNamedValueComparator -{ -public: - virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE - { - return object1 == object2; - } - virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE - { - return StringFrom(object); - } -}; - -TEST(MockDocumentation, ObjectParameters) -{ - void* object = (void*)1; - MyTypeComparator comparator; - mock().installComparator("myType", comparator); - mock().expectOneCall("function").withParameterOfType("myType", "parameterName", object); - mock().clear(); - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockDocumentation, returnValue) -{ - mock().expectOneCall("function").andReturnValue(10); - mock().actualCall("function").returnValue().getIntValue(); - int value = mock().returnValue().getIntValue(); - LONGS_EQUAL(10, value); -} - -TEST(MockDocumentation, setData) -{ - ClassFromProductionCode object; - mock().setData("importantValue", 10); - mock().setDataObject("importantObject", "ClassFromProductionCode", &object); - - ClassFromProductionCode* pobject; - int value = mock().getData("importantValue").getIntValue(); - pobject = (ClassFromProductionCode*)mock().getData("importantObject").getObjectPointer(); - - LONGS_EQUAL(10, value); - POINTERS_EQUAL(pobject, &object); -} - -static void doSomethingThatWouldOtherwiseBlowUpTheMockingFramework() {} - -TEST(MockDocumentation, otherMockSupport) -{ - mock().crashOnFailure(); - // mock().actualCall("unex"); - - mock().expectOneCall("foo"); - mock().ignoreOtherCalls(); - - mock().disable(); - doSomethingThatWouldOtherwiseBlowUpTheMockingFramework(); - mock().enable(); - - mock().clear(); -} - -TEST(MockDocumentation, scope) -{ - mock("xmlparser").expectOneCall("open"); - mock("filesystem").ignoreOtherCalls(); - - mock("xmlparser").actualCall("open"); -} - -static int equalMethod(const void* object1, const void* object2) -{ - return object1 == object2; -} - -static const char* toStringMethod(const void*) -{ - return "string"; -} - -TEST(MockDocumentation, CInterface) -{ - 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); - mock_c()->removeAllComparatorsAndCopiers(); - - mock_c()->setIntData("important", 10); - mock_c()->checkExpectations(); - mock_c()->clear(); -} - -TEST_GROUP(FooTestGroup) -{ - void setup() CPPUTEST_OVERRIDE - { - // Init stuff - } - - void teardown() CPPUTEST_OVERRIDE - { - // Uninit stuff - } -}; - -TEST(FooTestGroup, Foo) -{ - // Test FOO -} - -TEST(FooTestGroup, MoreFoo) -{ - // Test more FOO -} - -TEST_GROUP(BarTestGroup) -{ - void setup() CPPUTEST_OVERRIDE - { - // Init Bar - } -}; - -TEST(BarTestGroup, Bar) -{ - // Test Bar -} diff --git a/examples/AllTests/MockPrinter.h b/examples/AllTests/MockPrinter.h deleted file mode 100644 index 1df48962f..000000000 --- a/examples/AllTests/MockPrinter.h +++ /dev/null @@ -1,73 +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. - */ - -#ifndef D_MockPrinter_H -#define D_MockPrinter_H - -/////////////////////////////////////////////////////////////////////////////// -// -// MockPrinter.h -// -// MockPrinter is responsible for providing a test stub for Printer -// -/////////////////////////////////////////////////////////////////////////////// -#include "Printer.h" -#include "CppUTest/SimpleString.h" -#include -#include - -class MockPrinter : public Printer -{ -public: - explicit MockPrinter() {} - virtual ~MockPrinter() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - virtual void Print(const char* s) CPPUTEST_OVERRIDE - { - savedOutput.append(s); - } - - virtual void Print(long int value) CPPUTEST_OVERRIDE - { - SimpleString buffer; - buffer = StringFromFormat("%ld", value); - savedOutput.append(buffer.asCharString()); - } - - std::string getOutput() const - { - return savedOutput; - } - -private: - std::string savedOutput; - - MockPrinter(const MockPrinter&); - MockPrinter& operator=(const MockPrinter&); -}; - -#endif // D_MockPrinter_H diff --git a/examples/AllTests/PrinterTest.cpp b/examples/AllTests/PrinterTest.cpp deleted file mode 100644 index 88a5d1ca3..000000000 --- a/examples/AllTests/PrinterTest.cpp +++ /dev/null @@ -1,68 +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/TestHarness.h" -#include "Printer.h" -#include "MockPrinter.h" - -TEST_GROUP(Printer) -{ - Printer* printer; - MockPrinter* mockPrinter; - - void setup() CPPUTEST_OVERRIDE - { - mockPrinter = new MockPrinter(); - printer = mockPrinter; - } - void teardown() CPPUTEST_OVERRIDE - { - delete printer; - } -}; - -TEST(Printer, PrintConstCharStar) -{ - printer->Print("hello"); - printer->Print("hello\n"); - const char* expected = "hellohello\n"; - CHECK_EQUAL(expected, mockPrinter->getOutput()); -} - -TEST(Printer, PrintLong) -{ - printer->Print(1234); - const char* expected = "1234"; - CHECK_EQUAL(expected, mockPrinter->getOutput()); -} - -TEST(Printer, StreamOperators) -{ - *printer << "n=" << 1234; - const char* expected = "n=1234"; - CHECK_EQUAL(expected, mockPrinter->getOutput()); -} diff --git a/examples/AllTests/RunAllTests.sh b/examples/AllTests/RunAllTests.sh deleted file mode 100755 index df5d92233..000000000 --- a/examples/AllTests/RunAllTests.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -#put any pre-test execution commands here. -echo Running all tests -./AllTests $1 diff --git a/examples/ApplicationLib/ApplicationLib.vcproj b/examples/ApplicationLib/ApplicationLib.vcproj deleted file mode 100644 index f7b054bbe..000000000 --- a/examples/ApplicationLib/ApplicationLib.vcproj +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/ApplicationLib/ApplicationLib.vcxproj b/examples/ApplicationLib/ApplicationLib.vcxproj deleted file mode 100644 index dfa1dbcd5..000000000 --- a/examples/ApplicationLib/ApplicationLib.vcxproj +++ /dev/null @@ -1,133 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {348076B9-303C-4FE0-9380-17CDF11134A9} - - - - StaticLibrary - false - MultiByte - - - StaticLibrary - false - MultiByte - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\ - $(Configuration)\ - $(Configuration)\ - - - - Disabled - ../../include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - .\Debug/ApplicationLib.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\ApplicationLib.lib - true - - - true - ./$(Configuration)/ApplicationLib.bsc - - - - - MaxSpeed - ../../include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - ./$(Configuration)/ApplicationLib.pch - ./$(Configuration)/ - ./$(Configuration)/ - ./$(Configuration)/ - Level3 - true - - - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - ./$(Configuration)/ApplicationLib.lib - true - - - true - ./$(Configuration)/ApplicationLib.bsc - - - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/ApplicationLib/CMakeLists.txt b/examples/ApplicationLib/CMakeLists.txt deleted file mode 100644 index 564e1201f..000000000 --- a/examples/ApplicationLib/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_library(ApplicationLib - CircularBuffer.cpp - EventDispatcher.cpp - hello.c - Printer.cpp -) -target_include_directories(ExampleTests - PUBLIC - . -) - diff --git a/examples/ApplicationLib/CircularBuffer.cpp b/examples/ApplicationLib/CircularBuffer.cpp deleted file mode 100644 index a2d839be5..000000000 --- a/examples/ApplicationLib/CircularBuffer.cpp +++ /dev/null @@ -1,106 +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 "CircularBuffer.h" -#include "Printer.h" -#include - -CircularBuffer::CircularBuffer(int _capacity) : index(0), outdex(0), capacity(_capacity), empty(true), full(false) -{ - buffer = new int[(size_t)this->capacity]; -} - -CircularBuffer::~CircularBuffer() -{ - delete[] buffer; -} - -bool CircularBuffer::IsEmpty() -{ - return empty; -} - -bool CircularBuffer::IsFull() -{ - return full; -} - -void CircularBuffer::Put(int i) -{ - empty = false; - buffer[index] = i; - index = Next(index); - if (full) - outdex = Next(outdex); - else if (index == outdex) - full = true; -} - -int CircularBuffer::Get() -{ - int result = -1; - full = false; - - if (!empty) { - result = buffer[outdex]; - outdex = Next(outdex); - if (outdex == index) - empty = true; - } - return result; -} - -int CircularBuffer::Capacity() -{ - return capacity; -} - -int CircularBuffer::Next(int i) -{ - if (++i >= capacity) - i = 0; - return i; -} - -void CircularBuffer::Print(Printer* p) -{ - p->Print("Circular buffer content:\n<"); - - int printIndex = outdex; - int count = index - outdex; - - 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(", "); - } - p->Print(">\n"); -} diff --git a/examples/ApplicationLib/CircularBuffer.h b/examples/ApplicationLib/CircularBuffer.h deleted file mode 100644 index e9634f10a..000000000 --- a/examples/ApplicationLib/CircularBuffer.h +++ /dev/null @@ -1,70 +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. - */ - -#ifndef D_CircularBuffer_H -#define D_CircularBuffer_H - -/////////////////////////////////////////////////////////////////////////////// -// -// CircularBuffer.h -// -// CircularBuffer is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// -class Printer; - -class CircularBuffer -{ -public: - explicit CircularBuffer(int capacity = CAPACITY); - virtual ~CircularBuffer(); - - void Put(int); - int Get(); - bool IsEmpty(); - bool IsFull(); - int Capacity(); - int Next(int i); - void Print(Printer*); - -private: - int index; - int outdex; - int* buffer; - int capacity; - enum - { - CAPACITY = 5 - }; - bool empty; - bool full; - - CircularBuffer(const CircularBuffer&); - CircularBuffer& operator=(const CircularBuffer&); -}; - -#endif // D_CircularBuffer_H diff --git a/examples/ApplicationLib/EventDispatcher.cpp b/examples/ApplicationLib/EventDispatcher.cpp deleted file mode 100644 index 140be3547..000000000 --- a/examples/ApplicationLib/EventDispatcher.cpp +++ /dev/null @@ -1,47 +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 "EventDispatcher.h" -using namespace std; - -EventDispatcher::EventDispatcher() {} - -void EventDispatcher::registerObserver(EventType type, EventObserver* observer) -{ - for (list >::iterator i = observerList_.begin(); i != observerList_.end(); i++) - i->second->notifyRegistration(observer); - - observerList_.push_back(make_pair(type, observer)); -} - -void EventDispatcher::dispatchEvent(const Event& event, int timeoutSeconds) -{ - 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 deleted file mode 100644 index a27eb056f..000000000 --- a/examples/ApplicationLib/EventDispatcher.h +++ /dev/null @@ -1,64 +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. - */ - -#ifndef EVENTDISPATCHER_H -#define EVENTDISPATCHER_H - -#include - -enum EventType -{ - IMPORTANT_EVENT, - LESS_IMPORTANT_EVENT -}; - -class Event -{ -public: - EventType type; -}; - -class EventObserver -{ -public: - virtual void notify(const Event& event, int timeOutInSeconds) = 0; - virtual void notifyRegistration(EventObserver* newObserver) = 0; - virtual ~EventObserver() {} -}; - -class EventDispatcher -{ - std::list > observerList_; - -public: - EventDispatcher(); - - void registerObserver(EventType type, EventObserver* observer); - void dispatchEvent(const Event& event, int timeoutSeconds); -}; - -#endif diff --git a/examples/ApplicationLib/ExamplesNewOverrides.h b/examples/ApplicationLib/ExamplesNewOverrides.h deleted file mode 100644 index 86cb0219b..000000000 --- a/examples/ApplicationLib/ExamplesNewOverrides.h +++ /dev/null @@ -1,29 +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 -#include "CppUTest/MemoryLeakDetectorNewMacros.h" diff --git a/examples/ApplicationLib/Printer.cpp b/examples/ApplicationLib/Printer.cpp deleted file mode 100644 index 893ae1a40..000000000 --- a/examples/ApplicationLib/Printer.cpp +++ /dev/null @@ -1,56 +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 "Printer.h" -#include - -Printer::Printer() {} - -Printer::~Printer() {} - -void Printer::Print(const char* s) -{ - for (const char* p = s; *p; p++) - putchar(*p); -} - -void Printer::Print(long int n) -{ - printf("%ld", n); -} - -Printer& operator<<(Printer& p, const char* s) -{ - p.Print(s); - return p; -} - -Printer& operator<<(Printer& p, long int i) -{ - p.Print(i); - return p; -} diff --git a/examples/ApplicationLib/Printer.h b/examples/ApplicationLib/Printer.h deleted file mode 100644 index 51aa63313..000000000 --- a/examples/ApplicationLib/Printer.h +++ /dev/null @@ -1,54 +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. - */ - -#ifndef D_Printer_H -#define D_Printer_H - -/////////////////////////////////////////////////////////////////////////////// -// -// Printer is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// - -class Printer -{ -public: - explicit Printer(); - virtual ~Printer(); - - virtual void Print(const char*); - 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 diff --git a/examples/ApplicationLib/hello.c b/examples/ApplicationLib/hello.c deleted file mode 100644 index 2ab67a69c..000000000 --- a/examples/ApplicationLib/hello.c +++ /dev/null @@ -1,36 +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 -#include "hello.h" - -void printHelloWorld(void) -{ - PrintFormated("Hello World!\n"); -} - -int (*PrintFormated)(const char*, ...) = printf; diff --git a/examples/ApplicationLib/hello.h b/examples/ApplicationLib/hello.h deleted file mode 100644 index 83524a5c0..000000000 --- a/examples/ApplicationLib/hello.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. - */ - -#ifndef HELLO_H_ -#define HELLO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -extern void printHelloWorld(void); - -extern int (*PrintFormated)(const char*, ...); - -#ifdef __cplusplus -} -#endif - -#endif /*HELLO_H_*/ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index 98244cee6..000000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -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/examples/CppUTestExample_VS2008.sln b/examples/CppUTestExample_VS2008.sln deleted file mode 100644 index d3bcb4198..000000000 --- a/examples/CppUTestExample_VS2008.sln +++ /dev/null @@ -1,29 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllTests", "AllTests\AllTests.vcproj", "{95A5F8D0-12C0-4AC1-B46B-292DD3886108}" - ProjectSection(ProjectDependencies) = postProject - {348076B9-303C-4FE0-9380-17CDF11134A9} = {348076B9-303C-4FE0-9380-17CDF11134A9} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ApplicationLib", "ApplicationLib\ApplicationLib.vcproj", "{348076B9-303C-4FE0-9380-17CDF11134A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Debug|Win32.ActiveCfg = Debug|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Debug|Win32.Build.0 = Debug|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Release|Win32.ActiveCfg = Release|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Release|Win32.Build.0 = Release|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Debug|Win32.Build.0 = Debug|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Release|Win32.ActiveCfg = Release|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/examples/CppUTestExample_VS201x.sln b/examples/CppUTestExample_VS201x.sln deleted file mode 100644 index 2ea7d4a31..000000000 --- a/examples/CppUTestExample_VS201x.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllTests", "AllTests\AllTests.vcxproj", "{95A5F8D0-12C0-4AC1-B46B-292DD3886108}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ApplicationLib", "ApplicationLib\ApplicationLib.vcxproj", "{348076B9-303C-4FE0-9380-17CDF11134A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Debug|Win32.ActiveCfg = Debug|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Debug|Win32.Build.0 = Debug|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Release|Win32.ActiveCfg = Release|Win32 - {95A5F8D0-12C0-4AC1-B46B-292DD3886108}.Release|Win32.Build.0 = Release|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Debug|Win32.Build.0 = Debug|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Release|Win32.ActiveCfg = Release|Win32 - {348076B9-303C-4FE0-9380-17CDF11134A9}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 1aff02ddd..000000000 --- a/examples/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -#--------- -# -# CppUTest Examples Makefile -# -#---------- - -#Set this to @ to keep the makefile quiet -ifndef SILENCE - SILENCE = @ -endif - -#--- Inputs ----# -COMPONENT_NAME = CppUTestExamples -CPPUTEST_HOME = .. - -CPPUTEST_USE_EXTENSIONS = Y -CPP_PLATFORM = Gcc - -# This line is overriding the default new macros. This is helpful -# when using std library includes like and other containers -# so that memory leak detection does not conflict with stl. -CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE = -include ApplicationLib/ExamplesNewOverrides.h -SRC_DIRS = \ - ApplicationLib - -TEST_SRC_DIRS = \ - AllTests - -INCLUDE_DIRS =\ - .\ - ApplicationLib\ - $(CPPUTEST_HOME)/include\ - -include $(CPPUTEST_HOME)/build/MakefileWorker.mk - - diff --git a/examples/Makefile_ExamplesWithCppUTestInstalled.mk b/examples/Makefile_ExamplesWithCppUTestInstalled.mk deleted file mode 100644 index e42992fb9..000000000 --- a/examples/Makefile_ExamplesWithCppUTestInstalled.mk +++ /dev/null @@ -1,26 +0,0 @@ - -CPPFLAGS += -I /usr/local/include -LD_LIBRARIES = -L/usr/local/lib -lCppUTest -lCppUTestExt - -VPATH = ApplicationLib AllTests - -APPLIB_OBJECTS = CircularBuffer.o EventDispatcher.o hello.o Printer.o -TEST_OBJECTS = AllTests.o CircularBufferTest.o EventDispatcherTest.o FEDemoTest.o HelloTest.o MockDocumentationTest.o PrinterTest.o - -CPPFLAGS += -I ApplicationLib - -TEST_TARGET = CppUTestExamples -APPLIB = applicationLib.a - -$(TEST_TARGET): $(TEST_OBJECTS) applicationLib.a - $(CXX) -o $@ $^ $(LD_LIBRARIES) $(LDFLAGS) - ./$(TEST_TARGET) - -$(APPLIB): $(APPLIB_OBJECTS) - $(AR) $(ARFLAGS) $@ $^ - -clean: - rm -f -rf *.o - rm -f $(TEST_TARGET) - rm -f $(APPLIB) - diff --git a/examples/README.txt b/examples/README.txt deleted file mode 100644 index f3a2a2905..000000000 --- a/examples/README.txt +++ /dev/null @@ -1,7 +0,0 @@ -To build the examples - -for gcc: -make clean all test gcov - -for MS Studio: -The workspace files may be out of date. \ No newline at end of file diff --git a/gcovr.cfg b/gcovr.cfg deleted file mode 100644 index 1f027724a..000000000 --- a/gcovr.cfg +++ /dev/null @@ -1,6 +0,0 @@ -filter = src/ -filter = include/ -html = yes -html-details = yes -output = coverage.html -print-summary = yes diff --git a/images/bkg.png b/images/bkg.png new file mode 100644 index 000000000..fcebb5b22 Binary files /dev/null and b/images/bkg.png differ diff --git a/images/blacktocat.png b/images/blacktocat.png new file mode 100644 index 000000000..273d5710a Binary files /dev/null and b/images/blacktocat.png differ diff --git a/include/CppUTest/CommandLineArguments.h b/include/CppUTest/CommandLineArguments.h deleted file mode 100644 index d162a5e2f..000000000 --- a/include/CppUTest/CommandLineArguments.h +++ /dev/null @@ -1,120 +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. - */ - -#ifndef D_CommandLineArguments_H -#define D_CommandLineArguments_H - -#include "SimpleString.h" -#include "TestOutput.h" -#include "TestFilter.h" - -class TestPlugin; - -class CommandLineArguments -{ -public: - explicit CommandLineArguments(int ac, const char *const *av); - virtual ~CommandLineArguments(); - - bool parse(TestPlugin* plugin); - bool needHelp() const; - bool isVerbose() const; - bool isVeryVerbose() const; - 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; - bool isJUnitOutput() const; - bool isEclipseOutput() const; - bool isTeamCityOutput() const; - bool runTestsInSeperateProcess() const; - const SimpleString& getPackageName() const; - const char* usage() const; - const char* help() const; - -private: - - enum OutputType - { - OUTPUT_ECLIPSE, OUTPUT_JUNIT, OUTPUT_TEAMCITY - }; - - int ac_; - const char *const *av_; - - bool needHelp_; - bool verbose_; - bool veryVerbose_; - bool color_; - bool runTestsAsSeperateProcess_; - bool listTestGroupNames_; - bool listTestGroupAndCaseNames_; - bool listTestLocations_; - bool runIgnored_; - bool reversing_; - bool crashOnFail_; - bool rethrowExceptions_; - bool shuffling_; - bool shufflingPreSeeded_; - size_t repeat_; - size_t shuffleSeed_; - TestFilter* groupFilters_; - TestFilter* nameFilters_; - OutputType outputType_; - SimpleString packageName_; - - SimpleString getParameterField(int ac, const char *const *av, int& i, const SimpleString& parameterName); - 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, 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); - void addNameFilter(int ac, const char *const *av, int& index); - void addStrictNameFilter(int ac, const char *const *av, int& index); - void addExcludeNameFilter(int ac, const char *const *av, int& index); - void addExcludeStrictNameFilter(int ac, const char *const *av, int& index); - void addTestToRunBasedOnVerboseOutput(int ac, const char *const *av, int& index, const char* parameterName); - bool setOutputType(int ac, const char *const *av, int& index); - void setPackageName(int ac, const char *const *av, int& index); - - CommandLineArguments(const CommandLineArguments&); - CommandLineArguments& operator=(const CommandLineArguments&); - -}; - -#endif diff --git a/include/CppUTest/CommandLineTestRunner.h b/include/CppUTest/CommandLineTestRunner.h deleted file mode 100644 index 91c52d177..000000000 --- a/include/CppUTest/CommandLineTestRunner.h +++ /dev/null @@ -1,68 +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. - */ - -#ifndef D_CommandLineTestRunner_H -#define D_CommandLineTestRunner_H - -#include "TestHarness.h" -#include "TestOutput.h" -#include "CommandLineArguments.h" -#include "TestFilter.h" - -class TestRegistry; - -#define DEF_PLUGIN_MEM_LEAK "MemoryLeakPlugin" -#define DEF_PLUGIN_SET_POINTER "SetPointerPlugin" - -class CommandLineTestRunner -{ -public: - static int RunAllTests(int ac, const char *const *av); - static int RunAllTests(int ac, char** av); - - CommandLineTestRunner(int ac, const char *const *av, TestRegistry* registry); - virtual ~CommandLineTestRunner(); - - int runAllTestsMain(); - -protected: - virtual TestOutput* createTeamCityOutput(); - virtual TestOutput* createJUnitOutput(const SimpleString& packageName); - virtual TestOutput* createConsoleOutput(); - virtual TestOutput* createCompositeOutput(TestOutput* outputOne, TestOutput* outputTwo); - - TestOutput* output_; -private: - CommandLineArguments* arguments_; - TestRegistry* registry_; - - bool parseArguments(TestPlugin*); - int runAllTests(); - void initializeTestRun(); -}; - -#endif diff --git a/include/CppUTest/CppUTestConfig.h b/include/CppUTest/CppUTestConfig.h deleted file mode 100644 index 435ea74d2..000000000 --- a/include/CppUTest/CppUTestConfig.h +++ /dev/null @@ -1,358 +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. - */ - -#ifndef CPPUTESTCONFIG_H_ -#define CPPUTESTCONFIG_H_ - -#ifndef CPPUTEST_USE_OWN_CONFIGURATION - // 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 - -/* - * This file is added for some specific CppUTest configurations that earlier were spread out into multiple files. - * - * The goal of this file is to stay really small and not to include other things, but mainly to remove duplication - * from other files and resolve dependencies in #includes. - * - */ - -/* - * Lib C dependencies that are currently still left: - * - * stdarg.h -> We use formatting functions and va_list requires to include stdarg.h in SimpleString - * stdlib.h -> The TestHarness_c.h includes this to try to avoid conflicts in its malloc #define. This dependency can - * easily be removed by not enabling the MALLOC overrides. - * - * Lib C++ dependencies are all under the CPPUTEST_USE_STD_CPP_LIB. - * The only dependency is to which has the bad_alloc struct - * - */ - -/* Do we use Standard C or not? When doing Kernel development, standard C usage is out. */ -#ifndef CPPUTEST_USE_STD_C_LIB - #ifdef CPPUTEST_STD_C_LIB_DISABLED - #define CPPUTEST_USE_STD_C_LIB 0 - #else - #define CPPUTEST_USE_STD_C_LIB 1 - #endif -#endif - - -/* Do we use Standard C++ or not? */ -#ifndef CPPUTEST_USE_STD_CPP_LIB - #ifdef CPPUTEST_STD_CPP_LIB_DISABLED - #define CPPUTEST_USE_STD_CPP_LIB 0 - #else - #define CPPUTEST_USE_STD_CPP_LIB 1 - #endif -#endif - -/* Is memory leak detection enabled? - * Controls the override of the global operator new/deleted and malloc/free. - * Without this, there will be no memory leak detection in C/C++. -*/ - -#ifndef CPPUTEST_USE_MEM_LEAK_DETECTION - #ifdef CPPUTEST_MEM_LEAK_DETECTION_DISABLED - #define CPPUTEST_USE_MEM_LEAK_DETECTION 0 - #else - #define CPPUTEST_USE_MEM_LEAK_DETECTION 1 - #endif -#endif - -/* Should be the only #include here. Standard C library wrappers */ -#include "StandardCLibrary.h" - -/* 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 CPPUTEST_HAS_ATTRIBUTE(x) 0 -#else - #define CPPUTEST_HAS_ATTRIBUTE(x) __has_attribute(x) -#endif - -#if defined (__cplusplus) && __cplusplus >= 201103L - #define CPPUTEST_NORETURN [[noreturn]] -#elif CPPUTEST_HAS_ATTRIBUTE(noreturn) - #define CPPUTEST_NORETURN __attribute__((noreturn)) -#else - #define CPPUTEST_NORETURN -#endif - -#if defined(__MINGW32__) -#define CPPUTEST_CHECK_FORMAT_TYPE __MINGW_PRINTF_FORMAT -#else -#define CPPUTEST_CHECK_FORMAT_TYPE printf -#endif - -#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 - #define DEFAULT_COPY_CONSTRUCTOR(classname) classname(const classname &) = default; -#else - #define DEFAULT_COPY_CONSTRUCTOR(classname) -#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 -#elif defined(__SANITIZE_ADDRESS__) - #define CPPUTEST_SANITIZE_ADDRESS 1 -#endif - -#ifndef CPPUTEST_SANITIZE_ADDRESS - #define CPPUTEST_SANITIZE_ADDRESS 0 -#endif - -#if CPPUTEST_SANITIZE_ADDRESS - #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_DO_NOT_SANITIZE_ADDRESS -#endif - -/* - * Handling of IEEE754 (IEC559) floating point exceptions via fenv.h - * Predominantly works on non-Visual C++ compilers and Visual C++ 2008 and newer - */ -#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 - -/* - * Detection of different 64 bit environments - */ - -#if defined(__LP64__) || defined(_LP64) || (defined(__WORDSIZE) && (__WORDSIZE == 64 )) || defined(__x86_64) || defined(_WIN64) -#define CPPUTEST_64BIT -#if defined(_WIN64) -#define CPPUTEST_64BIT_32BIT_LONGS -#endif -#endif - -/* 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. - */ -#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). - */ -#if CPPUTEST_USE_STD_C_LIB && (INT_MAX == 0x7fff) -#define CPPUTEST_16BIT_INTS -#endif - -/* - * Support for "long long" type. - * - * 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 or CMake. - * LLONG_MAX is set in limits.h. This is a crude attempt to detect long long support when no configure is used - * - */ -#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 - -#if CPPUTEST_USE_LONG_LONG -typedef long long cpputest_longlong; -typedef unsigned long long cpputest_ulonglong; -#else -/* Define some placeholders to disable the overloaded methods. - * It's not required to have these match the size of the "real" type, but it's occasionally convenient. - */ - -#if defined(CPPUTEST_64BIT) && !defined(CPPUTEST_64BIT_32BIT_LONGS) -#define CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE 16 -#else -#define CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE 8 -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - -typedef struct -{ - char dummy[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE]; -} cpputest_longlong; - -typedef struct -{ - char dummy[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE]; -} cpputest_ulonglong; - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - -#endif - -#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 __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 deleted file mode 100644 index 5bcd53768..000000000 --- a/include/CppUTest/CppUTestGeneratedConfig.h +++ /dev/null @@ -1,47 +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. - */ - -/* - * This file is confusing, sorry for that :) Please never edit this file. - * - * It serves 3 purposes - * - * 1) When you installed CppUTest on your system (make install), then this file should be overwritten by one that - * actually contains some configuration of your system. Mostly info such as availability of types, headers, etc. - * 2) When you build CppUTest using autotools, this file will be included and it will include the generated file. - * That should be the same file as will be installed if you run make install - * 3) When you use CppUTest on another platform that doesn't require configuration, then this file does nothing and - * should be harmless. - * - * If you have done make install and you still found this text, then please report a bug :) - * - */ - -#ifdef HAVE_CONFIG_H -#include "generated/CppUTestGeneratedConfig.h" -#endif - diff --git a/include/CppUTest/JUnitTestOutput.h b/include/CppUTest/JUnitTestOutput.h deleted file mode 100644 index 5e5746f56..000000000 --- a/include/CppUTest/JUnitTestOutput.h +++ /dev/null @@ -1,81 +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. - */ - -#ifndef D_JUnitTestOutput_h -#define D_JUnitTestOutput_h - -#include "TestOutput.h" -#include "SimpleString.h" - -struct JUnitTestOutputImpl; -struct JUnitTestCaseResultNode; - -class JUnitTestOutput: public TestOutput -{ -public: - JUnitTestOutput(); - virtual ~JUnitTestOutput() 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 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() CPPUTEST_OVERRIDE; - - virtual SimpleString createFileName(const SimpleString& group); - void setPackageName(const SimpleString &package); - -protected: - - JUnitTestOutputImpl* impl_; - void resetTestGroupResult(); - - virtual void openFileForWrite(const SimpleString& fileName); - virtual void writeTestGroupToFile(); - virtual void writeToFile(const SimpleString& buffer); - virtual void closeFile(); - - virtual void writeXmlHeader(); - virtual void writeTestSuiteSummary(); - virtual void writeProperties(); - virtual void writeTestCases(); - virtual SimpleString encodeXmlText(const SimpleString& textbody); - virtual SimpleString encodeFileName(const SimpleString& fileName); - virtual void writeFailure(JUnitTestCaseResultNode* node); - virtual void writeFileEnding(); -}; - -#endif diff --git a/include/CppUTest/MemoryLeakDetector.h b/include/CppUTest/MemoryLeakDetector.h deleted file mode 100644 index 195a3384a..000000000 --- a/include/CppUTest/MemoryLeakDetector.h +++ /dev/null @@ -1,270 +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. - */ - -#ifndef D_MemoryLeakDetector_h -#define D_MemoryLeakDetector_h - -enum MemLeakPeriod -{ - mem_leak_period_all, - mem_leak_period_disabled, - mem_leak_period_enabled, - mem_leak_period_checking -}; - -class TestMemoryAllocator; -class SimpleMutex; - -class MemoryLeakFailure -{ -public: - virtual ~MemoryLeakFailure() - { - } - - virtual void fail(char* fail_string)=0; -}; - -struct SimpleStringBuffer -{ - enum - { - SIMPLE_STRING_BUFFER_LEN = 4096 - }; - - SimpleStringBuffer(); - void clear(); - void add(const char* format, ...) CPPUTEST_CHECK_FORMAT(CPPUTEST_CHECK_FORMAT_TYPE, 2, 3); - void addMemoryDump(const void* memory, size_t memorySize); - - char* toString(); - - void setWriteLimit(size_t write_limit); - void resetWriteLimit(); - bool reachedItsCapacity(); -private: - char buffer_[SIMPLE_STRING_BUFFER_LEN]; - size_t positions_filled_; - size_t write_limit_; -}; - -struct MemoryLeakDetectorNode; - -class MemoryLeakOutputStringBuffer -{ -public: - MemoryLeakOutputStringBuffer(); - - void clear(); - - void startMemoryLeakReporting(); - void stopMemoryLeakReporting(); - - void reportMemoryLeak(MemoryLeakDetectorNode* leak); - - void reportDeallocateNonAllocatedMemoryFailure(const char* freeFile, size_t freeLine, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter); - void reportMemoryCorruptionFailure(MemoryLeakDetectorNode* node, const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter); - void reportAllocationDeallocationMismatchFailure(MemoryLeakDetectorNode* node, const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter); - char* toString(); - -private: - void addAllocationLocation(const char* allocationFile, size_t allocationLineNumber, size_t allocationSize, TestMemoryAllocator* allocator); - void addDeallocationLocation(const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* allocator); - - void addMemoryLeakHeader(); - void addMemoryLeakFooter(size_t totalAmountOfLeaks); - void addWarningForUsingMalloc(); - void addNoMemoryLeaksMessage(); - void addErrorMessageForTooMuchLeaks(); - -private: - - size_t total_leaks_; - bool giveWarningOnUsingMalloc_; - - void reportFailure(const char* message, const char* allocFile, - size_t allocLine, size_t allocSize, - TestMemoryAllocator* allocAllocator, const char* freeFile, - size_t freeLine, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter); - - SimpleStringBuffer outputBuffer_; -}; - -struct MemoryLeakDetectorNode -{ - MemoryLeakDetectorNode() : - size_(0), number_(0), memory_(NULLPTR), file_(NULLPTR), line_(0), allocator_(NULLPTR), period_(mem_leak_period_enabled), allocation_stage_(0), next_(NULLPTR) - { - } - - void init(char* memory, unsigned number, size_t size, TestMemoryAllocator* allocator, MemLeakPeriod period, unsigned char allocation_stage, const char* file, size_t line); - - size_t size_; - unsigned number_; - char* memory_; - const char* file_; - size_t line_; - TestMemoryAllocator* allocator_; - MemLeakPeriod period_; - unsigned char allocation_stage_; - -private: - friend struct MemoryLeakDetectorList; - MemoryLeakDetectorNode* next_; -}; - -struct MemoryLeakDetectorList -{ - MemoryLeakDetectorList() : - head_(NULLPTR) - {} - - void addNewNode(MemoryLeakDetectorNode* node); - MemoryLeakDetectorNode* retrieveNode(char* memory); - MemoryLeakDetectorNode* removeNode(char* memory); - - MemoryLeakDetectorNode* getFirstLeak(MemLeakPeriod period); - MemoryLeakDetectorNode* getFirstLeakForAllocationStage(unsigned char allocation_stage); - - MemoryLeakDetectorNode* getNextLeak(MemoryLeakDetectorNode* node, MemLeakPeriod period); - MemoryLeakDetectorNode* getNextLeakForAllocationStage(MemoryLeakDetectorNode* node, unsigned char allocation_stage); - - MemoryLeakDetectorNode* getLeakFrom(MemoryLeakDetectorNode* node, MemLeakPeriod period); - MemoryLeakDetectorNode* getLeakForAllocationStageFrom(MemoryLeakDetectorNode* node, unsigned char allocation_stage); - - size_t getTotalLeaks(MemLeakPeriod period); - void clearAllAccounting(MemLeakPeriod period); - - bool isInPeriod(MemoryLeakDetectorNode* node, MemLeakPeriod period); - bool isInAllocationStage(MemoryLeakDetectorNode* node, unsigned char allocation_stage); - -private: - MemoryLeakDetectorNode* head_; -}; - -struct MemoryLeakDetectorTable -{ - void clearAllAccounting(MemLeakPeriod period); - - void addNewNode(MemoryLeakDetectorNode* node); - MemoryLeakDetectorNode* retrieveNode(char* memory); - MemoryLeakDetectorNode* removeNode(char* memory); - - size_t getTotalLeaks(MemLeakPeriod period); - - MemoryLeakDetectorNode* getFirstLeak(MemLeakPeriod period); - MemoryLeakDetectorNode* getFirstLeakForAllocationStage(unsigned char allocation_stage); - MemoryLeakDetectorNode* getNextLeak(MemoryLeakDetectorNode* leak, MemLeakPeriod period); - MemoryLeakDetectorNode* getNextLeakForAllocationStage(MemoryLeakDetectorNode* leak, unsigned char allocation_stage); - -private: - unsigned long hash(char* memory); - - enum - { - hash_prime = MEMORY_LEAK_HASH_TABLE_SIZE - }; - MemoryLeakDetectorList table_[hash_prime]; -}; - -class MemoryLeakDetector -{ -public: - MemoryLeakDetector(MemoryLeakFailure* reporter); - virtual ~MemoryLeakDetector(); - - void enable(); - void disable(); - - void disableAllocationTypeChecking(); - void enableAllocationTypeChecking(); - - void startChecking(); - void stopChecking(); - - unsigned char getCurrentAllocationStage() const; - void increaseAllocationStage(); - void decreaseAllocationStage(); - - const char* report(MemLeakPeriod period); - void markCheckingPeriodLeaksAsNonCheckingPeriod(); - size_t totalMemoryLeaks(MemLeakPeriod period); - void clearAllAccounting(MemLeakPeriod period); - - char* allocMemory(TestMemoryAllocator* allocator, size_t size, bool allocatNodesSeperately = false); - char* allocMemory(TestMemoryAllocator* allocator, size_t size, - const char* file, size_t line, bool allocatNodesSeperately = false); - void deallocMemory(TestMemoryAllocator* allocator, void* memory, bool allocatNodesSeperately = false); - void deallocMemory(TestMemoryAllocator* allocator, void* memory, const char* file, size_t line, bool allocatNodesSeperately = false); - void deallocAllMemoryInCurrentAllocationStage(); - char* reallocMemory(TestMemoryAllocator* allocator, char* memory, size_t size, const char* file, size_t line, bool allocatNodesSeperately = false); - - void invalidateMemory(char* memory); - void removeMemoryLeakInformationWithoutCheckingOrDeallocatingTheMemoryButDeallocatingTheAccountInformation(TestMemoryAllocator* allocator, void* memory, bool allocatNodesSeperately); - enum - { -#ifdef CPPUTEST_DISABLE_MEM_CORRUPTION_CHECK - memory_corruption_buffer_size = 0 -#else - memory_corruption_buffer_size = 3 -#endif - }; - - unsigned getCurrentAllocationNumber(); - - SimpleMutex* getMutex(void); -private: - MemoryLeakFailure* reporter_; - MemLeakPeriod current_period_; - MemoryLeakOutputStringBuffer outputBuffer_; - MemoryLeakDetectorTable memoryTable_; - bool doAllocationTypeChecking_; - unsigned allocationSequenceNumber_; - unsigned char current_allocation_stage_; - SimpleMutex* mutex_; - - char* allocateMemoryWithAccountingInformation(TestMemoryAllocator* allocator, size_t size, const char* file, size_t line, bool allocatNodesSeperately); - char* reallocateMemoryWithAccountingInformation(TestMemoryAllocator* allocator, char* memory, size_t size, const char* file, size_t line, bool allocatNodesSeperately); - MemoryLeakDetectorNode* createMemoryLeakAccountingInformation(TestMemoryAllocator* allocator, size_t size, char* memory, bool allocatNodesSeperately); - - - bool validMemoryCorruptionInformation(char* memory); - bool matchingAllocation(TestMemoryAllocator *alloc_allocator, TestMemoryAllocator *free_allocator); - - void storeLeakInformation(MemoryLeakDetectorNode * node, char *new_memory, size_t size, TestMemoryAllocator *allocator, const char *file, size_t line); - void ConstructMemoryLeakReport(MemLeakPeriod period); - - size_t sizeOfMemoryWithCorruptionInfo(size_t size); - MemoryLeakDetectorNode* getNodeFromMemoryPointer(char* memory, size_t size); - - char* reallocateMemoryAndLeakInformation(TestMemoryAllocator* allocator, char* memory, size_t size, const char* file, size_t line, bool allocatNodesSeperately); - - void addMemoryCorruptionInformation(char* memory); - void checkForCorruption(MemoryLeakDetectorNode* node, const char* file, size_t line, TestMemoryAllocator* allocator, bool allocateNodesSeperately); -}; - -#endif diff --git a/include/CppUTest/MemoryLeakDetectorForceInclude.h b/include/CppUTest/MemoryLeakDetectorForceInclude.h deleted file mode 100644 index 6de90e177..000000000 --- a/include/CppUTest/MemoryLeakDetectorForceInclude.h +++ /dev/null @@ -1,4 +0,0 @@ -// 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/MemoryLeakDetectorMallocMacros.h b/include/CppUTest/MemoryLeakDetectorMallocMacros.h deleted file mode 100644 index 42c324796..000000000 --- a/include/CppUTest/MemoryLeakDetectorMallocMacros.h +++ /dev/null @@ -1,68 +0,0 @@ - -/* - * This file can be used to get extra debugging information about memory leaks in your production code. - * It defines a preprocessor macro for malloc. This will pass additional information to the - * malloc and this will give the line/file information of the memory leaks in your code. - * - * You can use this by including this file to all your production code. When using gcc, you can use - * the -include file to do this for you. - * - */ - -#include "CppUTestConfig.h" - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -/* This prevents the declaration from done twice and makes sure the file only #defines malloc, so it can be included anywhere */ -#ifndef CPPUTEST_USE_MALLOC_MACROS - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern void* cpputest_malloc_location(size_t size, const char* file, size_t line); -extern void* cpputest_calloc_location(size_t count, size_t size, const char* file, size_t line); -extern void* cpputest_realloc_location(void *, size_t, const char* file, size_t line); -extern void cpputest_free_location(void* buffer, const char* file, size_t line); - -#ifdef __cplusplus -} -#endif - -extern void crash_on_allocation_number(unsigned number); - - -#define malloc(a) cpputest_malloc_location(a, __FILE__, __LINE__) -#define calloc(a, b) cpputest_calloc_location(a, b, __FILE__, __LINE__) -#define realloc(a, b) cpputest_realloc_location(a, b, __FILE__, __LINE__) -#define free(a) cpputest_free_location(a, __FILE__, __LINE__) - -#define CPPUTEST_USE_MALLOC_MACROS 1 -#endif /* CPPUTEST_USE_MALLOC_MACROS */ - -/* This prevents strdup macros to get defined, unless it has been enabled by the user or generated config */ -#ifdef CPPUTEST_HAVE_STRDUP - -/* This prevents the declaration from done twice and makes sure the file only #defines strdup, so it can be included anywhere */ -#ifndef CPPUTEST_USE_STRDUP_MACROS - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern char* cpputest_strdup_location(const char* str, const char* file, size_t line); -extern char* cpputest_strndup_location(const char* str, size_t n, const char* file, size_t line); - -#ifdef __cplusplus -} -#endif - -#define strdup(str) cpputest_strdup_location(str, __FILE__, __LINE__) -#define strndup(str, n) cpputest_strndup_location(str, n, __FILE__, __LINE__) - -#define CPPUTEST_USE_STRDUP_MACROS 1 -#endif /* CPPUTEST_USE_STRDUP_MACROS */ -#endif /* CPPUTEST_HAVE_STRDUP */ -#endif /* CPPUTEST_USE_MEM_LEAK_DETECTION */ diff --git a/include/CppUTest/MemoryLeakDetectorNewMacros.h b/include/CppUTest/MemoryLeakDetectorNewMacros.h deleted file mode 100644 index 880b89560..000000000 --- a/include/CppUTest/MemoryLeakDetectorNewMacros.h +++ /dev/null @@ -1,95 +0,0 @@ - -/* - * This file can be used to get extra debugging information about memory leaks in your production code. - * It defines a preprocessor macro for operator new. This will pass additional information to the - * operator new and this will give the line/file information of the memory leaks in your code. - * - * You can use this by including this file to all your production code. When using gcc, you can use - * the -include file to do this for you. - * - * Warning: Using the new macro can cause a conflict with newly declared operator news. This can be - * resolved by: - * 1. #undef operator new before including this file - * 2. Including the files that override operator new before this file. - * This can be done by creating your own NewMacros.h file that includes your operator new overrides - * and THEN this file. - * - * STL (or StdC++ lib) also does overrides for operator new. Therefore, you'd need to include the STL - * files *before* this file too. - * - */ - -#include "CppUTestConfig.h" - -/* Make sure that mem leak detection is on and that this is being included from a C++ file */ -#if CPPUTEST_USE_MEM_LEAK_DETECTION && defined(__cplusplus) - -/* This #ifndef prevents from being included twice and enables the file to be included anywhere */ -#ifndef CPPUTEST_USE_NEW_MACROS - - #if CPPUTEST_USE_STD_CPP_LIB - #ifdef CPPUTEST_USE_STRDUP_MACROS - #if CPPUTEST_USE_STRDUP_MACROS == 1 - /* - * 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 - * it has already been includeded earlier. - */ - #undef strdup - #undef strndup - #undef CPPUTEST_USE_STRDUP_MACROS - #define CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR - #endif - #endif - #include - #include - #include - #ifdef CPPUTEST_REINCLUDE_MALLOC_MEMORY_LEAK_DETECTOR - #include "MemoryLeakDetectorMallocMacros.h" - #endif - #endif - - /* 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; -#if __cplusplus >= 201402L - void operator delete (void* mem, size_t size) UT_NOTHROW; - void operator delete[] (void* mem, size_t size) UT_NOTHROW; -#endif - -#endif - - -#ifdef __clang__ - #pragma clang diagnostic push - #if (__clang_major__ == 3 && __clang_minor__ >= 6) || __clang_major__ >= 4 - #pragma clang diagnostic ignored "-Wkeyword-macro" - #endif -#endif - -#define new new(__FILE__, __LINE__) - -#ifdef __clang__ - #pragma clang diagnostic pop -#endif - -#define CPPUTEST_USE_NEW_MACROS 1 - -#endif diff --git a/include/CppUTest/MemoryLeakWarningPlugin.h b/include/CppUTest/MemoryLeakWarningPlugin.h deleted file mode 100644 index 01ae95be7..000000000 --- a/include/CppUTest/MemoryLeakWarningPlugin.h +++ /dev/null @@ -1,89 +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. - */ - -#ifndef D_MemoryLeakWarningPlugin_h -#define D_MemoryLeakWarningPlugin_h - -#include "TestPlugin.h" -#include "MemoryLeakDetectorNewMacros.h" - -#define IGNORE_ALL_LEAKS_IN_TEST() if (MemoryLeakWarningPlugin::getFirstPlugin()) MemoryLeakWarningPlugin::getFirstPlugin()->ignoreAllLeaksInTest() -#define EXPECT_N_LEAKS(n) if (MemoryLeakWarningPlugin::getFirstPlugin()) MemoryLeakWarningPlugin::getFirstPlugin()->expectLeaksInTest(n) - -extern void crash_on_allocation_number(unsigned alloc_number); - -class MemoryLeakDetector; -class MemoryLeakFailure; - -class MemoryLeakWarningPlugin: public TestPlugin -{ -public: - MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector = NULLPTR); - virtual ~MemoryLeakWarningPlugin() CPPUTEST_DESTRUCTOR_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); - - void ignoreAllLeaksInTest(); - void expectLeaksInTest(size_t n); - - void destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(bool des); - - MemoryLeakDetector* getMemoryLeakDetector(); - - static MemoryLeakWarningPlugin* getFirstPlugin(); - - static MemoryLeakDetector* getGlobalDetector(); - static MemoryLeakFailure* getGlobalFailureReporter(); - static void setGlobalDetector(MemoryLeakDetector* detector, MemoryLeakFailure* reporter); - static void destroyGlobalDetector(); - - static void turnOffNewDeleteOverloads(); - static void turnOnDefaultNotThreadSafeNewDeleteOverloads(); - static void turnOnThreadSafeNewDeleteOverloads(); - static bool areNewDeleteOverloaded(); - - static void saveAndDisableNewDeleteOverloads(); - static void restoreNewDeleteOverloads(); - -private: - MemoryLeakDetector* memLeakDetector_; - bool ignoreAllWarnings_; - bool destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_; - size_t expectedLeaks_; - size_t failureCount_; - - static MemoryLeakWarningPlugin* firstPlugin_; -}; - -extern void* cpputest_malloc_location_with_leak_detection(size_t size, const char* file, size_t line); -extern void* cpputest_realloc_location_with_leak_detection(void* memory, size_t size, const char* file, size_t line); -extern void cpputest_free_location_with_leak_detection(void* buffer, const char* file, size_t line); - -#endif diff --git a/include/CppUTest/PlatformSpecificFunctions.h b/include/CppUTest/PlatformSpecificFunctions.h deleted file mode 100644 index 3b2f983cc..000000000 --- a/include/CppUTest/PlatformSpecificFunctions.h +++ /dev/null @@ -1,46 +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. - */ - -#ifndef PLATFORMSPECIFICFUNCTIONS_H_ -#define PLATFORMSPECIFICFUNCTIONS_H_ - -#include "CppUTest/TestOutput.h" -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment(); - -class TestPlugin; -extern void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result); -extern int (*PlatformSpecificFork)(void); -extern int (*PlatformSpecificWaitPid)(int pid, int* status, int options); - -/* Platform specific interface we use in order to minimize dependencies with LibC. - * This enables porting to different embedded platforms. - * - */ - -#include "CppUTest/PlatformSpecificFunctions_c.h" - -#endif diff --git a/include/CppUTest/PlatformSpecificFunctions_c.h b/include/CppUTest/PlatformSpecificFunctions_c.h deleted file mode 100644 index 36700818b..000000000 --- a/include/CppUTest/PlatformSpecificFunctions_c.h +++ /dev/null @@ -1,97 +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. - */ - -/****************************************************************************** - * - * PlatformSpecificFunctions_c.H - * - * Provides an interface for when working with pure C - * - *******************************************************************************/ - - -#ifndef PLATFORMSPECIFICFUNCTIONS_C_H_ -#define PLATFORMSPECIFICFUNCTIONS_C_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Jumping operations. They manage their own jump buffers */ -extern int (*PlatformSpecificSetJmp)(void (*function) (void*), void* data); -extern void (*PlatformSpecificLongJmp)(void); -extern void (*PlatformSpecificRestoreJumpBuffer)(void); - -/* Time operations */ -extern unsigned long (*GetPlatformSpecificTimeInMillis)(void); -extern const char* (*GetPlatformSpecificTimeString)(void); - -/* String operations */ -extern int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list); - -/* Misc */ -extern double (*PlatformSpecificFabs)(double d); -extern int (*PlatformSpecificIsNan)(double d); -extern int (*PlatformSpecificIsInf)(double d); -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 void (*PlatformSpecificFlush)(void); - -/* Random operations */ -extern void (*PlatformSpecificSrand)(unsigned int); -extern int (*PlatformSpecificRand)(void); - -/* Dynamic Memory operations */ -extern void* (*PlatformSpecificMalloc)(size_t size); -extern void* (*PlatformSpecificRealloc)(void* memory, size_t size); -extern void (*PlatformSpecificFree)(void* memory); -extern void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size); -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 -} -#endif - -#endif /* PLATFORMSPECIFICFUNCTIONS_C_H_ */ diff --git a/include/CppUTest/SimpleMutex.h b/include/CppUTest/SimpleMutex.h deleted file mode 100644 index 8bb59fb69..000000000 --- a/include/CppUTest/SimpleMutex.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2014, Michael Feathers, James Grenning, Bas Vodde and Chen YewMing - * 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. - */ - -#ifndef D_SimpleMutex_h -#define D_SimpleMutex_h - -#include "CppUTest/PlatformSpecificFunctions.h" - -class SimpleMutex -{ -public: - SimpleMutex(void); - ~SimpleMutex(void); - void Lock(void); - void Unlock(void); -private: - PlatformSpecificMutex psMtx; -}; - - -class ScopedMutexLock -{ -public: - ScopedMutexLock(SimpleMutex *); - ~ScopedMutexLock(void); -private: - SimpleMutex * mutex; -}; - -#endif diff --git a/include/CppUTest/SimpleString.h b/include/CppUTest/SimpleString.h deleted file mode 100644 index 63e7684d0..000000000 --- a/include/CppUTest/SimpleString.h +++ /dev/null @@ -1,244 +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. - */ - -/////////////////////////////////////////////////////////////////////////////// -// -// SIMPLESTRING.H -// -// One of the design goals of CppUnitLite is to compilation with very old C++ -// compilers. For that reason, the simple string class that provides -// only the operations needed in CppUnitLite. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef D_SimpleString_h -#define D_SimpleString_h - -#include "StandardCLibrary.h" - -class SimpleStringCollection; -class TestMemoryAllocator; - -class SimpleString -{ - friend bool operator==(const SimpleString& left, const SimpleString& right); - friend bool operator!=(const SimpleString& left, const SimpleString& right); - -public: - SimpleString(const char *value = ""); - SimpleString(const char *value, size_t repeatCount); - SimpleString(const SimpleString& other); - ~SimpleString(); - - SimpleString& operator=(const SimpleString& other); - SimpleString operator+(const SimpleString&) const; - SimpleString& operator+=(const SimpleString&); - SimpleString& operator+=(const char*); - - static const size_t npos = (size_t) -1; - - char at(size_t pos) const; - size_t find(char ch) const; - size_t findFrom(size_t starting_position, char ch) const; - bool contains(const SimpleString& other) const; - bool containsNoCase(const SimpleString& other) const; - bool startsWith(const SimpleString& other) const; - bool endsWith(const SimpleString& other) const; - void split(const SimpleString& split, - SimpleStringCollection& outCollection) const; - bool equalsNoCase(const SimpleString& str) const; - - size_t count(const SimpleString& str) const; - - void replace(char to, char with); - void replace(const char* to, const char* with); - - SimpleString lowerCase() const; - SimpleString subString(size_t beginPos) const; - SimpleString subString(size_t beginPos, size_t amount) const; - 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; - - static void padStringsToSameLength(SimpleString& str1, SimpleString& str2, char ch); - - static TestMemoryAllocator* getStringAllocator(); - static void setStringAllocator(TestMemoryAllocator* allocator); - - static int AtoI(const char*str); - static unsigned AtoU(const char*str); - static int StrCmp(const char* s1, const char* s2); - static size_t StrLen(const char*); - static int StrNCmp(const char* s1, const char* s2, size_t n); - static char* StrNCpy(char* s1, const char* s2, size_t n); - static const char* StrStr(const char* s1, const char* s2); - static char ToLower(char ch); - static int MemCmp(const void* s1, const void *s2, size_t n); - static char* allocStringBuffer(size_t size, const char* file, size_t line); - static void deallocStringBuffer(char* str, size_t size, const char* file, size_t line); -private: - - const char* getBuffer() const; - - void deallocateInternalBuffer(); - void setInternalBufferAsEmptyString(); - void setInternalBufferToNewBuffer(size_t bufferSize); - void setInternalBufferTo(char* buffer, size_t bufferSize); - void copyBufferToNewInternalBuffer(const char* otherBuffer); - void copyBufferToNewInternalBuffer(const char* otherBuffer, size_t bufferSize); - void copyBufferToNewInternalBuffer(const SimpleString& otherBuffer); - - char *buffer_; - size_t bufferSize_; - - static TestMemoryAllocator* stringAllocator_; - - char* getEmptyString() const; - static char* copyToNewBuffer(const char* bufferToCopy, size_t bufferSize); - 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 -{ -public: - SimpleStringCollection(); - ~SimpleStringCollection(); - - void allocate(size_t size); - - size_t size() const; - SimpleString& operator[](size_t index); - -private: - SimpleString* collection_; - SimpleString empty_; - size_t size_; - - void operator =(SimpleStringCollection&); - SimpleStringCollection(SimpleStringCollection&); -}; - -class GlobalSimpleStringAllocatorStash -{ -public: - GlobalSimpleStringAllocatorStash(); - void save(); - void restore(); -private: - TestMemoryAllocator* originalAllocator_; -}; - -class MemoryAccountant; -class AccountingTestMemoryAllocator; - -class GlobalSimpleStringMemoryAccountant -{ -public: - GlobalSimpleStringMemoryAccountant(); - ~GlobalSimpleStringMemoryAccountant(); - - void useCacheSizes(size_t cacheSizes[], size_t length); - - void start(); - void stop(); - SimpleString report(); - - AccountingTestMemoryAllocator* getAllocator(); -private: - void restoreAllocator(); - - AccountingTestMemoryAllocator* allocator_; - MemoryAccountant* accountant_; -}; - -SimpleString StringFrom(bool value); -SimpleString StringFrom(const void* value); -SimpleString StringFrom(void (*value)()); -SimpleString StringFrom(char value); -SimpleString StringFrom(const char *value); -SimpleString StringFromOrNull(const char * value); -SimpleString StringFrom(int value); -SimpleString StringFrom(unsigned int value); -SimpleString StringFrom(long value); -SimpleString StringFrom(unsigned long value); -SimpleString StringFrom(cpputest_longlong value); -SimpleString StringFrom(cpputest_ulonglong value); -SimpleString HexStringFrom(unsigned int value); -SimpleString HexStringFrom(int value); -SimpleString HexStringFrom(signed char value); -SimpleString HexStringFrom(long value); -SimpleString HexStringFrom(unsigned long value); -SimpleString HexStringFrom(cpputest_longlong value); -SimpleString HexStringFrom(cpputest_ulonglong value); -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, ...) 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); -SimpleString StringFromBinaryWithSize(const unsigned char* value, size_t size); -SimpleString StringFromBinaryWithSizeOrNull(const unsigned char* value, size_t size); -SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_t byteCount); -SimpleString StringFromOrdinalNumber(unsigned int number); -SimpleString BracketsFormattedHexStringFrom(int value); -SimpleString BracketsFormattedHexStringFrom(unsigned int value); -SimpleString BracketsFormattedHexStringFrom(long value); -SimpleString BracketsFormattedHexStringFrom(unsigned long value); -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. - * Specifically nullptr_t is not officially supported - */ -#if __cplusplus > 199711L && !defined __arm__ && CPPUTEST_USE_STD_CPP_LIB -SimpleString StringFrom(const std::nullptr_t value); -#endif - -#if CPPUTEST_USE_STD_CPP_LIB - -SimpleString StringFrom(const std::string& other); - -#endif - -#endif diff --git a/include/CppUTest/SimpleStringInternalCache.h b/include/CppUTest/SimpleStringInternalCache.h deleted file mode 100644 index ebbd30f6b..000000000 --- a/include/CppUTest/SimpleStringInternalCache.h +++ /dev/null @@ -1,110 +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. - */ - -#ifndef D_SimpleStringInternalCache_h -#define D_SimpleStringInternalCache_h - -#include "CppUTest/TestMemoryAllocator.h" - -struct SimpleStringMemoryBlock; -struct SimpleStringInternalCacheNode; - -class SimpleStringInternalCache -{ -public: - SimpleStringInternalCache(); - ~SimpleStringInternalCache(); - - void setAllocator(TestMemoryAllocator* allocator); - - char* alloc(size_t size); - void dealloc(char* memory, size_t size); - - bool hasFreeBlocksOfSize(size_t size); - - void clearCache(); - void clearAllIncludingCurrentlyUsedMemory(); -private: - void printDeallocatingUnknownMemory(char* memory); - - enum { amountOfInternalCacheNodes = 5}; - bool isCached(size_t size); - size_t getIndexForCache(size_t size); - SimpleStringInternalCacheNode* getCacheNodeFromSize(size_t size); - - SimpleStringInternalCacheNode* createInternalCacheNodes(); - void destroyInternalCacheNode(SimpleStringInternalCacheNode * node); - SimpleStringMemoryBlock* createSimpleStringMemoryBlock(size_t sizeOfString, SimpleStringMemoryBlock* next); - void destroySimpleStringMemoryBlock(SimpleStringMemoryBlock * block, size_t size); - void destroySimpleStringMemoryBlockList(SimpleStringMemoryBlock * block, size_t size); - - SimpleStringMemoryBlock* reserveCachedBlockFrom(SimpleStringInternalCacheNode* node); - void releaseCachedBlockFrom(char* memory, SimpleStringInternalCacheNode* node); - void releaseNonCachedMemory(char* memory, size_t size); - - SimpleStringMemoryBlock* allocateNewCacheBlockFrom(SimpleStringInternalCacheNode* node); - SimpleStringMemoryBlock* addToSimpleStringMemoryBlockList(SimpleStringMemoryBlock* newBlock, SimpleStringMemoryBlock* previousHead); - - TestMemoryAllocator* allocator_; - SimpleStringInternalCacheNode* cache_; - SimpleStringMemoryBlock* nonCachedAllocations_; - bool hasWarnedAboutDeallocations; -}; - -class SimpleStringCacheAllocator : public TestMemoryAllocator -{ -public: - SimpleStringCacheAllocator(SimpleStringInternalCache& cache, TestMemoryAllocator* previousAllocator); - virtual ~SimpleStringCacheAllocator() CPPUTEST_DESTRUCTOR_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 CPPUTEST_OVERRIDE; - virtual const char* alloc_name() const CPPUTEST_OVERRIDE; - virtual const char* free_name() const CPPUTEST_OVERRIDE; - - virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE; - TestMemoryAllocator* originalAllocator(); -private: - SimpleStringInternalCache& cache_; - TestMemoryAllocator* originalAllocator_; -}; - -class GlobalSimpleStringCache -{ - SimpleStringCacheAllocator* allocator_; - SimpleStringInternalCache cache_; - -public: - GlobalSimpleStringCache(); - ~GlobalSimpleStringCache(); - - TestMemoryAllocator* getAllocator(); -}; - -#endif diff --git a/include/CppUTest/StandardCLibrary.h b/include/CppUTest/StandardCLibrary.h deleted file mode 100644 index d518236ca..000000000 --- a/include/CppUTest/StandardCLibrary.h +++ /dev/null @@ -1,104 +0,0 @@ - -/* Must include this first to ensure the StandardC include in CppUTestConfig still happens at the right moment */ -#include "CppUTestConfig.h" - -#ifndef STANDARDCLIBRARY_H_ -#define STANDARDCLIBRARY_H_ - -#if CPPUTEST_USE_STD_C_LIB - -/* Needed for size_t */ -#include - -/* Sometimes the C++ library does an #undef in stdlib of malloc and free. We want to prevent that */ -#ifdef __cplusplus - #if CPPUTEST_USE_STD_CPP_LIB - #include - #include - #include - #endif -#endif - -/* Needed for malloc */ -#include - -/* Needed for std::nullptr */ -#ifdef __cplusplus - #if CPPUTEST_USE_STD_CPP_LIB - #include - #endif -#endif - -/* Needed for ... */ -#include - -/* Kludge to get a va_copy in VC++ V6 and in GCC 98 */ -#ifndef va_copy -#ifdef __GNUC__ -#define va_copy __va_copy -#else -#define va_copy(copy, original) copy = original; -#endif -#endif - -/* Needed for some detection of long long and 64 bit */ -#include - -/* Needed to ensure that string.h is included prior to strdup redefinition */ -#ifdef CPPUTEST_HAVE_STRDUP -#include -#endif - -#else - -#ifdef __KERNEL__ - -/* Unfinished and not working! Hacking hacking hacking. Why bother make the header files C++ safe! */ -#define false kernel_false -#define true kernel_true -#define bool kernel_bool -#define new kernel_new -#define _Bool int -#include -#include -#undef false -#undef true -#undef bool -#undef new - -#else - -/* - * #warning "These definitions in StandardCLibrary.h are pure (educated, from linux kernel) guesses at the moment. Replace with your platform includes." - * Not on as warning are as errors :P - */ - -#ifdef __SIZE_TYPE__ -typedef __SIZE_TYPE__ size_t; -#else -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))) - -#define va_list __builtin_va_list -#define va_copy __builtin_va_copy -#define va_start __builtin_va_start -#define va_end __builtin_va_end - -#endif - -#endif - -#endif diff --git a/include/CppUTest/TeamCityTestOutput.h b/include/CppUTest/TeamCityTestOutput.h deleted file mode 100644 index caf67d586..000000000 --- a/include/CppUTest/TeamCityTestOutput.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef D_TeamCityTestOutput_h -#define D_TeamCityTestOutput_h - -#include "TestOutput.h" -#include "SimpleString.h" - -class TeamCityTestOutput: public ConsoleTestOutput -{ -public: - TeamCityTestOutput(void); - virtual ~TeamCityTestOutput(void) CPPUTEST_DESTRUCTOR_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) CPPUTEST_OVERRIDE; - -protected: - -private: - void printEscaped(const char* s); - const UtestShell *currtest_; - SimpleString currGroup_; -}; - -#endif diff --git a/include/CppUTest/TestFailure.h b/include/CppUTest/TestFailure.h deleted file mode 100644 index 7dc816f2c..000000000 --- a/include/CppUTest/TestFailure.h +++ /dev/null @@ -1,200 +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. - */ - -/////////////////////////////////////////////////////////////////////////////// -// -// Failure is a class which holds information for a specific -// test failure. It can be overriden for more complex failure messages -// -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef D_TestFailure_H -#define D_TestFailure_H - -#include "SimpleString.h" - -#if CPPUTEST_USE_STD_CPP_LIB -#include -#endif - -class UtestShell; -class TestOutput; - -class TestFailure -{ - -public: - TestFailure(UtestShell*, const char* fileName, size_t lineNumber, const SimpleString& theMessage); - TestFailure(UtestShell*, const SimpleString& theMessage); - TestFailure(UtestShell*, const char* fileName, size_t lineNumber); - TestFailure(const TestFailure&); - virtual ~TestFailure(); - - virtual SimpleString getFileName() const; - virtual SimpleString getTestName() const; - virtual SimpleString getTestNameOnly() const; - virtual size_t getFailureLineNumber() const; - virtual SimpleString getMessage() const; - virtual SimpleString getTestFileName() const; - virtual size_t getTestLineNumber() const; - bool isOutsideTestFile() const; - bool isInHelperFunction() const; - - -protected: - SimpleString createButWasString(const SimpleString& expected, const SimpleString& actual); - SimpleString createDifferenceAtPosString(const SimpleString& actual, size_t offset, size_t reportedPosition); - SimpleString createUserText(const SimpleString& text); - - SimpleString testName_; - SimpleString testNameOnly_; - SimpleString fileName_; - size_t lineNumber_; - SimpleString testFileName_; - size_t testLineNumber_; - SimpleString message_; - - TestFailure& operator=(const TestFailure&); - -}; - -class EqualsFailure: public TestFailure -{ -public: - EqualsFailure(UtestShell*, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text); - EqualsFailure(UtestShell*, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text); -}; - -class DoublesEqualFailure: public TestFailure -{ -public: - DoublesEqualFailure(UtestShell*, const char* fileName, size_t lineNumber, double expected, double actual, double threshold, const SimpleString& text); -}; - -class CheckEqualFailure : public TestFailure -{ -public: - CheckEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text); -}; - -class ComparisonFailure : public TestFailure -{ -public: - ComparisonFailure(UtestShell* test, const char *fileName, size_t lineNumber, const SimpleString& checkString, const SimpleString& comparisonString, const SimpleString& text); -}; - -class ContainsFailure: public TestFailure -{ -public: - ContainsFailure(UtestShell*, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text); -}; - -class CheckFailure : public TestFailure -{ -public: - CheckFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& checkString, const SimpleString& conditionString, const SimpleString& textString = ""); -}; - -class FailFailure : public TestFailure -{ -public: - FailFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& message); -}; - -class LongsEqualFailure : public TestFailure -{ -public: - LongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, long expected, long actual, const SimpleString& text); -}; - -class UnsignedLongsEqualFailure : public TestFailure -{ -public: - UnsignedLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, unsigned long expected, unsigned long actual, const SimpleString& text); -}; - -class LongLongsEqualFailure : public TestFailure -{ -public: - LongLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, cpputest_longlong expected, cpputest_longlong actual, const SimpleString& text); -}; - -class UnsignedLongLongsEqualFailure : public TestFailure -{ -public: - UnsignedLongLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, cpputest_ulonglong expected, cpputest_ulonglong actual, const SimpleString& text); -}; - -class SignedBytesEqualFailure : public TestFailure -{ -public: - SignedBytesEqualFailure (UtestShell* test, const char* fileName, size_t lineNumber, signed char expected, signed char actual, const SimpleString& text); -}; - -class StringEqualFailure : public TestFailure -{ -public: - StringEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text); -}; - -class StringEqualNoCaseFailure : public TestFailure -{ -public: - StringEqualNoCaseFailure(UtestShell* test, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text); -}; - -class BinaryEqualFailure : public TestFailure -{ -public: - BinaryEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const unsigned char* expected, const unsigned char* actual, size_t size, const SimpleString& text); -}; - -class BitsEqualFailure : public TestFailure -{ -public: - BitsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, unsigned long expected, unsigned long actual, unsigned long mask, size_t byteCount, const SimpleString& text); -}; - -class FeatureUnsupportedFailure : public TestFailure -{ -public: - 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 deleted file mode 100644 index 730f52e14..000000000 --- a/include/CppUTest/TestFilter.h +++ /dev/null @@ -1,63 +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. - */ - -#ifndef TESTFILTER_H_ -#define TESTFILTER_H_ - -#include "SimpleString.h" - -class TestFilter -{ -public: - - TestFilter(); - TestFilter(const char* filter); - TestFilter(const SimpleString& filter); - - TestFilter* add(TestFilter* filter); - TestFilter* getNext() const; - - bool match(const SimpleString& name) const; - - void strictMatching(); - void invertMatching(); - - bool operator==(const TestFilter& filter) const; - bool operator!=(const TestFilter& filter) const; - - SimpleString asString() const; -private: - SimpleString filter_; - bool strictMatching_; - bool invertMatching_; - TestFilter* next_; -}; - -SimpleString StringFrom(const TestFilter& filter); - -#endif - diff --git a/include/CppUTest/TestHarness.h b/include/CppUTest/TestHarness.h deleted file mode 100644 index a4f1a8f71..000000000 --- a/include/CppUTest/TestHarness.h +++ /dev/null @@ -1,46 +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. - */ - -#ifndef D_TestHarness_h -#define D_TestHarness_h - -#include "CppUTestConfig.h" - -/* original value was 9973 which works well with large programs. Now set to smaller since it takes - * a lot of memory in embedded apps. Change it if you experience the memory leak detector to be slow. - */ - -#define MEMORY_LEAK_HASH_TABLE_SIZE 73 - -#include "Utest.h" -#include "UtestMacros.h" -#include "SimpleString.h" -#include "TestResult.h" -#include "TestFailure.h" -#include "TestPlugin.h" -#include "MemoryLeakWarningPlugin.h" -#endif diff --git a/include/CppUTest/TestHarness_c.h b/include/CppUTest/TestHarness_c.h deleted file mode 100644 index f3a64cf83..000000000 --- a/include/CppUTest/TestHarness_c.h +++ /dev/null @@ -1,258 +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. - */ - -/****************************************************************************** - * - * Provides an interface for when working with pure C - * - *******************************************************************************/ - -#ifndef D_TestHarness_c_h -#define D_TestHarness_c_h - -#include "CppUTestConfig.h" - -#define CHECK_EQUAL_C_BOOL(expected,actual) \ - 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,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,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,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,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,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,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,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,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,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,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,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,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), 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__) - -#define FAIL_TEXT_C(text) \ - FAIL_TEXT_C_LOCATION(text,__FILE__,__LINE__) - -#define FAIL_C() \ - FAIL_C_LOCATION(__FILE__,__LINE__) - -#define CHECK_C(condition) \ - CHECK_C_LOCATION(condition, #condition, NULL, __FILE__,__LINE__) - -#define CHECK_C_TEXT(condition, text) \ - CHECK_C_LOCATION(condition, #condition, text, __FILE__, __LINE__) - -/****************************************************************************** - * - * TEST macros for in C. - * - *******************************************************************************/ - -/* 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) - -#define TEST_GROUP_C_TEARDOWN(group_name) \ - extern void group_##group_name##_teardown_wrapper_c(void); \ - 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) - -#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) - - -/* For use in C++ file */ - -#define TEST_GROUP_C_WRAPPER(group_name) \ - extern "C" void group_##group_name##_setup_wrapper_c(void); \ - extern "C" void group_##group_name##_teardown_wrapper_c(void); \ - TEST_GROUP(group_name) - -#define TEST_GROUP_C_SETUP_WRAPPER(group_name) \ - void setup() CPPUTEST_OVERRIDE { \ - group_##group_name##_setup_wrapper_c(); \ - } - -#define TEST_GROUP_C_TEARDOWN_WRAPPER(group_name) \ - void teardown() CPPUTEST_OVERRIDE { \ - group_##group_name##_teardown_wrapper_c(); \ - } - -#define TEST_C_WRAPPER(group_name, test_name) \ - extern "C" void test_##group_name##_##test_name##_wrapper_c(); \ - TEST(group_name, test_name) { \ - test_##group_name##_##test_name##_wrapper_c(); \ - } - -#define IGNORE_TEST_C_WRAPPER(group_name, test_name) \ - extern "C" void ignore_##group_name##_##test_name##_wrapper_c(); \ - IGNORE_TEST(group_name, test_name) { \ - ignore_##group_name##_##test_name##_wrapper_c(); \ - } - -#ifdef __cplusplus -extern "C" -{ -#endif - - -/* CHECKS that can be used from C code */ -extern void CHECK_EQUAL_C_BOOL_LOCATION(int expected, int actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_INT_LOCATION(int expected, int actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_UINT_LOCATION(unsigned int expected, unsigned int actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_LONG_LOCATION(long expected, long actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_ULONG_LOCATION(unsigned long expected, unsigned long actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_LONGLONG_LOCATION(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_ULONGLONG_LOCATION(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_REAL_LOCATION(double expected, double actual, double threshold, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_CHAR_LOCATION(char expected, char actual, const char* text, const char* fileName, size_t lineNumber); -extern void CHECK_EQUAL_C_UBYTE_LOCATION(unsigned char expected, unsigned char actual, const char* text, const char* fileName, size_t lineNumber); -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); -extern void CHECK_C_LOCATION(int condition, const char* conditionString, const char* text, const char* fileName, size_t lineNumber); - -extern void* cpputest_malloc(size_t size); -extern char* cpputest_strdup(const char* str); -extern char* cpputest_strndup(const char* str, size_t n); -extern void* cpputest_calloc(size_t num, size_t size); -extern void* cpputest_realloc(void* ptr, size_t size); -extern void cpputest_free(void* buffer); - -extern void* cpputest_malloc_location(size_t size, const char* file, size_t line); -extern char* cpputest_strdup_location(const char* str, const char* file, size_t line); -extern char* cpputest_strndup_location(const char* str, size_t n, const char* file, size_t line); -extern void* cpputest_calloc_location(size_t num, size_t size, const char* file, size_t line); -extern void* cpputest_realloc_location(void* memory, size_t size, const char* file, size_t line); -extern void cpputest_free_location(void* buffer, const char* file, size_t line); - -void cpputest_malloc_set_out_of_memory(void); -void cpputest_malloc_set_not_out_of_memory(void); -void cpputest_malloc_set_out_of_memory_countdown(int); -void cpputest_malloc_count_reset(void); -int cpputest_malloc_get_count(void); - -#ifdef __cplusplus -} -#endif - - -/* - * Small additional macro for unused arguments. This is common when stubbing, but in C you cannot remove the - * name of the parameter (as in C++). - */ - -#ifndef PUNUSED -#if defined(__GNUC__) || defined(__clang__) -# define PUNUSED(x) PUNUSED_ ##x __attribute__((unused)) -#else -# define PUNUSED(x) x -#endif -#endif - -#endif diff --git a/include/CppUTest/TestMemoryAllocator.h b/include/CppUTest/TestMemoryAllocator.h deleted file mode 100644 index 8f65bf508..000000000 --- a/include/CppUTest/TestMemoryAllocator.h +++ /dev/null @@ -1,261 +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. - */ - -#ifndef D_TestMemoryAllocator_h -#define D_TestMemoryAllocator_h - -struct MemoryLeakNode; -class TestMemoryAllocator; - -extern void setCurrentNewAllocator(TestMemoryAllocator* allocator); -extern TestMemoryAllocator* getCurrentNewAllocator(); -extern void setCurrentNewAllocatorToDefault(); -extern TestMemoryAllocator* defaultNewAllocator(); - -extern void setCurrentNewArrayAllocator(TestMemoryAllocator* allocator); -extern TestMemoryAllocator* getCurrentNewArrayAllocator(); -extern void setCurrentNewArrayAllocatorToDefault(); -extern TestMemoryAllocator* defaultNewArrayAllocator(); - -extern void setCurrentMallocAllocator(TestMemoryAllocator* allocator); -extern TestMemoryAllocator* getCurrentMallocAllocator(); -extern void setCurrentMallocAllocatorToDefault(); -extern TestMemoryAllocator* defaultMallocAllocator(); - -class GlobalMemoryAllocatorStash -{ -public: - GlobalMemoryAllocatorStash(); - void save(); - void restore(); - -private: - TestMemoryAllocator* originalMallocAllocator; - TestMemoryAllocator* originalNewAllocator; - TestMemoryAllocator* originalNewArrayAllocator; -}; - -class TestMemoryAllocator -{ -public: - TestMemoryAllocator(const char* name_str = "generic", const char* alloc_name_str = "alloc", const char* free_name_str = "free"); - virtual ~TestMemoryAllocator(); - bool hasBeenDestroyed(); - - virtual char* alloc_memory(size_t size, const char* file, size_t line); - virtual void free_memory(char* memory, size_t size, const char* file, size_t line); - - virtual const char* name() const; - virtual const char* alloc_name() const; - virtual const char* free_name() const; - - virtual bool isOfEqualType(TestMemoryAllocator* allocator); - - virtual char* allocMemoryLeakNode(size_t size); - virtual void freeMemoryLeakNode(char* memory); - - virtual TestMemoryAllocator* actualAllocator(); - -protected: - - const char* name_; - const char* alloc_name_; - const char* free_name_; - - bool hasBeenDestroyed_; -}; - -class MemoryLeakAllocator : public TestMemoryAllocator -{ -public: - MemoryLeakAllocator(TestMemoryAllocator* originalAllocator); - virtual ~MemoryLeakAllocator() CPPUTEST_DESTRUCTOR_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 CPPUTEST_OVERRIDE; - virtual const char* alloc_name() const CPPUTEST_OVERRIDE; - virtual const char* free_name() const CPPUTEST_OVERRIDE; - - virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE; -private: - TestMemoryAllocator* originalAllocator_; -}; - -class CrashOnAllocationAllocator : public TestMemoryAllocator -{ - unsigned allocationToCrashOn_; -public: - CrashOnAllocationAllocator(); - virtual ~CrashOnAllocationAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE; - - virtual void setNumberToCrashOn(unsigned allocationToCrashOn); - - virtual char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE; -}; - - -class NullUnknownAllocator: public TestMemoryAllocator -{ -public: - NullUnknownAllocator(); - virtual ~NullUnknownAllocator() CPPUTEST_DESTRUCTOR_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(); -}; - -class LocationToFailAllocNode; - -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() CPPUTEST_DESTRUCTOR_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); - - virtual void checkAllFailedAllocsWereDone(); - virtual void clearFailedAllocs(); - -protected: - - LocationToFailAllocNode* head_; - int currentAllocNumber_; -}; - -struct MemoryAccountantAllocationNode; - -class MemoryAccountant -{ -public: - MemoryAccountant(); - ~MemoryAccountant(); - - void useCacheSizes(size_t sizes[], size_t length); - - void clear(); - - void alloc(size_t size); - void dealloc(size_t size); - - size_t totalAllocationsOfSize(size_t size) const; - size_t totalDeallocationsOfSize(size_t size) const; - size_t maximumAllocationAtATimeOfSize(size_t size) const; - - size_t totalAllocations() const; - size_t totalDeallocations() const; - - SimpleString report() const; - - void setAllocator(TestMemoryAllocator* allocator); -private: - MemoryAccountantAllocationNode* findOrCreateNodeOfSize(size_t size); - MemoryAccountantAllocationNode* findNodeOfSize(size_t size) const; - - MemoryAccountantAllocationNode* createNewAccountantAllocationNode(size_t size, MemoryAccountantAllocationNode* next) const; - void destroyAccountantAllocationNode(MemoryAccountantAllocationNode* node) const; - - void createCacheSizeNodes(size_t sizes[], size_t length); - - MemoryAccountantAllocationNode* head_; - TestMemoryAllocator* allocator_; - bool useCacheSizes_; - - SimpleString reportNoAllocations() const; - SimpleString reportTitle() const; - SimpleString reportHeader() const; - SimpleString reportFooter() const; - SimpleString stringSize(size_t size) const; - -}; - -struct AccountingTestMemoryAllocatorMemoryNode; - -class AccountingTestMemoryAllocator : public TestMemoryAllocator -{ -public: - AccountingTestMemoryAllocator(MemoryAccountant& accountant, TestMemoryAllocator* originalAllocator); - virtual ~AccountingTestMemoryAllocator() CPPUTEST_DESTRUCTOR_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() CPPUTEST_OVERRIDE; - TestMemoryAllocator* originalAllocator(); - - virtual const char* alloc_name() const CPPUTEST_OVERRIDE; - virtual const char* free_name() const CPPUTEST_OVERRIDE; -private: - - void addMemoryToMemoryTrackingToKeepTrackOfSize(char* memory, size_t size); - size_t removeMemoryFromTrackingAndReturnAllocatedSize(char* memory); - - size_t removeNextNodeAndReturnSize(AccountingTestMemoryAllocatorMemoryNode* node); - size_t removeHeadAndReturnSize(); - - MemoryAccountant& accountant_; - TestMemoryAllocator* originalAllocator_; - AccountingTestMemoryAllocatorMemoryNode* head_; -}; - -class GlobalMemoryAccountant -{ -public: - GlobalMemoryAccountant(); - ~GlobalMemoryAccountant(); - - void useCacheSizes(size_t sizes[], size_t length); - - void start(); - void stop(); - SimpleString report(); - SimpleString reportWithCacheSizes(size_t sizes[], size_t length); - - TestMemoryAllocator* getMallocAllocator(); - TestMemoryAllocator* getNewAllocator(); - TestMemoryAllocator* getNewArrayAllocator(); - -private: - - void restoreMemoryAllocators(); - - MemoryAccountant accountant_; - AccountingTestMemoryAllocator* mallocAllocator_; - AccountingTestMemoryAllocator* newAllocator_; - AccountingTestMemoryAllocator* newArrayAllocator_; -}; - -#endif - diff --git a/include/CppUTest/TestOutput.h b/include/CppUTest/TestOutput.h deleted file mode 100644 index 47fbe02ea..000000000 --- a/include/CppUTest/TestOutput.h +++ /dev/null @@ -1,214 +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. - */ - -#ifndef D_TestOutput_h -#define D_TestOutput_h - -/////////////////////////////////////////////////////////////////////////////// -// -// This is a minimal printer interface. -// We kept streams out to keep footprint small, and so the test -// harness could be used with less capable compilers so more -// platforms could use this test harness -// -/////////////////////////////////////////////////////////////////////////////// - -#include "SimpleString.h" - -class UtestShell; -class TestFailure; -class TestResult; - -class TestOutput -{ -public: - enum WorkingEnvironment {visualStudio, eclipse, detectEnvironment}; - enum VerbosityLevel {level_quiet, level_verbose, level_veryVerbose}; - - explicit TestOutput(); - virtual ~TestOutput(); - - virtual void printTestsStarted(); - virtual void printTestsEnded(const TestResult& result); - virtual void printCurrentTestStarted(const UtestShell& test); - virtual void printCurrentTestEnded(const TestResult& res); - virtual void printCurrentGroupStarted(const UtestShell& test); - virtual void printCurrentGroupEnded(const TestResult& res); - - virtual void verbose(VerbosityLevel level); - virtual void color(); - virtual void printBuffer(const char*)=0; - virtual void print(const char*); - virtual void print(long); - virtual void print(size_t); - virtual void printDouble(double); - virtual void printFailure(const TestFailure& failure); - virtual void printTestRun(size_t number, size_t total); - virtual void setProgressIndicator(const char*); - - virtual void printVeryVerbose(const char*); - - virtual void flush()=0; - - static void setWorkingEnvironment(WorkingEnvironment workEnvironment); - static WorkingEnvironment getWorkingEnvironment(); - -protected: - - virtual void printEclipseErrorInFileOnLine(SimpleString file, size_t lineNumber); - virtual void printVisualStudioErrorInFileOnLine(SimpleString file, size_t lineNumber); - - virtual void printProgressIndicator(); - void printFileAndLineForTestAndFailure(const TestFailure& failure); - void printFileAndLineForFailure(const TestFailure& failure); - void printFailureInTest(SimpleString testName); - void printFailureMessage(SimpleString reason); - void printErrorInFileOnLineFormattedForWorkingEnvironment(SimpleString testFile, size_t lineNumber); - - TestOutput(const TestOutput&); - TestOutput& operator=(const TestOutput&); - - int dotCount_; - VerbosityLevel verbose_; - bool color_; - const char* progressIndication_; - - static WorkingEnvironment workingEnvironment_; -}; - -TestOutput& operator<<(TestOutput&, const char*); -TestOutput& operator<<(TestOutput&, long); - -/////////////////////////////////////////////////////////////////////////////// -// -// ConsoleTestOutput.h -// -// Printf Based Solution -// -/////////////////////////////////////////////////////////////////////////////// - -class ConsoleTestOutput: public TestOutput -{ -public: - explicit ConsoleTestOutput() - { - } - virtual ~ConsoleTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - virtual void printBuffer(const char* s) CPPUTEST_OVERRIDE; - virtual void flush() CPPUTEST_OVERRIDE; - -private: - ConsoleTestOutput(const ConsoleTestOutput&); - ConsoleTestOutput& operator=(const ConsoleTestOutput&); -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// StringBufferTestOutput.h -// -// TestOutput for test purposes -// -/////////////////////////////////////////////////////////////////////////////// - - -class StringBufferTestOutput: public TestOutput -{ -public: - explicit StringBufferTestOutput() - { - } - - virtual ~StringBufferTestOutput() CPPUTEST_DESTRUCTOR_OVERRIDE; - - void printBuffer(const char* s) CPPUTEST_OVERRIDE - { - output += s; - } - - void flush() CPPUTEST_OVERRIDE - { - output = ""; - } - - const SimpleString& getOutput() - { - return output; - } - -protected: - SimpleString output; - -private: - StringBufferTestOutput(const StringBufferTestOutput&); - StringBufferTestOutput& operator=(const StringBufferTestOutput&); - -}; - -class CompositeTestOutput : public TestOutput -{ -public: - virtual void setOutputOne(TestOutput* output); - virtual void setOutputTwo(TestOutput* output); - - CompositeTestOutput(); - 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&); - CompositeTestOutput& operator=(const TestOutput&); - -private: - TestOutput* outputOne_; - TestOutput* outputTwo_; -}; - -#endif diff --git a/include/CppUTest/TestPlugin.h b/include/CppUTest/TestPlugin.h deleted file mode 100644 index d0b3c41b3..000000000 --- a/include/CppUTest/TestPlugin.h +++ /dev/null @@ -1,123 +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. - */ - -#ifndef D_TestPlugin_h -#define D_TestPlugin_h - -#include "SimpleString.h" - -class UtestShell; -class TestResult; - -class TestPlugin -{ -public: - - TestPlugin(const SimpleString& name); - virtual ~TestPlugin(); - - virtual void preTestAction(UtestShell&, TestResult&) - { - } - - virtual void postTestAction(UtestShell&, TestResult&) - { - } - - virtual bool parseArguments(int /* ac */, const char *const * /* av */, int /* index */ ) - { - return false; - } - - virtual void runAllPreTestAction(UtestShell&, TestResult&); - virtual void runAllPostTestAction(UtestShell&, TestResult&); - virtual bool parseAllArguments(int ac, const char *const *av, int index); - virtual bool parseAllArguments(int ac, char** av, int index); - - virtual TestPlugin* addPlugin(TestPlugin*); - virtual TestPlugin* removePluginByName(const SimpleString& name); - virtual TestPlugin* getNext(); - - virtual void disable(); - virtual void enable(); - virtual bool isEnabled(); - - const SimpleString& getName(); - TestPlugin* getPluginByName(const SimpleString& name); - -protected: - TestPlugin(TestPlugin* next_); - -private: - TestPlugin* next_; - SimpleString name_; - bool enabled_; -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// SetPointerPlugin -// -// This is a very small plugin_ that resets pointers to their original value. -// -/////////////////////////////////////////////////////////////////////////////// - -extern void CppUTestStore(void **location); - -class SetPointerPlugin: public TestPlugin -{ -public: - SetPointerPlugin(const SimpleString& name); - virtual void postTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE; - - enum - { - MAX_SET = 32 - }; -}; - -#define UT_PTR_SET(a, b) \ - do { \ - CppUTestStore((void**)&(a)); \ - (a) = b; \ - } while (0) - -///////////// Null Plugin - -class NullTestPlugin: public TestPlugin -{ -public: - - NullTestPlugin(); - - virtual void runAllPreTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE; - virtual void runAllPostTestAction(UtestShell& test, TestResult& result) CPPUTEST_OVERRIDE; - - static NullTestPlugin* instance(); -}; - -#endif diff --git a/include/CppUTest/TestRegistry.h b/include/CppUTest/TestRegistry.h deleted file mode 100644 index 20575dd5a..000000000 --- a/include/CppUTest/TestRegistry.h +++ /dev/null @@ -1,96 +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. - */ - -/////////////////////////////////////////////////////////////////////////////// -// -// TestRegistry is a collection of tests that can be run -// - -#ifndef D_TestRegistry_h -#define D_TestRegistry_h - -#include "StandardCLibrary.h" -#include "SimpleString.h" -#include "TestFilter.h" - -class UtestShell; -class TestResult; -class TestPlugin; - -class TestRegistry -{ -public: - TestRegistry(); - virtual ~TestRegistry(); - - virtual void addTest(UtestShell *test); - virtual void unDoLastAddTest(); - virtual size_t countTests(); - virtual void runAllTests(TestResult& result); - virtual void shuffleTests(size_t seed); - 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); - virtual void resetPlugins(); - virtual TestPlugin* getFirstPlugin(); - virtual TestPlugin* getPluginByName(const SimpleString& name); - virtual void removePluginByName(const SimpleString& name); - virtual int countPlugins(); - - virtual UtestShell* getFirstTest(); - virtual UtestShell* getTestWithNext(UtestShell* test); - - virtual UtestShell* findTestWithName(const SimpleString& name); - virtual UtestShell* findTestWithGroup(const SimpleString& name); - - static TestRegistry* getCurrentRegistry(); - virtual void setCurrentRegistry(TestRegistry* registry); - - virtual void setRunTestsInSeperateProcess(); - int getCurrentRepetition(); - void setRunIgnored(); - -private: - - bool testShouldRun(UtestShell* test, TestResult& result); - bool endOfGroup(UtestShell* test); - - UtestShell * tests_; - const TestFilter* nameFilters_; - const TestFilter* groupFilters_; - TestPlugin* firstPlugin_; - static TestRegistry* currentRegistry_; - bool runInSeperateProcess_; - int currentRepetition_; - bool runIgnored_; -}; - -#endif diff --git a/include/CppUTest/TestResult.h b/include/CppUTest/TestResult.h deleted file mode 100644 index fc6e63fd6..000000000 --- a/include/CppUTest/TestResult.h +++ /dev/null @@ -1,116 +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. - */ - -/////////////////////////////////////////////////////////////////////////////// -// -// A TestResult is a collection of the history of some test runs. Right now -// it just collects failures. Really it just prints the failures. -// - -#ifndef D_TestResult_h -#define D_TestResult_h - -class TestFailure; -class TestOutput; -class UtestShell; - -class TestResult -{ -public: - TestResult(TestOutput&); - DEFAULT_COPY_CONSTRUCTOR(TestResult) - virtual ~TestResult(); - - virtual void testsStarted(); - virtual void testsEnded(); - virtual void currentGroupStarted(UtestShell* test); - virtual void currentGroupEnded(UtestShell* test); - virtual void currentTestStarted(UtestShell* test); - virtual void currentTestEnded(UtestShell* test); - - virtual void countTest(); - virtual void countRun(); - virtual void countCheck(); - virtual void countFilteredOut(); - virtual void countIgnored(); - virtual void addFailure(const TestFailure& failure); - virtual void print(const char* text); - virtual void printVeryVerbose(const char* text); - - size_t getTestCount() const - { - return testCount_; - } - size_t getRunCount() const - { - return runCount_; - } - size_t getCheckCount() const - { - return checkCount_; - } - size_t getFilteredOutCount() const - { - return filteredOutCount_; - } - size_t getIgnoredCount() const - { - return ignoredCount_; - } - size_t getFailureCount() const - { - return failureCount_; - } - - bool isFailure() const - { - return (getFailureCount() != 0) || (getRunCount() + getIgnoredCount() == 0); - } - - size_t getTotalExecutionTime() const; - void setTotalExecutionTime(size_t exTime); - - size_t getCurrentTestTotalExecutionTime() const; - size_t getCurrentGroupTotalExecutionTime() const; -private: - - TestOutput& output_; - size_t testCount_; - size_t runCount_; - size_t checkCount_; - size_t failureCount_; - size_t filteredOutCount_; - size_t ignoredCount_; - size_t totalExecutionTime_; - size_t timeStarted_; - size_t currentTestTimeStarted_; - size_t currentTestTotalExecutionTime_; - size_t currentGroupTimeStarted_; - size_t currentGroupTotalExecutionTime_; -}; - -#endif diff --git a/include/CppUTest/TestTestingFixture.h b/include/CppUTest/TestTestingFixture.h deleted file mode 100644 index 2c7cdd5ba..000000000 --- a/include/CppUTest/TestTestingFixture.h +++ /dev/null @@ -1,97 +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. - */ - -#ifndef D_TestTestingFixture_H -#define D_TestTestingFixture_H - -#include "TestRegistry.h" -#include "TestOutput.h" - -class TestTestingFixture -{ -public: - - TestTestingFixture(); - virtual ~TestTestingFixture(); - void flushOutputAndResetResult(); - - void addTest(UtestShell * test); - void installPlugin(TestPlugin* plugin); - - void setTestFunction(void(*testFunction)()); - void setTestFunction(ExecFunction* testFunction); - void setSetup(void(*setupFunction)()); - void setTeardown(void(*teardownFunction)()); - - void setOutputVerbose(); - void setRunTestsInSeperateProcess(); - - void runTestWithMethod(void(*method)()); - void runAllTests(); - - size_t getFailureCount(); - size_t getCheckCount(); - size_t getIgnoreCount(); - size_t getRunCount(); - size_t getTestCount(); - const SimpleString& getOutput(); - TestRegistry* getRegistry(); - - bool hasTestFailed(); - void assertPrintContains(const SimpleString& contains); - void assertPrintContainsNot(const SimpleString& contains); - void checkTestFailsWithProperTestLocation(const char* text, const char* file, size_t line); - - static void lineExecutedAfterCheck(); - -private: - void clearExecFunction(); - - static bool lineOfCodeExecutedAfterCheck; - - TestRegistry* registry_; - ExecFunctionTestShell* genTest_; - bool ownsExecFunction_; - StringBufferTestOutput* output_; - TestResult * result_; -}; - -class SetBooleanOnDestructorCall -{ - bool& booleanToSet_; -public: - SetBooleanOnDestructorCall(bool& booleanToSet) : booleanToSet_(booleanToSet) - { - } - - virtual ~SetBooleanOnDestructorCall() - { - booleanToSet_ = true; - } -}; - -#endif diff --git a/include/CppUTest/Utest.h b/include/CppUTest/Utest.h deleted file mode 100644 index 02e865b76..000000000 --- a/include/CppUTest/Utest.h +++ /dev/null @@ -1,337 +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. - */ - -// This file contains the Test class along with the macros which make effective -// in the harness. - -#ifndef D_UTest_h -#define D_UTest_h - -#include "SimpleString.h" - -class TestResult; -class TestPlugin; -class TestFailure; -class TestFilter; -class TestTerminator; - -extern bool doubles_equal(double d1, double d2, double threshold); - -//////////////////// Utest - -class UtestShell; - -class Utest -{ -public: - Utest(); - virtual ~Utest(); - virtual void run(); - - virtual void setup(); - virtual void teardown(); - virtual void testBody(); -}; - -//////////////////// TestTerminator - -class TestTerminator -{ -public: - virtual void exitCurrentTest() const=0; - virtual ~TestTerminator(); -}; - -class NormalTestTerminator : public TestTerminator -{ -public: - virtual void exitCurrentTest() const CPPUTEST_OVERRIDE; - virtual ~NormalTestTerminator() CPPUTEST_DESTRUCTOR_OVERRIDE; -}; - -class TestTerminatorWithoutExceptions : public TestTerminator -{ -public: - 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 - -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(); - - virtual UtestShell* addTest(UtestShell* test); - virtual UtestShell *getNext() const; - virtual size_t countTests(); - - bool shouldRun(const TestFilter* groupFilters, const TestFilter* nameFilters) const; - const SimpleString getName() const; - const SimpleString getGroup() const; - virtual SimpleString getFormattedName() const; - const SimpleString getFile() const; - size_t getLineNumber() const; - virtual bool willRun() const; - 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 = 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 = 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); - virtual void printVeryVerbose(const char* text); - - void setFileName(const char *fileName); - void setLineNumber(size_t lineNumber); - void setGroupName(const char *groupName); - void setTestName(const char *testName); - - static void crash(); - static void setCrashMethod(void (*crashme)()); - static void resetCrashMethod(); - - virtual bool isRunInSeperateProcess() const; - virtual void setRunInSeperateProcess(); - - virtual void setRunIgnored(); - - virtual Utest* createTest(); - virtual void destroyTest(Utest* test); - - virtual void runOneTest(TestPlugin* plugin, TestResult& result); - virtual void runOneTestInCurrentProcess(TestPlugin *plugin, TestResult & result); - - 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); - - virtual SimpleString getMacroName() const; - TestResult *getTestResult(); -private: - const char *group_; - const char *name_; - const char *file_; - size_t lineNumber_; - UtestShell *next_; - bool isRunAsSeperateProcess_; - bool hasFailed_; - - void setTestResult(TestResult* result); - void setCurrentTest(UtestShell* test); - bool match(const char* target, const TestFilter* filters) const; - - static UtestShell* currentTest_; - static TestResult* testResult_; - - static const TestTerminator *currentTestTerminator_; - static const TestTerminator *currentTestTerminatorWithoutExceptions_; - static bool rethrowExceptions_; -}; - - - -//////////////////// ExecFunctionTest - -class ExecFunctionTestShell; - -class ExecFunctionTest : public Utest -{ -public: - ExecFunctionTest(ExecFunctionTestShell* shell); - void testBody() CPPUTEST_OVERRIDE; - virtual void setup() CPPUTEST_OVERRIDE; - virtual void teardown() CPPUTEST_OVERRIDE; -private: - ExecFunctionTestShell* shell_; -}; - -//////////////////// ExecFunction - -class ExecFunction -{ -public: - ExecFunction(); - virtual ~ExecFunction(); - - virtual void exec()=0; -}; - -class ExecFunctionWithoutParameters : public ExecFunction -{ -public: - void (*testFunction_)(); - - ExecFunctionWithoutParameters(void(*testFunction)()); - virtual ~ExecFunctionWithoutParameters() CPPUTEST_DESTRUCTOR_OVERRIDE; - - virtual void exec() CPPUTEST_OVERRIDE; -}; - -//////////////////// ExecFunctionTestShell - -class ExecFunctionTestShell : public UtestShell -{ -public: - void (*setup_)(); - void (*teardown_)(); - ExecFunction* testFunction_; - - ExecFunctionTestShell(void(*set)() = NULLPTR, void(*tear)() = NULLPTR) : - UtestShell("ExecFunction", "ExecFunction", "ExecFunction", 1), setup_(set), teardown_(tear), testFunction_(NULLPTR) - { - } - - Utest* createTest() CPPUTEST_OVERRIDE { return new ExecFunctionTest(this); } - virtual ~ExecFunctionTestShell() CPPUTEST_DESTRUCTOR_OVERRIDE; -}; - -//////////////////// CppUTestFailedException - -class CppUTestFailedException -{ -public: - int dummy_; -}; - -//////////////////// IgnoredTest - -class IgnoredUtestShell : public UtestShell -{ -public: - IgnoredUtestShell(); - virtual ~IgnoredUtestShell() CPPUTEST_DESTRUCTOR_OVERRIDE; - explicit IgnoredUtestShell(const char* groupName, const char* testName, - const char* fileName, size_t lineNumber); - virtual bool willRun() const CPPUTEST_OVERRIDE; - virtual void setRunIgnored() CPPUTEST_OVERRIDE; -protected: - virtual SimpleString getMacroName() const CPPUTEST_OVERRIDE; - virtual void runOneTest(TestPlugin* plugin, TestResult& result) CPPUTEST_OVERRIDE; -private: - - IgnoredUtestShell(const IgnoredUtestShell&); - IgnoredUtestShell& operator=(const IgnoredUtestShell&); - - bool runIgnored_; - -}; - -//////////////////// UtestShellPointerArray - -class UtestShellPointerArray -{ -public: - UtestShellPointerArray(UtestShell* firstTest); - ~UtestShellPointerArray(); - - void shuffle(size_t seed); - void reverse(); - void relinkTestsInOrder(); - UtestShell* getFirstTest() const; - UtestShell* get(size_t index) const; - -private: - - void swap(size_t index1, size_t index2); - - UtestShell** arrayOfTests_; - size_t count_; -}; - - -//////////////////// TestInstaller - -class TestInstaller -{ -public: - explicit TestInstaller(UtestShell& shell, const char* groupName, const char* testName, - const char* fileName, size_t lineNumber); - virtual ~TestInstaller(); - - void unDo(); - -private: - - TestInstaller(const TestInstaller&); - TestInstaller& operator=(const TestInstaller&); - -}; - -#endif diff --git a/include/CppUTest/UtestMacros.h b/include/CppUTest/UtestMacros.h deleted file mode 100644 index 743bf069e..000000000 --- a/include/CppUTest/UtestMacros.h +++ /dev/null @@ -1,390 +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. - */ - -#ifndef D_UTestMacros_h -#define D_UTestMacros_h - -/*! \brief Define a group of tests - * - * All tests in a TEST_GROUP share the same setup() - * and teardown(). setup() is run before the opening - * curly brace of each TEST and teardown() is - * called after the closing curly brace of TEST. - * - */ - - -#define TEST_GROUP_BASE(testGroup, baseclass) \ - extern int externTestGroup##testGroup; \ - int externTestGroup##testGroup = 0; \ - struct TEST_GROUP_##CppUTestGroup##testGroup : public baseclass - -#define TEST_BASE(testBaseClass) \ - struct testBaseClass : public Utest - -#define TEST_GROUP(testGroup) \ - TEST_GROUP_BASE(testGroup, Utest) - -#define TEST_SETUP() \ - virtual void setup() CPPUTEST_OVERRIDE - -#define TEST_TEARDOWN() \ - virtual void teardown() CPPUTEST_OVERRIDE - -#define TEST(testGroup, testName) \ - /* External declarations for strict compilers */ \ - class TEST_##testGroup##_##testName##_TestShell; \ - extern TEST_##testGroup##_##testName##_TestShell TEST_##testGroup##_##testName##_TestShell_instance; \ - \ - class TEST_##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \ -{ public: TEST_##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \ - void testBody() CPPUTEST_OVERRIDE; }; \ - class TEST_##testGroup##_##testName##_TestShell : public UtestShell { \ - 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() - -#define IGNORE_TEST(testGroup, testName)\ - /* External declarations for strict compilers */ \ - class IGNORE##testGroup##_##testName##_TestShell; \ - extern IGNORE##testGroup##_##testName##_TestShell IGNORE##testGroup##_##testName##_TestShell_instance; \ - \ - class IGNORE##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \ -{ public: IGNORE##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \ - public: void testBody() CPPUTEST_OVERRIDE; }; \ - class IGNORE##testGroup##_##testName##_TestShell : public IgnoredUtestShell { \ - 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 () - -#define IMPORT_TEST_GROUP(testGroup) \ - extern int externTestGroup##testGroup;\ - extern int* p##testGroup; \ - int* p##testGroup = &externTestGroup##testGroup - -#define CPPUTEST_DEFAULT_MAIN \ - /*#include */ \ - int main(int argc, char** argv) \ - { \ - return CommandLineTestRunner::RunAllTests(argc, argv); \ - } - - -// Different checking macros - -#define CHECK(condition)\ - CHECK_TRUE_LOCATION(condition, "CHECK", #condition, NULLPTR, __FILE__, __LINE__) - -#define CHECK_TEXT(condition, text) \ - CHECK_TRUE_LOCATION((bool)(condition), "CHECK", #condition, text, __FILE__, __LINE__) - -#define CHECK_TRUE(condition)\ - CHECK_TRUE_LOCATION((bool) (condition), "CHECK_TRUE", #condition, NULLPTR, __FILE__, __LINE__) - -#define CHECK_TRUE_TEXT(condition, text)\ - CHECK_TRUE_LOCATION(condition, "CHECK_TRUE", #condition, text, __FILE__, __LINE__) - -#define CHECK_FALSE(condition)\ - CHECK_FALSE_LOCATION(condition, "CHECK_FALSE", #condition, NULLPTR, __FILE__, __LINE__) - -#define CHECK_FALSE_TEXT(condition, text)\ - CHECK_FALSE_LOCATION(condition, "CHECK_FALSE", #condition, text, __FILE__, __LINE__) - -#define CHECK_TRUE_LOCATION(condition, checkString, conditionString, text, file, line)\ - do { UtestShell::getCurrent()->assertTrue((condition), checkString, conditionString, text, file, line); } while(0) - -#define CHECK_FALSE_LOCATION(condition, checkString, conditionString, text, file, line)\ - do { UtestShell::getCurrent()->assertTrue(!(condition), checkString, conditionString, text, file, line); } while(0) - -//This check needs the operator!=(), and a StringFrom(YourType) function -#define CHECK_EQUAL(expected, actual)\ - CHECK_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define CHECK_EQUAL_TEXT(expected, actual, text)\ - CHECK_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define CHECK_EQUAL_LOCATION(expected, actual, text, file, line)\ - do { if ((expected) != (actual)) { \ - if ((actual) != (actual)) \ - UtestShell::getCurrent()->print("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.", file, line); \ - if ((expected) != (expected)) \ - UtestShell::getCurrent()->print("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.", file, line); \ - UtestShell::getCurrent()->assertEquals(true, StringFrom(expected).asCharString(), StringFrom(actual).asCharString(), text, file, line); \ - } \ - else \ - { \ - 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) - -#define CHECK_COMPARE_TEXT(first, relop, second, text)\ - CHECK_COMPARE_LOCATION(first, relop, second, text, __FILE__, __LINE__) - -#define CHECK_COMPARE_LOCATION(first, relop, second, 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. -//This makes up for the fact that CHECK_EQUAL only compares the pointers to char*'s -#define STRCMP_EQUAL(expected, actual)\ - STRCMP_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define STRCMP_EQUAL_TEXT(expected, actual, text)\ - STRCMP_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define STRCMP_EQUAL_LOCATION(expected, actual, text, file, line)\ - do { UtestShell::getCurrent()->assertCstrEqual(expected, actual, text, file, line); } while(0) - -#define STRNCMP_EQUAL(expected, actual, length)\ - STRNCMP_EQUAL_LOCATION(expected, actual, length, NULLPTR, __FILE__, __LINE__) - -#define STRNCMP_EQUAL_TEXT(expected, actual, length, text)\ - STRNCMP_EQUAL_LOCATION(expected, actual, length, text, __FILE__, __LINE__) - -#define STRNCMP_EQUAL_LOCATION(expected, actual, length, text, file, line)\ - do { UtestShell::getCurrent()->assertCstrNEqual(expected, actual, length, text, file, line); } while(0) - -#define STRCMP_NOCASE_EQUAL(expected, actual)\ - STRCMP_NOCASE_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define STRCMP_NOCASE_EQUAL_TEXT(expected, actual, text)\ - STRCMP_NOCASE_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define STRCMP_NOCASE_EQUAL_LOCATION(expected, actual, text, file, line)\ - do { UtestShell::getCurrent()->assertCstrNoCaseEqual(expected, actual, text, file, line); } while(0) - -#define STRCMP_CONTAINS(expected, actual)\ - STRCMP_CONTAINS_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define STRCMP_CONTAINS_TEXT(expected, actual, text)\ - STRCMP_CONTAINS_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define STRCMP_CONTAINS_LOCATION(expected, actual, text, file, line)\ - do { UtestShell::getCurrent()->assertCstrContains(expected, actual, text, file, line); } while(0) - -#define STRCMP_NOCASE_CONTAINS(expected, actual)\ - STRCMP_NOCASE_CONTAINS_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define STRCMP_NOCASE_CONTAINS_TEXT(expected, actual, text)\ - STRCMP_NOCASE_CONTAINS_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define STRCMP_NOCASE_CONTAINS_LOCATION(expected, actual, text, file, line)\ - do { UtestShell::getCurrent()->assertCstrNoCaseContains(expected, actual, text, file, line); } while(0) - -//Check two long integers for equality -#define LONGS_EQUAL(expected, actual)\ - LONGS_EQUAL_LOCATION((expected), (actual), "LONGS_EQUAL(" #expected ", " #actual ") failed", __FILE__, __LINE__) - -#define LONGS_EQUAL_TEXT(expected, actual, text)\ - LONGS_EQUAL_LOCATION((expected), (actual), text, __FILE__, __LINE__) - -#define UNSIGNED_LONGS_EQUAL(expected, actual)\ - UNSIGNED_LONGS_EQUAL_LOCATION((expected), (actual), NULLPTR, __FILE__, __LINE__) - -#define UNSIGNED_LONGS_EQUAL_TEXT(expected, actual, text)\ - 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) - -#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) - -#if CPPUTEST_USE_LONG_LONG -#define LONGLONGS_EQUAL(expected, actual)\ - LONGLONGS_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define LONGLONGS_EQUAL_TEXT(expected, actual, text)\ - LONGLONGS_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define UNSIGNED_LONGLONGS_EQUAL(expected, actual)\ - UNSIGNED_LONGLONGS_EQUAL_LOCATION(expected, actual, NULLPTR, __FILE__, __LINE__) - -#define UNSIGNED_LONGLONGS_EQUAL_TEXT(expected, actual, text)\ - UNSIGNED_LONGLONGS_EQUAL_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define LONGLONGS_EQUAL_LOCATION(expected, actual, text, file, line)\ - 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((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) - -#define BYTES_EQUAL_TEXT(expected, actual, text)\ - LONGS_EQUAL_TEXT((expected) & 0xff, (actual) & 0xff, text) - -#define SIGNED_BYTES_EQUAL(expected, actual)\ - SIGNED_BYTES_EQUAL_LOCATION(expected, actual, __FILE__, __LINE__) - -#define SIGNED_BYTES_EQUAL_LOCATION(expected, actual, file, line) \ - do { UtestShell::getCurrent()->assertSignedBytesEqual(expected, actual, NULLPTR, file, line); } while(0) - -#define SIGNED_BYTES_EQUAL_TEXT(expected, actual, text)\ - SIGNED_BYTES_EQUAL_TEXT_LOCATION(expected, actual, text, __FILE__, __LINE__) - -#define SIGNED_BYTES_EQUAL_TEXT_LOCATION(expected, actual, text, file, line) \ - do { UtestShell::getCurrent()->assertSignedBytesEqual(expected, actual, text, file, line); } while(0) - -#define POINTERS_EQUAL(expected, actual)\ - POINTERS_EQUAL_LOCATION((expected), (actual), NULLPTR, __FILE__, __LINE__) - -#define POINTERS_EQUAL_TEXT(expected, actual, text)\ - 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) - -#define FUNCTIONPOINTERS_EQUAL(expected, actual)\ - FUNCTIONPOINTERS_EQUAL_LOCATION((expected), (actual), NULLPTR, __FILE__, __LINE__) - -#define FUNCTIONPOINTERS_EQUAL_TEXT(expected, actual, text)\ - 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) - -//Check two doubles for equality within a tolerance threshold -#define DOUBLES_EQUAL(expected, actual, threshold)\ - DOUBLES_EQUAL_LOCATION(expected, actual, threshold, NULLPTR, __FILE__, __LINE__) - -#define DOUBLES_EQUAL_TEXT(expected, actual, threshold, text)\ - DOUBLES_EQUAL_LOCATION(expected, actual, threshold, text, __FILE__, __LINE__) - -#define DOUBLES_EQUAL_LOCATION(expected, actual, threshold, text, file, line)\ - do { UtestShell::getCurrent()->assertDoublesEqual(expected, actual, threshold, text, file, line); } while(0) - -#define MEMCMP_EQUAL(expected, actual, size)\ - MEMCMP_EQUAL_LOCATION(expected, actual, size, NULLPTR, __FILE__, __LINE__) - -#define MEMCMP_EQUAL_TEXT(expected, actual, size, text)\ - MEMCMP_EQUAL_LOCATION(expected, actual, size, text, __FILE__, __LINE__) - -#define MEMCMP_EQUAL_LOCATION(expected, actual, size, text, file, line)\ - do { UtestShell::getCurrent()->assertBinaryEqual(expected, actual, size, text, file, line); } while(0) - -#define BITS_EQUAL(expected, actual, mask)\ - BITS_LOCATION(expected, actual, mask, NULLPTR, __FILE__, __LINE__) - -#define BITS_EQUAL_TEXT(expected, actual, mask, text)\ - 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) // NOLINT(bugprone-sizeof-expression) - -#define ENUMS_EQUAL_INT(expected, actual)\ - ENUMS_EQUAL_TYPE(int, expected, actual) - -#define ENUMS_EQUAL_INT_TEXT(expected, actual, text)\ - ENUMS_EQUAL_TYPE_TEXT(int, expected, actual, text) - -#define ENUMS_EQUAL_TYPE(underlying_type, expected, actual)\ - ENUMS_EQUAL_TYPE_LOCATION(underlying_type, expected, actual, NULLPTR, __FILE__, __LINE__) - -#define ENUMS_EQUAL_TYPE_TEXT(underlying_type, expected, actual, text)\ - ENUMS_EQUAL_TYPE_LOCATION(underlying_type, expected, actual, text, __FILE__, __LINE__) - -#define ENUMS_EQUAL_TYPE_LOCATION(underlying_type, expected, actual, text, file, line)\ - do { underlying_type expected_underlying_value = (underlying_type)(expected); \ - underlying_type actual_underlying_value = (underlying_type)(actual); \ - if (expected_underlying_value != actual_underlying_value) { \ - UtestShell::getCurrent()->assertEquals(true, StringFrom(expected_underlying_value).asCharString(), StringFrom(actual_underlying_value).asCharString(), text, file, line); \ - } \ - else \ - { \ - UtestShell::getCurrent()->assertLongsEqual((long)0, long(0), NULLPTR, file, line); \ - } \ - } while(0) - -//Fail if you get to this macro -//The macro FAIL may already be taken, so allow FAIL_TEST too -#ifndef FAIL -#define FAIL(text)\ - FAIL_LOCATION(text, __FILE__,__LINE__) - -#define FAIL_LOCATION(text, file, line)\ - do { UtestShell::getCurrent()->fail(text, file, line); } while(0) -#endif - -#define FAIL_TEST(text)\ - FAIL_TEST_LOCATION(text, __FILE__,__LINE__) - -#define FAIL_TEST_LOCATION(text, file,line)\ - do { UtestShell::getCurrent()->fail(text, file, line); } while(0) - -#define TEST_EXIT\ - do { UtestShell::getCurrent()->exitTest(); } while(0) - -#define UT_PRINT_LOCATION(text, file, line) \ - do { UtestShell::getCurrent()->print(text, file, line); } while(0) - -#define UT_PRINT(text) \ - UT_PRINT_LOCATION(text, __FILE__, __LINE__) - -#if CPPUTEST_HAVE_EXCEPTIONS -#define CHECK_THROWS(expected, expression) \ - do { \ - SimpleString failure_msg("expected to throw "#expected "\nbut threw nothing"); \ - bool caught_expected = false; \ - try { \ - (expression); \ - } catch(const expected &) { \ - caught_expected = true; \ - } catch(...) { \ - failure_msg = "expected to throw " #expected "\nbut threw a different type"; \ - } \ - if (!caught_expected) { \ - UtestShell::getCurrent()->fail(failure_msg.asCharString(), __FILE__, __LINE__); \ - } \ - else { \ - UtestShell::getCurrent()->countCheck(); \ - } \ - } while(0) -#endif /* CPPUTEST_HAVE_EXCEPTIONS */ - -#define UT_CRASH() do { UtestShell::crash(); } while(0) -#define RUN_ALL_TESTS(ac, av) CommandLineTestRunner::RunAllTests(ac, av) - -#endif /*D_UTestMacros_h*/ diff --git a/include/CppUTestExt/CodeMemoryReportFormatter.h b/include/CppUTestExt/CodeMemoryReportFormatter.h deleted file mode 100644 index 6e87fe302..000000000 --- a/include/CppUTestExt/CodeMemoryReportFormatter.h +++ /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. - */ - -#ifndef D_CodeMemoryReportFormatter_h -#define D_CodeMemoryReportFormatter_h - -#include "CppUTestExt/MemoryReportFormatter.h" - -struct CodeReportingAllocationNode; -class CodeMemoryReportFormatter : public MemoryReportFormatter -{ -private: - CodeReportingAllocationNode* codeReportingList_; - TestMemoryAllocator* internalAllocator_; - -public: - CodeMemoryReportFormatter(TestMemoryAllocator* internalAllocator); - virtual ~CodeMemoryReportFormatter() CPPUTEST_DESTRUCTOR_OVERRIDE; - - 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) 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) CPPUTEST_OVERRIDE; - virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) CPPUTEST_OVERRIDE; - -private: - - void addNodeToList(const char* variableName, void* memory, CodeReportingAllocationNode* next); - CodeReportingAllocationNode* findNode(void* memory); - bool variableExists(const SimpleString& variableName); - void clearReporting(); - - bool isNewAllocator(TestMemoryAllocator* allocator); - SimpleString createVariableNameFromFileLineInfo(const char *file, size_t line); - - SimpleString getAllocationString(TestMemoryAllocator* allocator, const SimpleString& variableName, size_t size); - SimpleString getDeallocationString(TestMemoryAllocator* allocator, const SimpleString& variableName, const char* file, size_t line); -}; - -#endif diff --git a/include/CppUTestExt/GMock.h b/include/CppUTestExt/GMock.h deleted file mode 100644 index 131597371..000000000 --- a/include/CppUTestExt/GMock.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifndef GMOCK_H_ -#define GMOCK_H_ - -#undef new -#undef strdup -#undef strndup - -#undef RUN_ALL_TESTS - -#define GTEST_DONT_DEFINE_TEST 1 -#define GTEST_DONT_DEFINE_FAIL 1 - -#include "gmock/gmock.h" -#undef RUN_ALL_TESTS - -using testing::Return; -using testing::NiceMock; - -#ifdef CPPUTEST_USE_NEW_MACROS -#include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif - -#ifdef CPPUTEST_USE_MALLOC_MACROS -#include "CppUTest/MemoryLeakDetectorMallocMacros.h" -#endif - -#endif diff --git a/include/CppUTestExt/GTest.h b/include/CppUTestExt/GTest.h deleted file mode 100644 index a2472d3c7..000000000 --- a/include/CppUTestExt/GTest.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifndef GTEST_H_ -#define GTEST_H_ - -#undef new -#undef strdup -#undef strndup - -#undef RUN_ALL_TESTS - -#include "gtest/gtest.h" - -#ifdef CPPUTEST_USE_NEW_MACROS -#include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif - -#ifdef CPPUTEST_USE_MALLOC_MACROS -#include "CppUTest/MemoryLeakDetectorMallocMacros.h" -#endif - -#include "CppUTestExt/GTestSupport.h" - -#ifndef RUN_ALL_TESTS -#define GTEST_VERSION_GTEST_1_7 -#else -#ifdef ADD_FAILURE_AT -#define GTEST_VERSION_GTEST_1_6 -#else -#define GTEST_VERSION_GTEST_1_5 -#endif -#endif - -#undef RUN_ALL_TESTS - -#endif diff --git a/include/CppUTestExt/GTestConvertor.h b/include/CppUTestExt/GTestConvertor.h deleted file mode 100644 index c606d6c18..000000000 --- a/include/CppUTestExt/GTestConvertor.h +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifndef GTESTCONVERTOR_H_ -#define GTESTCONVERTOR_H_ - -#include "CppUTest/Utest.h" - -#ifdef GTEST_H_ - #error "Please include this file before you include any other GTest files" -#endif - -/* - * Usage: - * - * This file must only be included in the main. The whole implementation is inline so that this can - * be compiled on usage and not on CppUTest compile-time. This avoids a hard dependency with CppUTest - * and with GTest - * - * Add the following lines to your main: - * - * GTestConvertor convertor; - * convertor.addAllGTestToTestRegistry(); - * - * - */ - -class GTestResultReporter; -class GTestFlagsThatAllocateMemory; - -namespace testing { - class TestInfo; - class TestCase; - class Test; -} - -class GTestShell : public UtestShell -{ - ::testing::TestInfo* testinfo_; - GTestShell* next_; - GTestFlagsThatAllocateMemory* flags_; - -public: - GTestShell(::testing::TestInfo* testinfo, GTestShell* next, GTestFlagsThatAllocateMemory* flags); - - virtual Utest* createTest() CPPUTEST_OVERRIDE; - - GTestShell* nextGTest() - { - return next_; - } -}; - -/* Enormous hack! - * - * This sucks enormously. We need to do two things in GTest that seem to not be possible without - * this hack. Hopefully there is *another way*. - * - * We need to access the factory in the TestInfo in order to be able to create tests. The factory - * is private and there seems to be no way to access it... - * - * We need to be able to call the Test SetUp and TearDown methods, but they are protected for - * some reason. We can't subclass either as the tests are created with the TEST macro. - * - * If anyone knows how to get the above things done *without* these ugly #defines, let me know! - * - */ - -#define private public -#define protected public - -#include "CppUTestExt/GTest.h" -#include "CppUTestExt/GMock.h" -#include "gtest/gtest-spi.h" -#include "gtest/gtest-death-test.h" -/* - * We really need some of its internals as they don't have a public interface. - * - */ -#define GTEST_IMPLEMENTATION_ 1 -#include "../src/gtest-internal-inl.h" - -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestFailure.h" -#include "CppUTest/TestResult.h" - - -#ifdef GTEST_VERSION_GTEST_1_7 -#define GTEST_STRING std::string -#define GTEST_NO_STRING_VALUE "" -#else -#define GTEST_STRING ::testing::internal::String -#define GTEST_NO_STRING_VALUE NULL -#endif - -/* Store some of the flags as we'll need to reset them each test to avoid leaking memory */ - -class GTestFlagsThatAllocateMemory -{ -public: - void storeValuesOfGTestFlags() - { - GTestFlagcolor = ::testing::GTEST_FLAG(color); - GTestFlagfilter = ::testing::GTEST_FLAG(filter); - GTestFlagoutput = ::testing::GTEST_FLAG(output); - GTestFlagdeath_test_style = ::testing::GTEST_FLAG(death_test_style); - GTestFlaginternal_run_death_test = ::testing::internal::GTEST_FLAG(internal_run_death_test); - #ifndef GTEST_VERSION_GTEST_1_5 - GTestFlagstream_result_to = ::testing::GTEST_FLAG(stream_result_to); - #endif - } - - void resetValuesOfGTestFlags() - { - ::testing::GTEST_FLAG(color) = GTestFlagcolor; - ::testing::GTEST_FLAG(filter) = GTestFlagfilter; - ::testing::GTEST_FLAG(output) = GTestFlagoutput; - ::testing::GTEST_FLAG(death_test_style) = GTestFlagdeath_test_style; - ::testing::internal::GTEST_FLAG(internal_run_death_test) = GTestFlaginternal_run_death_test; - #ifndef GTEST_VERSION_GTEST_1_5 - ::testing::GTEST_FLAG(stream_result_to) = GTestFlagstream_result_to; - #endif - } - - void setGTestFlagValuesToNULLToAvoidMemoryLeaks() - { - #ifndef GTEST_VERSION_GTEST_1_7 - ::testing::GTEST_FLAG(color) = GTEST_NO_STRING_VALUE; - ::testing::GTEST_FLAG(filter) = GTEST_NO_STRING_VALUE; - ::testing::GTEST_FLAG(output) = GTEST_NO_STRING_VALUE; - ::testing::GTEST_FLAG(death_test_style) = GTEST_NO_STRING_VALUE; - ::testing::internal::GTEST_FLAG(internal_run_death_test) = GTEST_NO_STRING_VALUE; - #ifndef GTEST_VERSION_GTEST_1_5 - ::testing::GTEST_FLAG(stream_result_to) = GTEST_NO_STRING_VALUE; - #endif - #endif - } - -private: - GTEST_STRING GTestFlagcolor; - GTEST_STRING GTestFlagfilter; - GTEST_STRING GTestFlagoutput; - GTEST_STRING GTestFlagdeath_test_style; - GTEST_STRING GTestFlaginternal_run_death_test; - #ifndef GTEST_VERSION_GTEST_1_5 - GTEST_STRING GTestFlagstream_result_to; - #endif -}; - -class GTestConvertor -{ -public: - GTestConvertor(bool shouldSimulateFailureAtCreationToAllocateThreadLocalData = true); - virtual ~GTestConvertor(); - - virtual void addAllGTestToTestRegistry(); -protected: - virtual void simulateGTestFailureToPreAllocateAllTheThreadLocalData(); - - virtual void addNewTestCaseForTestInfo(::testing::TestInfo* testinfo); - virtual void addAllTestsFromTestCaseToTestRegistry(::testing::TestCase* testcase); - - virtual void createDummyInSequenceToAndFailureReporterAvoidMemoryLeakInGMock(); -private: - GTestResultReporter* reporter_; - GTestShell* first_; - GTestFlagsThatAllocateMemory flags_; -}; - -class GTestDummyResultReporter : public ::testing::ScopedFakeTestPartResultReporter -{ -public: - GTestDummyResultReporter () : ::testing::ScopedFakeTestPartResultReporter(INTERCEPT_ALL_THREADS, NULL) {} - virtual void ReportTestPartResult(const ::testing::TestPartResult& /*result*/) {} -}; - -class GMockTestTerminator : public TestTerminator -{ -public: - GMockTestTerminator(const ::testing::TestPartResult& result) : result_(result) - { - } - - virtual void exitCurrentTest() const - { - /* - * 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 - * already be at the end of the test, so it doesn't matter much - */ - - - /* - * TODO: We probably want this check here, however the tests fail when putting it there. Also, we'll need to - * check how to get all the gTest tests to run within CppUTest. At the moment, the 'death tests' seem to fail - * still. - * - * if (result_.type() == ::testing::TestPartResult::kFatalFailure) { - */ - if (!SimpleString(result_.message()).contains("Actual: never called") && - !SimpleString(result_.message()).contains("Actual function call count doesn't match")) - throw CppUTestFailedException(); - - } - virtual ~GMockTestTerminator() - { - } -private: - const ::testing::TestPartResult& result_; -}; - - -class GTestResultReporter : public ::testing::ScopedFakeTestPartResultReporter -{ -public: - GTestResultReporter () : ::testing::ScopedFakeTestPartResultReporter(INTERCEPT_ALL_THREADS, NULL) {} - - virtual void ReportTestPartResult(const ::testing::TestPartResult& result) - { - FailFailure failure(UtestShell::getCurrent(), result.file_name(), result.line_number(), result.message()); - UtestShell::getCurrent()->failWith(failure, GMockTestTerminator(result)); - } -}; - -inline GTestShell::GTestShell(::testing::TestInfo* testinfo, GTestShell* next, GTestFlagsThatAllocateMemory* flags) : testinfo_(testinfo), next_(next), flags_(flags) -{ - setGroupName(testinfo->test_case_name()); - setTestName(testinfo->name()); -} - -class GTestUTest: public Utest { -public: - GTestUTest(::testing::TestInfo* testinfo, GTestFlagsThatAllocateMemory* flags) : testinfo_(testinfo), test_(NULL), flags_(flags) - { - - } - - void testBody() - { - try { - test_->TestBody(); - } - catch (CppUTestFailedException& ex) - { - } - } - - void setup() - { - flags_->resetValuesOfGTestFlags(); - - #ifdef GTEST_VERSION_GTEST_1_5 - test_ = testinfo_->impl()->factory_->CreateTest(); - #else - test_ = testinfo_->factory_->CreateTest(); - #endif - - ::testing::UnitTest::GetInstance()->impl()->set_current_test_info(testinfo_); - try { - test_->SetUp(); - } - catch (CppUTestFailedException& ex) - { - } - } - - void teardown() - { - try { - test_->TearDown(); - } - catch (CppUTestFailedException& ex) - { - } - ::testing::UnitTest::GetInstance()->impl()->set_current_test_info(NULL); - delete test_; - - flags_->setGTestFlagValuesToNULLToAvoidMemoryLeaks(); - ::testing::internal::DeathTest::set_last_death_test_message(GTEST_NO_STRING_VALUE); - } - -private: - ::testing::Test* test_; - ::testing::TestInfo* testinfo_; - GTestFlagsThatAllocateMemory* flags_; -}; - -inline Utest* GTestShell::createTest() -{ - return new GTestUTest(testinfo_, flags_); -}; - -inline void GTestConvertor::simulateGTestFailureToPreAllocateAllTheThreadLocalData() -{ - GTestDummyResultReporter *dummyReporter = new GTestDummyResultReporter(); - ASSERT_TRUE(false); - delete dummyReporter; -} - -inline GTestConvertor::GTestConvertor(bool shouldSimulateFailureAtCreationToAllocateThreadLocalData) : first_(NULL) -{ - if (shouldSimulateFailureAtCreationToAllocateThreadLocalData) - simulateGTestFailureToPreAllocateAllTheThreadLocalData(); - reporter_ = new GTestResultReporter(); -} - -inline GTestConvertor::~GTestConvertor() -{ - delete reporter_; - - while (first_) { - GTestShell* next = first_->nextGTest(); - delete first_; - first_ = next; - } -} - -inline void GTestConvertor::addNewTestCaseForTestInfo(::testing::TestInfo* testinfo) -{ - first_ = new GTestShell(testinfo, first_, &flags_); - TestRegistry::getCurrentRegistry()->addTest(first_); -} - -inline void GTestConvertor::addAllTestsFromTestCaseToTestRegistry(::testing::TestCase* testcase) -{ - int currentTestCount = 0; - ::testing::TestInfo* currentTest = (::testing::TestInfo*) testcase->GetTestInfo(currentTestCount); - while (currentTest) { - addNewTestCaseForTestInfo(currentTest); - currentTestCount++; - currentTest = (::testing::TestInfo*) testcase->GetTestInfo(currentTestCount); - } -} - -inline void GTestConvertor::createDummyInSequenceToAndFailureReporterAvoidMemoryLeakInGMock() -{ - ::testing::InSequence seq; - ::testing::internal::GetFailureReporter(); -} - -inline void GTestConvertor::addAllGTestToTestRegistry() -{ - createDummyInSequenceToAndFailureReporterAvoidMemoryLeakInGMock(); - flags_.storeValuesOfGTestFlags(); - - int argc = 2; - const char * argv[] = {"NameOfTheProgram", "--gmock_catch_leaked_mocks=0"}; - ::testing::InitGoogleMock(&argc, (char**) argv); - - ::testing::UnitTest* unitTests = ::testing::UnitTest::GetInstance(); - - int currentUnitTestCount = 0; - ::testing::TestCase* currentTestCase = (::testing::TestCase*) unitTests->GetTestCase(currentUnitTestCount); - while (currentTestCase) { - addAllTestsFromTestCaseToTestRegistry(currentTestCase); - currentUnitTestCount++; - currentTestCase = (::testing::TestCase*) unitTests->GetTestCase(currentUnitTestCount); - } -} - - -#endif diff --git a/include/CppUTestExt/GTestSupport.h b/include/CppUTestExt/GTestSupport.h deleted file mode 100644 index 80892a0fa..000000000 --- a/include/CppUTestExt/GTestSupport.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifndef GTESTSUPPORT_H_ -#define GTESTSUPPORT_H_ - -extern void CppuTestGTestIgnoreLeaksInTest(); - -#endif diff --git a/include/CppUTestExt/IEEE754ExceptionsPlugin.h b/include/CppUTestExt/IEEE754ExceptionsPlugin.h deleted file mode 100644 index 35a18181f..000000000 --- a/include/CppUTestExt/IEEE754ExceptionsPlugin.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015, Michael Feathers, James Grenning, Bas Vodde - * and Arnd Strube. 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. - */ - -#ifndef D_IEEE754ExceptionsPlugin_h -#define D_IEEE754ExceptionsPlugin_h - -#include "CppUTest/TestPlugin.h" - -class IEEE754ExceptionsPlugin: public TestPlugin -{ -public: - IEEE754ExceptionsPlugin(const SimpleString& name = "IEEE754ExceptionsPlugin"); - - 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); - static bool checkIeee754OverflowExceptionFlag(); - static bool checkIeee754UnderflowExceptionFlag(); - static bool checkIeee754InexactExceptionFlag(); - static bool checkIeee754DivByZeroExceptionFlag(); - -private: - void ieee754Check(UtestShell& test, TestResult& result, int flag, const char* text); - static bool inexactDisabled_; -}; - -#endif diff --git a/include/CppUTestExt/MemoryReportAllocator.h b/include/CppUTestExt/MemoryReportAllocator.h deleted file mode 100644 index 2cca67e25..000000000 --- a/include/CppUTestExt/MemoryReportAllocator.h +++ /dev/null @@ -1,61 +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. - */ - -#ifndef D_MemoryReportAllocator_h -#define D_MemoryReportAllocator_h - -#include "CppUTest/TestMemoryAllocator.h" - -class MemoryReportFormatter; - -class MemoryReportAllocator : public TestMemoryAllocator -{ -protected: - TestResult* result_; - TestMemoryAllocator* realAllocator_; - MemoryReportFormatter* formatter_; -public: - MemoryReportAllocator(); - virtual ~MemoryReportAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE; - - virtual void setFormatter(MemoryReportFormatter* formatter); - virtual void setTestResult(TestResult* result); - virtual void setRealAllocator(TestMemoryAllocator* allocator); - - virtual TestMemoryAllocator* getRealAllocator(); - - 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 CPPUTEST_OVERRIDE; - virtual const char* alloc_name() const CPPUTEST_OVERRIDE; - virtual const char* free_name() const CPPUTEST_OVERRIDE; - - virtual TestMemoryAllocator* actualAllocator() CPPUTEST_OVERRIDE; -}; - -#endif diff --git a/include/CppUTestExt/MemoryReportFormatter.h b/include/CppUTestExt/MemoryReportFormatter.h deleted file mode 100644 index 2c7af57aa..000000000 --- a/include/CppUTestExt/MemoryReportFormatter.h +++ /dev/null @@ -1,65 +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. - */ - -#ifndef D_MemoryReportFormatter_h -#define D_MemoryReportFormatter_h - -class TestOutput; -class UtestShell; - -class MemoryReportFormatter -{ -public: - virtual ~MemoryReportFormatter(){} - - virtual void report_testgroup_start(TestResult* result, UtestShell& test)=0; - virtual void report_testgroup_end(TestResult* result, UtestShell& test)=0; - - virtual void report_test_start(TestResult* result, UtestShell& test)=0; - virtual void report_test_end(TestResult* result, UtestShell& test)=0; - - virtual void report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line)=0; - virtual void report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line)=0; -}; - -class NormalMemoryReportFormatter : public MemoryReportFormatter -{ -public: - NormalMemoryReportFormatter(); - virtual ~NormalMemoryReportFormatter() CPPUTEST_DESTRUCTOR_OVERRIDE; - - 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) 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) 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 deleted file mode 100644 index 5b1816f9b..000000000 --- a/include/CppUTestExt/MemoryReporterPlugin.h +++ /dev/null @@ -1,68 +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. - */ - -#ifndef D_MemoryReporterPlugin_h -#define D_MemoryReporterPlugin_h - -#include "CppUTest/TestPlugin.h" -#include "CppUTestExt/MemoryReportAllocator.h" - -class MemoryReportFormatter; - -class MemoryReporterPlugin : public TestPlugin -{ - MemoryReportFormatter* formatter_; - - MemoryReportAllocator mallocAllocator; - MemoryReportAllocator newAllocator; - MemoryReportAllocator newArrayAllocator; - - SimpleString currentTestGroup_; -public: - MemoryReporterPlugin(); - virtual ~MemoryReporterPlugin() CPPUTEST_DESTRUCTOR_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(); - MemoryReportAllocator* getNewArrayAllocator(); -protected: - virtual MemoryReportFormatter* createMemoryFormatter(const SimpleString& type); - -private: - void destroyMemoryFormatter(MemoryReportFormatter* formatter); - - void setGlobalMemoryReportAllocators(); - void removeGlobalMemoryReportAllocators(); - - void initializeAllocator(MemoryReportAllocator* allocator, TestResult & result); -}; - -#endif diff --git a/include/CppUTestExt/MockActualCall.h b/include/CppUTestExt/MockActualCall.h deleted file mode 100644 index 51f2fa7e5..000000000 --- a/include/CppUTestExt/MockActualCall.h +++ /dev/null @@ -1,120 +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. - */ - -#ifndef D_MockActualCall_h -#define D_MockActualCall_h - -#include "CppUTest/CppUTestConfig.h" -#include "CppUTest/TestHarness.h" -#include "CppUTestExt/MockNamedValue.h" -#include "CppUTestExt/MockExpectedCallsList.h" - -class MockFailureReporter; -class MockFailure; - -class MockActualCall -{ -public: - MockActualCall(); - virtual ~MockActualCall(); - - virtual MockActualCall& withName(const SimpleString& name)=0; - virtual MockActualCall& withCallOrder(unsigned int callOrder)=0; - MockActualCall& withParameter(const SimpleString& name, bool value) { return withBoolParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, int value) { return withIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, unsigned int value) { return withUnsignedIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, long int value) { return withLongIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, unsigned long int value) { return withUnsignedLongIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, cpputest_longlong value) { return withLongLongIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, cpputest_ulonglong value) { return withUnsignedLongLongIntParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, double value) { return withDoubleParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, const char* value) { return withStringParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, void* value) { return withPointerParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, void (*value)()) { return withFunctionPointerParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, const void* value) { return withConstPointerParameter(name, value); } - MockActualCall& withParameter(const SimpleString& name, const unsigned char* value, size_t size) { return withMemoryBufferParameter(name, value, size); } - virtual MockActualCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value)=0; - virtual MockActualCall& withOutputParameter(const SimpleString& name, void* output)=0; - virtual MockActualCall& withOutputParameterOfType(const SimpleString& typeName, const SimpleString& name, void* output)=0; - - virtual MockActualCall& withBoolParameter(const SimpleString& name, bool value)=0; - virtual MockActualCall& withIntParameter(const SimpleString& name, int value)=0; - virtual MockActualCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value)=0; - virtual MockActualCall& withLongIntParameter(const SimpleString& name, long int value)=0; - virtual MockActualCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value)=0; - virtual MockActualCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value)=0; - virtual MockActualCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value)=0; - virtual MockActualCall& withDoubleParameter(const SimpleString& name, double value)=0; - virtual MockActualCall& withStringParameter(const SimpleString& name, const char* value)=0; - virtual MockActualCall& withPointerParameter(const SimpleString& name, void* value)=0; - virtual MockActualCall& withFunctionPointerParameter(const SimpleString& name, void (*value)())=0; - virtual MockActualCall& withConstPointerParameter(const SimpleString& name, const void* value)=0; - virtual MockActualCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size)=0; - - virtual bool hasReturnValue()=0; - virtual MockNamedValue returnValue()=0; - - virtual bool returnBoolValueOrDefault(bool default_value)=0; - virtual bool returnBoolValue()=0; - - virtual int returnIntValueOrDefault(int default_value)=0; - virtual int returnIntValue()=0; - - virtual unsigned long int returnUnsignedLongIntValue()=0; - virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int default_value)=0; - - virtual long int returnLongIntValue()=0; - virtual long int returnLongIntValueOrDefault(long int default_value)=0; - - virtual cpputest_ulonglong returnUnsignedLongLongIntValue()=0; - virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value)=0; - - virtual cpputest_longlong returnLongLongIntValue()=0; - virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value)=0; - - virtual unsigned int returnUnsignedIntValue()=0; - virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int default_value)=0; - - virtual const char * returnStringValueOrDefault(const char * default_value)=0; - virtual const char * returnStringValue()=0; - - virtual double returnDoubleValue()=0; - virtual double returnDoubleValueOrDefault(double default_value)=0; - - virtual void * returnPointerValue()=0; - virtual void * returnPointerValueOrDefault(void * default_value)=0; - - virtual const void * returnConstPointerValue()=0; - virtual const void * returnConstPointerValueOrDefault(const void * default_value)=0; - - virtual void (*returnFunctionPointerValue())()=0; - virtual void (*returnFunctionPointerValueOrDefault(void (*default_value)()))()=0; - - virtual MockActualCall& onObject(const void* objectPtr)=0; -}; - -#endif diff --git a/include/CppUTestExt/MockCheckedActualCall.h b/include/CppUTestExt/MockCheckedActualCall.h deleted file mode 100644 index 51b12e405..000000000 --- a/include/CppUTestExt/MockCheckedActualCall.h +++ /dev/null @@ -1,319 +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. - */ - -#ifndef D_MockCheckedActualCall_h -#define D_MockCheckedActualCall_h - -#include "CppUTestExt/MockActualCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" - -class MockCheckedActualCall : public MockActualCall -{ -public: - MockCheckedActualCall(unsigned int callOrder, MockFailureReporter* reporter, const MockExpectedCallsList& expectations); - virtual ~MockCheckedActualCall() CPPUTEST_DESTRUCTOR_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() CPPUTEST_OVERRIDE; - virtual MockNamedValue returnValue() CPPUTEST_OVERRIDE; - - virtual bool returnBoolValueOrDefault(bool default_value) CPPUTEST_OVERRIDE; - virtual bool returnBoolValue() CPPUTEST_OVERRIDE; - - virtual int returnIntValueOrDefault(int default_value) CPPUTEST_OVERRIDE; - virtual int returnIntValue() CPPUTEST_OVERRIDE; - - virtual unsigned long int returnUnsignedLongIntValue() CPPUTEST_OVERRIDE; - virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) CPPUTEST_OVERRIDE; - - virtual long int returnLongIntValue() CPPUTEST_OVERRIDE; - virtual long int returnLongIntValueOrDefault(long int default_value) CPPUTEST_OVERRIDE; - - virtual cpputest_ulonglong returnUnsignedLongLongIntValue() CPPUTEST_OVERRIDE; - virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) CPPUTEST_OVERRIDE; - - virtual cpputest_longlong returnLongLongIntValue() CPPUTEST_OVERRIDE; - virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) CPPUTEST_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) CPPUTEST_OVERRIDE; - virtual const char * returnStringValue() CPPUTEST_OVERRIDE; - - virtual double returnDoubleValue() CPPUTEST_OVERRIDE; - virtual double returnDoubleValueOrDefault(double default_value) CPPUTEST_OVERRIDE; - - virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE; - virtual const void * returnConstPointerValueOrDefault(const void * default_value) CPPUTEST_OVERRIDE; - - virtual void * returnPointerValue() CPPUTEST_OVERRIDE; - virtual void * returnPointerValueOrDefault(void *) CPPUTEST_OVERRIDE; - - typedef void (*FunctionPointerReturnValue)(); - virtual FunctionPointerReturnValue returnFunctionPointerValue() CPPUTEST_OVERRIDE; - virtual FunctionPointerReturnValue returnFunctionPointerValueOrDefault(void (*)()) CPPUTEST_OVERRIDE; - - virtual MockActualCall& onObject(const void* objectPtr) CPPUTEST_OVERRIDE; - - virtual bool isFulfilled() const; - virtual bool hasFailed() const; - - virtual void checkExpectations(); - - virtual void setMockFailureReporter(MockFailureReporter* reporter); -protected: - void setName(const SimpleString& name); - SimpleString getName() const; - virtual UtestShell* getTest() const; - virtual void callHasSucceeded(); - virtual void copyOutputParameters(MockCheckedExpectedCall* call); - virtual void completeCallWhenMatchIsFound(); - virtual void failTest(const MockFailure& failure); - virtual void checkInputParameter(const MockNamedValue& actualParameter); - virtual void checkOutputParameter(const MockNamedValue& outputParameter); - virtual void discardCurrentlyMatchingExpectations(); - - enum ActualCallState { - CALL_IN_PROGRESS, - CALL_FAILED, - CALL_SUCCEED - }; - virtual void setState(ActualCallState state); - -private: - SimpleString functionName_; - unsigned int callOrder_; - MockFailureReporter* reporter_; - - ActualCallState state_; - bool expectationsChecked_; - MockCheckedExpectedCall* matchingExpectation_; - - MockExpectedCallsList potentiallyMatchingExpectations_; - const MockExpectedCallsList& allExpectations_; - - class MockOutputParametersListNode - { - public: - SimpleString name_; - SimpleString type_; - void* ptr_; - - MockOutputParametersListNode* next_; - MockOutputParametersListNode(const SimpleString& name, const SimpleString& type, void* ptr) - : name_(name), type_(type), ptr_(ptr), next_(NULLPTR) {} - }; - - MockOutputParametersListNode* outputParameterExpectations_; - - virtual void addOutputParameter(const SimpleString& name, const SimpleString& type, void* ptr); - void cleanUpOutputParameterList(); -}; - -class MockActualCallTrace : public MockActualCall -{ -public: - MockActualCallTrace(); - virtual ~MockActualCallTrace() CPPUTEST_DESTRUCTOR_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() CPPUTEST_OVERRIDE; - virtual MockNamedValue returnValue() CPPUTEST_OVERRIDE; - - virtual bool returnBoolValueOrDefault(bool default_value) CPPUTEST_OVERRIDE; - virtual bool returnBoolValue() CPPUTEST_OVERRIDE; - - virtual int returnIntValueOrDefault(int default_value) CPPUTEST_OVERRIDE; - virtual int returnIntValue() CPPUTEST_OVERRIDE; - - virtual unsigned long int returnUnsignedLongIntValue() CPPUTEST_OVERRIDE; - virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int) CPPUTEST_OVERRIDE; - - virtual long int returnLongIntValue() CPPUTEST_OVERRIDE; - virtual long int returnLongIntValueOrDefault(long int default_value) CPPUTEST_OVERRIDE; - - virtual cpputest_ulonglong returnUnsignedLongLongIntValue() CPPUTEST_OVERRIDE; - virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) CPPUTEST_OVERRIDE; - - virtual cpputest_longlong returnLongLongIntValue() CPPUTEST_OVERRIDE; - virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong default_value) CPPUTEST_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) CPPUTEST_OVERRIDE; - virtual const char * returnStringValue() CPPUTEST_OVERRIDE; - - virtual double returnDoubleValue() CPPUTEST_OVERRIDE; - virtual double returnDoubleValueOrDefault(double default_value) CPPUTEST_OVERRIDE; - - virtual void * returnPointerValue() CPPUTEST_OVERRIDE; - virtual void * returnPointerValueOrDefault(void *) CPPUTEST_OVERRIDE; - - virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE; - virtual const void * returnConstPointerValueOrDefault(const void * default_value) CPPUTEST_OVERRIDE; - - virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValue() CPPUTEST_OVERRIDE; - virtual MockCheckedActualCall::FunctionPointerReturnValue returnFunctionPointerValueOrDefault(void (*)()) CPPUTEST_OVERRIDE; - - virtual MockActualCall& onObject(const void* objectPtr) CPPUTEST_OVERRIDE; - - const char* getTraceOutput(); - void clear(); - static MockActualCallTrace& instance(); - static void clearInstance(); - -private: - SimpleString traceBuffer_; - - static MockActualCallTrace* instance_; - - void addParameterName(const SimpleString& name); -}; - -class MockIgnoredActualCall: public MockActualCall -{ -public: - 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 cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong value) CPPUTEST_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 returnLongLongIntValueOrDefault(cpputest_longlong value) CPPUTEST_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() CPPUTEST_OVERRIDE { return 0.0; } - virtual double returnDoubleValueOrDefault(double value) CPPUTEST_OVERRIDE { return value; } - - virtual const char * returnStringValue() CPPUTEST_OVERRIDE { return ""; } - virtual const char * returnStringValueOrDefault(const char * value) CPPUTEST_OVERRIDE { return value; } - - virtual void * returnPointerValue() CPPUTEST_OVERRIDE { return NULLPTR; } - virtual void * returnPointerValueOrDefault(void * value) CPPUTEST_OVERRIDE { return value; } - - virtual const void * returnConstPointerValue() CPPUTEST_OVERRIDE { return NULLPTR; } - virtual const void * returnConstPointerValueOrDefault(const void * value) CPPUTEST_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* ) CPPUTEST_OVERRIDE { return *this; } - - static MockIgnoredActualCall& instance(); -}; - -#endif diff --git a/include/CppUTestExt/MockCheckedExpectedCall.h b/include/CppUTestExt/MockCheckedExpectedCall.h deleted file mode 100644 index a1a87fd6e..000000000 --- a/include/CppUTestExt/MockCheckedExpectedCall.h +++ /dev/null @@ -1,195 +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. - */ - -#ifndef D_MockCheckedExpectedCall_h -#define D_MockCheckedExpectedCall_h - -#include "CppUTestExt/MockExpectedCall.h" -#include "CppUTestExt/MockNamedValue.h" - -class MockCheckedExpectedCall : public MockExpectedCall -{ - -public: - MockCheckedExpectedCall(); - MockCheckedExpectedCall(unsigned int numCalls); - 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) CPPUTEST_OVERRIDE; - - virtual MockNamedValue getInputParameter(const SimpleString& name); - virtual MockNamedValue getOutputParameter(const SimpleString& name); - virtual SimpleString getInputParameterType(const SimpleString& name); - virtual SimpleString getInputParameterValueString(const SimpleString& name); - - virtual bool hasInputParameterWithName(const SimpleString& name); - virtual bool hasInputParameter(const MockNamedValue& parameter); - virtual bool hasOutputParameterWithName(const SimpleString& name); - virtual bool hasOutputParameter(const MockNamedValue& parameter); - virtual bool relatesTo(const SimpleString& functionName); - virtual bool relatesToObject(const void* objectPtr) const; - - virtual bool isFulfilled(); - virtual bool canMatchActualCalls(); - virtual bool isMatchingActualCallAndFinalized(); - virtual bool isMatchingActualCall(); - virtual bool areParametersMatchingActualCall(); - virtual bool isOutOfOrder() const; - - virtual void callWasMade(unsigned int callOrder); - virtual void inputParameterWasPassed(const SimpleString& name); - virtual void outputParameterWasPassed(const SimpleString& name); - virtual void finalizeActualCallMatch(); - virtual void wasPassedToObject(); - virtual void resetActualCallMatchingState(); - - virtual SimpleString callToString(); - virtual SimpleString missingParametersToString(); - - enum { NO_EXPECTED_CALL_ORDER = 0 }; - - virtual unsigned int getActualCallsFulfilled() const; - -protected: - void setName(const SimpleString& name); - SimpleString getName() const; - -private: - SimpleString functionName_; - - class MockExpectedFunctionParameter : public MockNamedValue - { - public: - MockExpectedFunctionParameter(const SimpleString& name); - void setMatchesActualCall(bool b); - bool isMatchingActualCall() const; - - private: - bool matchesActualCall_; - }; - - MockExpectedFunctionParameter* item(MockNamedValueListNode* node); - - bool ignoreOtherParameters_; - bool isActualCallMatchFinalized_; - unsigned int initialExpectedCallOrder_; - unsigned int finalExpectedCallOrder_; - bool outOfOrder_; - MockNamedValueList* inputParameters_; - MockNamedValueList* outputParameters_; - MockNamedValue returnValue_; - void* objectPtr_; - bool isSpecificObjectExpected_; - bool wasPassedToObject_; - unsigned int actualCalls_; - unsigned int expectedCalls_; -}; - -class MockIgnoredExpectedCall: public MockExpectedCall -{ -public: - - 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(); -}; - -#endif diff --git a/include/CppUTestExt/MockExpectedCall.h b/include/CppUTestExt/MockExpectedCall.h deleted file mode 100644 index e043de886..000000000 --- a/include/CppUTestExt/MockExpectedCall.h +++ /dev/null @@ -1,96 +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. - */ - -#ifndef D_MockExpectedCall_h -#define D_MockExpectedCall_h - -#include "CppUTest/CppUTestConfig.h" - -class MockNamedValue; - -extern SimpleString StringFrom(const MockNamedValue& parameter); - -class MockExpectedCall -{ -public: - MockExpectedCall(); - virtual ~MockExpectedCall(); - - virtual MockExpectedCall& withName(const SimpleString& name)=0; - virtual MockExpectedCall& withCallOrder(unsigned int)=0; - virtual MockExpectedCall& withCallOrder(unsigned int, unsigned int)=0; - MockExpectedCall& withParameter(const SimpleString& name, bool value) { return withBoolParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, int value) { return withIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, unsigned int value) { return withUnsignedIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, long int value) { return withLongIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, unsigned long int value) { return withUnsignedLongIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, cpputest_longlong value) { return withLongLongIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, cpputest_ulonglong value) { return withUnsignedLongLongIntParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, double value) { return withDoubleParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, double value, double tolerance) { return withDoubleParameter(name, value, tolerance); } - MockExpectedCall& withParameter(const SimpleString& name, const char* value) { return withStringParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, void* value) { return withPointerParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, const void* value) { return withConstPointerParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, void (*value)()) { return withFunctionPointerParameter(name, value); } - MockExpectedCall& withParameter(const SimpleString& name, const unsigned char* value, size_t size) { return withMemoryBufferParameter(name, value, size); } - virtual MockExpectedCall& withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value)=0; - virtual MockExpectedCall& withOutputParameterReturning(const SimpleString& name, const void* value, size_t size)=0; - virtual MockExpectedCall& withOutputParameterOfTypeReturning(const SimpleString& typeName, const SimpleString& name, const void* value)=0; - virtual MockExpectedCall& withUnmodifiedOutputParameter(const SimpleString& name)=0; - virtual MockExpectedCall& ignoreOtherParameters()=0; - - virtual MockExpectedCall& withBoolParameter(const SimpleString& name, bool value)=0; - virtual MockExpectedCall& withIntParameter(const SimpleString& name, int value)=0; - virtual MockExpectedCall& withUnsignedIntParameter(const SimpleString& name, unsigned int value)=0; - virtual MockExpectedCall& withLongIntParameter(const SimpleString& name, long int value)=0; - virtual MockExpectedCall& withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value)=0; - virtual MockExpectedCall& withLongLongIntParameter(const SimpleString& name, cpputest_longlong value)=0; - virtual MockExpectedCall& withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value)=0; - virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value)=0; - virtual MockExpectedCall& withDoubleParameter(const SimpleString& name, double value, double tolerance)=0; - virtual MockExpectedCall& withStringParameter(const SimpleString& name, const char* value)=0; - virtual MockExpectedCall& withPointerParameter(const SimpleString& name, void* value)=0; - virtual MockExpectedCall& withFunctionPointerParameter(const SimpleString& name, void (*value)())=0; - virtual MockExpectedCall& withConstPointerParameter(const SimpleString& name, const void* value)=0; - virtual MockExpectedCall& withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size)=0; - virtual MockExpectedCall& andReturnValue(bool value)=0; - virtual MockExpectedCall& andReturnValue(int value)=0; - virtual MockExpectedCall& andReturnValue(unsigned int value)=0; - virtual MockExpectedCall& andReturnValue(long int value)=0; - virtual MockExpectedCall& andReturnValue(unsigned long int value)=0; - virtual MockExpectedCall& andReturnValue(cpputest_longlong value)=0; - virtual MockExpectedCall& andReturnValue(cpputest_ulonglong value)=0; - virtual MockExpectedCall& andReturnValue(double value)=0; - virtual MockExpectedCall& andReturnValue(const char* value)=0; - virtual MockExpectedCall& andReturnValue(void* value)=0; - virtual MockExpectedCall& andReturnValue(const void* value)=0; - virtual MockExpectedCall& andReturnValue(void (*value)())=0; - - virtual MockExpectedCall& onObject(void* objectPtr)=0; -}; - -#endif diff --git a/include/CppUTestExt/MockExpectedCallsList.h b/include/CppUTestExt/MockExpectedCallsList.h deleted file mode 100644 index 3cb2e651d..000000000 --- a/include/CppUTestExt/MockExpectedCallsList.h +++ /dev/null @@ -1,100 +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. - */ - -#ifndef D_MockExpectedCallsList_h -#define D_MockExpectedCallsList_h - -class MockCheckedExpectedCall; -class MockNamedValue; - -class MockExpectedCallsList -{ - -public: - MockExpectedCallsList(); - virtual ~MockExpectedCallsList(); - virtual void deleteAllExpectationsAndClearList(); - - virtual unsigned int size() const; - virtual unsigned int amountOfActualCallsFulfilledFor(const SimpleString& name) const; - virtual unsigned int amountOfUnfulfilledExpectations() const; - virtual bool hasUnfulfilledExpectations() const; - virtual bool hasFinalizedMatchingExpectations() const; - virtual bool hasUnmatchingExpectationsBecauseOfMissingParameters() const; - virtual bool hasExpectationWithName(const SimpleString& name) const; - virtual bool hasCallsOutOfOrder() const; - virtual bool isEmpty() const; - - virtual void addExpectedCall(MockCheckedExpectedCall* call); - virtual void addExpectations(const MockExpectedCallsList& list); - virtual void addExpectationsRelatedTo(const SimpleString& name, const MockExpectedCallsList& list); - - virtual void onlyKeepOutOfOrderExpectations(); - virtual void addPotentiallyMatchingExpectations(const MockExpectedCallsList& list); - - virtual void onlyKeepExpectationsRelatedTo(const SimpleString& name); - virtual void onlyKeepExpectationsWithInputParameter(const MockNamedValue& parameter); - virtual void onlyKeepExpectationsWithInputParameterName(const SimpleString& name); - virtual void onlyKeepExpectationsWithOutputParameter(const MockNamedValue& parameter); - virtual void onlyKeepExpectationsWithOutputParameterName(const SimpleString& name); - virtual void onlyKeepExpectationsOnObject(const void* objectPtr); - virtual void onlyKeepUnmatchingExpectations(); - - virtual MockCheckedExpectedCall* removeFirstFinalizedMatchingExpectation(); - virtual MockCheckedExpectedCall* removeFirstMatchingExpectation(); - virtual MockCheckedExpectedCall* getFirstMatchingExpectation(); - - virtual void resetActualCallMatchingState(); - virtual void wasPassedToObject(); - virtual void parameterWasPassed(const SimpleString& parameterName); - virtual void outputParameterWasPassed(const SimpleString& parameterName); - - virtual SimpleString unfulfilledCallsToString(const SimpleString& linePrefix = "") const; - virtual SimpleString fulfilledCallsToString(const SimpleString& linePrefix = "") const; - virtual SimpleString callsWithMissingParametersToString(const SimpleString& linePrefix, - const SimpleString& missingParametersPrefix) const; - -protected: - virtual void pruneEmptyNodeFromList(); - - class MockExpectedCallsListNode - { - public: - MockCheckedExpectedCall* expectedCall_; - - MockExpectedCallsListNode* next_; - MockExpectedCallsListNode(MockCheckedExpectedCall* expectedCall) - : expectedCall_(expectedCall), next_(NULLPTR) {} - }; - -private: - MockExpectedCallsListNode* head_; - - MockExpectedCallsList(const MockExpectedCallsList&); -}; - -#endif diff --git a/include/CppUTestExt/MockFailure.h b/include/CppUTestExt/MockFailure.h deleted file mode 100644 index 3ee4f73d3..000000000 --- a/include/CppUTestExt/MockFailure.h +++ /dev/null @@ -1,124 +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. - */ - - -#ifndef D_MockFailure_h -#define D_MockFailure_h - -#include "CppUTest/TestFailure.h" - -class MockExpectedCallsList; -class MockCheckedActualCall; -class MockNamedValue; -class MockFailure; - -class MockFailureReporter -{ -protected: - bool crashOnFailure_; -public: - MockFailureReporter() : crashOnFailure_(false){} - virtual ~MockFailureReporter() {} - - virtual void failTest(const MockFailure& failure); - virtual UtestShell* getTestToFail(); - - virtual void crashOnFailure(bool shouldCrash) { crashOnFailure_ = shouldCrash; } -}; - -class MockFailure : public TestFailure -{ -public: - MockFailure(UtestShell* test); - virtual ~MockFailure() CPPUTEST_DESTRUCTOR_OVERRIDE {} -protected: - void addExpectationsAndCallHistory(const MockExpectedCallsList& expectations); - void addExpectationsAndCallHistoryRelatedTo(const SimpleString& function, const MockExpectedCallsList& expectations); -}; - -class MockExpectedCallsDidntHappenFailure : public MockFailure -{ -public: - MockExpectedCallsDidntHappenFailure(UtestShell* test, const MockExpectedCallsList& expectations); -}; - -class MockUnexpectedCallHappenedFailure : public MockFailure -{ -public: - MockUnexpectedCallHappenedFailure(UtestShell* test, const SimpleString& name, const MockExpectedCallsList& expectations); -}; - -class MockCallOrderFailure : public MockFailure -{ -public: - MockCallOrderFailure(UtestShell* test, const MockExpectedCallsList& expectations); -}; - -class MockUnexpectedInputParameterFailure : public MockFailure -{ -public: - MockUnexpectedInputParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedCallsList& expectations); -}; - -class MockUnexpectedOutputParameterFailure : public MockFailure -{ -public: - MockUnexpectedOutputParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedCallsList& expectations); -}; - -class MockExpectedParameterDidntHappenFailure : public MockFailure -{ -public: - MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& allExpectations, - const MockExpectedCallsList& matchingExpectations); -}; - -class MockNoWayToCompareCustomTypeFailure : public MockFailure -{ -public: - MockNoWayToCompareCustomTypeFailure(UtestShell* test, const SimpleString& typeName); -}; - -class MockNoWayToCopyCustomTypeFailure : public MockFailure -{ -public: - MockNoWayToCopyCustomTypeFailure(UtestShell* test, const SimpleString& typeName); -}; - -class MockUnexpectedObjectFailure : public MockFailure -{ -public: - MockUnexpectedObjectFailure(UtestShell* test, const SimpleString& functionName, const void* expected, const MockExpectedCallsList& expectations); -}; - -class MockExpectedObjectDidntHappenFailure : public MockFailure -{ -public: - MockExpectedObjectDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& expectations); -}; - -#endif diff --git a/include/CppUTestExt/MockNamedValue.h b/include/CppUTestExt/MockNamedValue.h deleted file mode 100644 index b6e5be2cc..000000000 --- a/include/CppUTestExt/MockNamedValue.h +++ /dev/null @@ -1,251 +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. - */ - -#ifndef D_MockNamedValue_h -#define D_MockNamedValue_h - -#include "CppUTest/CppUTestConfig.h" - -/* - * MockNamedValueComparator is an interface that needs to be used when creating Comparators. - * This is needed when comparing values of non-native type. - */ - -class MockNamedValueComparator -{ -public: - MockNamedValueComparator() {} - virtual ~MockNamedValueComparator() {} - - virtual bool isEqual(const void* object1, const void* object2)=0; - virtual SimpleString valueToString(const void* object)=0; -}; - -/* - * MockNamedValueCopier is an interface that needs to be used when creating Copiers. - * This is needed when copying values of non-native type. - */ - -class MockNamedValueCopier -{ -public: - MockNamedValueCopier() {} - virtual ~MockNamedValueCopier() {} - - virtual void copy(void* out, const void* in)=0; -}; - - -class MockFunctionComparator : public MockNamedValueComparator -{ -public: - typedef bool (*isEqualFunction)(const void*, const void*); - typedef SimpleString (*valueToStringFunction)(const void*); - - MockFunctionComparator(isEqualFunction equal, valueToStringFunction valToString) - : equal_(equal), valueToString_(valToString) {} - - 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_; -}; - -class MockFunctionCopier : public MockNamedValueCopier -{ -public: - typedef void (*copyFunction)(void*, const void*); - - MockFunctionCopier(copyFunction copier) : copier_(copier) {} - - virtual void copy(void* dst, const void* src) CPPUTEST_OVERRIDE { copier_(dst, src); } - -private: - copyFunction copier_; -}; - -/* - * MockNamedValue is the generic value class used. It encapsulates basic types and can use them "as if one" - * Also it enables other types by putting object pointers. They can be compared with comparators. - * - * Basically this class ties together a Name, a Value, a Type, and a Comparator - */ - -class MockNamedValueComparatorsAndCopiersRepository; -class MockNamedValue -{ -public: - MockNamedValue(const SimpleString& name); - DEFAULT_COPY_CONSTRUCTOR(MockNamedValue) - virtual ~MockNamedValue(); - - virtual void setValue(bool value); - virtual void setValue(int value); - virtual void setValue(unsigned int value); - virtual void setValue(long int value); - virtual void setValue(unsigned long int value); - virtual void setValue(cpputest_longlong value); - virtual void setValue(cpputest_ulonglong value); - virtual void setValue(double value); - virtual void setValue(double value, double tolerance); - virtual void setValue(void* value); - virtual void setValue(const void* value); - virtual void setValue(void (*value)()); - virtual void setValue(const char* value); - virtual void setMemoryBuffer(const unsigned char* value, size_t size); - virtual void setConstObjectPointer(const SimpleString& type, const void* objectPtr); - virtual void setObjectPointer(const SimpleString& type, void* objectPtr); - virtual void setSize(size_t size); - - virtual void setName(const char* name); - - virtual bool equals(const MockNamedValue& p) const; - virtual bool compatibleForCopying(const MockNamedValue& p) const; - - virtual SimpleString toString() const; - - virtual SimpleString getName() const; - virtual SimpleString getType() const; - - virtual bool getBoolValue() const; - virtual int getIntValue() const; - virtual unsigned int getUnsignedIntValue() const; - virtual long int getLongIntValue() const; - virtual unsigned long int getUnsignedLongIntValue() const; - virtual cpputest_longlong getLongLongIntValue() const; - virtual cpputest_ulonglong getUnsignedLongLongIntValue() const; - virtual double getDoubleValue() const; - virtual double getDoubleTolerance() const; - virtual const char* getStringValue() const; - virtual void* getPointerValue() const; - virtual const void* getConstPointerValue() const; - virtual void (*getFunctionPointerValue() const)(); - virtual const unsigned char* getMemoryBuffer() const; - virtual const void* getConstObjectPointer() const; - virtual void* getObjectPointer() const; - virtual size_t getSize() const; - - - virtual MockNamedValueComparator* getComparator() const; - virtual MockNamedValueCopier* getCopier() const; - - static void setDefaultComparatorsAndCopiersRepository(MockNamedValueComparatorsAndCopiersRepository* repository); - static MockNamedValueComparatorsAndCopiersRepository* getDefaultComparatorsAndCopiersRepository(); - - static const double defaultDoubleTolerance; -private: - SimpleString name_; - SimpleString type_; - union { - bool boolValue_; - int intValue_; - unsigned int unsignedIntValue_; - long int longIntValue_; - unsigned long int unsignedLongIntValue_; -#if CPPUTEST_USE_LONG_LONG - cpputest_longlong longLongIntValue_; - cpputest_ulonglong unsignedLongLongIntValue_; -#else - char longLongPlaceholder_[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE]; -#endif - struct { - double value; - double tolerance; - } doubleValue_; - const char* stringValue_; - void* pointerValue_; - const void* constPointerValue_; - void (*functionPointerValue_)(); - const unsigned char* memoryBufferValue_; - const void* constObjectPointerValue_; - void* objectPointerValue_; - const void* outputPointerValue_; - } value_; - size_t size_; - MockNamedValueComparator* comparator_; - MockNamedValueCopier* copier_; - static MockNamedValueComparatorsAndCopiersRepository* defaultRepository_; -}; - -class MockNamedValueListNode -{ -public: - MockNamedValueListNode(MockNamedValue* newValue); - - SimpleString getName() const; - SimpleString getType() const; - - MockNamedValueListNode* next(); - MockNamedValue* item(); - - void destroy(); - void setNext(MockNamedValueListNode* node); -private: - MockNamedValue* data_; - MockNamedValueListNode* next_; -}; - -class MockNamedValueList -{ -public: - MockNamedValueList(); - - MockNamedValueListNode* begin(); - - void add(MockNamedValue* newValue); - void clear(); - - MockNamedValue* getValueByName(const SimpleString& name); - -private: - MockNamedValueListNode* head_; -}; - -/* - * MockParameterComparatorRepository is a class which stores comparators and copiers which can be used for comparing non-native types - * - */ - -struct MockNamedValueComparatorsAndCopiersRepositoryNode; -class MockNamedValueComparatorsAndCopiersRepository -{ - MockNamedValueComparatorsAndCopiersRepositoryNode* head_; -public: - MockNamedValueComparatorsAndCopiersRepository(); - virtual ~MockNamedValueComparatorsAndCopiersRepository(); - - virtual void installComparator(const SimpleString& name, MockNamedValueComparator& comparator); - virtual void installCopier(const SimpleString& name, MockNamedValueCopier& copier); - virtual void installComparatorsAndCopiers(const MockNamedValueComparatorsAndCopiersRepository& repository); - virtual MockNamedValueComparator* getComparatorForType(const SimpleString& name); - virtual MockNamedValueCopier* getCopierForType(const SimpleString& name); - - void clear(); -}; - -#endif diff --git a/include/CppUTestExt/MockSupport.h b/include/CppUTestExt/MockSupport.h deleted file mode 100644 index c8532187d..000000000 --- a/include/CppUTestExt/MockSupport.h +++ /dev/null @@ -1,167 +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. - */ - -#ifndef D_MockSupport_h -#define D_MockSupport_h - -#include "CppUTestExt/MockFailure.h" -#include "CppUTestExt/MockCheckedActualCall.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" - -class UtestShell; -class MockSupport; - -/* This allows access to "the global" mocking support for easier testing */ -MockSupport& mock(const SimpleString& mockName = "", MockFailureReporter* failureReporterForThisCall = NULLPTR); - -class MockSupport -{ -public: - MockSupport(const SimpleString& mockName = ""); - virtual ~MockSupport(); - - virtual void strictOrder(); - virtual MockExpectedCall& expectOneCall(const SimpleString& functionName); - virtual void expectNoCall(const SimpleString& functionName); - virtual MockExpectedCall& expectNCalls(unsigned int amount, const SimpleString& functionName); - virtual MockActualCall& actualCall(const SimpleString& functionName); - virtual bool hasReturnValue(); - virtual MockNamedValue returnValue(); - virtual bool boolReturnValue(); - virtual bool returnBoolValueOrDefault(bool defaultValue); - virtual int intReturnValue(); - virtual int returnIntValueOrDefault(int defaultValue); - virtual unsigned int unsignedIntReturnValue(); - virtual long int longIntReturnValue(); - virtual long int returnLongIntValueOrDefault(long int defaultValue); - virtual unsigned long int unsignedLongIntReturnValue(); - virtual unsigned long int returnUnsignedLongIntValueOrDefault(unsigned long int defaultValue); - virtual cpputest_longlong longLongIntReturnValue(); - virtual cpputest_longlong returnLongLongIntValueOrDefault(cpputest_longlong defaultValue); - virtual cpputest_ulonglong unsignedLongLongIntReturnValue(); - virtual cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong defaultValue); - virtual unsigned int returnUnsignedIntValueOrDefault(unsigned int defaultValue); - virtual const char* stringReturnValue(); - virtual const char* returnStringValueOrDefault(const char * defaultValue); - virtual double returnDoubleValueOrDefault(double defaultValue); - virtual double doubleReturnValue(); - virtual void* pointerReturnValue(); - virtual void* returnPointerValueOrDefault(void * defaultValue); - virtual const void* returnConstPointerValueOrDefault(const void * defaultValue); - virtual const void* constPointerReturnValue(); - virtual void (*returnFunctionPointerValueOrDefault(void (*defaultValue)()))(); - virtual void (*functionPointerReturnValue())(); - - bool hasData(const SimpleString& name); - void setData(const SimpleString& name, bool value); - void setData(const SimpleString& name, int value); - void setData(const SimpleString& name, unsigned int value); - void setData(const SimpleString& name, long int value); - void setData(const SimpleString& name, unsigned long int value); - void setData(const SimpleString& name, const char* value); - void setData(const SimpleString& name, double value); - void setData(const SimpleString& name, void* value); - void setData(const SimpleString& name, const void* value); - void setData(const SimpleString& name, void (*value)()); - void setDataObject(const SimpleString& name, const SimpleString& type, void* value); - void setDataConstObject(const SimpleString& name, const SimpleString& type, const void* value); - MockNamedValue getData(const SimpleString& name); - - MockSupport* getMockSupportScope(const SimpleString& name); - - const char* getTraceOutput(); - /* - * The following functions are recursively through the lower MockSupports scopes - * This means, if you do mock().disable() it will disable *all* mocking scopes, including mock("myScope"). - */ - - virtual void disable(); - virtual void enable(); - virtual void tracing(bool enabled); - virtual void ignoreOtherCalls(); - - virtual void checkExpectations(); - virtual bool expectedCallsLeft(); - - virtual void clear(); - virtual void crashOnFailure(bool shouldFail = true); - - /* - * Each mock() call will set the activeReporter to standard, unless a special reporter is passed for this call. - */ - - virtual void setMockFailureStandardReporter(MockFailureReporter* reporter); - virtual void setActiveReporter(MockFailureReporter* activeReporter); - virtual void setDefaultComparatorsAndCopiersRepository(); - - virtual void installComparator(const SimpleString& typeName, MockNamedValueComparator& comparator); - virtual void installCopier(const SimpleString& typeName, MockNamedValueCopier& copier); - virtual void installComparatorsAndCopiers(const MockNamedValueComparatorsAndCopiersRepository& repository); - virtual void removeAllComparatorsAndCopiers(); - -protected: - MockSupport* clone(const SimpleString& mockName); - virtual MockCheckedActualCall *createActualCall(); - virtual void failTest(MockFailure& failure); - void countCheck(); - -private: - unsigned int actualCallOrder_; - unsigned int expectedCallOrder_; - bool strictOrdering_; - MockFailureReporter *activeReporter_; - MockFailureReporter *standardReporter_; - MockFailureReporter defaultReporter_; - MockExpectedCallsList expectations_; - bool ignoreOtherCalls_; - bool enabled_; - MockCheckedActualCall *lastActualFunctionCall_; - MockNamedValueComparatorsAndCopiersRepository comparatorsAndCopiersRepository_; - MockNamedValueList data_; - const SimpleString mockName_; - - bool tracing_; - - void checkExpectationsOfLastActualCall(); - bool wasLastActualCallFulfilled(); - void failTestWithExpectedCallsNotFulfilled(); - void failTestWithOutOfOrderCalls(); - - MockNamedValue* retrieveDataFromStore(const SimpleString& name); - - MockSupport* getMockSupport(MockNamedValueListNode* node); - - bool callIsIgnored(const SimpleString& functionName); - bool hasCallsOutOfOrder(); - - SimpleString appendScopeToName(const SimpleString& functionName); - -}; - -#endif - diff --git a/include/CppUTestExt/MockSupportPlugin.h b/include/CppUTestExt/MockSupportPlugin.h deleted file mode 100644 index b77041c38..000000000 --- a/include/CppUTestExt/MockSupportPlugin.h +++ /dev/null @@ -1,51 +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. - */ - -#ifndef D_MockSupportPlugin_h -#define D_MockSupportPlugin_h - -#include "CppUTest/TestPlugin.h" -#include "CppUTestExt/MockNamedValue.h" - -class MockSupportPlugin : public TestPlugin -{ -public: - MockSupportPlugin(const SimpleString& name = "MockSupportPLugin"); - virtual ~MockSupportPlugin() CPPUTEST_DESTRUCTOR_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); - - void clear(); -private: - MockNamedValueComparatorsAndCopiersRepository repository_; -}; - -#endif diff --git a/include/CppUTestExt/MockSupport_c.h b/include/CppUTestExt/MockSupport_c.h deleted file mode 100644 index fc2745f1e..000000000 --- a/include/CppUTestExt/MockSupport_c.h +++ /dev/null @@ -1,240 +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. - */ - -#ifndef D_MockSupport_c_h -#define D_MockSupport_c_h - -#ifdef __cplusplus -extern "C" { -#endif - -#include "CppUTest/CppUTestConfig.h" -#include "CppUTest/StandardCLibrary.h" - -typedef enum { - MOCKVALUETYPE_BOOL, - MOCKVALUETYPE_UNSIGNED_INTEGER, - MOCKVALUETYPE_INTEGER, - MOCKVALUETYPE_LONG_INTEGER, - MOCKVALUETYPE_UNSIGNED_LONG_INTEGER, - MOCKVALUETYPE_LONG_LONG_INTEGER, - MOCKVALUETYPE_UNSIGNED_LONG_LONG_INTEGER, - MOCKVALUETYPE_DOUBLE, - MOCKVALUETYPE_STRING, - MOCKVALUETYPE_POINTER, - MOCKVALUETYPE_CONST_POINTER, - MOCKVALUETYPE_FUNCTIONPOINTER, - MOCKVALUETYPE_MEMORYBUFFER, - MOCKVALUETYPE_OBJECT -} MockValueType_c; - -typedef struct SMockValue_c -{ - MockValueType_c type; - union { - int boolValue; - int intValue; - unsigned int unsignedIntValue; - long int longIntValue; - unsigned long int unsignedLongIntValue; -#if CPPUTEST_USE_LONG_LONG - cpputest_longlong longLongIntValue; - cpputest_ulonglong unsignedLongLongIntValue; -#else - char longLongPlaceholder[CPPUTEST_SIZE_OF_FAKE_LONG_LONG_TYPE]; -#endif - double doubleValue; - const char* stringValue; - void* pointerValue; - const void* constPointerValue; - void (*functionPointerValue)(void); - const unsigned char* memoryBufferValue; - void* objectValue; - const void* constObjectValue; - } value; -} MockValue_c; - -typedef struct SMockActualCall_c MockActualCall_c; -struct SMockActualCall_c -{ - MockActualCall_c* (*withBoolParameters)(const char* name, int value); - MockActualCall_c* (*withIntParameters)(const char* name, int value); - MockActualCall_c* (*withUnsignedIntParameters)(const char* name, unsigned int value); - MockActualCall_c* (*withLongIntParameters)(const char* name, long int value); - MockActualCall_c* (*withUnsignedLongIntParameters)(const char* name, unsigned long int value); - MockActualCall_c* (*withLongLongIntParameters)(const char* name, cpputest_longlong value); - MockActualCall_c* (*withUnsignedLongLongIntParameters)(const char* name, cpputest_ulonglong value); - MockActualCall_c* (*withDoubleParameters)(const char* name, double value); - MockActualCall_c* (*withStringParameters)(const char* name, const char* value); - MockActualCall_c* (*withPointerParameters)(const char* name, void* value); - MockActualCall_c* (*withConstPointerParameters)(const char* name, const void* value); - MockActualCall_c* (*withFunctionPointerParameters)(const char* name, void (*value)(void)); - MockActualCall_c* (*withMemoryBufferParameter)(const char* name, const unsigned char* value, size_t size); - MockActualCall_c* (*withParameterOfType)(const char* type, const char* name, const void* value); - MockActualCall_c* (*withOutputParameter)(const char* name, void* value); - MockActualCall_c* (*withOutputParameterOfType)(const char* type, const char* name, void* value); - int (*hasReturnValue)(void); - MockValue_c (*returnValue)(void); - int (*boolReturnValue)(void); - int (*returnBoolValueOrDefault)(int defaultValue); - int (*intReturnValue)(void); - int (*returnIntValueOrDefault)(int defaultValue); - unsigned int (*unsignedIntReturnValue)(void); - unsigned int (*returnUnsignedIntValueOrDefault)(unsigned int defaultValue); - long int (*longIntReturnValue)(void); - long int (*returnLongIntValueOrDefault)(long int defaultValue); - unsigned long int (*unsignedLongIntReturnValue)(void); - unsigned long int (*returnUnsignedLongIntValueOrDefault)(unsigned long int defaultValue); - cpputest_longlong (*longLongIntReturnValue)(void); - cpputest_longlong (*returnLongLongIntValueOrDefault)(cpputest_longlong defaultValue); - cpputest_ulonglong (*unsignedLongLongIntReturnValue)(void); - cpputest_ulonglong (*returnUnsignedLongLongIntValueOrDefault)(cpputest_ulonglong defaultValue); - const char* (*stringReturnValue)(void); - const char* (*returnStringValueOrDefault)(const char * defaultValue); - double (*doubleReturnValue)(void); - double (*returnDoubleValueOrDefault)(double defaultValue); - void* (*pointerReturnValue)(void); - void* (*returnPointerValueOrDefault)(void * defaultValue); - const void* (*constPointerReturnValue)(void); - const void* (*returnConstPointerValueOrDefault)(const void * defaultValue); - void (*(*functionPointerReturnValue)(void))(void); - void (*(*returnFunctionPointerValueOrDefault)(void(*defaultValue)(void)))(void); -}; - -typedef struct SMockExpectedCall_c MockExpectedCall_c; -struct SMockExpectedCall_c -{ - MockExpectedCall_c* (*withBoolParameters)(const char* name, int value); - MockExpectedCall_c* (*withIntParameters)(const char* name, int value); - MockExpectedCall_c* (*withUnsignedIntParameters)(const char* name, unsigned int value); - MockExpectedCall_c* (*withLongIntParameters)(const char* name, long int value); - MockExpectedCall_c* (*withUnsignedLongIntParameters)(const char* name, unsigned long int value); - MockExpectedCall_c* (*withLongLongIntParameters)(const char* name, cpputest_longlong value); - MockExpectedCall_c* (*withUnsignedLongLongIntParameters)(const char* name, cpputest_ulonglong value); - MockExpectedCall_c* (*withDoubleParameters)(const char* name, double value); - MockExpectedCall_c* (*withDoubleParametersAndTolerance)(const char* name, double value, double tolerance); - MockExpectedCall_c* (*withStringParameters)(const char* name, const char* value); - MockExpectedCall_c* (*withPointerParameters)(const char* name, void* value); - MockExpectedCall_c* (*withConstPointerParameters)(const char* name, const void* value); - MockExpectedCall_c* (*withFunctionPointerParameters)(const char* name, void (*value)(void)); - MockExpectedCall_c* (*withMemoryBufferParameter)(const char* name, const unsigned char* value, size_t size); - MockExpectedCall_c* (*withParameterOfType)(const char* type, const char* name, const void* value); - MockExpectedCall_c* (*withOutputParameterReturning)(const char* name, const void* value, size_t size); - MockExpectedCall_c* (*withOutputParameterOfTypeReturning)(const char* type, const char* name, const void* value); - MockExpectedCall_c* (*withUnmodifiedOutputParameter)(const char* name); - MockExpectedCall_c* (*ignoreOtherParameters)(void); - - MockExpectedCall_c* (*andReturnBoolValue)(int value); - MockExpectedCall_c* (*andReturnUnsignedIntValue)(unsigned int value); - MockExpectedCall_c* (*andReturnIntValue)(int value); - MockExpectedCall_c* (*andReturnLongIntValue)(long int value); - MockExpectedCall_c* (*andReturnUnsignedLongIntValue)(unsigned long int value); - MockExpectedCall_c* (*andReturnLongLongIntValue)(cpputest_longlong value); - MockExpectedCall_c* (*andReturnUnsignedLongLongIntValue)(cpputest_ulonglong value); - MockExpectedCall_c* (*andReturnDoubleValue)(double value); - MockExpectedCall_c* (*andReturnStringValue)(const char* value); - MockExpectedCall_c* (*andReturnPointerValue)(void* value); - MockExpectedCall_c* (*andReturnConstPointerValue)(const void* value); - MockExpectedCall_c* (*andReturnFunctionPointerValue)(void (*value)(void)); -}; - -typedef int (*MockTypeEqualFunction_c)(const void* object1, const void* object2); -typedef const char* (*MockTypeValueToStringFunction_c)(const void* object1); -typedef void (*MockTypeCopyFunction_c)(void* dst, const void* src); - -typedef struct SMockSupport_c MockSupport_c; -struct SMockSupport_c -{ - void (*strictOrder)(void); - MockExpectedCall_c* (*expectOneCall)(const char* name); - void (*expectNoCall)(const char* name); - MockExpectedCall_c* (*expectNCalls)(unsigned int number, const char* name); - MockActualCall_c* (*actualCall)(const char* name); - int (*hasReturnValue)(void); - MockValue_c (*returnValue)(void); - int (*boolReturnValue)(void); - int (*returnBoolValueOrDefault)(int defaultValue); - int (*intReturnValue)(void); - int (*returnIntValueOrDefault)(int defaultValue); - unsigned int (*unsignedIntReturnValue)(void); - unsigned int (*returnUnsignedIntValueOrDefault)(unsigned int defaultValue); - long int (*longIntReturnValue)(void); - long int (*returnLongIntValueOrDefault)(long int defaultValue); - unsigned long int (*unsignedLongIntReturnValue)(void); - unsigned long int (*returnUnsignedLongIntValueOrDefault)(unsigned long int defaultValue); - cpputest_longlong (*longLongIntReturnValue)(void); - cpputest_longlong (*returnLongLongIntValueOrDefault)(cpputest_longlong defaultValue); - cpputest_ulonglong (*unsignedLongLongIntReturnValue)(void); - cpputest_ulonglong (*returnUnsignedLongLongIntValueOrDefault)(cpputest_ulonglong defaultValue); - const char* (*stringReturnValue)(void); - const char* (*returnStringValueOrDefault)(const char * defaultValue); - double (*doubleReturnValue)(void); - double (*returnDoubleValueOrDefault)(double defaultValue); - void* (*pointerReturnValue)(void); - void* (*returnPointerValueOrDefault)(void * defaultValue); - const void* (*constPointerReturnValue)(void); - const void* (*returnConstPointerValueOrDefault)(const void * defaultValue); - void (*(*functionPointerReturnValue)(void))(void); - void (*(*returnFunctionPointerValueOrDefault) (void(*defaultValue)(void)))(void); - - void (*setBoolData) (const char* name, int value); - void (*setIntData) (const char* name, int value); - void (*setUnsignedIntData) (const char* name, unsigned int value); - void (*setLongIntData) (const char* name, long int value); - void (*setUnsignedLongIntData) (const char* name, unsigned long int value); - void (*setStringData) (const char* name, const char* value); - void (*setDoubleData) (const char* name, double value); - void (*setPointerData) (const char* name, void* value); - void (*setConstPointerData) (const char* name, const void* value); - void (*setFunctionPointerData) (const char* name, void (*value)(void)); - void (*setDataObject) (const char* name, const char* type, void* value); - void (*setDataConstObject) (const char* name, const char* type, const void* value); - MockValue_c (*getData)(const char* name); - - void (*disable)(void); - void (*enable)(void); - void (*ignoreOtherCalls)(void); - - void (*checkExpectations)(void); - int (*expectedCallsLeft)(void); - - void (*clear)(void); - void (*crashOnFailure)(unsigned shouldCrash); - - void (*installComparator) (const char* typeName, MockTypeEqualFunction_c isEqual, MockTypeValueToStringFunction_c valueToString); - void (*installCopier) (const char* typeName, MockTypeCopyFunction_c copier); - void (*removeAllComparatorsAndCopiers)(void); -}; - -MockSupport_c* mock_c(void); -MockSupport_c* mock_scope_c(const char* scope); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/CppUTestExt/OrderedTest.h b/include/CppUTestExt/OrderedTest.h deleted file mode 100644 index 3db756b2a..000000000 --- a/include/CppUTestExt/OrderedTest.h +++ /dev/null @@ -1,87 +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. - */ - -#ifndef D_OrderedTest_h -#define D_OrderedTest_h - -class OrderedTestShell : public UtestShell -{ -public: - OrderedTestShell(); - virtual ~OrderedTestShell() CPPUTEST_DESTRUCTOR_OVERRIDE; - - virtual OrderedTestShell* addOrderedTest(OrderedTestShell* test); - virtual OrderedTestShell* getNextOrderedTest(); - - int getLevel(); - void setLevel(int level); - - static void addOrderedTestToHead(OrderedTestShell* test); - static OrderedTestShell* getOrderedTestHead(); - static bool firstOrderedTest(); - - static void setOrderedTestHead(OrderedTestShell* test); -private: - static OrderedTestShell* _orderedTestsHead; - OrderedTestShell* _nextOrderedTest; - - int _level; - -}; - -class OrderedTestInstaller -{ - public: - explicit OrderedTestInstaller(OrderedTestShell& test, const char* groupName, const char* testName, const char* fileName, size_t lineNumber, int level); - virtual ~OrderedTestInstaller(); - - private: - void addOrderedTestInOrder(OrderedTestShell* test); - void addOrderedTestInOrderNotAtHeadPosition(OrderedTestShell* test); - -}; - -#define TEST_ORDERED(testGroup, testName, testLevel) \ - /* declarations for compilers */ \ - class TEST_##testGroup##_##testName##_TestShell; \ - 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() CPPUTEST_OVERRIDE; }; \ - class TEST_##testGroup##_##testName##_TestShell : public OrderedTestShell { \ - 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() - -#define TEST_ORDERED_C_WRAPPER(group_name, test_name, testLevel) \ - extern "C" void test_##group_name##_##test_name##_wrapper_c(void); \ - TEST_ORDERED(group_name, test_name, testLevel) { \ - test_##group_name##_##test_name##_wrapper_c(); \ - } - -#endif diff --git a/include/Platforms/c2000/stdint.h b/include/Platforms/c2000/stdint.h deleted file mode 100644 index 3e076a500..000000000 --- a/include/Platforms/c2000/stdint.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde - * and Arnd R. Strube - * 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. - */ - - #ifndef stdint_wrapper_h - #define stdint_wrapper_h - - #include - - typedef unsigned char uint8_t; /* This will still compile to 16 bit */ - - #endif /* stdint_wrapper_h */ \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 000000000..501083e04 --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + Cpputest + + + + Moved to cpputest.github.io + + diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 000000000..d8135d37b --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1 @@ +console.log('This would be the main JS file.'); diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4 deleted file mode 100644 index e4e91d3c9..000000000 --- a/m4/acx_pthread.m4 +++ /dev/null @@ -1,242 +0,0 @@ -dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -dnl -dnl @summary figure out how to build C programs using POSIX threads -dnl -dnl This macro figures out how to build C programs using POSIX threads. -dnl It sets the PTHREAD_LIBS output variable to the threads library and -dnl linker flags, and the PTHREAD_CFLAGS output variable to any special -dnl C compiler flags that are needed. (The user can also force certain -dnl compiler flags/libs to be tested by setting these environment -dnl variables.) -dnl -dnl Also sets PTHREAD_CC to any special C compiler that is needed for -dnl multi-threaded programs (defaults to the value of CC otherwise). -dnl (This is necessary on AIX to use the special cc_r compiler alias.) -dnl -dnl NOTE: You are assumed to not only compile your program with these -dnl flags, but also link it with them as well. e.g. you should link -dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS -dnl $LIBS -dnl -dnl If you are only building threads programs, you may wish to use -dnl these variables in your default LIBS, CFLAGS, and CC: -dnl -dnl LIBS="$PTHREAD_LIBS $LIBS" -dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -dnl CC="$PTHREAD_CC" -dnl -dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute -dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to -dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -dnl -dnl ACTION-IF-FOUND is a list of shell commands to run if a threads -dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to -dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the -dnl default action will define HAVE_PTHREAD. -dnl -dnl Please let the authors know if this macro fails on any platform, or -dnl if you have any other suggestions or comments. This macro was based -dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with -dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros -dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. -dnl We are also grateful for the helpful feedback of numerous users. -dnl -dnl @category InstalledPackages -dnl @author Steven G. Johnson -dnl @version 2006-05-29 -dnl @license GPLWithACException - -AC_DEFUN([ACX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C -acx_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on True64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) - AC_MSG_RESULT($acx_pthread_ok) - if test x"$acx_pthread_ok" = xno; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) -# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) -# -pthreads: Solaris/gcc -# -mthreads: Mingw32/gcc, Lynx/gcc -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads too; -# also defines -D_REENTRANT) -# ... -mt is also the pthreads flag for HP/aCC -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case "${host_cpu}-${host_os}" in - *solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (We need to link with -pthreads/-mt/ - # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather - # a function called by this macro, so we could check for that, but - # who knows whether they'll stub that too in a future libc.) So, - # we'll just look for -pthreads and -lpthread first: - - acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" - ;; -esac - -if test x"$acx_pthread_ok" = xno; then -for flag in $acx_pthread_flags; do - - case $flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $flag]) - PTHREAD_CFLAGS="$flag" - ;; - - pthread-config) - AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) - if test x"$acx_pthread_config" = xno; then continue; fi - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$flag]) - PTHREAD_LIBS="-l$flag" - ;; - esac - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - AC_MSG_RESULT($acx_pthread_ok) - if test "x$acx_pthread_ok" = xyes; then - break; - fi - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$acx_pthread_ok" = xyes; then - save_LIBS="$LIBS" - LIBS="$PTHREAD_LIBS $LIBS" - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_MSG_CHECKING([for joinable pthread attribute]) - attr_name=unknown - for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_TRY_LINK([#include ], [int attr=$attr; return attr;], - [attr_name=$attr; break]) - done - AC_MSG_RESULT($attr_name) - if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - fi - - AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no - case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; - esac - AC_MSG_RESULT(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" - fi - - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) - else - PTHREAD_CC=$CC - fi -else - PTHREAD_CC="$CC" -fi - -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test x"$acx_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) - : -else - acx_pthread_ok=no - $2 -fi -AC_LANG_RESTORE -])dnl ACX_PTHREAD diff --git a/m4/m4_ax_compiler_vendor.m4 b/m4/m4_ax_compiler_vendor.m4 deleted file mode 100644 index f06e86540..000000000 --- a/m4/m4_ax_compiler_vendor.m4 +++ /dev/null @@ -1,117 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VENDOR -# -# DESCRIPTION -# -# Determine the vendor of the C, C++ or Fortran compiler. The vendor is -# returned in the cache variable $ax_cv_c_compiler_vendor for C, -# $ax_cv_cxx_compiler_vendor for C++ or $ax_cv_fc_compiler_vendor for -# (modern) Fortran. The value is one of "intel", "ibm", "pathscale", -# "clang" (LLVM), "cray", "fujitsu", "sdcc", "sx", "portland" (PGI), "gnu" -# (GCC), "sun" (Oracle Developer Studio), "hp", "dec", "borland", -# "comeau", "kai", "lcc", "sgi", "microsoft", "metrowerks", "watcom", -# "tcc" (Tiny CC) or "unknown" (if the compiler cannot be determined). -# -# To check for a Fortran compiler, you must first call AC_FC_PP_SRCEXT -# with an appropriate preprocessor-enabled extension. For example: -# -# AC_LANG_PUSH([Fortran]) -# AC_PROG_FC -# AC_FC_PP_SRCEXT([F]) -# AX_COMPILER_VENDOR -# AC_LANG_POP([Fortran]) -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson -# Copyright (c) 2008 Matteo Frigo -# Copyright (c) 2018-19 John Zaitseff -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 30 - -AC_DEFUN([AX_COMPILER_VENDOR], [dnl - AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor, [dnl - dnl If you modify this list of vendors, please add similar support - dnl to ax_compiler_version.m4 if at all possible. - dnl - dnl Note: Do NOT check for GCC first since some other compilers - dnl define __GNUC__ to remain compatible with it. Compilers that - dnl are very slow to start (such as Intel) are listed first. - - vendors=" - intel: __ICC,__ECC,__INTEL_COMPILER - ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__,__ibmxl__ - pathscale: __PATHCC__,__PATHSCALE__ - clang: __clang__ - cray: _CRAYC - fujitsu: __FUJITSU - sdcc: SDCC,__SDCC - sx: _SX - portland: __PGI - gnu: __GNUC__ - sun: __SUNPRO_C,__SUNPRO_CC,__SUNPRO_F90,__SUNPRO_F95 - hp: __HP_cc,__HP_aCC - dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER - borland: __BORLANDC__,__CODEGEARC__,__TURBOC__ - comeau: __COMO__ - kai: __KCC - lcc: __LCC__ - sgi: __sgi,sgi - microsoft: _MSC_VER - metrowerks: __MWERKS__ - watcom: __WATCOMC__ - tcc: __TINYC__ - unknown: UNKNOWN - " - for ventest in $vendors; do - case $ventest in - *:) - vendor=$ventest - continue - ;; - *) - vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" - ;; - esac - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[ -#if !($vencpp) - thisisanerror; -#endif - ]])], [break]) - done - - ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1` - ]) -])dnl diff --git a/m4/m4_ax_compiler_version.m4 b/m4/m4_ax_compiler_version.m4 deleted file mode 100644 index 0581d1bc0..000000000 --- a/m4/m4_ax_compiler_version.m4 +++ /dev/null @@ -1,529 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_compiler_version.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPILER_VERSION -# -# DESCRIPTION -# -# This macro retrieves the compiler version and returns it in the cache -# variable $ax_cv_c_compiler_version for C and $ax_cv_cxx_compiler_version -# for C++. -# -# Version is returned as epoch:major.minor.patchversion -# -# Epoch is used in order to have an increasing version number in case of -# marketing change. -# -# Epoch use: * borland compiler use chronologically 0turboc for turboc -# era, -# -# 1borlanc BORLANDC++ before 5, 2cppbuilder for cppbuilder era, -# 3borlancpp for return of BORLANDC++ (after version 5.5), -# 4cppbuilder for cppbuilder with year version, -# and 5xe for XE era. -# -# An empty string is returned otherwise. -# -# LICENSE -# -# Copyright (c) 2014 Bastien ROUCARIES -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 12 - -# for intel -AC_DEFUN([_AX_COMPILER_VERSION_INTEL], - [ dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [__INTEL_COMPILER/100],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__INTEL_COMPILER%100)/10],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [(__INTEL_COMPILER%10)],, - AC_MSG_FAILURE([[[$0]] unknown intel compiler version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for IBM -AC_DEFUN([_AX_COMPILER_VERSION_IBM], - [ dnl - dnl check between z/OS C/C++ and XL C/C++ - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([], - [ - #if defined(__COMPILER_VER__) - choke me; - #endif - ])], - [ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [__xlC__/100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [__xlC__%100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__xlC_ver__/0x100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, - [__xlC_ver__%0x100],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler build version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" - ], - [ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__xlC__%1000],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__xlC__/10000)%10],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__xlC__/100000)%10],, - AC_MSG_FAILURE([[[$0]] unknown IBM compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) -]) - -# for pathscale -AC_DEFUN([_AX_COMPILER_VERSION_PATHSCALE],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __PATHCC__,, - AC_MSG_FAILURE([[[$0]] unknown pathscale major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __PATHCC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown pathscale minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__PATHCC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown pathscale patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for clang -AC_DEFUN([_AX_COMPILER_VERSION_CLANG],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __clang_major__,, - AC_MSG_FAILURE([[[$0]] unknown clang major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __clang_minor__,, - AC_MSG_FAILURE([[[$0]] unknown clang minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__clang_patchlevel__],,0) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for crayc -AC_DEFUN([_AX_COMPILER_VERSION_CRAY],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - _RELEASE,, - AC_MSG_FAILURE([[[$0]] unknown crayc release])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _RELEASE_MINOR,, - AC_MSG_FAILURE([[[$0]] unknown crayc minor])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# for fujitsu -AC_DEFUN([_AX_COMPILER_VERSION_FUJITSU],[ - AC_COMPUTE_INT(ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, - __FCC_VERSION,, - AC_MSG_FAILURE([[[$0]]unknown fujitsu release])) - ]) - -# for GNU -AC_DEFUN([_AX_COMPILER_VERSION_GNU],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __GNUC__,, - AC_MSG_FAILURE([[[$0]] unknown gcc major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __GNUC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown gcc minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__GNUC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown gcc patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# For sun -AC_DEFUN([_AX_COMPILER_VERSION_SUN],[ - m4_define([_AX_COMPILER_VERSION_SUN_NUMBER], - [ - #if defined(__SUNPRO_CC) - __SUNPRO_CC - #else - __SUNPRO_C - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59, - !!(_AX_COMPILER_VERSION_SUN_NUMBER < 0x1000),, - AC_MSG_FAILURE([[[$0]] unknown sun release version])) - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_until59" = X1], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x10) % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100),, - AC_MSG_FAILURE([[[$0]] unknown sun major version])) - ], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _AX_COMPILER_VERSION_SUN_NUMBER % 0x10,, - AC_MSG_FAILURE([[[$0]] unknown sun patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x100) % 0x100,, - AC_MSG_FAILURE([[[$0]] unknown sun minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_SUN_NUMBER / 0x1000),, - AC_MSG_FAILURE([[[$0]] unknown sun major version])) - ]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" -]) - -AC_DEFUN([_AX_COMPILER_VERSION_HP],[ - m4_define([_AX_COMPILER_VERSION_HP_NUMBER], - [ - #if defined(__HP_cc) - __HP_cc - #else - __HP_aCC - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121, - !!(_AX_COMPILER_VERSION_HP_NUMBER <= 1),, - AC_MSG_FAILURE([[[$0]] unknown hp release version])) - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_untilA0121" = X1], - [dnl By default output last version with this behavior. - dnl it is so old - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="01.21.00" - ], - [dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - (_AX_COMPILER_VERSION_HP_NUMBER % 100),, - AC_MSG_FAILURE([[[$0]] unknown hp release version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - ((_AX_COMPILER_VERSION_HP_NUMBER / 100)%100),, - AC_MSG_FAILURE([[[$0]] unknown hp minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - ((_AX_COMPILER_VERSION_HP_NUMBER / 10000)%100),, - AC_MSG_FAILURE([[[$0]] unknown hp major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) -]) - -AC_DEFUN([_AX_COMPILER_VERSION_DEC],[dnl - m4_define([_AX_COMPILER_VERSION_DEC_NUMBER], - [ - #if defined(__DECC_VER) - __DECC_VER - #else - __DECCXX_VER - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - (_AX_COMPILER_VERSION_DEC_NUMBER % 10000),, - AC_MSG_FAILURE([[[$0]] unknown dec release version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - ((_AX_COMPILER_VERSION_DEC_NUMBER / 100000UL)%100),, - AC_MSG_FAILURE([[[$0]] unknown dec minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - ((_AX_COMPILER_VERSION_DEC_NUMBER / 10000000UL)%100),, - AC_MSG_FAILURE([[[$0]] unknown dec major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# borland -AC_DEFUN([_AX_COMPILER_VERSION_BORLAND],[dnl - m4_define([_AX_COMPILER_VERSION_TURBOC_NUMBER], - [ - #if defined(__TURBOC__) - __TURBOC__ - #else - choke me - #endif - ]) - m4_define([_AX_COMPILER_VERSION_BORLANDC_NUMBER], - [ - #if defined(__BORLANDC__) - __BORLANDC__ - #else - __CODEGEARC__ - #endif - ]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM(, - _AX_COMPILER_VERSION_TURBOC_NUMBER)], - [dnl TURBOC - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw, - _AX_COMPILER_VERSION_TURBOC_NUMBER,, - AC_MSG_FAILURE([[[$0]] unknown turboc version])) - AS_IF( - [test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -lt 661 || test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw -gt 1023], - [dnl compute normal version - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _AX_COMPILER_VERSION_TURBOC_NUMBER % 0x100,, - AC_MSG_FAILURE([[[$0]] unknown turboc minor version])) - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_AX_COMPILER_VERSION_TURBOC_NUMBER/0x100)%0x100,, - AC_MSG_FAILURE([[[$0]] unknown turboc major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor"], - [dnl special version - AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_turboc_raw], - [661],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.00"], - [662],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:1.01"], - [663],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="0turboc:2.00"], - [ - AC_MSG_WARN([[[$0]] unknown turboc version between 0x295 and 0x400 please report bug]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="" - ]) - ]) - ], - # borlandc - [ - AC_COMPUTE_INT( - _ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw, - _AX_COMPILER_VERSION_BORLANDC_NUMBER,, - AC_MSG_FAILURE([[[$0]] unknown borlandc version])) - AS_CASE([$_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw], - dnl BORLANDC++ before 5.5 - [512] ,[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:2.00"], - [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], - [1024],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.00"], - [1040],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:3.1"], - [1106],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:4.0"], - [1280],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.0"], - [1312],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="1borlanc:5.02"], - dnl C++ Builder era - [1328],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:3.0"], - [1344],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="2cppbuilder:4.0"], - dnl BORLANDC++ after 5.5 - [1360],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.5"], - [1361],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.51"], - [1378],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="3borlancpp:5.6.4"], - dnl C++ Builder with year number - [1392],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2006"], - [1424],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2007"], - [1555],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2009"], - [1569],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="4cppbuilder:2010"], - dnl XE version - [1584],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe"], - [1600],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:2"], - [1616],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:3"], - [1632],[ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="5xe:4"], - [ - AC_MSG_WARN([[[$0]] Unknown borlandc compiler version $_ax_[]_AC_LANG_ABBREV[]_compiler_version_borlandc_raw please report bug]) - ]) - ]) - ]) - -# COMO -AC_DEFUN([_AX_COMPILER_VERSION_COMEAU], - [ dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [__COMO_VERSION__%100],, - AC_MSG_FAILURE([[[$0]] unknown comeau compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__COMO_VERSION__/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown comeau compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# KAI -AC_DEFUN([_AX_COMPILER_VERSION_KAI],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__KCC_VERSION%100],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(__KCC_VERSION/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(__KCC_VERSION/1000)%10],, - AC_MSG_FAILURE([[[$0]] unknown kay compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -dnl LCC -dnl LCC does not output version... - -# SGI -AC_DEFUN([_AX_COMPILER_VERSION_SGI],[ - m4_define([_AX_COMPILER_VERSION_SGI_NUMBER], - [ - #if defined(_COMPILER_VERSION) - _COMPILER_VERSION - #else - _SGI_COMPILER_VERSION - #endif - ]) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [_AX_COMPILER_VERSION_SGI_NUMBER%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - [(_AX_COMPILER_VERSION_SGI_NUMBER/10)%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - [(_AX_COMPILER_VERSION_SGI_NUMBER/100)%10],, - AC_MSG_FAILURE([[[$0]] unknown SGI compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# microsoft -AC_DEFUN([_AX_COMPILER_VERSION_MICROSOFT],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - _MSC_VER%100,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (_MSC_VER/100)%100,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler major version])) - dnl could be overridden - _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0 - _ax_[]_AC_LANG_ABBREV[]_compiler_version_build=0 - # special case for version 6 - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X12"], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%1000,, - _ax_[]_AC_LANG_ABBREV[]_compiler_version_patch=0)]) - # for version 7 - AS_IF([test "X$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major" = "X13"], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%1000,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) - ]) - # for version > 8 - AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 14], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - _MSC_FULL_VER%10000,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler patch version])) - ]) - AS_IF([test $_ax_[]_AC_LANG_ABBREV[]_compiler_version_major -ge 15], - [AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_build, - _MSC_BUILD,, - AC_MSG_FAILURE([[[$0]] unknown microsoft compiler build version])) - ]) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_build" - ]) - -# for metrowerks -AC_DEFUN([_AX_COMPILER_VERSION_METROWERKS],[dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - __MWERKS__%0x100,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler patch version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - (__MWERKS__/0x100)%0x10,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (__MWERKS__/0x1000)%0x10,, - AC_MSG_FAILURE([[[$0]] unknown metrowerks compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# for watcom -AC_DEFUN([_AX_COMPILER_VERSION_WATCOM],[dnl - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __WATCOMC__%100,, - AC_MSG_FAILURE([[[$0]] unknown watcom compiler minor version])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - (__WATCOMC__/100)%100,, - AC_MSG_FAILURE([[[$0]] unknown watcom compiler major version])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor" - ]) - -# for PGI -AC_DEFUN([_AX_COMPILER_VERSION_PORTLAND],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - __PGIC__,, - AC_MSG_FAILURE([[[$0]] unknown pgi major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - __PGIC_MINOR__,, - AC_MSG_FAILURE([[[$0]] unknown pgi minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [__PGIC_PATCHLEVEL__],, - AC_MSG_FAILURE([[[$0]] unknown pgi patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# tcc -AC_DEFUN([_AX_COMPILER_VERSION_TCC],[ - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=[`tcc -v | $SED 's/^[ ]*tcc[ ]\+version[ ]\+\([0-9.]\+\).*/\1/g'`] - ]) - -# for GNU -AC_DEFUN([_AX_COMPILER_VERSION_SDCC],[ - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_major, - /* avoid parse error with comments */ - #if(defined(__SDCC_VERSION_MAJOR)) - __SDCC_VERSION_MAJOR - #else - SDCC/100 - #endif - ,, - AC_MSG_FAILURE([[[$0]] unknown sdcc major])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor, - /* avoid parse error with comments */ - #if(defined(__SDCC_VERSION_MINOR)) - __SDCC_VERSION_MINOR - #else - (SDCC%100)/10 - #endif - ,, - AC_MSG_FAILURE([[[$0]] unknown sdcc minor])) - AC_COMPUTE_INT(_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch, - [ - /* avoid parse error with comments */ - #if(defined(__SDCC_VERSION_PATCH)) - __SDCC_VERSION_PATCH - #elsif(defined(_SDCC_VERSION_PATCHLEVEL)) - __SDCC_VERSION_PATCHLEVEL - #else - SDCC%10 - #endif - ],, - AC_MSG_FAILURE([[[$0]] unknown sdcc patch level])) - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version="$_ax_[]_AC_LANG_ABBREV[]_compiler_version_major.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_minor.$_ax_[]_AC_LANG_ABBREV[]_compiler_version_patch" - ]) - -# main entry point -AC_DEFUN([AX_COMPILER_VERSION],[dnl - AC_REQUIRE([AX_COMPILER_VENDOR]) - AC_REQUIRE([AC_PROG_SED]) - AC_CACHE_CHECK([for _AC_LANG compiler version], - ax_cv_[]_AC_LANG_ABBREV[]_compiler_version, - [ dnl - AS_CASE([$ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], - [intel],[_AX_COMPILER_VERSION_INTEL], - [ibm],[_AX_COMPILER_VERSION_IBM], - [pathscale],[_AX_COMPILER_VERSION_PATHSCALE], - [clang],[_AX_COMPILER_VERSION_CLANG], - [cray],[_AX_COMPILER_VERSION_CRAY], - [fujitsu],[_AX_COMPILER_VERSION_FUJITSU], - [gnu],[_AX_COMPILER_VERSION_GNU], - [sun],[_AX_COMPILER_VERSION_SUN], - [hp],[_AX_COMPILER_VERSION_HP], - [dec],[_AX_COMPILER_VERSION_DEC], - [borland],[_AX_COMPILER_VERSION_BORLAND], - [comeau],[_AX_COMPILER_VERSION_COMEAU], - [kai],[_AX_COMPILER_VERSION_KAI], - [sgi],[_AX_COMPILER_VERSION_SGI], - [microsoft],[_AX_COMPILER_VERSION_MICROSOFT], - [metrowerks],[_AX_COMPILER_VERSION_METROWERKS], - [watcom],[_AX_COMPILER_VERSION_WATCOM], - [portland],[_AX_COMPILER_VERSION_PORTLAND], - [tcc],[_AX_COMPILER_VERSION_TCC], - [sdcc],[_AX_COMPILER_VERSION_SDCC], - [ax_cv_[]_AC_LANG_ABBREV[]_compiler_version=""]) - ]) -]) diff --git a/m4/m4_ax_prefix_config_h.m4 b/m4/m4_ax_prefix_config_h.m4 deleted file mode 100644 index c17563f44..000000000 --- a/m4/m4_ax_prefix_config_h.m4 +++ /dev/null @@ -1,203 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_prefix_config_h.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PREFIX_CONFIG_H [(OUTPUT-HEADER [,PREFIX [,ORIG-HEADER]])] -# -# DESCRIPTION -# -# Generate an installable config.h. -# -# A package should not normally install its config.h as a system header, -# but if it must, this macro can be used to avoid namespace pollution by -# making a copy of config.h with a prefix added to all the macro names. -# -# Each "#define SOMEDEF" line of the configuration header has the given -# prefix added, in the same case as the first character of the macro name. -# -# Defaults: -# -# OUTPUT-HEADER = $PACKAGE-config.h -# PREFIX = $PACKAGE -# ORIG-HEADER, from AM_CONFIG_HEADER(config.h) -# -# Your configure.ac script should contain both macros in this order. -# -# Example: -# -# AC_INIT(config.h.in) # config.h.in as created by "autoheader" -# AM_INIT_AUTOMAKE(testpkg, 0.1.1) # makes #undef VERSION and PACKAGE -# AM_CONFIG_HEADER(config.h) # prep config.h from config.h.in -# AX_PREFIX_CONFIG_H(mylib/_config.h) # prep mylib/_config.h from it.. -# AC_MEMORY_H # makes "#undef NEED_MEMORY_H" -# AC_C_CONST_H # makes "#undef const" -# AC_OUTPUT(Makefile) # creates the "config.h" now -# # and also mylib/_config.h -# -# If the argument to AX_PREFIX_CONFIG_H would have been omitted then the -# default output file would have been called simply "testpkg-config.h", -# but even under the name "mylib/_config.h" it contains prefix-defines -# like -# -# #ifndef TESTPKG_VERSION -# #define TESTPKG_VERSION "0.1.1" -# #endif -# #ifndef TESTPKG_NEED_MEMORY_H -# #define TESTPKG_NEED_MEMORY_H 1 -# #endif -# #ifndef _testpkg_const -# #define _testpkg_const _const -# #endif -# -# and this "mylib/_config.h" can be installed along with other header -# files, which is most convenient when creating a shared library (that has -# some headers) whose functionality depends on features detected at -# compile-time. No need to invent some "mylib-confdefs.h.in" manually. -# -# Note that some AC_DEFINEs that end up in the config.h file are actually -# self-referential - e.g. AC_C_INLINE, AC_C_CONST, and the AC_TYPE_OFF_T -# say that they "will define inline|const|off_t if the system does not do -# it by itself". You might want to clean up about these - consider an -# extra mylib/conf.h that reads something like: -# -# #include -# #ifndef _testpkg_const -# #define _testpkg_const const -# #endif -# -# and then start using _testpkg_const in the header files. That is also a -# good thing to differentiate whether some library-user has starting to -# take up with a different compiler, so perhaps it could read something -# like this: -# -# #ifdef _MSC_VER -# #include -# #else -# #include -# #endif -# #ifndef _testpkg_const -# #define _testpkg_const const -# #endif -# -# LICENSE -# -# Copyright (c) 2014 Reuben Thomas -# Copyright (c) 2008 Guido U. Draheim -# Copyright (c) 2008 Marten Svantesson -# Copyright (c) 2008 Gerald Point -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 15 - -AC_DEFUN([AX_PREFIX_CONFIG_H],[dnl -AC_PREREQ([2.62]) -AC_BEFORE([AC_CONFIG_HEADERS],[$0])dnl -AC_CONFIG_COMMANDS(m4_default([$1], [$PACKAGE-config.h]),[dnl -AS_VAR_PUSHDEF([_OUT],[ac_prefix_conf_OUT])dnl -AS_VAR_PUSHDEF([_DEF],[ac_prefix_conf_DEF])dnl -AS_VAR_PUSHDEF([_PKG],[ac_prefix_conf_PKG])dnl -AS_VAR_PUSHDEF([_LOW],[ac_prefix_conf_LOW])dnl -AS_VAR_PUSHDEF([_UPP],[ac_prefix_conf_UPP])dnl -AS_VAR_PUSHDEF([_INP],[ac_prefix_conf_INP])dnl -m4_pushdef([_script],[conftest.prefix])dnl -m4_pushdef([_symbol],[m4_cr_Letters[]m4_cr_digits[]_])dnl -_OUT=`echo m4_default([$1], [$PACKAGE-config.h])` -_DEF=`echo _$_OUT | sed -e "y:m4_cr_letters:m4_cr_LETTERS[]:" -e "s/@<:@^m4_cr_Letters@:>@/_/g"` -_PKG=`echo m4_default([$2], [$PACKAGE])` -_LOW=`echo _$_PKG | sed -e "y:m4_cr_LETTERS-:m4_cr_letters[]_:"` -_UPP=`echo $_PKG | sed -e "y:m4_cr_letters-:m4_cr_LETTERS[]_:" -e "/^@<:@m4_cr_digits@:>@/s/^/_/"` -_INP=`echo "$3" | sed -e 's/ *//'` -if test ".$_INP" = "."; then - for ac_file in : $CONFIG_HEADERS; do test "_$ac_file" = _: && continue - case "$ac_file" in - *.h) _INP=$ac_file ;; - *) - esac - test ".$_INP" != "." && break - done -fi -if test ".$_INP" = "."; then - case "$_OUT" in - */*) _INP=`basename "$_OUT"` - ;; - *-*) _INP=`echo "$_OUT" | sed -e "s/@<:@_symbol@:>@*-//"` - ;; - *) _INP=config.h - ;; - esac -fi -if test -z "$_PKG" ; then - AC_MSG_ERROR([no prefix for _PREFIX_PKG_CONFIG_H]) -else - if test ! -f "$_INP" ; then if test -f "$srcdir/$_INP" ; then - _INP="$srcdir/$_INP" - fi fi - AC_MSG_NOTICE(creating $_OUT - prefix $_UPP for $_INP defines) - if test -f $_INP ; then - AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_LETTERS[]_@:>@\\)/@%:@undef $_UPP""_\\1/"]) > _script - AS_ECHO(["s/^@%:@undef *\\(@<:@m4_cr_letters@:>@\\)/@%:@undef $_LOW""_\\1/"]) >> _script - AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_LETTERS[]_@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_UPP""_\\1\\"]) >> _script - AS_ECHO(["@%:@def[]ine $_UPP""_\\1\\2\\"]) >> _script - AS_ECHO(["@%:@endif/"]) >> _script - AS_ECHO(["s/^@%:@def[]ine *\\(@<:@m4_cr_letters@:>@@<:@_symbol@:>@*\\)\\(.*\\)/@%:@ifndef $_LOW""_\\1\\"]) >> _script - AS_ECHO(["@%:@define $_LOW""_\\1\\2\\"]) >> _script - AS_ECHO(["@%:@endif/"]) >> _script - # now executing _script on _DEF input to create _OUT output file - echo "@%:@ifndef $_DEF" >$tmp/pconfig.h - echo "@%:@def[]ine $_DEF 1" >>$tmp/pconfig.h - echo ' ' >>$tmp/pconfig.h - echo /'*' $_OUT. Generated automatically at end of configure. '*'/ >>$tmp/pconfig.h - - sed -f _script $_INP >>$tmp/pconfig.h - echo ' ' >>$tmp/pconfig.h - echo '/* once:' $_DEF '*/' >>$tmp/pconfig.h - echo "@%:@endif" >>$tmp/pconfig.h - if cmp -s $_OUT $tmp/pconfig.h 2>/dev/null; then - AC_MSG_NOTICE([$_OUT is unchanged]) - else - ac_dir=`AS_DIRNAME(["$_OUT"])` - AS_MKDIR_P(["$ac_dir"]) - rm -f "$_OUT" - mv $tmp/pconfig.h "$_OUT" - fi - else - AC_MSG_ERROR([input file $_INP does not exist - skip generating $_OUT]) - fi - rm -f conftest.* -fi -m4_popdef([_symbol])dnl -m4_popdef([_script])dnl -AS_VAR_POPDEF([_INP])dnl -AS_VAR_POPDEF([_UPP])dnl -AS_VAR_POPDEF([_LOW])dnl -AS_VAR_POPDEF([_PKG])dnl -AS_VAR_POPDEF([_DEF])dnl -AS_VAR_POPDEF([_OUT])dnl -],[PACKAGE="$PACKAGE"])]) diff --git a/makeVS2008.bat b/makeVS2008.bat deleted file mode 100644 index 29f742735..000000000 --- a/makeVS2008.bat +++ /dev/null @@ -1,9 +0,0 @@ -rem **** -rem * Command line build - For CppUTest - Run from CppUTest directory -rem * -rem * this path works on my machine -rem ****PATH=C:\Windows\Microsoft.NET\Framework\v3.5;c:\windows;c:\windows\system32 - -msbuild /t:rebuild /verbosity:quiet CppUTest_VS2008.sln -set test_exe=tests\Debug\AllTests.exe -if exist %test_exe% %test_exe% -v diff --git a/makeVS201x.bat b/makeVS201x.bat deleted file mode 100644 index ead5eb7b4..000000000 --- a/makeVS201x.bat +++ /dev/null @@ -1,9 +0,0 @@ -rem **** -rem * Command line build - For CppUTest - Run from CppUTest directory -rem * -rem * this path works on my machine -rem ****PATH=C:\Windows\Microsoft.NET\Framework\v4.0.30319;c:\windows\system32;c:\windows -msbuild /t:rebuild /verbosity:quiet CppUTest_VS201x.sln -set test_exe=tests\Debug\AllTests.exe -if exist %test_exe% %test_exe% -v - diff --git a/params.json b/params.json new file mode 100644 index 000000000..60141920b --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"note":"Don't delete this file! It's used internally to help with page regeneration.","name":"Cpputest","body":"### Welcome to CppUTest github page.\r\n\r\nThis is CppUTest\r\n\r\n```\r\nSome code here\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.","google":"","tagline":"CppUTest unit testing and mocking framework for C/C++"} \ No newline at end of file diff --git a/platforms/CCStudio/CppUTest.pjt b/platforms/CCStudio/CppUTest.pjt deleted file mode 100644 index 3186c6109..000000000 --- a/platforms/CCStudio/CppUTest.pjt +++ /dev/null @@ -1,53 +0,0 @@ -; Code Composer Project File, Version 2.0 (do not modify or remove this line) - -[Project Settings] -ProjectDir="C:\data\00_Dev\05_CppUTest\cpputest\platforms\CCStudio\" -ProjectType=Library -CPUFamily=TMS320C28XX -Tool="Archiver" -Tool="Compiler" -Tool="CustomBuilder" -Tool="DspBiosBuilder" -Config="Debug" - -[Source Files] -Source="..\..\src\CppUTest\CommandLineArguments.cpp" -Source="..\..\src\CppUTest\CommandLineTestRunner.cpp" -Source="..\..\src\CppUTest\JUnitTestOutput.cpp" -Source="..\..\src\CppUTest\MemoryLeakDetector.cpp" -Source="..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp" -Source="..\..\src\CppUTest\SimpleMutex.cpp" -Source="..\..\src\CppUTest\SimpleString.cpp" -Source="..\..\src\CppUTest\TeamCityTestOutput.cpp" -Source="..\..\src\CppUTest\TestFailure.cpp" -Source="..\..\src\CppUTest\TestFilter.cpp" -Source="..\..\src\CppUTest\TestHarness_c.cpp" -Source="..\..\src\CppUTest\TestMemoryAllocator.cpp" -Source="..\..\src\CppUTest\TestOutput.cpp" -Source="..\..\src\CppUTest\TestPlugin.cpp" -Source="..\..\src\CppUTest\TestRegistry.cpp" -Source="..\..\src\CppUTest\TestResult.cpp" -Source="..\..\src\CppUTest\TestTestingFixture.cpp" -Source="..\..\src\CppUTest\Utest.cpp" -Source="..\..\src\CppUTestExt\CodeMemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\GTest.cpp" -Source="..\..\src\CppUTestExt\MemoryReportAllocator.cpp" -Source="..\..\src\CppUTestExt\MemoryReporterPlugin.cpp" -Source="..\..\src\CppUTestExt\MemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\MockActualCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCallsList.cpp" -Source="..\..\src\CppUTestExt\MockFailure.cpp" -Source="..\..\src\CppUTestExt\MockNamedValue.cpp" -Source="..\..\src\CppUTestExt\MockSupport.cpp" -Source="..\..\src\CppUTestExt\MockSupport_c.cpp" -Source="..\..\src\CppUTestExt\MockSupportPlugin.cpp" -Source="..\..\src\CppUTestExt\OrderedTest.cpp" -Source="..\..\src\Platforms\C2000\UtestPlatform.cpp" - -["Archiver" Settings: "Debug"] -Options=-r -o"..\..\lib\c2000\CppUTestd.lib" - -["Compiler" Settings: "Debug"] -Options=-g -rtti -pdsw225 -pden -pds1 -fr"$(Proj_dir)\Debug" -i"$(Proj_dir)\..\..\include" -d"_DEBUG" -d"LARGE_MODEL" -d"CPPUTEST_STD_CPP_LIB_DISABLED" -d"CPPUTEST_USE_MEM_LEAK_DETECTION" -ml -v28 - diff --git a/platforms/CCStudio/CppUTest.wks b/platforms/CCStudio/CppUTest.wks deleted file mode 100644 index edcb3b00c..000000000 Binary files a/platforms/CCStudio/CppUTest.wks and /dev/null differ diff --git a/platforms/CCStudio/CppUTestExtRunAllTests1.pjt b/platforms/CCStudio/CppUTestExtRunAllTests1.pjt deleted file mode 100644 index 2afdd31e3..000000000 --- a/platforms/CCStudio/CppUTestExtRunAllTests1.pjt +++ /dev/null @@ -1,72 +0,0 @@ -; Code Composer Project File, Version 2.0 (do not modify or remove this line) - -[Project Settings] -ProjectDir="C:\data\00_Dev\05_CppUTest\cpputest\platforms\CCStudio\" -ProjectType=Executable -CPUFamily=TMS320C28XX -Tool="Compiler" -Tool="CustomBuilder" -Tool="DspBiosBuilder" -Tool="Linker" -Config="Debug" - -[Source Files] -Source="..\..\src\CppUTest\CommandLineArguments.cpp" -Source="..\..\src\CppUTest\CommandLineTestRunner.cpp" -Source="..\..\src\CppUTest\JUnitTestOutput.cpp" -Source="..\..\src\CppUTest\MemoryLeakDetector.cpp" -Source="..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp" -Source="..\..\src\CppUTest\SimpleMutex.cpp" -Source="..\..\src\CppUTest\SimpleString.cpp" -Source="..\..\src\CppUTest\SimpleStringInternalCache.cpp" -Source="..\..\src\CppUTest\TeamCityTestOutput.cpp" -Source="..\..\src\CppUTest\TestFailure.cpp" -Source="..\..\src\CppUTest\TestFilter.cpp" -Source="..\..\src\CppUTest\TestHarness_c.cpp" -Source="..\..\src\CppUTest\TestMemoryAllocator.cpp" -Source="..\..\src\CppUTest\TestOutput.cpp" -Source="..\..\src\CppUTest\TestPlugin.cpp" -Source="..\..\src\CppUTest\TestRegistry.cpp" -Source="..\..\src\CppUTest\TestResult.cpp" -Source="..\..\src\CppUTest\TestTestingFixture.cpp" -Source="..\..\src\CppUTest\Utest.cpp" -Source="..\..\src\CppUTestExt\CodeMemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\GTest.cpp" -Source="..\..\src\CppUTestExt\MemoryReportAllocator.cpp" -Source="..\..\src\CppUTestExt\MemoryReporterPlugin.cpp" -Source="..\..\src\CppUTestExt\MemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\MockActualCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCallsList.cpp" -Source="..\..\src\CppUTestExt\MockFailure.cpp" -Source="..\..\src\CppUTestExt\MockNamedValue.cpp" -Source="..\..\src\CppUTestExt\MockSupport.cpp" -Source="..\..\src\CppUTestExt\MockSupportPlugin.cpp" -Source="..\..\src\CppUTestExt\OrderedTest.cpp" -Source="..\..\src\Platforms\C2000\UtestPlatform.cpp" -Source="..\..\tests\CppUTestExt\CodeMemoryReporterTest.cpp" -Source="..\..\tests\CppUTestExt\GMockTest.cpp" -Source="..\..\tests\CppUTestExt\GTest1Test.cpp" -Source="..\..\tests\CppUTestExt\GTest2ConvertorTest.cpp" -Source="..\..\tests\CppUTestExt\MemoryReportAllocatorTest.cpp" -Source="..\..\tests\CppUTestExt\MemoryReportFormatterTest.cpp" -Source="..\..\tests\CppUTestExt\MockActualCallTest.cpp" -Source="..\..\tests\CppUTestExt\MockCheatSheetTest.cpp" -Source="..\..\tests\CppUTestExt\MockExpectedCallTest.cpp" -Source="..\..\tests\CppUTestExt\MockFailureReporterForTest.cpp" -Source="..\..\tests\CppUTestExt\MockFailureTest.cpp" -Source="..\..\tests\CppUTestExt\MockHierarchyTest.cpp" -Source="..\..\tests\CppUTestExt\MockPluginTest.cpp" -Source="..\..\tests\CppUTestExt\MockReturnValueTest.cpp" -Source="..\..\tests\CppUTestExt\MockStrictOrderTest.cpp" -Source="..\..\tests\CppUTestExt\MockSupportTest.cpp" -Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp" -Source="tests\CppUTestExt\AllTestsForTarget.cpp" -Source="sim28335.cmd" - -["Compiler" Settings: "Debug"] -Options=-g -rtti -pdsw225 -pden -pds1 -fr"$(Proj_dir)\Debug" -i"$(Proj_dir)\..\..\include" -i"$(Proj_dir)\..\..\include\CppUTestExt\CppUTestGMock" -i"$(Proj_dir)\..\..\tests" -d"_DEBUG" -d"LARGE_MODEL" -d"CPPUTEST_STD_CPP_LIB_DISABLED" -d"CPPUTEST_USE_MEM_LEAK_DETECTION" -d"CPPUTEST_USE_MALLOC_MACROS" -ml -v28 --preinclude="$(Proj_dir)\..\..\include\Platforms\c2000\stdint.h" - -["Linker" Settings: "Debug"] -Options=-a -c -farheap0x20000 -f0x0 -heap0x2000 -m".\Debug\CppUTestExtRunAllTests.map" -o".\Debug\CppUTestExtRunAllTests1.out" -stack0x4000 --disable_auto_rts -w -l"rts2800_ml.lib" - diff --git a/platforms/CCStudio/CppUTestExtRunAllTests2.pjt b/platforms/CCStudio/CppUTestExtRunAllTests2.pjt deleted file mode 100644 index b9a40b195..000000000 --- a/platforms/CCStudio/CppUTestExtRunAllTests2.pjt +++ /dev/null @@ -1,67 +0,0 @@ -; Code Composer Project File, Version 2.0 (do not modify or remove this line) - -[Project Settings] -ProjectDir="C:\data\00_Dev\05_CppUTest\cpputest\platforms\CCStudio\" -ProjectType=Executable -CPUFamily=TMS320C28XX -Tool="Compiler" -Tool="CustomBuilder" -Tool="DspBiosBuilder" -Tool="Linker" -Config="Debug" - -[Source Files] -Source="..\..\src\CppUTest\CommandLineArguments.cpp" -Source="..\..\src\CppUTest\CommandLineTestRunner.cpp" -Source="..\..\src\CppUTest\JUnitTestOutput.cpp" -Source="..\..\src\CppUTest\MemoryLeakDetector.cpp" -Source="..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp" -Source="..\..\src\CppUTest\SimpleMutex.cpp" -Source="..\..\src\CppUTest\SimpleString.cpp" -Source="..\..\src\CppUTest\SimpleStringInternalCache.cpp" -Source="..\..\src\CppUTest\TeamCityTestOutput.cpp" -Source="..\..\src\CppUTest\TestFailure.cpp" -Source="..\..\src\CppUTest\TestFilter.cpp" -Source="..\..\src\CppUTest\TestHarness_c.cpp" -Source="..\..\src\CppUTest\TestMemoryAllocator.cpp" -Source="..\..\src\CppUTest\TestOutput.cpp" -Source="..\..\src\CppUTest\TestPlugin.cpp" -Source="..\..\src\CppUTest\TestRegistry.cpp" -Source="..\..\src\CppUTest\TestResult.cpp" -Source="..\..\src\CppUTest\TestTestingFixture.cpp" -Source="..\..\src\CppUTest\Utest.cpp" -Source="..\..\src\CppUTestExt\CodeMemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\GTest.cpp" -Source="..\..\src\CppUTestExt\MemoryReportAllocator.cpp" -Source="..\..\src\CppUTestExt\MemoryReporterPlugin.cpp" -Source="..\..\src\CppUTestExt\MemoryReportFormatter.cpp" -Source="..\..\src\CppUTestExt\MockActualCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCall.cpp" -Source="..\..\src\CppUTestExt\MockExpectedCallsList.cpp" -Source="..\..\src\CppUTestExt\MockFailure.cpp" -Source="..\..\src\CppUTestExt\MockNamedValue.cpp" -Source="..\..\src\CppUTestExt\MockSupport.cpp" -Source="..\..\src\CppUTestExt\MockSupport_c.cpp" -Source="..\..\src\CppUTestExt\MockSupportPlugin.cpp" -Source="..\..\src\CppUTestExt\OrderedTest.cpp" -Source="..\..\src\Platforms\C2000\UtestPlatform.cpp" -Source="..\..\tests\CppUTestExt\MemoryReporterPluginTest.cpp" -Source="..\..\tests\CppUTestExt\MockCallTest.cpp" -Source="..\..\tests\CppUTestExt\MockComparatorCopierTest.cpp" -Source="..\..\tests\CppUTestExt\MockFailureReporterForTest.cpp" -Source="..\..\tests\CppUTestExt\MockNamedValueTest.cpp" -Source="..\..\tests\CppUTestExt\MockParameterTest.cpp" -Source="..\..\tests\CppUTestExt\MockSupport_cTest.cpp" -Source="..\..\tests\CppUTestExt\MockSupport_cTestCFile.c" -Source="..\..\tests\CppUTestExt\OrderedTestTest.cpp" -Source="..\..\tests\CppUTestExt\OrderedTestTest_c.c" -Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp" -Source="tests\CppUTestExt\AllTestsForTarget.cpp" -Source="sim28335.cmd" - -["Compiler" Settings: "Debug"] -Options=-g -rtti -pdsw225 -pden -pds1 -fr"$(Proj_dir)\Debug" -i"$(Proj_dir)\..\..\include" -i"$(Proj_dir)\..\..\include\CppUTestExt\CppUTestGMock" -i"$(Proj_dir)\..\..\tests" -d"_DEBUG" -d"LARGE_MODEL" -d"CPPUTEST_STD_CPP_LIB_DISABLED" -d"CPPUTEST_USE_MEM_LEAK_DETECTION" -d"CPPUTEST_USE_MALLOC_MACROS" -ml -v28 --preinclude="$(Proj_dir)\..\..\include\Platforms\c2000\stdint.h" - -["Linker" Settings: "Debug"] -Options=-a -c -farheap0x20000 -f0x0 -heap0x2000 -m".\Debug\CppUTestExtRunAllTests.map" -o".\Debug\CppUTestExtRunAllTests2.out" -stack0x4000 --disable_auto_rts -w -l"rts2800_ml.lib" - diff --git a/platforms/CCStudio/CppUTestRunAllTests1.pjt b/platforms/CCStudio/CppUTestRunAllTests1.pjt deleted file mode 100644 index 9625021ee..000000000 --- a/platforms/CCStudio/CppUTestRunAllTests1.pjt +++ /dev/null @@ -1,62 +0,0 @@ -; Code Composer Project File, Version 2.0 (do not modify or remove this line) - -[Project Settings] -ProjectDir="C:\data\00_Dev\05_CppUTest\cpputest\platforms\CCStudio\" -ProjectType=Executable -CPUFamily=TMS320C28XX -Tool="Compiler" -Tool="CustomBuilder" -Tool="DspBiosBuilder" -Tool="Linker" -Config="Debug" - -[Source Files] -Source="..\..\src\CppUTest\CommandLineArguments.cpp" -Source="..\..\src\CppUTest\CommandLineTestRunner.cpp" -Source="..\..\src\CppUTest\JUnitTestOutput.cpp" -Source="..\..\src\CppUTest\MemoryLeakDetector.cpp" -Source="..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp" -Source="..\..\src\CppUTest\SimpleMutex.cpp" -Source="..\..\src\CppUTest\SimpleString.cpp" -Source="..\..\src\CppUTest\SimpleStringInternalCache.cpp" -Source="..\..\src\CppUTest\TeamCityTestOutput.cpp" -Source="..\..\src\CppUTest\TestFailure.cpp" -Source="..\..\src\CppUTest\TestFilter.cpp" -Source="..\..\src\CppUTest\TestHarness_c.cpp" -Source="..\..\src\CppUTest\TestMemoryAllocator.cpp" -Source="..\..\src\CppUTest\TestOutput.cpp" -Source="..\..\src\CppUTest\TestPlugin.cpp" -Source="..\..\src\CppUTest\TestRegistry.cpp" -Source="..\..\src\CppUTest\TestResult.cpp" -Source="..\..\src\CppUTest\TestTestingFixture.cpp" -Source="..\..\src\CppUTest\Utest.cpp" -Source="..\..\src\Platforms\C2000\UtestPlatform.cpp" -Source="..\..\tests\AllocationInCFile.c" -Source="..\..\tests\AllocationInCppFile.cpp" -Source="..\..\tests\AllocLetTestFree.c" -Source="..\..\tests\AllocLetTestFreeTest.cpp" -Source="..\..\tests\CheatSheetTest.cpp" -Source="..\..\tests\CompatabilityTests.cpp" -Source="..\..\tests\CommandLineArgumentsTest.cpp" -Source="..\..\tests\CommandLineTestRunnerTest.cpp" -Source="..\..\tests\JUnitOutputTest.cpp" -Source="..\..\tests\MemoryLeakDetectorTest.cpp" -Source="..\..\tests\MemoryLeakWarningTest.cpp" -Source="..\..\tests\MemoryOperatorOverloadTest.cpp" -Source="..\..\tests\PluginTest.cpp" -Source="..\..\tests\PreprocessorTest.cpp" -Source="..\..\tests\SetPluginTest.cpp" -Source="..\..\tests\TeamCityOutputTest.cpp" -Source="..\..\tests\TestFailureNaNTest.cpp" -Source="..\..\tests\TestFailureTest.cpp" -Source="..\..\tests\TestUTestStringMacro.cpp" -Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp" -Source="tests\CppUTest\AllTestsForTarget.cpp" -Source="sim28335.cmd" - -["Compiler" Settings: "Debug"] -Options=-g -rtti -pdsw225 -pden -pds1 -fr"$(Proj_dir)\Debug" -i"$(Proj_dir)\..\..\include" -i"$(Proj_dir)\..\..\tests" -d"_DEBUG" -d"LARGE_MODEL" -d"CPPUTEST_STD_CPP_LIB_DISABLED" -d"CPPUTEST_USE_MEM_LEAK_DETECTION" -ml -v28 --preinclude="$(Proj_dir)\..\..\include\Platforms\c2000\stdint.h" - -["Linker" Settings: "Debug"] -Options=-a -c -farheap0x020000 -f0x0 -heap0x2000 -m".\Debug\CppUTestRunAllTests1.map" -o".\Debug\CppUTestRunAllTests1.out" -stack0x4000 --disable_auto_rts -w -l"rts2800_ml.lib" - diff --git a/platforms/CCStudio/CppUTestRunAllTests2.pjt b/platforms/CCStudio/CppUTestRunAllTests2.pjt deleted file mode 100644 index 256969796..000000000 --- a/platforms/CCStudio/CppUTestRunAllTests2.pjt +++ /dev/null @@ -1,55 +0,0 @@ -; Code Composer Project File, Version 2.0 (do not modify or remove this line) - -[Project Settings] -ProjectDir="C:\data\00_Dev\05_CppUTest\cpputest\platforms\CCStudio\" -ProjectType=Executable -CPUFamily=TMS320C28XX -Tool="Compiler" -Tool="CustomBuilder" -Tool="DspBiosBuilder" -Tool="Linker" -Config="Debug" - -[Source Files] -Source="..\..\src\CppUTest\CommandLineArguments.cpp" -Source="..\..\src\CppUTest\CommandLineTestRunner.cpp" -Source="..\..\src\CppUTest\JUnitTestOutput.cpp" -Source="..\..\src\CppUTest\MemoryLeakDetector.cpp" -Source="..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp" -Source="..\..\src\CppUTest\SimpleMutex.cpp" -Source="..\..\src\CppUTest\SimpleString.cpp" -Source="..\..\src\CppUTest\SimpleStringInternalCache.cpp" -Source="..\..\src\CppUTest\TeamCityTestOutput.cpp" -Source="..\..\src\CppUTest\TestFailure.cpp" -Source="..\..\src\CppUTest\TestFilter.cpp" -Source="..\..\src\CppUTest\TestHarness_c.cpp" -Source="..\..\src\CppUTest\TestMemoryAllocator.cpp" -Source="..\..\src\CppUTest\TestOutput.cpp" -Source="..\..\src\CppUTest\TestPlugin.cpp" -Source="..\..\src\CppUTest\TestRegistry.cpp" -Source="..\..\src\CppUTest\TestResult.cpp" -Source="..\..\src\CppUTest\TestTestingFixture.cpp" -Source="..\..\src\CppUTest\Utest.cpp" -Source="..\..\src\CppUTestExt\MockSupportPlugin.cpp" -Source="..\..\src\Platforms\C2000\UtestPlatform.cpp" -Source="..\..\tests\SimpleStringCacheTest.cpp" -Source="..\..\tests\TestFilterTest.cpp" -Source="..\..\tests\TestHarness_cTest.cpp" -Source="..\..\tests\TestHarness_cTestCFile.c" -Source="..\..\tests\TestInstallerTest.cpp" -Source="..\..\tests\TestMemoryAllocatorTest.cpp" -Source="..\..\tests\TestOutputTest.cpp" -Source="..\..\tests\TestRegistryTest.cpp" -Source="..\..\tests\TestResultTest.cpp" -Source="..\..\tests\TestUTestMacro.cpp" -Source="..\..\tests\UtestTest.cpp" -Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp" -Source="tests\CppUTest\AllTestsForTarget.cpp" -Source="sim28335.cmd" - -["Compiler" Settings: "Debug"] -Options=-g -rtti -pdsw225 -pden -pds1 -fr"$(Proj_dir)\Debug" -i"$(Proj_dir)\..\..\include" -i"$(Proj_dir)\..\..\tests" -d"_DEBUG" -d"LARGE_MODEL" -d"CPPUTEST_STD_CPP_LIB_DISABLED" -d"CPPUTEST_USE_MEM_LEAK_DETECTION" -ml -v28 --preinclude="$(Proj_dir)\..\..\include\Platforms\c2000\stdint.h" - -["Linker" Settings: "Debug"] -Options=-a -c -farheap0x020000 -f0x0 -heap0x2000 -m".\Debug\CppUTestRunAllTests2.map" -o".\Debug\CppUTestRunAllTests2.out" -stack0x4000 --disable_auto_rts -w -l"rts2800_ml.lib" - diff --git a/platforms/CCStudio/sim28335.cmd b/platforms/CCStudio/sim28335.cmd deleted file mode 100644 index f18ee8ffb..000000000 --- a/platforms/CCStudio/sim28335.cmd +++ /dev/null @@ -1,43 +0,0 @@ -/************************************************************/ -/* Linker command file for simulator only */ -/************************************************************/ - -/* Contains only the bare necessities for running a unit test - * in the TI CCS 3.3 Simulator - */ - -MEMORY -{ -PAGE 0 : /* Program Memory */ - - /* Flash as one big segment */ - FLASH : origin = 0x300000, length = 0x040000 - -PAGE 1 : /* Data Memory */ - - /* Internal SARAM */ - RAM_0 : origin = 0x000000, length = 0x002000 - /* 0x2000 to 0x3FFF: Not defined */ - STACK : origin = 0x004000, length = 0x004000 /* stack needs own segment in low RAM */ - RAM_1 : origin = 0x008000, length = 0x008000 - - /* External memory */ - EMEM : origin = 0x100000, length = 0x030000 -} - -SECTIONS -{ - /* segment allocation */ - .cinit : > FLASH, PAGE = 0 /* initialized internal RAM-data */ - .pinit : > FLASH, PAGE = 0 /* initialized constructors */ - .stack : > STACK, PAGE = 1 - .text : > FLASH, PAGE = 0 - .bss : > RAM_0, PAGE = 1 - .ebss : > RAM_1, FILL = 0x0020, PAGE = 1 /* uninitialized external RAM-data */ - .econst : > FLASH, PAGE = 0 - .esysmem : > EMEM, PAGE = 1 /* not used if no malloc calls in code */ - .cio : > RAM_0, PAGE = 1 - - /* keep the linker from complaining */ - .reset : > FLASH, PAGE = 0, TYPE = DSECT /* not used */ -} diff --git a/platforms/CCStudio/sim28335.gel b/platforms/CCStudio/sim28335.gel deleted file mode 100644 index ddfcb9436..000000000 --- a/platforms/CCStudio/sim28335.gel +++ /dev/null @@ -1,247 +0,0 @@ -/********************************************************************/ -/* f28335.gel */ -/* Version 4.00.2 */ -/* */ -/* This GEL file is to be used with the TMS320F28335 DSP. */ -/* Changes may be required to support specific hardware designs. */ -/* */ -/* Code Composer Studio supports six reserved GEL functions that */ -/* automatically get executed if they are defined. They are: */ -/* */ -/* StartUp() - Executed whenever CCS is invoked */ -/* OnReset() - Executed after Debug->Reset CPU */ -/* OnRestart() - Executed after Debug->Restart */ -/* OnPreFileLoaded() - Executed before File->Load Program */ -/* OnFileLoaded() - Executed after File->Load Program */ -/* OnTargetConnect() - Executed after Debug->Connect */ -/* */ -/********************************************************************/ - -StartUp() -{ - /* The next line automatically loads the .gel file that comes */ - /* with the DSP2833x Peripheral Header Files download. To use, */ - /* uncomment, and copy the peripheral header .gel file to */ - /* same directory as device .gel file. */ - // GEL_LoadGel("$(GEL_file_dir)\\DSP2833x_Peripheral.gel"); -} - -OnReset(int nErrorCode) -{ - C28x_Mode(); - XINTF_Enable(); -} - -OnRestart(int nErrorCode) -{ -/* CCS will call OnRestart() when you do a Debug->Restart and */ -/* after you load a new file. Between running interrupt based */ -/* programs, this function will clear interrupts and help keep */ -/* the processor from going off into invalid memory. */ - C28x_Mode(); - IER = 0; - IFR = 0; -} - -OnPreFileLoaded() -{ - C28x_Mode(); - XINTF_Enable(); - GEL_Reset(); -} - -OnFileLoaded(int nErrorCode, int bSymbolsOnly) -{ -} - -OnTargetConnect() -{ - C28335_Memory_Map(); /* Initialize the CCS memory map */ - - /* Check to see if CCS has been started-up with the DSP already */ - /* running in real-time mode. The user can add whatever */ - /* custom initialization stuff they want to each case. */ - - if (GEL_IsInRealtimeMode()) /* Do real-time mode target initialization */ - { - // Note: This case never executes with the simulator - } - else /* Do stop-mode target initialization */ - { - // Note: This case always executes with the simulator - } -} - - -/********************************************************************/ -/* F28335 Memory Map */ -/* */ -/* Note: M0M1MAP and VMAP signals tied high on F28335 core */ -/* */ -/* 0x000000 - 0x0003ff M0 SARAM (Prog and Data) */ -/* 0x000400 - 0x0007ff M1 SARAM (Prog and Data) */ -/* 0x000800 - 0x001fff Peripheral Frame0 (PF0) (Data only) */ -/* 0x004000 - 0x004fff XINTF Zone 0 (Prog and Data) */ -/* 0x005000 - 0x005fff Peripheral Frame3 (PF3) (Data only) */ -/* 0x006000 - 0x006fff Peripheral Frame1 (PF1) (Data only) */ -/* 0x007000 - 0x007fff Peripheral Frame2 (PF2) (Data only) */ -/* 0x008000 - 0x008fff L0 SARAM (Prog and Data) */ -/* 0x009000 - 0x009fff L1 SARAM (Prog and Data) */ -/* 0x00A000 - 0x00Afff L2 SARAM (Prog and Data) */ -/* 0x00B000 - 0x00Bfff L3 SARAM (Prog and Data) */ -/* 0x00C000 - 0x00Cfff L4 SARAM (Prog and Data) */ -/* 0x00D000 - 0x00Dfff L5 SARAM (Prog and Data) */ -/* 0x00E000 - 0x00Efff L6 SARAM (Prog and Data) */ -/* 0x00F000 - 0x00Ffff L7 SARAM (Prog and Data) */ -/* 0x100000 - 0x1fffff XINTF Zone 6 (Prog and Data) */ -/* 0x200000 - 0x2fffff XINTF Zone 7 (Prog and Data */ -/* 0x300000 - 0x33ffff Flash (Prog and Data) */ -/* 0x380080 - 0x380088 ADC_cal function (Prog and Data) */ -/* 0x380090 - 0x380090 PARTID value (Prog and Data) */ -/* 0x380400 - 0x3807ff OTP (Prog and Data) */ -/* 0x3f8000 - 0x3f8fff L0 SARAM (Prog and Data) */ -/* 0x3f9000 - 0x3f9fff L1 SARAM (Prog and Data) */ -/* 0x3fA000 - 0x3fAfff L2 SARAM (Prog and Data) */ -/* 0x3fB000 - 0x3fBfff L3 SARAM (Prog and Data) */ -/* 0x3fe000 - 0x3fffff BOOT ROM (Prog and Data) */ -/********************************************************************/ -menuitem "Initialize Memory Map"; - -hotmenu Memory_Map_Off() -{ - GEL_MapReset(); - GEL_MapOff(); -} - -hotmenu C28335_Memory_Map() -{ - GEL_MapReset(); - GEL_MapOn(); - - /* Program memory map */ - GEL_MapAdd(0x000,0,0x400,1,1); /* M0 SARAM */ - GEL_MapAdd(0x400,0,0x400,1,1); /* M1 SARAM */ - GEL_MapAdd(0x4000,0,0x1000,1,1); /* Zone 0 */ - GEL_MapAdd(0x8000,0,0x1000,1,1); /* L0 SARAM */ - GEL_MapAdd(0x9000,0,0x1000,1,1); /* L1 SARAM */ - GEL_MapAdd(0xA000,0,0x1000,1,1); /* L2 SARAM */ - GEL_MapAdd(0xB000,0,0x1000,1,1); /* L3 SARAM */ - GEL_MapAdd(0xC000,0,0x1000,1,1); /* L4 SARAM */ - GEL_MapAdd(0xD000,0,0x1000,1,1); /* L5 SARAM */ - GEL_MapAdd(0xE000,0,0x1000,1,1); /* L6 SARAM */ - GEL_MapAdd(0xF000,0,0x1000,1,1); /* L7 SARAM */ - GEL_MapAdd(0x100000,0,0x100000,1,1); /* Zone 6 */ - GEL_MapAdd(0x200000,0,0x100000,1,1); /* Zone 7 */ - GEL_MapAdd(0x300000,0,0x40000,1,1); /* FLASH */ - GEL_MapAdd(0x380080,0,0x00009,1,0); /* ADC_cal function*/ - GEL_MapAdd(0x380090,0,0x00001,1,0); /* PARTID value */ - GEL_MapAdd(0x380400,0,0x00400,1,0); /* OTP */ - GEL_MapAdd(0x3f8000,0,0x1000,1,1); /* L0 SARAM Mirror */ - GEL_MapAdd(0x3f9000,0,0x1000,1,1); /* L1 SARAM Mirror */ - GEL_MapAdd(0x3fA000,0,0x1000,1,1); /* L2 SARAM Mirror */ - GEL_MapAdd(0x3fb000,0,0x1000,1,1); /* L3 SARAM Mirror */ - GEL_MapAdd(0x3fe000,0,0x2000,1,0); /* BOOT ROM */ - - /* Data memory map */ - GEL_MapAdd(0x000,1,0x400,1,1); /* M0 SARAM */ - GEL_MapAdd(0x400,1,0x400,1,1); /* M1 SARAM */ - GEL_MapAdd(0x800,1,0x1800,1,1); /* PF0 */ - GEL_MapAdd(0x4000,1,0x1000,1,1); /* Zone 0 */ - GEL_MapAdd(0x5000,1,0x1000,1,1); /* PF3 */ - GEL_MapAdd(0x6000,1,0x1000,1,1); /* PF1 */ - GEL_MapAddStr(0x7000,1,0x1000,"R|W|AS2",0); /* PF2 */ - GEL_MapAdd(0x8000,1,0x1000,1,1); /* L0 SARAM */ - GEL_MapAdd(0x9000,1,0x1000,1,1); /* L1 SARAM */ - GEL_MapAdd(0xA000,1,0x1000,1,1); /* L2 SARAM */ - GEL_MapAdd(0xB000,1,0x1000,1,1); /* L3 SARAM */ - GEL_MapAdd(0xC000,1,0x1000,1,1); /* L4 SARAM */ - GEL_MapAdd(0xD000,1,0x1000,1,1); /* L5 SARAM */ - GEL_MapAdd(0xE000,1,0x1000,1,1); /* L6 SARAM */ - GEL_MapAdd(0xF000,1,0x1000,1,1); /* L7 SARAM */ - GEL_MapAdd(0x100000,1,0x100000,1,1); /* Zone 6 */ - GEL_MapAdd(0x200000,1,0x100000,1,1); /* Zone 7 */ - GEL_MapAdd(0x300000,1,0x40000,1,0); /* FLASH */ - GEL_MapAdd(0x380400,1,0x00400,1,0); /* OTP */ - GEL_MapAdd(0x380080,1,0x00009,1,0); /* ADC_cal function*/ - GEL_MapAdd(0x380090,1,0x00001,1,0); /* PARTID value */ - GEL_MapAdd(0x3f8000,1,0x1000,1,1); /* L0 SARAM Mirror */ - GEL_MapAdd(0x3f9000,1,0x1000,1,1); /* L1 SARAM Mirror */ - GEL_MapAdd(0x3fA000,1,0x1000,1,1); /* L2 SARAM Mirror */ - GEL_MapAdd(0x3fb000,1,0x1000,1,1); /* L3 SARAM Mirror */ - GEL_MapAdd(0x3fe000,1,0x2000,1,0); /* BOOT ROM */ -} - -/********************************************************************/ -menuitem "Addressing Modes"; - -hotmenu C28x_Mode() -{ - ST1 = ST1 & (~0x0100); /* AMODE = 0 */ - ST1 = ST1 | 0x0200; /* OBJMODE = 1 */ -} - -hotmenu C24x_Mode() -{ - ST1 = ST1 | 0x0100; /* AMODE = 1 */ - ST1 = ST1 | 0x0200; /* OBJMODE = 1 */ -} - -hotmenu C27x_Mode() -{ - ST1 = ST1 & (~0x0100); /* AMODE = 0 */ - ST1 = ST1 & (~0x0200); /* OBJMODE = 0 */ -} - -/********************************************************************/ -/* Enable the XINTF and configure GPIOs for XINTF function */ -/********************************************************************/ -int TxtOutCtl=0; -menuitem "XINTF Enable" -hotmenu XINTF_Enable() -{ - - if (TxtOutCtl==0) - { - GEL_TextOut("\nNOTES:\nTo configure the XINTF automatically on reset:\n uncomment the XINTF_Enable call in the OnReset function of the GEL file."); - GEL_TextOut("\nNOTES:\nGel will enable XINTFx16 during Debug only.\nEnable XINTF in code prior to use."); - TxtOutCtl=1; - } - - /* enable XINTF clock (XTIMCLK) */ - - *0x7020 = 0x3700; - /* GPBMUX1: XA0-XA7, XA16, XZCS0, */ - /* XZCS7, XREADY, XRNW, XWE0 */ - /* GPAMUX2: XA17-XA19, XZCS6 */ - /* GPCMUX2: XA8-XA15 */ - /* GPCMUX1: XD0-XD15 */ - *(unsigned long *)0x6F96 = 0xFFFFFFC0; /* GPBMUX1 */ - *(unsigned long *)0x6f88 = 0xFF000000; /* GPAMUX2 */ - *(unsigned long *)0x6FA8 = 0x0000AAAA; /* GPCMUX2 */ - *(unsigned long *)0x6FA6 = 0xAAAAAAAA; /* GPCMUX1 */ - - /* Uncomment for x32 data bus */ - /* GPBMUX2: XD16-XD31 */ -// *(unsigned long *)0x6F98 = 0xFFFFFFFF; /* GPBMUX2 */ - - /* Zone timing. - /* Each zone can be configured seperately */ - /* Uncomment the x16 or the x32 timing */ - /* depending on the data bus width for */ - /* the zone */ - - /* x16 Timing */ - *(unsigned long *)0x0B20 = 0x0043FFFF; /* Zone0 */ - *(unsigned long *)0x0B2C = 0x0043FFFF; /* Zone6 */ - *(unsigned long *)0x0B2E = 0x0043FFFF; /* Zone7 */ - - /* x32 Timing: -// *(unsigned long *)0x0B20 = 0x0041FFFF; /* x32 */ -// *(unsigned long *)0x0B2C = 0x0041FFFF; /* x32 */ -// *(unsigned long *)0x0B2E = 0x0041FFFF; /* x32 */ - - -} - -/********************************************************************/ -/*** End of file ***/ diff --git a/platforms/CCStudio/sim2833x.cfg b/platforms/CCStudio/sim2833x.cfg deleted file mode 100644 index 9c9f536be..000000000 --- a/platforms/CCStudio/sim2833x.cfg +++ /dev/null @@ -1,411 +0,0 @@ -/////////////////////////////////////////////////////////// -// Initialize default F2833x memory map as defined by // -// the MEMRSn signal. For F2833x, M0M1MAP=1 and VMAP=1. // -/////////////////////////////////////////////////////////// -module F2833x_memory; - -/////////////////////////////////////////////////////////// -// M0 SARAM, shared prog and data space // -/////////////////////////////////////////////////////////// -memory M0_prog_mem; - first 0x000000; - last 0x0003FF; - space prog; - waitstates 0; - type saram; - shared M0_data_mem; -end M0_prog_mem; - -memory M0_data_mem; - first 0x000000; - last 0x0003FF; - space data; - waitstates 0; - type saram; -end M0_data_mem; - -/////////////////////////////////////////////////////////// -// M1 SARAM, shared prog and data space // -/////////////////////////////////////////////////////////// -memory M1_prog_mem; - first 0x000400; - last 0x0007FF; - space prog; - waitstates 0; - type saram; - shared M1_data_mem; -end M1_prog_mem; - -memory M1_data_mem; - first 0x000400; - last 0x0007FF; - space data; - waitstates 0; - type saram; -end M1_data_mem; - -/////////////////////////////////////////////////////////// -// PF0A, data space only // -/////////////////////////////////////////////////////////// -memory PF0A_data_mem; - first 0x000800; - last 0x000CFF; - space data; - waitstates 1; - type saram; -end PF0A_data_mem; - -/////////////////////////////////////////////////////////// -// PIE Vector Table // -/////////////////////////////////////////////////////////// -memory PIE_vectors; - first 0x000D00; - last 0x000DFF; - space data; - waitstates 0; - type saram; -end PIE_vectors; - -/////////////////////////////////////////////////////////// -// PF0B, data space only // -/////////////////////////////////////////////////////////// -memory PF0B_data_mem; - first 0x000E00; - last 0x001FFF; - space data; - waitstates 1; - type saram; -end PF0B_data_mem; - -/////////////////////////////////////////////////////////// -// PF3, data space only // -/////////////////////////////////////////////////////////// -memory PF3_data_mem; - first 0x005000; - last 0x005FFF; - space data; - waitstates 2; - type saram; -end PF3_data_mem; - -////////////////////////////////////////////////////////// -// VBUS32 data space (PF1) // -// 0x6000 - 0x6FFF // -////////////////////////////////////////////////////////// -memory vbus32_data_mem; - read_waitstates 2; - write_waitstates 0; - type vbus32; -end vbus32_data_mem; - -////////////////////////////////////////////////////////// -// VBUS16 data space (PF2) // -// 0x7000 - 0x7FFF // -////////////////////////////////////////////////////////// -memory vbus16_data_mem; - read_waitstates 2; - write_waitstates 0; - type vbus16; -end vbus16_data_mem; - -////////////////////////////////////////////////////////// -// XINTF ZONE 0, shared prog and data space // -////////////////////////////////////////////////////////// -memory XINTF0_prog_mem; - first 0x004000; - last 0x004FFF; - space prog; - waitstates 7; - type saram; - shared XINTF0_data_mem; -end XINTF0_prog_mem; - -memory XINTF0_data_mem; - first 0x004000; - last 0x004FFF; - space data; - waitstates 7; - type saram; -end XINTF0_data_mem; - -////////////////////////////////////////////////////////// -// L0 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L0_prog_mem; - first 0x008000; - last 0x008FFF; - space prog; - waitstates 0; - type saram; - shared L0_data_mem; -end L0_prog_mem; - -memory L0_data_mem; - first 0x008000; - last 0x008FFF; - space data; - waitstates 0; - type saram; -end L0_data_mem; - -////////////////////////////////////////////////////////// -// L1 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L1_prog_mem; - first 0x009000; - last 0x009FFF; - space prog; - waitstates 0; - type saram; - shared L1_data_mem; -end L1_prog_mem; - -memory L1_data_mem; - first 0x009000; - last 0x009FFF; - space data; - waitstates 0; - type saram; -end L1_data_mem; - -////////////////////////////////////////////////////////// -// L2 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L2_prog_mem; - first 0x00A000; - last 0x00AFFF; - space prog; - waitstates 0; - type saram; - shared L2_data_mem; -end L2_prog_mem; - -memory L2_data_mem; - first 0x00A000; - last 0x00AFFF; - space data; - waitstates 0; - type saram; -end L2_data_mem; - -////////////////////////////////////////////////////////// -// L3 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L3_prog_mem; - first 0x00B000; - last 0x00BFFF; - space prog; - waitstates 0; - type saram; - shared L3_data_mem; -end L3_prog_mem; - -memory L3_data_mem; - first 0x00B000; - last 0x00BFFF; - space data; - waitstates 0; - type saram; -end L3_data_mem; - -////////////////////////////////////////////////////////// -// L4 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L4_prog_mem; - first 0x00C000; - last 0x00CFFF; - space prog; - waitstates 0; - type saram; - shared L4_data_mem; -end L4_prog_mem; - -memory L4_data_mem; - first 0x00C000; - last 0x00CFFF; - space data; - waitstates 0; - type saram; -end L4_data_mem; - -////////////////////////////////////////////////////////// -// L5 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L5_prog_mem; - first 0x00D000; - last 0x00DFFF; - space prog; - waitstates 0; - type saram; - shared L5_data_mem; -end L5_prog_mem; - -memory L5_data_mem; - first 0x00D000; - last 0x00DFFF; - space data; - waitstates 0; - type saram; -end L5_data_mem; - -////////////////////////////////////////////////////////// -// L6 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L6_prog_mem; - first 0x00E000; - last 0x00EFFF; - space prog; - waitstates 1; - type saram; - shared L6_data_mem; -end L6_prog_mem; - -memory L6_data_mem; - first 0x00E000; - last 0x00EFFF; - space data; - waitstates 1; - type saram; -end L6_data_mem; - -////////////////////////////////////////////////////////// -// L7 SARAM, shared prog and data space // -////////////////////////////////////////////////////////// -memory L7_prog_mem; - first 0x00F000; - last 0x00FFFF; - space prog; - waitstates 1; - type saram; - shared L7_data_mem; -end L7_prog_mem; - -memory L7_data_mem; - first 0x00F000; - last 0x00FFFF; - space data; - waitstates 1; - type saram; -end L7_data_mem; - -////////////////////////////////////////////////////////// -// XINTF ZONE 6, shared prog and data space // -////////////////////////////////////////////////////////// -memory XINTF6_prog_mem; - first 0x100000; - last 0x1FFFFF; - space prog; - waitstates 7; - type saram; - shared XINTF6_data_mem; -end XINTF6_prog_mem; - -memory XINTF6_data_mem; - first 0x100000; - last 0x1FFFFF; - space data; - waitstates 7; - type saram; -end XINTF6_data_mem; - -////////////////////////////////////////////////////////// -// XINTF ZONE 7, shared prog and data space // -////////////////////////////////////////////////////////// -memory XINTF7_prog_mem; - first 0x200000; - last 0x2FFFFF; - space prog; - waitstates 7; - type saram; - shared XINTF7_data_mem; -end XINTF7_prog_mem; - -memory XINTF7_data_mem; - first 0x200000; - last 0x2FFFFF; - space data; - waitstates 7; - type saram; -end XINTF7_data_mem; - -////////////////////////////////////////////////////////// -// FLASH, shared prog and data space // -////////////////////////////////////////////////////////// -memory FLASH_prog_mem; - first 0x300000; - last 0x33FFF7; - space prog; - waitstates 5; - type flash; - shared FLASH_data_mem; -end FLASH_prog_mem; - -memory FLASH_data_mem; - first 0x300000; - last 0x33FFF7; - space data; - waitstates 5; - type flash; -end FLASH_data_mem; - -////////////////////////////////////////////////////////// -// PASSWORDS, shared prog and data space // -////////////////////////////////////////////////////////// -memory PASSWORDS_prog_mem; - first 0x33FFF8; - last 0x33FFFF; - space prog; - waitstates 16; - type flash; - shared PASSWORDS_data_mem; -end PASSWORDS_prog_mem; - -memory PASSWORDS_data_mem; - first 0x33FFF8; - last 0x33FFFF; - space data; - waitstates 16; - type flash; -end PASSWORDS_data_mem; - -////////////////////////////////////////////////////////// -// OTP, shared prog and data space // -////////////////////////////////////////////////////////// -memory OTP_prog_mem; - first 0x380400; - last 0x3807FF; - space prog; - waitstates 8; - type flash; - shared OTP_data_mem; -end OTP_prog_mem; - -memory OTP_data_mem; - first 0x380400; - last 0x3807FF; - space data; - waitstates 8; - type flash; -end OTP_data_mem; - -////////////////////////////////////////////////////////// -// BOOT ROM, shared prog and data space // -////////////////////////////////////////////////////////// -memory BOOT_prog_mem; - first 0x3FE000; - last 0x3FFFFF; - space prog; - waitstates 1; - type rom; - shared BOOT_data_mem; -end BOOT_prog_mem; - -memory BOOT_data_mem; - first 0x3FE000; - last 0x3FFFFF; - space data; - waitstates 1; - type rom; -end BOOT_data_mem; - -end F2833x_memory; diff --git a/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp b/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp deleted file mode 100644 index 1c977dbde..000000000 --- a/platforms/CCStudio/tests/CppUTest/AllTestsForTarget.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2013, Michael Feathers, James Grenning, Bas Vodde - * and Arnd Strube - * 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, char** av) -{ - /* Specify commandline arguments here as needed */ - char* argv[] = - { - (char*) 0, - (char*) "-v", -// (char*) "-gSimpleStringBuffer", -// (char*) "-ojunit", - }; - - ac = sizeof(argv) / sizeof(char*); - - /* These checks are here to make sure assertions outside test runs don't crash */ - CHECK(true); - LONGS_EQUAL(1, 1); - - return CommandLineTestRunner::RunAllTests(ac, argv); -} - diff --git a/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp b/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp deleted file mode 100644 index d55800a2d..000000000 --- a/platforms/CCStudio/tests/CppUTestExt/AllTestsForTarget.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2013, Michael Feathers, James Grenning, Bas Vodde - * and Arnd Strube - * 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" - -int main(int ac, char** av) -{ - /* Specify commandline arguments here as needed */ - char* argv[] = - { - (char*) 0, - (char*) "-v", -// (char*) "-gSimpleStringBuffer", -// (char*) "-ojunit", - }; - - ac = sizeof(argv) / sizeof(char*); - - MemoryReporterPlugin plugin; - MockSupportPlugin mockPlugin; - TestRegistry::getCurrentRegistry()->installPlugin(&plugin); - TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin); - return CommandLineTestRunner::RunAllTests(ac, argv); -} - diff --git a/platforms/Dos/.gitignore b/platforms/Dos/.gitignore deleted file mode 100644 index e37978cfb..000000000 --- a/platforms/Dos/.gitignore +++ /dev/null @@ -1 +0,0 @@ -platform.mk diff --git a/platforms/Dos/ALLTESTS.BAT b/platforms/Dos/ALLTESTS.BAT deleted file mode 100644 index 25bf9dfee..000000000 --- a/platforms/Dos/ALLTESTS.BAT +++ /dev/null @@ -1,16 +0,0 @@ -REM Run all tests on Windows systems -@echo off -set log=%~n0.LOG & shift & set args=%* -if exist %log% del %log% -echo.>exit -for %%a in (*.EXE) do call :run %%a -echo. & type %log% -echo. & echo Done. -exit/b - -:run - echo Running %1 inside DOSBox... - echo *** %1 (%~z1 bytes) *********************>>%log% - DOSBox.exe -conf ..\platforms\Dos\dosbox-0.74.conf exit ^ - -c "%1 %args%>>%log%" -noconsole -exit -exit/b diff --git a/platforms/Dos/Makefile b/platforms/Dos/Makefile deleted file mode 100644 index 7b19cafa4..000000000 --- a/platforms/Dos/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -CXX := wcl -CC := wcl -AR := wlib -LINK := wlink -LOG := ALLTESTS.LOG -NULL := -space := $(NULL) # -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 - -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,$(WATCOM)/h) -i$(call convert_paths,$(WATCOM)/h/nt) \ - -# 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 - -all: CPPU.LIB CPPUX.LIB \ - CPPU1.EXE CPPU2.EXE CPPU3.EXE CPPU4.EXE CPPU5.EXE CPPU6.EXE CPPU7.EXE CPPU8.EXE \ - CPPUX1.EXE CPPUX2.EXE CPPUX3.EXE CPPUX4.EXE CPPUX5.EXE CPPUX6.EXE CPPUX7.EXE CPPUX8.EXE CPPUX9.EXE - -clean: - rm -rf ../src/CppUTest/*.o ../src/CppUTestExt/*.o \ - ../src/Platforms/dos/*.o ../tests/*.o ../tests/CppUTestExt/*.o \ - *.o *.map *.LOG *.EXE *.err *.LIB *.LST - -%.o: %.cpp - $(CXX) $(CXXFLAGS) -fo=$(call convert_paths,$@) $(call convert_paths,$<) - -%.o: %.c - $(CC) $(CFLAGS) -fo=$(call convert_paths,$@) $(call convert_paths,$<) - -.SECONDEXPANSION: - -%.LIB: $$($$*_OBJECTS) - $(AR) -q -lCPPU.LST $@ $(addprefix +,$(call convert_paths,$?)) - -%.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/README.txt b/platforms/Dos/README.txt deleted file mode 100644 index 66825b6c0..000000000 --- a/platforms/Dos/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -To compile on your Windows PC (or other platform), please create -a file called "platform.mk" in this directory. - -### Example platform.mk for use with Cygwin on Windows XP -WATCOM := d:\\bin\\watcom -CPPUTEST_HOME := /d/dev/05_CppUTest/cpputest -DOSBOX := DOSBox -CYGDRIVE:= /d/ -path_separator := \\ - -### Another example platform.mk for use with Cygwin on Windows 7 -WATCOM := d:\watcom -CPPUTEST_HOME := /cygdrive/c/data/00_Dev/05_CppUTest/cpputest -INCLUDE := c:\data\00_Dev\05_CppUTest\cpputest\include -DOSBOX := DOSBox -CYGDRIVE:= /cygdrive/d/ -path_separator := \\ - -### platform.mk for use with Cygwin 2.5.0 on Windows 7 -WATCOM := d:\watcom -CPPUTEST_HOME := c:\\data\\00_Dev\\05_CppUTest\\cpputest -INCLUDE := c:\data\00_Dev\05_CppUTest\cpputest\include -DOSBOX := DOSBox -CYGDRIVE:= /cygdrive/d/ -path_separator := \\ diff --git a/platforms/Dos/alltests.sh b/platforms/Dos/alltests.sh deleted file mode 100755 index 9c54b3e0b..000000000 --- a/platforms/Dos/alltests.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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" - exit 1 - fi - if [ ! -d "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set to a directory. You must set CPPUTEST_HOME to the top level CppUTest directory" - exit 2 - fi -} - -checkForCppUTestToolsEnvVariable - -printf "" > exit # so dosbox will run 'external' command 'exit' correctly -printf "" >ALLTESTS.LOG -for test in `ls *.EXE`; do - kb=`ls -lsk ${test} | awk '{print $1}'` - printf "Running ${test} (${kb}k) inside DOSBox...\n" - dosbox -conf $CPPUTEST_HOME/platforms/Dos/dosbox-0.74.conf exit \ - -c "echo *** ${test} (${kb}k) *****************************>>ALLTESTS.LOG" \ - -c "${test}>>ALLTESTS.LOG" \ - -noconsole -exit 1>console_output 2>dosbox_error.log || { printf "error running command!\n"; cat dosbox_error.log; exit 1; } -done -printf "\n" -[ "`cat ALLTESTS.LOG`" ] || { printf "No tests to run!\n"; exit 1; } -[ "`cat ALLTESTS.LOG|grep checks`" ] || { printf "No test output!\n"; exit 1; } -cat ALLTESTS.LOG -[ -z "`cat ALLTESTS.LOG|grep Failure`" ] || { printf "Failed tests!\n"; exit 1; } diff --git a/platforms/Dos/dosbox-0.74.conf b/platforms/Dos/dosbox-0.74.conf deleted file mode 100644 index 3846a0ece..000000000 --- a/platforms/Dos/dosbox-0.74.conf +++ /dev/null @@ -1,240 +0,0 @@ -# This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox) -# Lines starting with a # are commentlines and are ignored by DOSBox. -# They are used to (briefly) document the effect of each option. - -[sdl] -# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back) -# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox. -# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768). -# Using your monitor's native resolution with aspect=true might give the best results. -# If you end up with small window on a large screen, try an output different from surface. -# windowresolution: Scale the window to this size IF the output device supports hardware scaling. -# (output=surface does not!) -# output: What video system to use for output. -# Possible values: surface, overlay, opengl, openglnb. -# autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock) -# sensitivity: Mouse sensitivity. -# waitonerror: Wait before closing the console if dosbox has an error. -# priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized. -# pause is only valid for the second entry. -# Possible values: lowest, lower, normal, higher, highest, pause. -# mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value. -# usescancodes: Avoid usage of symkeys, might not work on all operating systems. - -fullscreen=false -fulldouble=false -fullresolution=1366x768 -windowresulultion=900x675 -output=surface -autolock=false -sensitivity=50 -waitonerror=true -priority=higher,normal -mapperfile=mapper-0.74.map -usescancodes=true - -[dosbox] -# language: Select another language file. -# machine: The type of machine tries to emulate. -# Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe. -# captures: Directory where things like wave, midi, screenshot get captured. -# memsize: Amount of memory DOSBox has in megabytes. -# This value is best left at its default to avoid problems with some games, -# though few games might require a higher value. -# There is generally no speed advantage when raising this value. - -language= -machine=svga_s3 -captures=capture -memsize=16 - -[render] -# frameskip: How many frames DOSBox skips before drawing one. -# aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!. -# scaler: Scaler used to enlarge/enhance low resolution modes. -# If 'forced' is appended, then the scaler will be used even if the result might not be desired. -# Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x. - -frameskip=0 -aspect=false -scaler=normal2x - -[cpu] -# core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate. -# Possible values: auto, dynamic, normal, simple. -# cputype: CPU Type used in emulation. auto is the fastest choice. -# Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch. -# cycles: Amount of instructions DOSBox tries to emulate each millisecond. -# Setting this value too high results in sound dropouts and lags. -# Cycles can be set in 3 ways: -# 'auto' tries to guess what a game needs. -# It usually works, but can fail for certain games. -# 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails. -# (Example: fixed 4000). -# 'max' will allocate as much cycles as your computer is able to handle. -# -# Possible values: auto, fixed, max. -# cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12) -# cycledown: Setting it lower than 100 will be a percentage. - -core=auto -cputype=auto -cycles=max -cycleup=10 -cycledown=20 - -[mixer] -# nosound: Enable silent mode, sound is still emulated though. -# rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality. -# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. -# blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged. -# Possible values: 1024, 2048, 4096, 8192, 512, 256. -# prebuffer: How many milliseconds of data to keep on top of the blocksize. - -nosound=true -rate=44100 -blocksize=1024 -prebuffer=20 - -[midi] -# mpu401: Type of MPU-401 to emulate. -# Possible values: intelligent, uart, none. -# mididevice: Device that will receive the MIDI data from MPU-401. -# Possible values: default, win32, alsa, oss, coreaudio, coremidi, none. -# midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use. -# See the README/Manual for more details. - -mpu401=none -mididevice=none -midiconfig= - -[sblaster] -# sbtype: Type of Soundblaster to emulate. gb is Gameblaster. -# Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none. -# sbbase: The IO address of the soundblaster. -# Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300. -# irq: The IRQ number of the soundblaster. -# Possible values: 7, 5, 3, 9, 10, 11, 12. -# dma: The DMA number of the soundblaster. -# Possible values: 1, 5, 0, 3, 6, 7. -# hdma: The High DMA number of the soundblaster. -# Possible values: 1, 5, 0, 3, 6, 7. -# sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer. -# oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'. -# Possible values: auto, cms, opl2, dualopl2, opl3, none. -# oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well). -# Possible values: default, compat, fast. -# oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly). -# Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000. - -sbtype=none -sbbase=220 -irq=7 -dma=1 -hdma=5 -sbmixer=false -oplmode=none -oplemu=default -oplrate=44100 - -[gus] -# gus: Enable the Gravis Ultrasound emulation. -# gusrate: Sample rate of Ultrasound emulation. -# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. -# gusbase: The IO base address of the Gravis Ultrasound. -# Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300. -# gusirq: The IRQ number of the Gravis Ultrasound. -# Possible values: 5, 3, 7, 9, 10, 11, 12. -# gusdma: The DMA channel of the Gravis Ultrasound. -# Possible values: 3, 0, 1, 5, 6, 7. -# ultradir: Path to Ultrasound directory. In this directory -# there should be a MIDI directory that contains -# the patch files for GUS playback. Patch sets used -# with Timidity should work fine. - -gus=false -gusrate=44100 -gusbase=240 -gusirq=5 -gusdma=3 -ultradir=~ - -[speaker] -# pcspeaker: Enable PC-Speaker emulation. -# pcrate: Sample rate of the PC-Speaker sound generation. -# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. -# tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'. -# Possible values: auto, on, off. -# tandyrate: Sample rate of the Tandy 3-Voice generation. -# Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. -# disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible). - -pcspeaker=false -pcrate=44100 -tandy=auto -tandyrate=44100 -disney=false - -[joystick] -# joysticktype: Type of joystick to emulate: auto (default), none, -# 2axis (supports two joysticks), -# 4axis (supports one joystick, first joystick used), -# 4axis_2 (supports one joystick, second joystick used), -# fcs (Thrustmaster), ch (CH Flightstick). -# none disables joystick emulation. -# auto chooses emulation depending on real joystick(s). -# (Remember to reset dosbox's mapperfile if you saved it earlier) -# Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none. -# timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away). -# autofire: continuously fires as long as you keep the button pressed. -# swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks. -# buttonwrap: enable button wrapping at the number of emulated buttons. - -joysticktype=none - -[serial] -# serial1: set type of device connected to com port. -# Can be disabled, dummy, modem, nullmodem, directserial. -# Additional parameters must be in the same line in the form of -# parameter:value. Parameter for all types is irq (optional). -# for directserial: realport (required), rxdelay (optional). -# (realport:COM1 realport:ttyS0). -# for modem: listenport (optional). -# for nullmodem: server, rxdelay, txdelay, telnet, usedtr, -# transparent, port, inhsocket (all optional). -# Example: serial1=modem listenport:5000 -# Possible values: dummy, disabled, modem, nullmodem, directserial. -# serial2: see serial1 -# Possible values: dummy, disabled, modem, nullmodem, directserial. -# serial3: see serial1 -# Possible values: dummy, disabled, modem, nullmodem, directserial. -# serial4: see serial1 -# Possible values: dummy, disabled, modem, nullmodem, directserial. - -serial1=dummy -serial2=dummy -serial3=disabled -serial4=disabled - -[dos] -# xms: Enable XMS support. -# ems: Enable EMS support. -# umb: Enable UMB support. -# keyboardlayout: Language code of the keyboard layout (or none). - -xms=true -ems=true -umb=true -keyboardlayout=auto - -[ipx] -# ipx: Enable ipx over UDP/IP emulation. - -ipx=false - -[autoexec] -# Lines in this section will be run at startup. -# You can put your MOUNT lines here. -mount d . -d: -cd \ diff --git a/platforms/Dos/sources.mk b/platforms/Dos/sources.mk deleted file mode 100644 index 7515febe6..000000000 --- a/platforms/Dos/sources.mk +++ /dev/null @@ -1,166 +0,0 @@ -CPPU_OBJECTS := \ - $(CPPUTEST_HOME)/src/CppUTest/CommandLineArguments.o \ - $(CPPUTEST_HOME)/src/CppUTest/CommandLineTestRunner.o \ - $(CPPUTEST_HOME)/src/CppUTest/JUnitTestOutput.o \ - $(CPPUTEST_HOME)/src/CppUTest/TeamCityTestOutput.o \ - $(CPPUTEST_HOME)/src/CppUTest/MemoryLeakDetector.o \ - $(CPPUTEST_HOME)/src/CppUTest/MemoryLeakWarningPlugin.o \ - $(CPPUTEST_HOME)/src/CppUTest/SimpleMutex.o \ - $(CPPUTEST_HOME)/src/CppUTest/SimpleString.o \ - $(CPPUTEST_HOME)/src/CppUTest/SimpleStringInternalCache.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestFailure.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestFilter.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestHarness_c.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestMemoryAllocator.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestOutput.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestPlugin.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestRegistry.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestTestingFixture.o \ - $(CPPUTEST_HOME)/src/CppUTest/TestResult.o \ - $(CPPUTEST_HOME)/src/CppUTest/Utest.o \ - $(CPPUTEST_HOME)/src/Platforms/Dos/UtestPlatform.o - -CPPUX_OBJECTS := \ - $(CPPUTEST_HOME)/src/CppUTestExt/CodeMemoryReportFormatter.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MemoryReporterPlugin.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/IEEE754ExceptionsPlugin.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockFailure.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockSupportPlugin.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockActualCall.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockSupport_c.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MemoryReportAllocator.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockExpectedCall.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockNamedValue.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/OrderedTest.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MemoryReportFormatter.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockExpectedCallsList.o \ - $(CPPUTEST_HOME)/src/CppUTestExt/MockSupport.o - -CPPU1_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/AllocLetTestFree.o \ - $(CPPUTEST_HOME)/tests/CppUTest/AllocLetTestFreeTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/CheatSheetTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/CompatabilityTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/CommandLineArgumentsTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/CommandLineTestRunnerTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/JUnitOutputTest.o - -CPPU2_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/DummyMemoryLeakDetector.o \ - $(CPPUTEST_HOME)/tests/CppUTest/MemoryLeakWarningTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/PluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/PreprocessorTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/SetPluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/SimpleMutexTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TeamCityOutputTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestFailureNaNTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestFailureTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestResultTest.o \ - -CPPU3_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/MemoryLeakDetectorTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/SimpleStringTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/SimpleStringCacheTest.o - -CPPU4_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestOutputTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestRegistryTest.o \ - -CPPU5_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/AllocationInCFile.o \ - $(CPPUTEST_HOME)/tests/CppUTest/AllocationInCppFile.o \ - $(CPPUTEST_HOME)/tests/CppUTest/MemoryOperatorOverloadTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TeamCityOutputTest.o - -CPPU6_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestFilterTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestHarness_cTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestHarness_cTestCFile.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestInstallerTest.o - -CPPU7_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestMemoryAllocatorTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestUTestMacro.o - -CPPU8_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTest/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTest/UtestPlatformTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/UtestTest.o \ - $(CPPUTEST_HOME)/tests/CppUTest/TestUTestStringMacro.o \ - -CPPUX1_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/ExpectedFunctionsListTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/GMockTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/GTest1Test.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/GTest2ConvertorTest.o - -CPPUX2_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MemoryReportAllocatorTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MemoryReportFormatterTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MemoryReporterPluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockActualCallTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockCheatSheetTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockComparatorCopierTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockExpectedCallTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockHierarchyTest.o - -CPPUX3_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/CodeMemoryReporterTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/OrderedTestTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/OrderedTestTest_c.o \ - -CPPUX4_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockReturnValueTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockNamedValueTest.o - -CPPUX5_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockPluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockSupport_cTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockSupport_cTestCFile.o \ - -CPPUX6_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/ExpectedFunctionsListTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockCallTest.o - -CPPUX7_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockComparatorCopierTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockHierarchyTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockParameterTest.o \ - -CPPUX8_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/IEEE754PluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/IEEE754PluginTest_c.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockComparatorCopierTest.o - -CPPUX9_OBJECTS := \ - $(CPPUTEST_HOME)/tests/CppUTestExt/AllTests.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureReporterForTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockFailureTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockHierarchyTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockPluginTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockReturnValueTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockStrictOrderTest.o \ - $(CPPUTEST_HOME)/tests/CppUTestExt/MockSupportTest.o \ diff --git a/platforms/Eclipse-Cygwin/.cproject b/platforms/Eclipse-Cygwin/.cproject deleted file mode 100644 index 174ccf923..000000000 --- a/platforms/Eclipse-Cygwin/.cproject +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - extensions - true - true - true - - - make - - examples - true - true - true - - - make - - cleanExamples - true - true - true - - - - - - diff --git a/platforms/Eclipse-Cygwin/.project b/platforms/Eclipse-Cygwin/.project deleted file mode 100644 index 488e625d5..000000000 --- a/platforms/Eclipse-Cygwin/.project +++ /dev/null @@ -1,2473 +0,0 @@ - - - CppUTest - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - - - 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 - - - - .gitattributes - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/.gitattributes - - - .gitignore - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/.gitignore - - - .travis.yml - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/.travis.yml - - - AUTHORS - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/AUTHORS - - - CMakeLists.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CMakeLists.txt - - - COPYING - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/COPYING - - - ChangeLog - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/ChangeLog - - - CppUTest.dsw - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest.dsw - - - CppUTest.vcproj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest.vcproj - - - CppUTest.vcxproj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest.vcxproj - - - CppUTest_VS2008.ncb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest_VS2008.ncb - - - CppUTest_VS2008.sln - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest_VS2008.sln - - - CppUTest_VS2008.suo - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest_VS2008.suo - - - CppUTest_VS2010.sln - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest_VS2010.sln - - - CppUTest_VS2010.suo - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/CppUTest_VS2010.suo - - - Doxyfile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/Doxyfile - - - INSTALL - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/INSTALL - - - Makefile.am - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/Makefile.am - - - Makefile.in - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/Makefile.in - - - Makefile_CppUTestExt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/Makefile_CppUTestExt - - - Makefile_using_MakefileWorker - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/Makefile_using_MakefileWorker - - - NEWS - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/NEWS - - - README - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/README - - - README.md - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/README.md - - - README_CppUTest_for_C.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/README_CppUTest_for_C.txt - - - README_InstallCppUTest.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/README_InstallCppUTest.txt - - - README_UsersOfPriorVersions.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/README_UsersOfPriorVersions.txt - - - aclocal.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/aclocal.m4 - - - autogen.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/autogen.sh - - - build - 2 - virtual:/virtual - - - builds - 2 - virtual:/virtual - - - cmake - 2 - virtual:/virtual - - - compile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/compile - - - config.guess - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/config.guess - - - config.h.cmake - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/config.h.cmake - - - config.h.in - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/config.h.in - - - config.h.in~ - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/config.h.in~ - - - config.sub - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/config.sub - - - configure - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/configure - - - configure.ac - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/configure.ac - - - cpputest.pc.in - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/cpputest.pc.in - - - cpputest_build - 2 - virtual:/virtual - - - cpputest_doxy_gen.conf - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/cpputest_doxy_gen.conf - - - depcomp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/depcomp - - - docs - 2 - virtual:/virtual - - - examples - 2 - virtual:/virtual - - - include - 2 - virtual:/virtual - - - install-sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/install-sh - - - lib - 2 - virtual:/virtual - - - ltmain.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/ltmain.sh - - - m4 - 2 - virtual:/virtual - - - makeVS2008.bat - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/makeVS2008.bat - - - makeVS2010.bat - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/makeVS2010.bat - - - makeVc6.bat - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/makeVc6.bat - - - missing - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/missing - - - scripts - 2 - virtual:/virtual - - - src - 2 - virtual:/virtual - - - test-driver - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/test-driver - - - tests - 2 - virtual:/virtual - - - valgrind.suppressions - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/valgrind.suppressions - - - build/ComponentMakefile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/ComponentMakefile - - - build/ComponentMakefileExampleParameters - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/ComponentMakefileExampleParameters - - - build/MakefileWorker.mk - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/MakefileWorker.mk - - - build/StaticLibMakefile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/StaticLibMakefile - - - build/alltests.mmp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/alltests.mmp - - - build/bld.inf - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/bld.inf - - - build/cpputest.mmp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/build/cpputest.mmp - - - builds/make-gcc-macport.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/builds/make-gcc-macport.sh - - - cmake/Modules - 2 - virtual:/virtual - - - cpputest_build/CppUTestExtTests.exe - 1 - PARENT-2-PROJECT_LOC/cpputest_build/CppUTestExtTests.exe - - - cpputest_build/CppUTestTests.exe - 1 - PARENT-2-PROJECT_LOC/cpputest_build/CppUTestTests.exe - - - cpputest_build/Makefile - 1 - PARENT-2-PROJECT_LOC/cpputest_build/Makefile - - - examples/.cdtproject - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/.cdtproject - - - examples/.project - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/.project - - - examples/.settings - 2 - virtual:/virtual - - - examples/AllTests - 2 - virtual:/virtual - - - examples/ApplicationLib - 2 - virtual:/virtual - - - examples/CppUTestExample.dsw - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/CppUTestExample.dsw - - - examples/Makefile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/Makefile - - - examples/README.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/README.txt - - - include/CppUTest - 2 - virtual:/virtual - - - include/CppUTestExt - 2 - virtual:/virtual - - - include/Platforms - 2 - virtual:/virtual - - - lib/CppUTest.lib - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/lib/CppUTest.lib - - - lib/NoteOnVisualStudio.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/lib/NoteOnVisualStudio.txt - - - lib/vs2008 - 2 - virtual:/virtual - - - m4/acx_pthread.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/acx_pthread.m4 - - - m4/libtool.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/libtool.m4 - - - m4/ltoptions.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/ltoptions.m4 - - - m4/ltsugar.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/ltsugar.m4 - - - m4/ltversion.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/ltversion.m4 - - - m4/lt~obsolete.m4 - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/m4/lt~obsolete.m4 - - - scripts/CppUnitTemplates - 2 - virtual:/virtual - - - scripts/GenerateSrcFiles.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/GenerateSrcFiles.sh - - - scripts/InstallScripts.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/InstallScripts.sh - - - scripts/NewCBaseModule.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCBaseModule.sh - - - scripts/NewCFunction.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCFunction.sh - - - scripts/NewCInterface.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCInterface.sh - - - scripts/NewCIoDriver.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCIoDriver.sh - - - scripts/NewCModule.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCModule.sh - - - scripts/NewClass.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewClass.sh - - - scripts/NewCmiModule.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewCmiModule.sh - - - scripts/NewHelp.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewHelp.sh - - - scripts/NewInterface.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewInterface.sh - - - scripts/NewLibrary.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewLibrary.sh - - - scripts/NewPackageDirs.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewPackageDirs.sh - - - scripts/NewProject.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/NewProject.sh - - - scripts/README.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/README.txt - - - scripts/RefactorRenameIncludeFile.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/RefactorRenameIncludeFile.sh - - - scripts/ReleaseCppUTest.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/ReleaseCppUTest.sh - - - scripts/UnityTemplates - 2 - virtual:/virtual - - - scripts/VS2010Templates - 2 - virtual:/virtual - - - scripts/checkForCppUTestEnvVariable.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/checkForCppUTestEnvVariable.sh - - - scripts/convertToUnity - 2 - virtual:/virtual - - - scripts/filterGcov.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/filterGcov.sh - - - scripts/generate_junit_report_ant.xml - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/generate_junit_report_ant.xml - - - scripts/reformat.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/reformat.sh - - - scripts/squeeze.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/squeeze.sh - - - scripts/svnignore.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/svnignore.txt - - - scripts/templates - 2 - virtual:/virtual - - - scripts/travis_ci_build.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/travis_ci_build.sh - - - scripts/zipExclude.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/zipExclude.txt - - - src/CppUTest - 2 - virtual:/virtual - - - src/CppUTestExt - 2 - virtual:/virtual - - - src/Platforms - 2 - virtual:/virtual - - - tests/AllTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllTests.cpp - - - tests/AllTests.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllTests.h - - - tests/AllTests.vcproj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllTests.vcproj - - - tests/AllTests.vcproj.HELLADE.struar2.user - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllTests.vcproj.HELLADE.struar2.user - - - tests/AllTests.vcxproj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllTests.vcxproj - - - tests/AllocLetTestFree.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocLetTestFree.c - - - tests/AllocLetTestFree.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocLetTestFree.h - - - tests/AllocLetTestFreeTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocLetTestFreeTest.cpp - - - tests/AllocationInCFile.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocationInCFile.c - - - tests/AllocationInCFile.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocationInCFile.h - - - tests/AllocationInCppFile.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocationInCppFile.cpp - - - tests/AllocationInCppFile.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/AllocationInCppFile.h - - - tests/CMakeLists.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CMakeLists.txt - - - tests/CheatSheetTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CheatSheetTest.cpp - - - tests/CompatabilityTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CompatabilityTests.cpp - - - tests/CommandLineArgumentsTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CommandLineArgumentsTest.cpp - - - tests/CommandLineTestRunnerTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CommandLineTestRunnerTest.cpp - - - tests/CppUTestExt - 2 - virtual:/virtual - - - tests/Debug - 2 - virtual:/virtual - - - tests/JUnitOutputTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/JUnitOutputTest.cpp - - - tests/MemoryLeakDetectorTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/MemoryLeakDetectorTest.cpp - - - tests/MemoryLeakOperatorOverloadsTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/MemoryLeakOperatorOverloadsTest.cpp - - - tests/MemoryLeakWarningTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/MemoryLeakWarningTest.cpp - - - tests/PluginTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/PluginTest.cpp - - - tests/PreprocessorTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/PreprocessorTest.cpp - - - tests/RunAllTests.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/RunAllTests.sh - - - tests/SetPluginTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/SetPluginTest.cpp - - - tests/SimpleStringCacheTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/SimpleStringCacheTest.cpp - - - tests/SimpleStringTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/SimpleStringTest.cpp - - - tests/TestFailureNaNTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestFailureNaNTest.cpp - - - tests/TestFailureTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestFailureTest.cpp - - - tests/TestFilterTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestFilterTest.cpp - - - tests/TestHarness_cTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestHarness_cTest.cpp - - - tests/TestHarness_cTestCFile.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestHarness_cTestCFile.c - - - tests/TestInstallerTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestInstallerTest.cpp - - - tests/TestMemoryAllocatorTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestMemoryAllocatorTest.cpp - - - tests/TestOutputTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestOutputTest.cpp - - - tests/TestRegistryTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestRegistryTest.cpp - - - tests/TestResultTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestResultTest.cpp - - - tests/TestUTestMacro.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/TestUTestMacro.cpp - - - tests/UtestTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/UtestTest.cpp - - - cmake/Modules/CppUTestConfigurationOptions.cmake - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/cmake/Modules/CppUTestConfigurationOptions.cmake - - - cmake/Modules/CppUTestWarningFlags.cmake - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/cmake/Modules/CppUTestWarningFlags.cmake - - - cmake/Modules/FindCXX11.cmake - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/cmake/Modules/FindCXX11.cmake - - - examples/.settings/org.eclipse.cdt.core.prefs - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/.settings/org.eclipse.cdt.core.prefs - - - examples/AllTests/AllTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/AllTests.cpp - - - examples/AllTests/CircularBufferTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/CircularBufferTest.cpp - - - examples/AllTests/EventDispatcherTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/EventDispatcherTest.cpp - - - examples/AllTests/HelloTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/HelloTest.cpp - - - examples/AllTests/MockDocumentationTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/MockDocumentationTest.cpp - - - examples/AllTests/PrinterTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/PrinterTest.cpp - - - examples/AllTests/RunAllTests.sh - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/AllTests/RunAllTests.sh - - - examples/ApplicationLib/AllTests.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/AllTests.h - - - examples/ApplicationLib/CircularBuffer.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/CircularBuffer.cpp - - - examples/ApplicationLib/CircularBuffer.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/CircularBuffer.h - - - examples/ApplicationLib/EventDispatcher.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/EventDispatcher.cpp - - - examples/ApplicationLib/EventDispatcher.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/EventDispatcher.h - - - examples/ApplicationLib/ExamplesNewOverrides.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/ExamplesNewOverrides.h - - - examples/ApplicationLib/MockPrinter.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/MockPrinter.h - - - examples/ApplicationLib/Printer.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/Printer.cpp - - - examples/ApplicationLib/Printer.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/Printer.h - - - examples/ApplicationLib/hello.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/hello.c - - - examples/ApplicationLib/hello.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/examples/ApplicationLib/hello.h - - - include/CppUTest/CommandLineArguments.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/CommandLineArguments.h - - - include/CppUTest/CommandLineTestRunner.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/CommandLineTestRunner.h - - - include/CppUTest/CppUTestConfig.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/CppUTestConfig.h - - - include/CppUTest/JUnitTestOutput.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/JUnitTestOutput.h - - - include/CppUTest/MemoryLeakDetector.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/MemoryLeakDetector.h - - - include/CppUTest/MemoryLeakDetectorMallocMacros.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h - - - include/CppUTest/MemoryLeakDetectorNewMacros.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h - - - include/CppUTest/MemoryLeakWarningPlugin.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h - - - include/CppUTest/PlatformSpecificFunctions.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/PlatformSpecificFunctions.h - - - include/CppUTest/PlatformSpecificFunctions_c.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/PlatformSpecificFunctions_c.h - - - include/CppUTest/SimpleString.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/SimpleString.h - - - include/CppUTest/SimpleStringInternalCache.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/SimpleStringInternalCache.h - - - include/CppUTest/StandardCLibrary.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/StandardCLibrary.h - - - include/CppUTest/TestFailure.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestFailure.h - - - include/CppUTest/TestFilter.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestFilter.h - - - include/CppUTest/TestHarness.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestHarness.h - - - include/CppUTest/TestHarness_c.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestHarness_c.h - - - include/CppUTest/TestMemoryAllocator.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestMemoryAllocator.h - - - include/CppUTest/TestOutput.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestOutput.h - - - include/CppUTest/TestPlugin.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestPlugin.h - - - include/CppUTest/TestRegistry.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestRegistry.h - - - include/CppUTest/TestResult.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestResult.h - - - include/CppUTest/TestTestingFixture.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/TestTestingFixture.h - - - include/CppUTest/Utest.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/Utest.h - - - include/CppUTest/UtestMacros.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTest/UtestMacros.h - - - include/CppUTestExt/CodeMemoryReportFormatter.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/CodeMemoryReportFormatter.h - - - include/CppUTestExt/GMock.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/GMock.h - - - include/CppUTestExt/GTestSupport.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/GTestSupport.h - - - include/CppUTestExt/GTest.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/GTest.h - - - include/CppUTestExt/GTestConvertor.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/GTestConvertor.h - - - include/CppUTestExt/MemoryReportAllocator.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MemoryReportAllocator.h - - - include/CppUTestExt/MemoryReportFormatter.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MemoryReportFormatter.h - - - include/CppUTestExt/MemoryReporterPlugin.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MemoryReporterPlugin.h - - - include/CppUTestExt/MockActualCall.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockActualCall.h - - - include/CppUTestExt/MockCheckedActualCall.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockCheckedActualCall.h - - - include/CppUTestExt/MockCheckedExpectedCall.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockCheckedExpectedCall.h - - - include/CppUTestExt/MockExpectedCall.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockExpectedCall.h - - - include/CppUTestExt/MockExpectedCallsList.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockExpectedCallsList.h - - - include/CppUTestExt/MockFailure.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockFailure.h - - - include/CppUTestExt/MockNamedValue.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockNamedValue.h - - - include/CppUTestExt/MockSupport.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockSupport.h - - - include/CppUTestExt/MockSupportPlugin.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockSupportPlugin.h - - - include/CppUTestExt/MockSupport_c.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/MockSupport_c.h - - - include/CppUTestExt/OrderedTest.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/CppUTestExt/OrderedTest.h - - - include/Platforms/Gcc - 2 - virtual:/virtual - - - include/Platforms/Symbian - 2 - virtual:/virtual - - - include/Platforms/VisualCpp - 2 - virtual:/virtual - - - include/Platforms/armcc - 2 - virtual:/virtual - - - include/Platforms/c2000 - 2 - virtual:/virtual - - - lib/vs2008/CppUTest.lib - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/lib/vs2008/CppUTest.lib - - - lib/vs2008/vc90.pdb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/lib/vs2008/vc90.pdb - - - scripts/CppUnitTemplates/ClassName.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassName.cpp - - - scripts/CppUnitTemplates/ClassName.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassName.h - - - scripts/CppUnitTemplates/ClassNameC.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameC.c - - - scripts/CppUnitTemplates/ClassNameC.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameC.h - - - scripts/CppUnitTemplates/ClassNameCMultipleInstance.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCMultipleInstance.c - - - scripts/CppUnitTemplates/ClassNameCMultipleInstance.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCMultipleInstance.h - - - scripts/CppUnitTemplates/ClassNameCMultipleInstanceTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCMultipleInstanceTest.cpp - - - scripts/CppUnitTemplates/ClassNameCPolymorphic.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCPolymorphic.c - - - scripts/CppUnitTemplates/ClassNameCPolymorphic.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCPolymorphic.h - - - scripts/CppUnitTemplates/ClassNameCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameCTest.cpp - - - scripts/CppUnitTemplates/ClassNameTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ClassNameTest.cpp - - - scripts/CppUnitTemplates/InterfaceCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/InterfaceCTest.cpp - - - scripts/CppUnitTemplates/InterfaceTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/InterfaceTest.cpp - - - scripts/CppUnitTemplates/MockClassName.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/MockClassName.h - - - scripts/CppUnitTemplates/MockClassNameC.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/MockClassNameC.c - - - scripts/CppUnitTemplates/MockClassNameC.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/MockClassNameC.h - - - scripts/CppUnitTemplates/ProjectTemplate - 2 - virtual:/virtual - - - scripts/UnityTemplates/ClassNameCIoDriverTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/UnityTemplates/ClassNameCIoDriverTest.cpp - - - scripts/UnityTemplates/ClassNameCMultipleInstanceTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/UnityTemplates/ClassNameCMultipleInstanceTest.cpp - - - scripts/UnityTemplates/ClassNameCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/UnityTemplates/ClassNameCTest.cpp - - - scripts/UnityTemplates/FunctionNameCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/UnityTemplates/FunctionNameCTest.cpp - - - scripts/UnityTemplates/InterfaceCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/UnityTemplates/InterfaceCTest.cpp - - - scripts/VS2010Templates/CppUTest_VS2010.props - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/VS2010Templates/CppUTest_VS2010.props - - - scripts/VS2010Templates/README.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/VS2010Templates/README.txt - - - scripts/convertToUnity/README.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/README.txt - - - scripts/convertToUnity/cpp_u_test_to_unity.rb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/cpp_u_test_to_unity.rb - - - scripts/convertToUnity/cpp_u_test_to_unity_utils.rb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/cpp_u_test_to_unity_utils.rb - - - scripts/convertToUnity/cpp_u_test_to_unity_utils_tests.rb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/cpp_u_test_to_unity_utils_tests.rb - - - scripts/convertToUnity/create_group_runner.rb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/create_group_runner.rb - - - scripts/convertToUnity/create_unity_test_runner.rb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/convertToUnity/create_unity_test_runner.rb - - - scripts/templates/ClassName.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassName.cpp - - - scripts/templates/ClassName.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassName.h - - - scripts/templates/ClassNameC.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameC.c - - - scripts/templates/ClassNameC.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameC.h - - - scripts/templates/ClassNameCIoDriver.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCIoDriver.c - - - scripts/templates/ClassNameCIoDriver.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCIoDriver.h - - - scripts/templates/ClassNameCIoDriverTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCIoDriverTest.cpp - - - scripts/templates/ClassNameCMultipleInstance.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCMultipleInstance.c - - - scripts/templates/ClassNameCMultipleInstance.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCMultipleInstance.h - - - scripts/templates/ClassNameCMultipleInstanceTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCMultipleInstanceTest.cpp - - - scripts/templates/ClassNameCPolymorphic.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCPolymorphic.c - - - scripts/templates/ClassNameCPolymorphic.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCPolymorphic.h - - - scripts/templates/ClassNameCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameCTest.cpp - - - scripts/templates/ClassNameTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ClassNameTest.cpp - - - scripts/templates/FunctionNameC.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/FunctionNameC.c - - - scripts/templates/FunctionNameC.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/FunctionNameC.h - - - scripts/templates/FunctionNameCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/FunctionNameCTest.cpp - - - scripts/templates/InterfaceCTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/InterfaceCTest.cpp - - - scripts/templates/InterfaceTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/InterfaceTest.cpp - - - scripts/templates/MockClassName.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/MockClassName.h - - - scripts/templates/MockClassNameC.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/MockClassNameC.c - - - scripts/templates/MockClassNameC.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/MockClassNameC.h - - - scripts/templates/ProjectTemplate - 2 - virtual:/virtual - - - src/CppUTest/CMakeLists.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/CMakeLists.txt - - - src/CppUTest/CommandLineArguments.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/CommandLineArguments.cpp - - - src/CppUTest/CommandLineTestRunner.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/CommandLineTestRunner.cpp - - - src/CppUTest/JUnitTestOutput.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/JUnitTestOutput.cpp - - - src/CppUTest/MemoryLeakDetector.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/MemoryLeakDetector.cpp - - - src/CppUTest/MemoryLeakWarningPlugin.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/MemoryLeakWarningPlugin.cpp - - src/CppUTest/SimpleString.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/SimpleString.cpp - - src/CppUTest/SimpleStringInternalCache.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/SimpleStringInternalCache.cpp - - - src/CppUTest/TestFailure.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestFailure.cpp - - - src/CppUTest/TestFilter.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestFilter.cpp - - - src/CppUTest/TestHarness_c.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestHarness_c.cpp - - - src/CppUTest/TestMemoryAllocator.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestMemoryAllocator.cpp - - - src/CppUTest/TestOutput.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestOutput.cpp - - - src/CppUTest/TestPlugin.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestPlugin.cpp - - - src/CppUTest/TestRegistry.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestRegistry.cpp - - - src/CppUTest/TestResult.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/TestResult.cpp - - - src/CppUTest/Utest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTest/Utest.cpp - - - src/CppUTestExt/CMakeLists.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/CMakeLists.txt - - - src/CppUTestExt/CodeMemoryReportFormatter.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/CodeMemoryReportFormatter.cpp - - - src/CppUTestExt/GTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/GTest.cpp - - - src/CppUTestExt/MemoryReportAllocator.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MemoryReportAllocator.cpp - - - src/CppUTestExt/MemoryReportFormatter.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MemoryReportFormatter.cpp - - - src/CppUTestExt/MemoryReporterPlugin.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MemoryReporterPlugin.cpp - - - src/CppUTestExt/MockActualCall.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockActualCall.cpp - - - src/CppUTestExt/MockExpectedCall.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockExpectedCall.cpp - - - src/CppUTestExt/MockExpectedCallsList.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockExpectedCallsList.cpp - - - src/CppUTestExt/MockFailure.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockFailure.cpp - - - src/CppUTestExt/MockNamedValue.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockNamedValue.cpp - - - src/CppUTestExt/MockSupport.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockSupport.cpp - - - src/CppUTestExt/MockSupportPlugin.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockSupportPlugin.cpp - - - src/CppUTestExt/MockSupport_c.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/MockSupport_c.cpp - - - src/CppUTestExt/OrderedTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/CppUTestExt/OrderedTest.cpp - - - src/Platforms/C2000 - 2 - virtual:/virtual - - - src/Platforms/Gcc - 2 - virtual:/virtual - - - src/Platforms/GccNoStdC - 2 - virtual:/virtual - - - src/Platforms/Iar - 2 - virtual:/virtual - - - src/Platforms/Symbian - 2 - virtual:/virtual - - - src/Platforms/VisualCpp - 2 - virtual:/virtual - - - src/Platforms/armcc - 2 - virtual:/virtual - - - tests/CppUTestExt/AllTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/AllTests.cpp - - - tests/CppUTestExt/CMakeLists.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/CMakeLists.txt - - - tests/CppUTestExt/CodeMemoryReportFormatterTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/CodeMemoryReportFormatterTest.cpp - - - tests/CppUTestExt/GMockTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/GMockTest.cpp - - - tests/CppUTestExt/GTest1Test.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/GTest1Test.cpp - - - tests/CppUTestExt/GTest2ConvertorTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/GTest2ConvertorTest.cpp - - - tests/CppUTestExt/MemoryReportAllocatorTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MemoryReportAllocatorTest.cpp - - - tests/CppUTestExt/MemoryReportFormatterTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MemoryReportFormatterTest.cpp - - - tests/CppUTestExt/MemoryReporterPluginTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MemoryReporterPluginTest.cpp - - - tests/CppUTestExt/MockActualCallTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockActualCallTest.cpp - - - tests/CppUTestExt/MockCheatSheetTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockCheatSheetTest.cpp - - - tests/CppUTestExt/MockExpectedCallTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockExpectedCallTest.cpp - - - tests/CppUTestExt/MockExpectedFunctionsListTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockExpectedFunctionsListTest.cpp - - - tests/CppUTestExt/MockFailureTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockFailureTest.cpp - - - tests/CppUTestExt/MockFailureTest.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockFailureTest.h - - - tests/CppUTestExt/MockPluginTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockPluginTest.cpp - - - tests/CppUTestExt/MockSupportTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockSupportTest.cpp - - - tests/CppUTestExt/MockSupport_cTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockSupport_cTest.cpp - - - tests/CppUTestExt/MockSupport_cTestCFile.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockSupport_cTestCFile.c - - - tests/CppUTestExt/MockSupport_cTestCFile.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/MockSupport_cTestCFile.h - - - tests/CppUTestExt/OrderedTestTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/OrderedTestTest.cpp - - - tests/CppUTestExt/OrderedTestTest_c.c - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/OrderedTestTest_c.c - - - tests/CppUTestExt/OrderedTestTest.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/CppUTestExt/OrderedTestTest.h - - - tests/Debug/AllTests.bsc - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.bsc - - - tests/Debug/AllTests.exe - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.exe - - - tests/Debug/AllTests.exe.embed.manifest - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.exe.embed.manifest - - - tests/Debug/AllTests.exe.embed.manifest.res - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.exe.embed.manifest.res - - - tests/Debug/AllTests.exe.intermediate.manifest - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.exe.intermediate.manifest - - - tests/Debug/AllTests.ilk - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.ilk - - - tests/Debug/AllTests.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.obj - - - tests/Debug/AllTests.pdb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.pdb - - - tests/Debug/AllTests.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllTests.sbr - - - tests/Debug/AllocationInCFile.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllocationInCFile.obj - - - tests/Debug/AllocationInCFile.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllocationInCFile.sbr - - - tests/Debug/AllocationInCppFile.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllocationInCppFile.obj - - - tests/Debug/AllocationInCppFile.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/AllocationInCppFile.sbr - - - tests/Debug/BuildLog.htm - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/BuildLog.htm - - - tests/Debug/CheatSheetTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CheatSheetTest.obj - - - tests/Debug/CheatSheetTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CheatSheetTest.sbr - - - tests/Debug/CodeMemoryReportFormatterTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CodeMemoryReportFormatterTest.obj - - - tests/Debug/CodeMemoryReportFormatterTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CodeMemoryReportFormatterTest.sbr - - - tests/Debug/CompatabilityTests.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CompatabilityTests.obj - - - tests/Debug/CompatabilityTests.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CompatabilityTests.sbr - - - tests/Debug/CommandLineArgumentsTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CommandLineArgumentsTest.obj - - - tests/Debug/CommandLineArgumentsTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CommandLineArgumentsTest.sbr - - - tests/Debug/CommandLineTestRunnerTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CommandLineTestRunnerTest.obj - - - tests/Debug/CommandLineTestRunnerTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/CommandLineTestRunnerTest.sbr - - - tests/Debug/GMockTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/GMockTest.obj - - - tests/Debug/GMockTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/GMockTest.sbr - - - tests/Debug/GTest1Test.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/GTest1Test.obj - - - tests/Debug/GTest1Test.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/GTest1Test.sbr - - - tests/Debug/JUnitOutputTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/JUnitOutputTest.obj - - - tests/Debug/JUnitOutputTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/JUnitOutputTest.sbr - - - tests/Debug/MemoryLeakDetectorTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakDetectorTest.obj - - - tests/Debug/MemoryLeakDetectorTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakDetectorTest.sbr - - - tests/Debug/MemoryLeakOperatorOverloadsTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakOperatorOverloadsTest.obj - - - tests/Debug/MemoryLeakOperatorOverloadsTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakOperatorOverloadsTest.sbr - - - tests/Debug/MemoryLeakWarningTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakWarningTest.obj - - - tests/Debug/MemoryLeakWarningTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryLeakWarningTest.sbr - - - tests/Debug/MemoryReportAllocatorTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReportAllocatorTest.obj - - - tests/Debug/MemoryReportAllocatorTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReportAllocatorTest.sbr - - - tests/Debug/MemoryReportFormatterTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReportFormatterTest.obj - - - tests/Debug/MemoryReportFormatterTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReportFormatterTest.sbr - - - tests/Debug/MemoryReporterPluginTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReporterPluginTest.obj - - - tests/Debug/MemoryReporterPluginTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MemoryReporterPluginTest.sbr - - - tests/Debug/MockActualCallTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockActualCallTest.obj - - - tests/Debug/MockActualCallTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockActualCallTest.sbr - - - tests/Debug/MockCheatSheetTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockCheatSheetTest.obj - - - tests/Debug/MockCheatSheetTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockCheatSheetTest.sbr - - - tests/Debug/MockExpectedCallTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockExpectedCallTest.obj - - - tests/Debug/MockExpectedCallTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockExpectedCallTest.sbr - - - tests/Debug/MockExpectedFunctionsListTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockExpectedFunctionsListTest.obj - - - tests/Debug/MockExpectedFunctionsListTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockExpectedFunctionsListTest.sbr - - - tests/Debug/MockFailureTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockFailureTest.obj - - - tests/Debug/MockFailureTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockFailureTest.sbr - - - tests/Debug/MockPluginTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockPluginTest.obj - - - tests/Debug/MockPluginTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockPluginTest.sbr - - - tests/Debug/MockSupportTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupportTest.obj - - - tests/Debug/MockSupportTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupportTest.sbr - - - tests/Debug/MockSupport_cTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupport_cTest.obj - - - tests/Debug/MockSupport_cTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupport_cTest.sbr - - - tests/Debug/MockSupport_cTestCFile.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupport_cTestCFile.obj - - - tests/Debug/MockSupport_cTestCFile.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/MockSupport_cTestCFile.sbr - - - tests/Debug/OrderedTestTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/OrderedTestTest.obj - - - tests/Debug/OrderedTestTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/OrderedTestTest.sbr - - - tests/Debug/OrderedTestTest_c.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/OrderedTestTest_c.obj - - - tests/Debug/OrderedTestTest_c.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/OrderedTestTest_c.sbr - - - tests/Debug/PluginTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/PluginTest.obj - - - tests/Debug/PluginTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/PluginTest.sbr - - - tests/Debug/PreprocessorTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/PreprocessorTest.obj - - - tests/Debug/PreprocessorTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/PreprocessorTest.sbr - - - tests/Debug/SetPluginTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/SetPluginTest.obj - - - tests/Debug/SetPluginTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/SetPluginTest.sbr - - - tests/Debug/SimpleStringTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/SimpleStringTest.obj - - - tests/Debug/SimpleStringTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/SimpleStringTest.sbr - - - tests/Debug/TestFailureTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestFailureTest.obj - - - tests/Debug/TestFailureTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestFailureTest.sbr - - - tests/Debug/TestFilterTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestFilterTest.obj - - - tests/Debug/TestFilterTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestFilterTest.sbr - - - tests/Debug/TestHarness_cTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestHarness_cTest.obj - - - tests/Debug/TestHarness_cTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestHarness_cTest.sbr - - - tests/Debug/TestHarness_cTestCFile.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestHarness_cTestCFile.obj - - - tests/Debug/TestHarness_cTestCFile.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestHarness_cTestCFile.sbr - - - tests/Debug/TestInstallerTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestInstallerTest.obj - - - tests/Debug/TestInstallerTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestInstallerTest.sbr - - - tests/Debug/TestMemoryAllocatorTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestMemoryAllocatorTest.obj - - - tests/Debug/TestMemoryAllocatorTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestMemoryAllocatorTest.sbr - - - tests/Debug/TestOutputTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestOutputTest.obj - - - tests/Debug/TestOutputTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestOutputTest.sbr - - - tests/Debug/TestRegistryTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestRegistryTest.obj - - - tests/Debug/TestRegistryTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestRegistryTest.sbr - - - tests/Debug/TestResultTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestResultTest.obj - - - tests/Debug/TestResultTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/TestResultTest.sbr - - - tests/Debug/UtestTest.obj - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/UtestTest.obj - - - tests/Debug/UtestTest.sbr - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/UtestTest.sbr - - - tests/Debug/mt.dep - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/mt.dep - - - tests/Debug/vc90.idb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/vc90.idb - - - tests/Debug/vc90.pdb - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/tests/Debug/vc90.pdb - - - include/Platforms/Gcc/Platform.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/Gcc/Platform.h - - - include/Platforms/Symbian/Platform.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/Symbian/Platform.h - - - include/Platforms/VisualCpp/Platform.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/VisualCpp/Platform.h - - - include/Platforms/VisualCpp/stdint.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/VisualCpp/stdint.h - - - include/Platforms/armcc/Platform.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/armcc/Platform.h - - - include/Platforms/c2000/Platform.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/c2000/Platform.h - - - include/Platforms/c2000/stdint.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/include/Platforms/c2000/stdint.h - - - scripts/CppUnitTemplates/ProjectTemplate/ProjectMakefile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ProjectTemplate/ProjectMakefile - - - scripts/CppUnitTemplates/ProjectTemplate/include - 2 - virtual:/virtual - - - scripts/CppUnitTemplates/ProjectTemplate/src - 2 - virtual:/virtual - - - scripts/CppUnitTemplates/ProjectTemplate/tests - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/Project.cproject - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/Project.cproject - - - scripts/templates/ProjectTemplate/Project.project - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/Project.project - - - scripts/templates/ProjectTemplate/ProjectMakefile - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/ProjectMakefile - - - scripts/templates/ProjectTemplate/include - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/src - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/tests - 2 - virtual:/virtual - - - src/Platforms/C2000/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/C2000/UtestPlatform.cpp - - - src/Platforms/Gcc/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/Gcc/UtestPlatform.cpp - - - src/Platforms/GccNoStdC/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/GccNoStdC/UtestPlatform.cpp - - - src/Platforms/Iar/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/Iar/UtestPlatform.cpp - - - src/Platforms/Symbian/README_Symbian.txt - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/Symbian/README_Symbian.txt - - - src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp - - - src/Platforms/Symbian/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/Symbian/UtestPlatform.cpp - - - src/Platforms/VisualCpp/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/VisualCpp/UtestPlatform.cpp - - - src/Platforms/armcc/UtestPlatform.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/src/Platforms/armcc/UtestPlatform.cpp - - - scripts/CppUnitTemplates/ProjectTemplate/include/util - 2 - virtual:/virtual - - - scripts/CppUnitTemplates/ProjectTemplate/src/util - 2 - virtual:/virtual - - - scripts/CppUnitTemplates/ProjectTemplate/tests/AllTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ProjectTemplate/tests/AllTests.cpp - - - scripts/CppUnitTemplates/ProjectTemplate/tests/util - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/include/util - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/src/util - 2 - virtual:/virtual - - - scripts/templates/ProjectTemplate/tests/AllTests.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/tests/AllTests.cpp - - - scripts/templates/ProjectTemplate/tests/util - 2 - virtual:/virtual - - - scripts/CppUnitTemplates/ProjectTemplate/include/util/ProjectBuildTime.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ProjectTemplate/include/util/ProjectBuildTime.h - - - scripts/CppUnitTemplates/ProjectTemplate/src/util/ProjectBuildTime.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ProjectTemplate/src/util/ProjectBuildTime.cpp - - - scripts/CppUnitTemplates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/CppUnitTemplates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp - - - scripts/templates/ProjectTemplate/include/util/ProjectBuildTime.h - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/include/util/ProjectBuildTime.h - - - scripts/templates/ProjectTemplate/src/util/ProjectBuildTime.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/src/util/ProjectBuildTime.cpp - - - scripts/templates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp - 1 - PARENT-2-ECLIPSE_HOME/00_Dev/05_CppUTest/cpputest/scripts/templates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp - - - diff --git a/platforms/Eclipse-Cygwin/CppUTestExtTests.launch b/platforms/Eclipse-Cygwin/CppUTestExtTests.launch deleted file mode 100644 index 18d768b11..000000000 --- a/platforms/Eclipse-Cygwin/CppUTestExtTests.launch +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms/Eclipse-Cygwin/CppUTestTests.launch b/platforms/Eclipse-Cygwin/CppUTestTests.launch deleted file mode 100644 index 50f76495a..000000000 --- a/platforms/Eclipse-Cygwin/CppUTestTests.launch +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms/Eclipse-Cygwin/README.md b/platforms/Eclipse-Cygwin/README.md deleted file mode 100644 index 503b21eb5..000000000 --- a/platforms/Eclipse-Cygwin/README.md +++ /dev/null @@ -1,65 +0,0 @@ -## Using the Eclipse-Cygwin Project - -This project is for use on the Windows platform. These are the steps required for using it. (If you only wish to compile the CppUTest libraries, it is recommended that you use the method described at http://cpputest.github.io, rather than setting up Eclipse). - -### Preparation -#### 1. Install Cygwin -You need to have Cygwin installed, with at least the Gnu C\C++ compiler, make, autotools and libtool. Please follow the instructions at http://cpputest.github.io to build CppUTest from the Cygwin bash prompt. - -#### 2. Set your PATH -Next, you need to add the path to your Cygwin binaries to your Windows system path, e.g. -```dos -C:\\Cygwin\bin -``` - -#### 3. Install Eclipse CDT -Use your existing Eclipse CDT (Juno, Kepler, ...) or unpack the release to your system drive. You may use the 32 bit version as it will work on all systems. Unless you have a specific reason, you do not require the 64 bit version. You may need to install or update your Java JRE and add it to your system path. The JRE needs to match, e.g. 32 bit Eclipse requires the 32 bit JRE. - -#### 4. Install the C/C++Unit plugin -Open Eclipse. -Accept the default workspace for now (you may want to set a more appropriate workspace location later on). Then install the "C/C++ Unit Test" plugin: - "Help"->"Install New Software"-> work with "Kepler - http://download.eclipse.org/releases/kepler". - You will find the plugin under: -``` - [ ] Programming Languages - [x] C/C++ Unit Testing Support. -``` -While you are at it, you might also want to install: -``` - [ ] Linux Tools - [x] Gcov Integration -``` - -#### 5. Add the CppUTest plugin -Clone the [CppUTest Eclipse Test Runner](https://github.com/tcmak/CppUTestEclipseJunoTestRunner) and add it to Eclipse following the instructions there. - -### Import this project into Eclipse -In Eclipse you can't simply "open" a project - you have to first import it into the workspace: - * File->Import...->General->Existing Projects into workspace - * [Next >]->Select root directory: `/Platforms/Eclipse-Cygwin` - * Make sure that `[ ] Copy projects into workspace` is **NOT** ticked. - * Click Finish. - -### Compile and run tests -Before you can compile CppUTest in Eclipse, you must configure it using Automake. Instructions can be found at http://cpputest.github.io/. Once you have done this, select a configuration (Libraries, Check, CppUTestTests or CppUTestExtTests) via Project->BuildConfiguration->Set Active>. The 'Check' configuration will build the libraries along with all tests and run the tests. - -### Working with the C/C++ Unit plugin -Make sure your unit test executable has been built and exists, e.g. cpputest_build/CppUTestTests.exe. - -The first time you run tests using the plugin, you need to select them via -Run->Run Configurations...->C/C++Unit->CppUTestTest. -Click [Run]. (If Run is greyed out, you need to build the configuration CppUTestTests first) -Once you have run the tests at least once, you should be able to select them by clicking the down triangle next to the green "Run" icon, where it should be listed right at the top. On subsequent runs, the executable will be built automatically, if necessary. - -Note that launch configurations have been included with this project; in your own projects, you will need to create these yourself. - -This is an example of what a successful test run would look like: -![Successful Test Run](https://raw.githubusercontent.com/cpputest/cpputest.github.io/master/images/eclipse-testrunner-01.png) -You can select and rerun individual tests in the upper pane, and error messages for failed tests will appear in the lower pane. -### Troubleshooting -#### Problem: I am getting no test results... -...but you know your tests should have run, and you did not receive any error message. -##### Possible Reason: -This can happen if the Cygwin-generated binary can't find the Cygwin DLLs. (If you were to run your test executable at the Windows cmd prompt, you would see a Windows error message box to that effect). Since no error message is displayed in the console via stderr, this leaves the test runner ignorant of what happenend -##### Solution: -You need to add /Cygwin/bin to your system PATH variable. Then you must restart Eclipse. diff --git a/platforms/armcc/Makefile b/platforms/armcc/Makefile deleted file mode 100644 index 0bb7c5db9..000000000 --- a/platforms/armcc/Makefile +++ /dev/null @@ -1,194 +0,0 @@ -# We don't need to clean up when we're making these targets -NODEPS := clean debug - -# CPU architecture. Passing to armcc.exe. For list: armcc --cpu list -ifndef CPU - CPU = ARM7TDMI -endif - -# ARM/THUMB mode. Passing to armcc.exe. May be 'thumb' or 'arm' -ifndef CPU_MODE - CPU_MODE = thumb -endif - -# Path to cygwin binary -CYGWIN_DIR :=C:/CYGWIN/bin - -# Path to ARMCC of Keil MDK-ARM, with libraries, includes and executables -KEIL_DIR :=D:/Keil/ARM/ARMCC - -MKDIR :=$(CYGWIN_DIR)/mkdir -RM :=$(CYGWIN_DIR)/rm -CC :=@$(KEIL_DIR)/bin/armcc.exe -AR :=@$(KEIL_DIR)/bin/armar.exe - - -# source CppUTest files -CPPUTEST_HOME := ../.. -COMPONENT_NAME := CppUTest - -INCLUDE_DIRS :=\ - $(CPPUTEST_HOME)/include \ - -# armcc system include path -SYS_INCLUDE_DIRS:=$(KEIL_DIR)/include - -SRC_DIRS :=\ - $(CPPUTEST_HOME)/src/$(COMPONENT_NAME)\ - $(CPPUTEST_HOME)/src/Platforms/armcc\ - -TARGET_PLATFORM :=armcc_$(CPU)_$(CPU_MODE) -CPPUTEST_USE_MEM_LEAK_DETECTION := N -CPPUTEST_USE_STD_CPP_LIB := N -CPPUTEST_USE_VPATH := Y -CPPUTEST_USE_STD_C_LIB := Y -CPPUTEST_ENABLE_DEBUG := Y - - -# Default dir for temporary files (d, o) -# Default dir for the outout library -CPPUTEST_OBJS_DIR = objs -CPPUTEST_LIB_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM) - -TARGET_LIB = \ - $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a - - -#Helper Functions -get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c) -get_dirs_from_dirspec = $(wildcard $1) -get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir))) -__src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1,$(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2)))) -src_to = $(addprefix $(CPPUTEST_OBJS_DIR)/,$(call __src_to,$1,$2)) -src_to_o = $(call src_to,.o,$1) -src_to_d = $(call src_to,.d,$1) -src_to_gcda = $(call src_to,.gcda,$1) -src_to_gcno = $(call src_to,.gcno,$1) -time = $(shell date +%s) -delta_t = $(eval minus, $1, $2) -debug_print_list = $(foreach word,$1,echo " $(word)";) echo; - -#Derived -SRC = $(call get_src_from_dir_list, $(SRC_DIRS)) -OBJ = $(call src_to_o,$(SRC)) - -STUFF_TO_CLEAN = $(OBJ) - -ALL_SRC = $(SRC) - -CPUFLAGS =--cpu=$(CPU) -ifeq ($(CPU_MODE), thumb) - CPUFLAGS +=--apcs=/interwork -endif -DEPFLAGS =$(CPUFLAGS) -M $(INCLUDES) --depend_format=unix_escaped --depend_single_line --no_depend_system_headers -OPTFLAGS =-O1 -CCFLAGS =$(CPUFLAGS) $(OPTFLAGS) -c $(INCLUDES)\ - --$(CPU_MODE)\ - --exceptions\ - -D__CLK_TCK=1000\ - - -# If we're using VPATH -ifeq ($(CPPUTEST_USE_VPATH), Y) -# gather all the source directories and add them - VPATH += $(sort $(dir $(ALL_SRC))) -# Add the component name to the objs dir path, to differentiate between same-name objects - CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR)) -endif - -INCLUDES_DIRS_EXPANDED = $(call get_dirs_from_dirspec, $(INCLUDE_DIRS)) -INCLUDES += $(foreach dir, $(INCLUDES_DIRS_EXPANDED), -I$(dir)) - -DEP_FILES = $(call src_to_d, $(ALL_SRC)) -STUFF_TO_CLEAN += $(DEP_FILES) - - -# Without the C library, we'll need to disable the C++ library and ... -ifeq ($(CPPUTEST_USE_STD_C_LIB), N) - CPPUTEST_USE_STD_CPP_LIB = N - CPPUTEST_USE_MEM_LEAK_DETECTION = N - CCFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED -else - INCLUDE_DIRS +=$(SYS_INCLUDE_DIRS) -endif - -ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N) - CCFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED -endif - -ifeq ($(CPPUTEST_ENABLE_DEBUG), Y) - CCFLAGS += -g - ARFLAGS := --debug_symbols -endif - -ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N) - CCFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED -endif - - -OBJS_DIRS :=$(sort $(dir $(STUFF_TO_CLEAN))) - -$(OBJS_DIRS) $(CPPUTEST_LIB_DIR): - @echo Updating directory $@ - $(MKDIR) -p $@ - - -#This is the rule for creating the dependency files -$(CPPUTEST_OBJS_DIR)/%.d: %.c Makefile | $(OBJS_DIRS) - @echo Compiling C file $< for dependency. Out file $@. - $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)' - -$(CPPUTEST_OBJS_DIR)/%.d: %.cpp Makefile | $(OBJS_DIRS) - @echo Compiling C++ file $< for dependency. Out file $@. - $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)' - -#This rule does the compilation C++ files -$(CPPUTEST_OBJS_DIR)/%.o: %.cpp $(CPPUTEST_OBJS_DIR)/%.d Makefile - @echo Compiling C++ file $<. Out file $@ - $(CC) $(CCFLAGS) $< -o $@ - -#This rule does the compilation C files -$(CPPUTEST_OBJS_DIR)/%.o: %.c $(CPPUTEST_OBJS_DIR)/%.d Makefile - @echo Compiling C file $<. Out file $@ - $(CC) $(CCFLAGS) $< -o $@ - - -$(TARGET_LIB): $(OBJ) | $(CPPUTEST_LIB_DIR) - @echo Archiving to $@ - $(AR) $(ARFLAGS) --create $@ $^ - - -.PHONY: all - -all: $(TARGET_LIB) - @echo Done! - - -.PHONY: debug -debug: - @echo - @echo "Target Source files:" - @$(call debug_print_list,$(SRC)) - @echo "Target Object files:" - @$(call debug_print_list,$(OBJ)) - @echo "All Input Dependency files:" - @$(call debug_print_list,$(DEP_FILES)) - @echo Stuff to clean: - @$(call debug_print_list,$(STUFF_TO_CLEAN)) - @echo Includes: - @$(call debug_print_list,$(INCLUDES)) - @echo Directories to create: - @$(call debug_print_list,$(OBJS_DIRS)) - @echo Directories of CppUTest object files: - @$(call debug_print_list,$(CPPUTEST_OBJS_DIR)) - @echo Flags: - @$(call debug_print_list,$(CCFLAGS)) - - -#Don't create dependencies when we're cleaning, for instance -ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS)))) - -include $(DEP_FILES) -endif - -clean: - @$(RM) -rf $(STUFF_TO_CLEAN) diff --git a/platforms/armcc/README b/platforms/armcc/README deleted file mode 100644 index c064d5395..000000000 --- a/platforms/armcc/README +++ /dev/null @@ -1,69 +0,0 @@ -Makefile to build CppUTest library to run in hardware using ARM C/C++ compiler. - -Also it is possible to build CppUTestExt library using -"make all COMPONENT_NAME=CppUTestExt". - -All libraries is placed in lib directory of CppUTest home. - -Thumb mode is using. For ARM mode, you need to remove compiler key -"--apcs=/interwork" and change $(CPU_MODE) to arm. - -You need installed CYGWIN with make.exe, rm.exe, mkdir.exe and installed - Keil MDK-ARM. - -For compiling CppUTest library using ARMCC, please adjust Makefile: -1. # Path to cygwin binary - CYGWIN_DIR :=C:/CYGWIN/bin -2. # Path to ARMCC of Keil MDK-ARM, with libraries, includes and executables - KEIL_DIR :=D:/Keil/ARM/ARMCC -3. # source CppUTest files - CPPUTEST_HOME := ../.. -4. other options explained in $(CPPUTEST_HOME)/build/MakefileWorker.mk - CPPUTEST_USE_MEM_LEAK_DETECTION := Y - CPPUTEST_USE_STD_CPP_LIB := N - CPPUTEST_USE_VPATH := Y - CPPUTEST_USE_STD_C_LIB := Y - CPPUTEST_ENABLE_DEBUG := Y - -You may add additional options "CPU=xx" and "CPU_MODE=yy" -CPU is an option that passed to armcc.exe. It selects CPU. List of CPU is - available by executing 'armcc.exe --cpu list'. - Default CPU architecture is ARM7TDMI. - For armcc v5.02 build 28, CPU is one of the next: - ARM7EJ-S - ARM7TM - ARM7TDM - ARM7TDMI - ARM710T - ARM720T - ARM740T - ARM7TM-S - ARM7TDMI-S - ARM9TDMI - ARM920T - ARM922T - ARM940T - ARM9E-S - ARM9EJ-S - ARM926EJ-S - ARM946E-S - ARM966E-S - ARM968E-S - Cortex-M0 - Cortex-M0plus - SC000 - Cortex-M1 - Cortex-M1.os_extension - Cortex-M1.no_os_extension - Cortex-M3 - Cortex-M3-rev0 - SC300 - Cortex-M4 - Cortex-M4.fp - Cortex-R4 - Cortex-R4F - -CPU_MODE is one of 'arm', 'thumb'. - Default is thumb. - -Tested with Keil MDK-ARM Pro v4.60 diff --git a/platforms/armcc/TODO b/platforms/armcc/TODO deleted file mode 100644 index e566a0712..000000000 --- a/platforms/armcc/TODO +++ /dev/null @@ -1,6 +0,0 @@ -I am not familiar with automake. - -There is need to change build libCppUTest.a for target platform from - makefile in current directory to automake in CppUTest root directory. - And keep in mind that I want to add gcc way, and the others may want to add - some instructions for different compilers and chips. diff --git a/platforms/iar/CppUTest.ewd b/platforms/iar/CppUTest.ewd deleted file mode 100644 index 1c6f889c9..000000000 --- a/platforms/iar/CppUTest.ewd +++ /dev/null @@ -1,3269 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - C-SPY - 2 - - 28 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 1 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 1 - - - - - - - - - - - - CADI_ID - 2 - - 0 - 1 - 1 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 1 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 1 - - - - - - - - - IJET_ID - 2 - - 8 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 1 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 1 - - - - - - - - RDI_ID - 2 - - 2 - 1 - 1 - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 3 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 1 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 1 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 5 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - - - Release - - ARM - - 0 - - C-SPY - 2 - - 28 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - - CADI_ID - 2 - - 0 - 1 - 0 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 0 - - - - - - - - - IJET_ID - 2 - - 8 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 0 - - - - - - - - RDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 5 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - - - - diff --git a/platforms/iar/CppUTest.ewp b/platforms/iar/CppUTest.ewp deleted file mode 100644 index f2f1fbe16..000000000 --- a/platforms/iar/CppUTest.ewp +++ /dev/null @@ -1,2005 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - General - 3 - - 24 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BILINK - 0 - - - - - Release - - ARM - - 0 - - General - 3 - - 24 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - - - src - - CppUTest - - $PROJ_DIR$\..\..\src\CppUTest\CommandLineArguments.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\CommandLineTestRunner.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\JUnitTestOutput.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\MemoryLeakDetector.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\MemoryLeakWarningPlugin.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\SimpleMutex.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\SimpleString.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\SimpleStringInternalCache.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TeamCityTestOutput.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestFailure.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestFilter.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestHarness_c.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestMemoryAllocator.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestOutput.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestPlugin.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestRegistry.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestResult.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\TestTestingFixture.cpp - - - $PROJ_DIR$\..\..\src\CppUTest\Utest.cpp - - - - Platforms - - Iar - - $PROJ_DIR$\..\..\src\Platforms\Iar\UtestPlatform.cpp - - - - - - - diff --git a/platforms/iar/CppUTest.eww b/platforms/iar/CppUTest.eww deleted file mode 100644 index 004925c23..000000000 --- a/platforms/iar/CppUTest.eww +++ /dev/null @@ -1,19 +0,0 @@ - - - - - $WS_DIR$\CppUTest.ewp - - - $WS_DIR$\CppUTestExt.ewp - - - $WS_DIR$\CppUTestExtTest.ewp - - - $WS_DIR$\CppUTestTest.ewp - - - - - diff --git a/platforms/iar/CppUTestExt.ewp b/platforms/iar/CppUTestExt.ewp deleted file mode 100644 index 429c3f5cf..000000000 --- a/platforms/iar/CppUTestExt.ewp +++ /dev/null @@ -1,1993 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - General - 3 - - 24 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BILINK - 0 - - - - - Release - - ARM - - 0 - - General - 3 - - 24 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - - - src - - CppUTestExt - - $PROJ_DIR$\..\..\src\CppUTestExt\CodeMemoryReportFormatter.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\GTest.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\IEEE754ExceptionsPlugin.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MemoryReportAllocator.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MemoryReporterPlugin.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MemoryReportFormatter.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockActualCall.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockExpectedCall.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockExpectedCallsList.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockFailure.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockNamedValue.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockSupport.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockSupport_c.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\MockSupportPlugin.cpp - - - $PROJ_DIR$\..\..\src\CppUTestExt\OrderedTest.cpp - - - - Platforms - - Iar - - $PROJ_DIR$\..\..\src\Platforms\Iar\UtestPlatform.cpp - - - - - - - diff --git a/platforms/iar/CppUTestExtTest.ewp b/platforms/iar/CppUTestExtTest.ewp deleted file mode 100644 index 6ad4084c7..000000000 --- a/platforms/iar/CppUTestExtTest.ewp +++ /dev/null @@ -1,2048 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - General - 3 - - 24 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BILINK - 0 - - - - - Release - - ARM - - 0 - - General - 3 - - 24 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - - - tests - - failing - - - passing - - $PROJ_DIR$\..\..\tests\CppUTestExt\CodeMemoryReporterTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\ExpectedFunctionsListTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\GMockTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\GTest1Test.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\GTest2ConvertorTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\IEEE754PluginTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\IEEE754PluginTest_c.c - - - $PROJ_DIR$\..\..\tests\CppUTestExt\IEEE754PluginTest_c.h - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MemoryReportAllocatorTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MemoryReporterPluginTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MemoryReportFormatterTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockActualCallTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockCallTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockCheatSheetTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockComparatorCopierTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockExpectedCallTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockFailureReporterForTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockFailureReporterForTest.h - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockFailureTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockHierarchyTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockNamedValueTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockParameterTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockPluginTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockReturnValueTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockStrictOrderTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockSupport_cTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockSupport_cTestCFile.c - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockSupport_cTestCFile.h - - - $PROJ_DIR$\..\..\tests\CppUTestExt\MockSupportTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest.h - - - $PROJ_DIR$\..\..\tests\CppUTestExt\OrderedTestTest_c.c - - - - warnings - - - $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 deleted file mode 100644 index 23bfb64c3..000000000 --- a/platforms/iar/CppUTestExtTest.icf +++ /dev/null @@ -1,72 +0,0 @@ -/*###ICF### Section handled by ICF editor, don't touch! ****/ -/*-Editor annotation file-*/ -/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_1.xml" */ -/*-Specials-*/ -define symbol __ICFEDIT_intvec_start__ = 0x00000000; -/*-Memory Regions-*/ -define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080; -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; -define symbol __ICFEDIT_region_EROM1_end__ = 0x0; -define symbol __ICFEDIT_region_EROM2_start__ = 0x0; -define symbol __ICFEDIT_region_EROM2_end__ = 0x0; -define symbol __ICFEDIT_region_EROM3_start__ = 0x0; -define symbol __ICFEDIT_region_EROM3_end__ = 0x0; -define symbol __ICFEDIT_region_IRAM1_start__ = 0x00100000; -define symbol __ICFEDIT_region_IRAM1_end__ = 0x001FFFFF; -define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; -define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; -define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; -define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; -define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; -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__ = 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__ = 0x10000; -/**** End of ICF editor section. ###ICF###*/ - -define memory mem with size = 4G; -define region IROM_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__] - | mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; -define region EROM_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__] - | mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__] - | mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; -define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] - | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; -define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] - | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] - | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; - -define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; -define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { }; -define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { }; -define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { }; -define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { }; -define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { }; -define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; - -do not initialize { section .noinit }; -initialize by copy { readwrite }; -if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) -{ - // Required in a multi-threaded application - initialize by copy with packing = none { section __DLIB_PERTHREAD }; -} - -place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; - -place in IROM_region { readonly }; -place in EROM_region { readonly section application_specific_ro }; -place in IRAM_region { readwrite, - block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK, - block UND_STACK, block ABT_STACK, block HEAP }; -place in ERAM_region { readwrite section application_specific_rw }; \ No newline at end of file diff --git a/platforms/iar/CppUTestTest.ewd b/platforms/iar/CppUTestTest.ewd deleted file mode 100644 index 1c6f889c9..000000000 --- a/platforms/iar/CppUTestTest.ewd +++ /dev/null @@ -1,3269 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - C-SPY - 2 - - 28 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 1 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 1 - - - - - - - - - - - - CADI_ID - 2 - - 0 - 1 - 1 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 1 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 1 - - - - - - - - - IJET_ID - 2 - - 8 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 1 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 1 - - - - - - - - RDI_ID - 2 - - 2 - 1 - 1 - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 3 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 1 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 1 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 5 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - - - Release - - ARM - - 0 - - C-SPY - 2 - - 28 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ARMSIM_ID - 2 - - 1 - 1 - 0 - - - - - - - - ANGEL_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - - CADI_ID - 2 - - 0 - 1 - 0 - - - - - - - - - CMSISDAP_ID - 2 - - 4 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GDBSERVER_ID - 2 - - 0 - 1 - 0 - - - - - - - - - - - IARROM_ID - 2 - - 1 - 1 - 0 - - - - - - - - - IJET_ID - 2 - - 8 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - JLINK_ID - 2 - - 16 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LMIFTDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - MACRAIGOR_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - PEMICRO_ID - 2 - - 3 - 1 - 0 - - - - - - - - RDI_ID - 2 - - 2 - 1 - 0 - - - - - - - - - - - - - - - - STLINK_ID - 2 - - 3 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - THIRDPARTY_ID - 2 - - 0 - 1 - 0 - - - - - - - - TIFET_ID - 2 - - 1 - 1 - 0 - - - - - - - - - - - - - - - - - - - XDS100_ID - 2 - - 5 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $TOOLKIT_DIR$\plugins\middleware\HCCWare\HCCWare.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\middleware\PercepioTraceExporter\PercepioTraceExportPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\AVIX\AVIX.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\CMX\CmxTinyArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\embOS\embOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\MQX\MQXRtosPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\Quadros\Quadros_EWB7_Plugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin - 0 - - - $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin - 0 - - - $EW_DIR$\common\plugins\CodeCoverage\CodeCoverage.ENU.ewplugin - 1 - - - $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin - 0 - - - $EW_DIR$\common\plugins\uCProbe\uCProbePlugin.ENU.ewplugin - 0 - - - - - - diff --git a/platforms/iar/CppUTestTest.ewp b/platforms/iar/CppUTestTest.ewp deleted file mode 100644 index c1283fe9e..000000000 --- a/platforms/iar/CppUTestTest.ewp +++ /dev/null @@ -1,2053 +0,0 @@ - - - - 2 - - Debug - - ARM - - 1 - - General - 3 - - 24 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 1 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 1 - - - - - - - BILINK - 0 - - - - - Release - - ARM - - 0 - - General - 3 - - 24 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ICCARM - 2 - - 31 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AARM - 2 - - 9 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - OBJCOPY - 0 - - 1 - 1 - 0 - - - - - - - - - CUSTOM - 3 - - - - 0 - - - - BICOMP - 0 - - - - BUILDACTION - 1 - - - - - - - ILINK - 0 - - 18 - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IARCHIVE - 0 - - 0 - 1 - 0 - - - - - - - BILINK - 0 - - - - - tests - - failing - - - passing - - $PROJ_DIR$\..\..\tests\CppUTest\AllocationInCFile.c - - - $PROJ_DIR$\..\..\tests\CppUTest\AllocationInCppFile.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\AllocLetTestFree.c - - - $PROJ_DIR$\..\..\tests\CppUTest\AllocLetTestFreeTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\CheatSheetTest.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 - - - $PROJ_DIR$\..\..\tests\CppUTest\MemoryLeakDetectorTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\MemoryLeakWarningTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\MemoryOperatorOverloadTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\PluginTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\PreprocessorTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\SetPluginTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\SimpleMutexTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\SimpleStringCacheTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\SimpleStringTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TeamCityOutputTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestFailureNaNTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestFailureTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestFilterTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestHarness_cTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestHarness_cTestCFile.c - - - $PROJ_DIR$\..\..\tests\CppUTest\TestInstallerTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestMemoryAllocatorTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestOutputTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestRegistryTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestResultTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestUTestMacro.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\TestUTestStringMacro.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\UtestPlatformTest.cpp - - - $PROJ_DIR$\..\..\tests\CppUTest\UtestTest.cpp - - - - warnings - - - $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 deleted file mode 100644 index 23bfb64c3..000000000 --- a/platforms/iar/CppUTestTest.icf +++ /dev/null @@ -1,72 +0,0 @@ -/*###ICF### Section handled by ICF editor, don't touch! ****/ -/*-Editor annotation file-*/ -/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_1.xml" */ -/*-Specials-*/ -define symbol __ICFEDIT_intvec_start__ = 0x00000000; -/*-Memory Regions-*/ -define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080; -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; -define symbol __ICFEDIT_region_EROM1_end__ = 0x0; -define symbol __ICFEDIT_region_EROM2_start__ = 0x0; -define symbol __ICFEDIT_region_EROM2_end__ = 0x0; -define symbol __ICFEDIT_region_EROM3_start__ = 0x0; -define symbol __ICFEDIT_region_EROM3_end__ = 0x0; -define symbol __ICFEDIT_region_IRAM1_start__ = 0x00100000; -define symbol __ICFEDIT_region_IRAM1_end__ = 0x001FFFFF; -define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; -define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; -define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; -define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; -define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; -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__ = 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__ = 0x10000; -/**** End of ICF editor section. ###ICF###*/ - -define memory mem with size = 4G; -define region IROM_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__] - | mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; -define region EROM_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__] - | mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__] - | mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; -define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] - | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; -define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] - | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] - | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; - -define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; -define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { }; -define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { }; -define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { }; -define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { }; -define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { }; -define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; - -do not initialize { section .noinit }; -initialize by copy { readwrite }; -if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) -{ - // Required in a multi-threaded application - initialize by copy with packing = none { section __DLIB_PERTHREAD }; -} - -place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; - -place in IROM_region { readonly }; -place in EROM_region { readonly section application_specific_ro }; -place in IRAM_region { readwrite, - block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK, - block UND_STACK, block ABT_STACK, block HEAP }; -place in ERAM_region { readwrite section application_specific_rw }; \ No newline at end of file diff --git a/platforms/iar/tests/iar_argc_argv.c b/platforms/iar/tests/iar_argc_argv.c deleted file mode 100644 index e12de9d41..000000000 --- a/platforms/iar/tests/iar_argc_argv.c +++ /dev/null @@ -1,14 +0,0 @@ -#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/README b/platforms_examples/README deleted file mode 100644 index e4925fd0b..000000000 --- a/platforms_examples/README +++ /dev/null @@ -1,9 +0,0 @@ -Directory to place test examples for different toolchains/chips combinations. - -Source files from this directory is compiled to executable using CppUTest, - CppUTestExt and startup libraries from lib directory in CppUTest home. - -There is a sample eclipse project in armcc/AT91SAM7A3 folder. It may be used -to see at possibility way of cross development with CppUTest running in -target platform. It is based on Makefile. -Makefile need some Cygwin utility, so you need to install cygwin. diff --git a/platforms_examples/armcc/AT91SAM7A3/.cproject b/platforms_examples/armcc/AT91SAM7A3/.cproject deleted file mode 100644 index 3a097b784..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/.cproject +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms_examples/armcc/AT91SAM7A3/.project b/platforms_examples/armcc/AT91SAM7A3/.project deleted file mode 100644 index 9190a3d23..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - CppUTest AT91SAM7A3 sample project - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.core.ccnature - - diff --git a/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.jflash b/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.jflash deleted file mode 100644 index 1e286e568..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.jflash +++ /dev/null @@ -1,247 +0,0 @@ - AppVersion = 47803 -[GENERAL] - ConnectMode = 0 - CurrentFile = "obj/tst.mot" - DataFileSAddr = 0x00000000 - GUIMode = 0 - HostName = "" - TargetIF = 0 - USBPort = 0 - USBSerialNo = 0x00000000 -[JTAG] - IRLen = 0 - MultipleTargets = 0 - NumDevices = 0 - Speed0 = 30 - Speed1 = 400 - TAP_Number = 0 - UseAdaptive0 = 0 - UseAdaptive1 = 0 - UseMaxSpeed0 = 0 - UseMaxSpeed1 = 1 -[CPU] - CheckCoreID = 1 - ChipName = "Atmel AT91SAM7A3" - ClockSpeed = 0x003D0900 - Core = 0x070000FF - CoreID = 0x3F0F0F0F - CoreIDMask = 0xFFFFFFFF - DeviceFamily = 0x00000007 - EndianMode = 0 - HasInternalFlash = 1 - InitStep0_Action = "Write 32bit" - InitStep0_Comment = "Peripherial reset, need for disable WDT" - InitStep0_Value0 = 0xFFFFFD00 - InitStep0_Value1 = 0xA5000004 - InitStep10_Action = "Write 32bit" - InitStep10_Comment = "Unlock 0 region" - InitStep10_Value0 = 0xFFFFFF64 - InitStep10_Value1 = 0x5A000004 - InitStep11_Action = "Delay" - InitStep11_Comment = "" - InitStep11_Value0 = 0x00000000 - InitStep11_Value1 = 0x00000001 - InitStep12_Action = "Write 32bit" - InitStep12_Comment = "Unlock 1 region" - InitStep12_Value0 = 0xFFFFFF64 - InitStep12_Value1 = 0x5A001004 - InitStep13_Action = "Delay" - InitStep13_Comment = "" - InitStep13_Value0 = 0x00000000 - InitStep13_Value1 = 0x00000001 - InitStep14_Action = "Write 32bit" - InitStep14_Comment = "Unlock 2 region" - InitStep14_Value0 = 0xFFFFFF64 - InitStep14_Value1 = 0x5A002004 - InitStep15_Action = "Delay" - InitStep15_Comment = "" - InitStep15_Value0 = 0x00000000 - InitStep15_Value1 = 0x00000001 - InitStep16_Action = "Write 32bit" - InitStep16_Comment = "Unlock 3 region" - InitStep16_Value0 = 0xFFFFFF64 - InitStep16_Value1 = 0x5A003004 - InitStep17_Action = "Delay" - InitStep17_Comment = "" - InitStep17_Value0 = 0x00000000 - InitStep17_Value1 = 0x00000001 - InitStep18_Action = "Write 32bit" - InitStep18_Comment = "Unlock 4 region" - InitStep18_Value0 = 0xFFFFFF64 - InitStep18_Value1 = 0x5A004004 - InitStep19_Action = "Delay" - InitStep19_Comment = "" - InitStep19_Value0 = 0x00000000 - InitStep19_Value1 = 0x00000001 - InitStep1_Action = "Reset" - InitStep1_Comment = "" - InitStep1_Value0 = 0x00000000 - InitStep1_Value1 = 0x00000000 - InitStep20_Action = "Write 32bit" - InitStep20_Comment = "Unlock 5 region" - InitStep20_Value0 = 0xFFFFFF64 - InitStep20_Value1 = 0x5A005004 - InitStep21_Action = "Delay" - InitStep21_Comment = "" - InitStep21_Value0 = 0x00000000 - InitStep21_Value1 = 0x00000001 - InitStep22_Action = "Write 32bit" - InitStep22_Comment = "Unlock 6 region" - InitStep22_Value0 = 0xFFFFFF64 - InitStep22_Value1 = 0x5A006004 - InitStep23_Action = "Delay" - InitStep23_Comment = "" - InitStep23_Value0 = 0x00000000 - InitStep23_Value1 = 0x00000001 - InitStep24_Action = "Write 32bit" - InitStep24_Comment = "Unlock 7 region" - InitStep24_Value0 = 0xFFFFFF64 - InitStep24_Value1 = 0x5A007004 - InitStep25_Action = "Delay" - InitStep25_Comment = "" - InitStep25_Value0 = 0x00000000 - InitStep25_Value1 = 0x00000001 - InitStep26_Action = "Write 32bit" - InitStep26_Comment = "Unlock 8 region" - InitStep26_Value0 = 0xFFFFFF64 - InitStep26_Value1 = 0x5A008004 - InitStep27_Action = "Delay" - InitStep27_Comment = "" - InitStep27_Value0 = 0x00000000 - InitStep27_Value1 = 0x00000001 - InitStep28_Action = "Write 32bit" - InitStep28_Comment = "Unlock 9 region" - InitStep28_Value0 = 0xFFFFFF64 - InitStep28_Value1 = 0x5A009004 - InitStep29_Action = "Delay" - InitStep29_Comment = "" - InitStep29_Value0 = 0x00000000 - InitStep29_Value1 = 0x00000001 - InitStep2_Action = "Delay" - InitStep2_Comment = "" - InitStep2_Value0 = 0x00000000 - InitStep2_Value1 = 0x00000002 - InitStep30_Action = "Write 32bit" - InitStep30_Comment = "Unlock 10 region" - InitStep30_Value0 = 0xFFFFFF64 - InitStep30_Value1 = 0x5A00A004 - InitStep31_Action = "Delay" - InitStep31_Comment = "" - InitStep31_Value0 = 0x00000000 - InitStep31_Value1 = 0x00000001 - InitStep32_Action = "Write 32bit" - InitStep32_Comment = "Unlock 11 region" - InitStep32_Value0 = 0xFFFFFF64 - InitStep32_Value1 = 0x5A00B004 - InitStep33_Action = "Delay" - InitStep33_Comment = "" - InitStep33_Value0 = 0x00000000 - InitStep33_Value1 = 0x00000001 - InitStep34_Action = "Write 32bit" - InitStep34_Comment = "Unlock 12 region" - InitStep34_Value0 = 0xFFFFFF64 - InitStep34_Value1 = 0x5A00C004 - InitStep35_Action = "Delay" - InitStep35_Comment = "" - InitStep35_Value0 = 0x00000000 - InitStep35_Value1 = 0x00000001 - InitStep36_Action = "Write 32bit" - InitStep36_Comment = "Unlock 13 region" - InitStep36_Value0 = 0xFFFFFF64 - InitStep36_Value1 = 0x5A00D004 - InitStep37_Action = "Delay" - InitStep37_Comment = "" - InitStep37_Value0 = 0x00000000 - InitStep37_Value1 = 0x00000001 - InitStep38_Action = "Write 32bit" - InitStep38_Comment = "Unlock 14 region" - InitStep38_Value0 = 0xFFFFFF64 - InitStep38_Value1 = 0x5A00E004 - InitStep39_Action = "Delay" - InitStep39_Comment = "" - InitStep39_Value0 = 0x00000000 - InitStep39_Value1 = 0x00000001 - InitStep3_Action = "Write 32bit" - InitStep3_Comment = "Disable watchdog" - InitStep3_Value0 = 0xFFFFFD44 - InitStep3_Value1 = 0x00008000 - InitStep40_Action = "Write 32bit" - InitStep40_Comment = "Unlock 15 region" - InitStep40_Value0 = 0xFFFFFF64 - InitStep40_Value1 = 0x5A00F004 - InitStep41_Action = "Delay" - InitStep41_Comment = "" - InitStep41_Value0 = 0x00000000 - InitStep41_Value1 = 0x00000001 - InitStep4_Action = "Write 32bit" - InitStep4_Comment = "Set PLL" - InitStep4_Value0 = 0xFFFFFC20 - InitStep4_Value1 = 0x00000601 - InitStep5_Action = "Delay" - InitStep5_Comment = "" - InitStep5_Value0 = 0x00000000 - InitStep5_Value1 = 0x00000002 - InitStep6_Action = "Write 32bit" - InitStep6_Comment = "Set PLL and divider" - InitStep6_Value0 = 0xFFFFFC2C - InitStep6_Value1 = 0x00C79E04 - InitStep7_Action = "Write 32bit" - InitStep7_Comment = "4MHz" - InitStep7_Value0 = 0xFFFFFC30 - InitStep7_Value1 = 0x00000001 - InitStep8_Action = "Delay" - InitStep8_Comment = "" - InitStep8_Value0 = 0x00000000 - InitStep8_Value1 = 0x00000002 - InitStep9_Action = "Write 32bit" - InitStep9_Comment = "Set WS = 2 (for write), FCN = 6 for 4 MHz" - InitStep9_Value0 = 0xFFFFFF60 - InitStep9_Value1 = 0x00060000 - NumExitSteps = 0 - NumInitSteps = 42 - RAMAddr = 0x00200000 - RAMSize = 0x00004000 - ScriptFile = "" - UseAutoSpeed = 0x00000001 - UseRAM = 1 - UseScriptFile = 0 -[FLASH] - aSectorSel[1024] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 - AutoDetect = 0 - BankName = "" - BankSelMode = 0 - BaseAddr = 0x00100000 - CheckId = 0 - CustomRAMCode = "" - DeviceName = "AT91SAM7A3 internal" - EndBank = 1023 - NumBanks = 1 - OrgNumBits = 32 - OrgNumChips = 1 - StartBank = 0 - UseCustomRAMCode = 0 -[PRODUCTION] - AutoPerformsErase = 1 - AutoPerformsHardLock = 0 - AutoPerformsHardUnlock = 0 - AutoPerformsProgram = 1 - AutoPerformsSecure = 0 - AutoPerformsSoftLock = 0 - AutoPerformsSoftUnlock = 1 - AutoPerformsStartApp = 1 - AutoPerformsUnsecure = 0 - AutoPerformsVerify = 1 - EnableProductionMode = 0 - EnableTargetPower = 1 - EraseType = 1 - ProductionDelay = 0x000001F4 - ProductionThreshold = 0x00000BB8 - ProgramSN = 0 - SerialFile = "" - SNAddr = 0x00000000 - SNInc = 0x00000001 - SNLen = 0x00000008 - SNListFile = "" - SNValue = 0x00000001 - TargetPowerDelay = 0x00000014 - VerifyType = 2 diff --git a/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.launch b/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.launch deleted file mode 100644 index 547685818..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/AT91SAM7A3.launch +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms_examples/armcc/AT91SAM7A3/HEAP.txt b/platforms_examples/armcc/AT91SAM7A3/HEAP.txt deleted file mode 100644 index 6ec80d250..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/HEAP.txt +++ /dev/null @@ -1,4 +0,0 @@ -Heap usage for initialization of std::cout is about 1496 bytes. -Additional heap usage for std::cout << (double) is about 644 bytes. - -All heap usage for CRT + cpp + sample tests is about 10624 bytes. \ No newline at end of file diff --git a/platforms_examples/armcc/AT91SAM7A3/LICENSE b/platforms_examples/armcc/AT91SAM7A3/LICENSE deleted file mode 100644 index 4f4994441..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -No any additional license is used except standard Keil MDK-ARM license. - -If you use Keil MDK-ARM or ARM C/C++ then you agreed with terms of -Keil MDK-ARM license. - diff --git a/platforms_examples/armcc/AT91SAM7A3/Makefile b/platforms_examples/armcc/AT91SAM7A3/Makefile deleted file mode 100644 index 125f751ea..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/Makefile +++ /dev/null @@ -1,321 +0,0 @@ -.SILENT: - -#We don't need to clean up when we're making these targets -NODEPS = clean - -# CPU architecture. Passing to armcc.exe. For list: armcc --cpu list -ifndef CPU - CPU = ARM7TDMI -endif - -# ARM/THUMB mode. Passing to armcc.exe. May be 'thumb' or 'arm' -ifndef CPU_MODE - CPU_MODE = thumb -endif - -TARGET_PLATFORM =armcc_$(CPU)_$(CPU_MODE) - -# Need to use only relative path! Path with logical letters does not working. -CPPUTEST_HOME = ../../.. - -COMPONENT_NAME = app - -CPPUTEST_OBJS_DIR = objs - -# directory for appication library -CPPUTEST_LIB_DIR = lib - -CPPUTEST_USE_MEM_LEAK_DETECTION = N -CPPUTEST_USE_STD_CPP_LIB = Y -CPPUTEST_USE_VPATH = Y -CPPUTEST_USE_STD_C_LIB = Y -CPPUTEST_ENABLE_DEBUG = Y -CPPUTEST_USE_EXTENSIONS = N - -SRC_DIRS = \ - -SRC_FILES = $(CPPUTEST_HOME)/examples/ApplicationLib/CircularBuffer.cpp \ - $(CPPUTEST_HOME)/examples/ApplicationLib/Printer.cpp - -TEST_SRC_DIRS = \ - tests \ - -TEST_FILES = $(CPPUTEST_HOME)/examples/AllTests/CircularBufferTest.cpp - - -# directory with CppUTest and startup libraries -CPPUTEST_LIB_LINK_DIR = $(CPPUTEST_HOME)/lib/$(TARGET_PLATFORM) - -INCLUDE_DIRS = \ - $(CPPUTEST_HOME)/include \ - $(SRC_DIRS) \ - $(CPPUTEST_HOME)/examples/ApplicationLib \ - -# name of extension of output file. Default Keil MDK-ARM extension is .axf which is elf format -# .axf will be .elf for eclipse debug -OUTFILE_EXT = elf - -# output filename, mapfile (.map), hexfile (.mot) -OUTNAME = $(COMPONENT_NAME) -OUTFILE = $(OUTNAME).$(OUTFILE_EXT) -HEXFILE = $(OUTNAME).mot -MAPFILE = $(OUTNAME).map - -# CYGWIN path -CYGWIN =C:/CYGWIN/bin -MKDIR =$(CYGWIN)/mkdir -RM =$(CYGWIN)/rm -TOUCH =$(CYGWIN)/touch -ECHO =$(CYGWIN)/echo - -KEIL_DIR=D:/Keil/ARM/ARMCC -CC=$(KEIL_DIR)/bin/armcc.exe -AS=$(KEIL_DIR)/bin/armasm.exe -AR=$(KEIL_DIR)/bin/armar.exe -LD=$(KEIL_DIR)/bin/armlink.exe -FROMELF=$(KEIL_DIR)/bin/fromelf.exe -# armcc system include path -SYS_INCLUDE_DIRS =$(KEIL_DIR)/include - -JFLASH ="C:/Program Files (x86)/SEGGER/JLink_V490b/JFlash.exe" -JFLASHPRJ =AT91SAM7A3.jflash -LDSCRIPT = ROM.sct - -CPUFLAGS =--cpu=$(CPU) -ifeq ($(CPU_MODE), thumb) - CPUFLAGS +=--apcs=/interwork -endif -DEPFLAGS =-M \ - $(INCLUDES) \ - --depend_format=unix_escaped \ - --depend_single_line \ - --no_depend_system_headers - -OPTFLAGS =-O3 - -CPPUTEST_CPPFLAGS =$(CPUFLAGS) \ - $(OPTFLAGS) \ - -c \ - -g \ - $(INCLUDES) \ - --$(CPU_MODE) \ - --exceptions \ - -D__CLK_TCK=1000 \ - -CPPUTEST_LDFLAGS =$(CPUFLAGS) \ - --strict \ - --entry=Reset_Handler \ - --summary_stderr \ - --map \ - --callgraph \ - --info=summarysizes \ - --info=sizes \ - --info=totals \ - --info=veneers\ - --load_addr_map_info \ - --library_type=standardlib \ - --remove \ - --debug \ - -ARFLAGS = --debug_symbols - - -# new and delete for memory leak detection on by default -ifndef CPPUTEST_USE_MEM_LEAK_DETECTION - CPPUTEST_USE_MEM_LEAK_DETECTION = Y -endif - -# Use the standard C library -ifndef CPPUTEST_USE_STD_C_LIB - CPPUTEST_USE_STD_C_LIB = Y -endif - -# Use the standard C++ library -ifndef CPPUTEST_USE_STD_CPP_LIB - CPPUTEST_USE_STD_CPP_LIB = Y -endif - -# No extentions is default -ifndef CPPUTEST_USE_EXTENSIONS - CPPUTEST_USE_EXTENSIONS = N -endif - -# No VPATH is default -ifndef CPPUTEST_USE_VPATH - CPPUTEST_USE_VPATH = N -endif -# Make empty, instead of 'N', for usage in $(if ) conditionals -ifneq ($(CPPUTEST_USE_VPATH), Y) - CPPUTEST_USE_VPATH = -endif - -# Without the C library, we'll need to disable the C++ library and ... -ifeq ($(CPPUTEST_USE_STD_C_LIB), N) - CPPUTEST_USE_STD_CPP_LIB = N - CPPUTEST_USE_MEM_LEAK_DETECTION = N - CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_C_LIB_DISABLED - CPPUTEST_LDFLAGS +=--no_scanlib -else - INCLUDE_DIRS +=$(SYS_INCLUDE_DIRS) -endif - - -ifeq ($(CPPUTEST_USE_MEM_LEAK_DETECTION), N) - CPPUTEST_CPPFLAGS += -DCPPUTEST_MEM_LEAK_DETECTION_DISABLED -else - ifndef CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE - CPPUTEST_MEMLEAK_DETECTOR_NEW_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorNewMacros.h - endif - ifndef CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE - CPPUTEST_MEMLEAK_DETECTOR_MALLOC_MACRO_FILE = -include $(CPPUTEST_HOME)/include/CppUTest/MemoryLeakDetectorMallocMacros.h - endif -endif - - -ifeq ($(CPPUTEST_USE_STD_CPP_LIB), N) - CPPUTEST_CPPFLAGS += -DCPPUTEST_STD_CPP_LIB_DISABLED -endif - -# Link with CppUTest lib -CPPUTEST_LIB = $(CPPUTEST_LIB_LINK_DIR)/libCppUTest.a - -# Link with startup lib -CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libStartup_AT91SAM7A3.a - -# Link with CppUTestExt lib -ifeq ($(CPPUTEST_USE_EXTENSIONS), Y) -CPPUTEST_LIB += $(CPPUTEST_LIB_LINK_DIR)/libCppUTestExt.a -endif - -TARGET_LIB = \ - $(CPPUTEST_LIB_DIR)/lib$(COMPONENT_NAME).a - -ifndef TEST_TARGET - ifndef TARGET_PLATFORM - TEST_TARGET = $(COMPONENT_NAME)_tests - else - TEST_TARGET = $(COMPONENT_NAME)_$(TARGET_PLATFORM)_tests - endif -endif - -#Helper Functions -get_src_from_dir = $(wildcard $1/*.cpp) $(wildcard $1/*.cc) $(wildcard $1/*.c) $(wildcard $1/*.asm) -get_src_from_dir_list = $(foreach dir, $1, $(call get_src_from_dir,$(dir))) -__src_to = $(subst .c,$1, $(subst .cc,$1, $(subst .cpp,$1, $(if $(CPPUTEST_USE_VPATH),$(notdir $2),$2)))) -src_to = $(addprefix $3/,$(call __src_to,$1,$2)) -src_to_o = $(call src_to,.o,$1,$2) -src_to_d = $(call src_to,.d,$1,$2) -time = $(shell date +%s) -delta_t = $(eval minus, $1, $2) -debug_print_list = $(foreach word,$1,echo " $(word)";) echo - -# исходники программных модулей -SRC = $(call get_src_from_dir_list, $(SRC_DIRS)) $(SRC_FILES) -OBJ = $(call src_to_o,$(SRC),$(CPPUTEST_OBJS_DIR)) -# исходники тестов -TEST_SRC = $(call get_src_from_dir_list, $(TEST_SRC_DIRS)) $(TEST_FILES) -TEST_OBJ = $(call src_to_o,$(TEST_SRC),$(CPPUTEST_OBJS_DIR)) - -# If we're using VPATH -ALL_SRC = $(SRC) $(TEST_SRC) -ifeq ($(CPPUTEST_USE_VPATH), Y) -# gather all the source directories and add them - VPATH += $(sort $(dir $(ALL_SRC))) -# Add the component name to the objs dir path, to differentiate between same-name objects - CPPUTEST_OBJS_DIR := $(addsuffix /$(COMPONENT_NAME),$(CPPUTEST_OBJS_DIR)) -endif - -# for building application library -INCLUDES += $(foreach dir, $(INCLUDE_DIRS), -I$(dir)) -DEP_FILES = $(call src_to_d, $(SRC), $(CPPUTEST_OBJS_DIR)) -DEP_TEST_FILES = $(call src_to_d, $(TEST_SRC), $(CPPUTEST_OBJS_DIR)) -STUFF_TO_CLEAN = $(OBJ) $(TEST_OBJ) $(DEP_FILES) $(DEP_TEST_FILES) $(TARGET_LIB) - -#Don't create CRT dependencies when we're cleaning, for instance -ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS)))) - -include $(DEP_FILES) -endif - -STUFF_TO_CLEAN += $(OUTFILE) $(MAPFILE) - - -all: $(CPPUTEST_OBJS_DIR)/$(OUTFILE) - echo Done! - -$(TARGET_LIB): $(OBJ) | $(CPPUTEST_LIB_DIR) - echo Building application library $@ - $(AR) $(ARFLAGS) --create $@ $^ - -$(CPPUTEST_OBJS_DIR)/$(OUTFILE): $(TEST_OBJ) $(CPPUTEST_LIB) $(TARGET_LIB) | ROM.sct Makefile - echo Linking! - $(LD) $(CPPUTEST_LDFLAGS) $^ --scatter $(LDSCRIPT) --list $(MAPFILE) -o $@ - - -.PHONY: prog -prog: $(CPPUTEST_OBJS_DIR)/$(HEXFILE) - $(JFLASH) -openprj$(JFLASHPRJ) -open$< -auto -exit - -$(CPPUTEST_OBJS_DIR)/$(HEXFILE): $(CPPUTEST_OBJS_DIR)/$(OUTFILE) - echo Converting to Motorola S19 - $(FROMELF) --m32 --output=$@ $< - -debug: - echo - echo "Target Source files:" - $(call debug_print_list,$(SRC)) - echo "Target Object files:" - $(call debug_print_list,$(OBJ)) - echo "All Input Dependency files:" - $(call debug_print_list,$(DEP_FILES)) - echo Stuff to clean: - $(call debug_print_list,$(STUFF_TO_CLEAN)) - echo Includes: - $(call debug_print_list,$(INCLUDES)) - echo Directories to create: - $(call debug_print_list,$(OBJS_DIRS)) - echo Directories of CppUTest object files: - $(call debug_print_list,$(OBJS_DIR)) - -#Don't create dependencies when we're cleaning, for instance -ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS)))) - -include $(DEP_FILES) -endif - -OBJS_DIRS =$(sort $(dir $(STUFF_TO_CLEAN))) - -$(LIB_DIR) $(OBJS_DIRS): - echo Updating directory $@ - $(MKDIR) -p $@ - -#This is the rule for creating the dependency files -$(CPPUTEST_OBJS_DIR)/%.d: %.c Makefile | $(OBJS_DIRS) - echo Compiling C file $< for dependency. Out file $@. - $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)' - -$(CPPUTEST_OBJS_DIR)/%.d: %.cpp Makefile | $(OBJS_DIRS) - echo Compiling C++ file $< for dependency. Out file $@. - $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)' - -$(CPPUTEST_OBJS_DIR)/%.d: %.cc Makefile | $(OBJS_DIRS) - echo Compiling CC++ file $< for dependency. Out file $@. - $(CC) $(DEPFLAGS) $< --depend=$@ --depend_target='$(patsubst %.d,%.o,$@)' - -#This rule does the compilation C++ files -$(CPPUTEST_OBJS_DIR)/%.o: %.cpp $(CPPUTEST_OBJS_DIR)/%.d - echo Compiling C++ file $<. Out file $@ - $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@ - -#This rule does the compilation CC++ files -$(CPPUTEST_OBJS_DIR)/%.o: %.cc $(CPPUTEST_OBJS_DIR)/%.d - echo Compiling CC++ file $<. Out file $@ - $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@ - -#This rule does the compilation C files -$(CPPUTEST_OBJS_DIR)/%.o: %.c $(CPPUTEST_OBJS_DIR)/%.d - echo Compiling C file $<. Out file $@ - $(CC) $(CPPUTEST_CPPFLAGS) $< -o $@ - -clean: - $(RM) -f $(STUFF_TO_CLEAN) - - diff --git a/platforms_examples/armcc/AT91SAM7A3/RAM.txt b/platforms_examples/armcc/AT91SAM7A3/RAM.txt deleted file mode 100644 index 2514ad0c1..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/RAM.txt +++ /dev/null @@ -1,7 +0,0 @@ -bss memory usage for std::cout is about 12248 bytes - -Library cpp_ts(ios.o) needs two big regions of 7472 and 4104 bytes and other - small regions. - -More than 8k needed for statically created arrays with size - SetPointerPlugin::MAX_SET diff --git a/platforms_examples/armcc/AT91SAM7A3/README b/platforms_examples/armcc/AT91SAM7A3/README deleted file mode 100644 index b03624fcc..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/README +++ /dev/null @@ -1,55 +0,0 @@ -Sample project to test CppUTest for Keil MDK-ARM toolchain and AT91SAM7A3 chip. - -Requirements: -1. CYGWIN (rm.exe, mkdir.exe, make.exe) - -2. Keil MDK-ARM - -3. JLink Flash (for programming chip) - -4. serial connection to DBGU interface - -5. 4 MHz quartz. If else, need to be adjusted in - $(CPPUTEST_HOME)/platforms_startup/armcc/AT91SAM7A3/SAM7A3.asm - (for setup PLL and change core clock from IRC to PLL) - and - $(CPPUTEST_HOME)/platforms_startup/armcc/AT91SAM7A3/Retarget.c - (for _clock_init() function working correctly) - -6. eclipse + gdb server from JLink + arm-none-eabi-gdb from GNU ARM Tools Embedded - For debug only. - -First, you need to compile CppUTest and target startup library: - make -C ../../../platforms/armcc - make -C ../../../platforms_startup/armcc/AT91SAM7A3 - -Second, you need to write tests. As example, I use - $(CPPUTEST_HOME)/examples/AllTests/CircularBufferTest.cpp. - All test from $(CPPUTEST_HOME)/examples/AllTests/ needs to many - RAM (chip does not have such). - -Third, you need to make executable: - make all - -Fourth, you need to program executable on target chip: - make prog - -Project use semihosting, so you may use standard printf() or std::cout << "Hello!" - -If problems with heap or low memory, adjust heap size in - $(CPPUTEST_HOME)/platforms_startup/armcc/AT91SAM7A3/SAM7A3.asm - and rebuild startup library. - -Startup library uses standard Keil MDK-ARM license. - -Eclipse project is tested in eclipse Kepler, eclipse Luna. -You need to adjust some environment variables in "C/C++ Build" tab in -properties window for project. -"CPPUTEST_HOME" is a path to root of CppUTest -"KEIL_DIR" is a path to ARM C/C++ compiler -"PATH" there is need to add path to make.exe -Eclipse project use plugin "GDB Hardware Debugger" to debug, so for debug -you may install "GDB Hardware Debugger" and gdb client (from -GNU ARM Tools Embedded) or create your own debug configuration -(for exampe, use eclipse plugin from Keil MDK-ARM installation; no need to -install other plugins and toolchains). diff --git a/platforms_examples/armcc/AT91SAM7A3/ROM.sct b/platforms_examples/armcc/AT91SAM7A3/ROM.sct deleted file mode 100644 index fdec39576..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/ROM.sct +++ /dev/null @@ -1,34 +0,0 @@ -#! armcc -E -; code upper need to use #define - -;------------------------------------------------------------------------------------- -; Keil scatter loading file -; For AT91SAM7A3 -;------------------------------------------------------------------------------------- - -#define FLASH_START (0x00100000) -#define FLASH_END (0x00140000) -#define FLASH_SIZE (FLASH_END-FLASH_START) - -; Internal SRAM -#define RAM_START 0x00200000 -#define RAM_END 0x00208000 -#define RAM_SIZE (RAM_END-RAM_START) - -; Load region for main program -LR1 FLASH_START FLASH_SIZE { - ER2 FLASH_START { - *.o(.reset, +First) - *.o(InRoot$$Sections) - *.o(+RO) - } - ER5 RAM_START RAM_SIZE { - *.o(+RW +ZI) - *.o(STACK) - } -} - - - -/*----------------------------------------------------------------------------*/ - diff --git a/platforms_examples/armcc/AT91SAM7A3/STACK.txt b/platforms_examples/armcc/AT91SAM7A3/STACK.txt deleted file mode 100644 index 31b3197b5..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/STACK.txt +++ /dev/null @@ -1,14 +0,0 @@ -See objs/app/app.htm for details about stack sizes for functions and call tree. - -Stack usage for std::cout << (double) is about 1336 bytes - -Stack usage for CppUTest is at least 4368 bytes with call chain: -main -> - CommandLineTestRunner::RunAllTests(int, char**) -> - CommandLineTestRunner::RunAllTests(int, const char**) -> - MemoryLeakWarningPlugin::MemoryLeakWarningPlugin(const SimpleString&, MemoryLeakDetector*) -> - MemoryLeakWarningPlugin::getGlobalDetector() -> - MemoryLeakDetector::MemoryLeakDetector(MemoryLeakFailure*) -> - MemoryLeakDetectorTable::MemoryLeakDetectorTable() -> - __aeabi_vec_ctor_nocookie_nodtor -Maximum stack consumption for constructor MemoryLeakDetector::MemoryLeakDetector(MemoryLeakFailure*) diff --git a/platforms_examples/armcc/AT91SAM7A3/jlink_gdb.cmd b/platforms_examples/armcc/AT91SAM7A3/jlink_gdb.cmd deleted file mode 100644 index 8dbc18e5a..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/jlink_gdb.cmd +++ /dev/null @@ -1 +0,0 @@ -start "JLink GDB Server" "C:\Program Files (x86)\SEGGER\JLink_V490b\JLinkGDBServerCL.exe" -device AT91SAM7A3 diff --git a/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp b/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp deleted file mode 100644 index 8199883d5..000000000 --- a/platforms_examples/armcc/AT91SAM7A3/tests/main.cpp +++ /dev/null @@ -1,34 +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, char** av) -{ - return RUN_ALL_TESTS(ac, av); -} - diff --git a/platforms_examples/armcc/LPC1768/.cproject b/platforms_examples/armcc/LPC1768/.cproject deleted file mode 100644 index 59508320c..000000000 --- a/platforms_examples/armcc/LPC1768/.cproject +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms_examples/armcc/LPC1768/.project b/platforms_examples/armcc/LPC1768/.project deleted file mode 100644 index 1ea89b7ea..000000000 --- a/platforms_examples/armcc/LPC1768/.project +++ /dev/null @@ -1,26 +0,0 @@ - - - cpputest_example - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - - - - - 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/platforms_examples/armcc/LPC1768/LPC1768.jflash b/platforms_examples/armcc/LPC1768/LPC1768.jflash deleted file mode 100644 index 9179a9d76..000000000 --- a/platforms_examples/armcc/LPC1768/LPC1768.jflash +++ /dev/null @@ -1,83 +0,0 @@ - AppVersion = 46202 -[GENERAL] - ConnectMode = 0 - CurrentFile = "objs/app/app.mot" - DataFileSAddr = 0x00000000 - GUIMode = 0 - HostName = "" - TargetIF = 1 - USBPort = 0 - USBSerialNo = 0x00000000 -[JTAG] - IRLen = 0 - MultipleTargets = 0 - NumDevices = 0 - Speed0 = 5 - Speed1 = 4000 - TAP_Number = 0 - UseAdaptive0 = 0 - UseAdaptive1 = 0 - UseMaxSpeed0 = 1 - UseMaxSpeed1 = 1 -[CPU] - CheckCoreID = 1 - ChipName = "NXP LPC1768" - ClockSpeed = 0x05F5E100 - Core = 0x030000FF - CoreID = 0x4BA00477 - CoreIDMask = 0xFFFFFFFF - DeviceFamily = 0x00000003 - EndianMode = 0 - HasInternalFlash = 1 - InitStep0_Action = "Reset" - InitStep0_Comment = "Reset and halt target" - InitStep0_Value0 = 0x00000000 - InitStep0_Value1 = 0x00000000 - NumExitSteps = 0 - NumInitSteps = 1 - RAMAddr = 0x10000000 - RAMSize = 0x00008000 - ScriptFile = "" - UseAutoSpeed = 0x00000001 - UseRAM = 1 - UseScriptFile = 0 -[FLASH] - aSectorSel[30] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 - AutoDetect = 0 - BankName = "" - BankSelMode = 0 - BaseAddr = 0x00000000 - CheckId = 0 - CustomRAMCode = "" - DeviceName = "LPC1768 internal" - EndBank = 29 - NumBanks = 1 - OrgNumBits = 32 - OrgNumChips = 1 - StartBank = 0 - UseCustomRAMCode = 0 -[PRODUCTION] - AutoPerformsErase = 1 - AutoPerformsHardLock = 0 - AutoPerformsHardUnlock = 0 - AutoPerformsProgram = 1 - AutoPerformsSecure = 0 - AutoPerformsSoftLock = 0 - AutoPerformsSoftUnlock = 1 - AutoPerformsStartApp = 1 - AutoPerformsUnsecure = 0 - AutoPerformsVerify = 1 - EnableProductionMode = 0 - EnableTargetPower = 0 - EraseType = 2 - ProductionDelay = 0x000001F4 - ProductionThreshold = 0x00000BB8 - ProgramSN = 0 - SerialFile = "" - SNAddr = 0x00000000 - SNInc = 0x00000001 - SNLen = 0x00000008 - SNListFile = "" - SNValue = 0x00000001 - TargetPowerDelay = 0x00000014 - VerifyType = 1 diff --git a/platforms_examples/armcc/LPC1768/README b/platforms_examples/armcc/LPC1768/README deleted file mode 100644 index b41eefec7..000000000 --- a/platforms_examples/armcc/LPC1768/README +++ /dev/null @@ -1,40 +0,0 @@ -Sample project to test CppUTest for Keil MDK-ARM toolchain and LPC1768 chip. - -Requirements: -1. CYGWIN (rm.exe, mkdir.exe, make.exe) - -2. Keil MDK-ARM - -3. JLink Flash (for programming chip) or FlashMagic - -4. serial connection to UART0 or UART1 interface - -5. 12 or 24 MHz quartz. If else, need to be adjusted in - $(CPPUTEST_HOME)/platforms_startup/armcc/LPC1768/system_LPC17xx.c - (for _clock_init() function working correctly and to set up 100 MHz core - clock). - Please check system_LPC17xx.c for correct quartz selection in function - SystemInit(), and rebuild startup library for any change. - Default is 12 MHz quartz. - -6. eclipse + gdb server from JLink + arm-none-eabi-gdb from GNU ARM Tools Embedded - For debug only. - -First, you need to compile CppUTest and target startup library: - make -C ../../../platforms/armcc CPU=Cortex-M3 all - make -C ../../../platforms_startup/armcc/LPC1768 all - -Second, you need to write tests. As example, I use - $(CPPUTEST_HOME)/examples/AllTests/CircularBufferTest.cpp. - -Third, you need to make executable: - make all - -Fourth, you need to program executable on target chip: - make prog - -Project use semihosting, so you may use standard printf() or std::cout << "Hello!" - -If problems with heap or low memory, adjust heap size in - $(CPPUTEST_HOME)/platforms_startup/armcc/LPC1768/startup_LPC17xx.asm - and rebuild startup library. diff --git a/platforms_examples/armcc/LPC1768/ROM.sct b/platforms_examples/armcc/LPC1768/ROM.sct deleted file mode 100644 index 97783d246..000000000 --- a/platforms_examples/armcc/LPC1768/ROM.sct +++ /dev/null @@ -1,42 +0,0 @@ -#! armcc -E -; code upper need to use #define - -;------------------------------------------------------------------------------------- -; Keil scatter loading file -; For LPC1768 -;------------------------------------------------------------------------------------- - -#define FLASH_START (0x00000000) -#define FLASH_END (0x00080000) -#define FLASH_SIZE (FLASH_END-FLASH_START) - -; Internal SRAM -#define RAM1_START 0x10000000 -#define RAM1_END 0x10008000 -#define RAM1_SIZE (RAM1_END-RAM1_START) - -; Internal SRAM for peripherial DMA -#define RAM2_START 0x2007C000 -#define RAM2_END 0x20084000 -#define RAM2_SIZE (RAM2_END-RAM2_START) - -; Load region for main program -LR1 FLASH_START FLASH_SIZE { - ER1 FLASH_START { - *.o(RESET, +First) - *.o(InRoot$$Sections) - *.o(+RO) - } - ER2 RAM1_START RAM1_SIZE { - *.o(+RW +ZI) - } - ER3 RAM2_START RAM2_SIZE { - *.o(HEAP) - *.o(STACK) - } -} - - - -/*----------------------------------------------------------------------------*/ - diff --git a/platforms_examples/armcc/LPC1768/cpputest_example_Default.launch b/platforms_examples/armcc/LPC1768/cpputest_example_Default.launch deleted file mode 100644 index 8176b3b4a..000000000 --- a/platforms_examples/armcc/LPC1768/cpputest_example_Default.launch +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platforms_examples/armcc/LPC1768/jlink_gdb.cmd b/platforms_examples/armcc/LPC1768/jlink_gdb.cmd deleted file mode 100644 index 6db2e137d..000000000 --- a/platforms_examples/armcc/LPC1768/jlink_gdb.cmd +++ /dev/null @@ -1 +0,0 @@ -start "JLink GDB Server" "C:\Program Files (x86)\SEGGER\JLinkARM_V486a\JLinkGDBServerCL.exe" -device LPC1768 -if SWD diff --git a/platforms_examples/armcc/LPC1768/tests/main.cpp b/platforms_examples/armcc/LPC1768/tests/main.cpp deleted file mode 100644 index 254b171ae..000000000 --- a/platforms_examples/armcc/LPC1768/tests/main.cpp +++ /dev/null @@ -1,46 +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 -#include - -extern "C" void _clock_init(void); -extern std::uint32_t SystemCoreClock; -extern const std::uint32_t SystemCoreClock12; - -int main(int ac, char** av) -{ - SystemCoreClock = SystemCoreClock12; /* if 12 MHz quartz is used; need to LPC_TIM3 measure */ - _clock_init(); /* secondary call for new SystemCoreClock freq; previous call worked with unknown value */ - - std::cout << "Hello, World!\n"; - int result = RUN_ALL_TESTS(ac, av); - - return result; -} - diff --git a/platforms_examples/armcc/LPC1833/FLASH.sct b/platforms_examples/armcc/LPC1833/FLASH.sct deleted file mode 100644 index 6d2f0edaf..000000000 --- a/platforms_examples/armcc/LPC1833/FLASH.sct +++ /dev/null @@ -1,52 +0,0 @@ -#! armcc -E -; code upper need to use #define - -;------------------------------------------------------------------------------------- -; Keil scatter loading file -; For LPC1833 -;------------------------------------------------------------------------------------- - -; Internal SRAM0 -#define SRAM0_START 0x10000000 -#define SRAM0_END 0x10008000 -#define SRAM0_SIZE (SRAM0_END-SRAM0_START) - -; Internal SRAM1 -#define SRAM1_START 0x10080000 -#define SRAM1_END 0x1008A000 -#define SRAM1_SIZE (SRAM1_END-SRAM1_START) - -; Internal SRAM2 -#define SRAM2_START 0x20000000 -#define SRAM2_END 0x20010000 -#define SRAM2_SIZE (SRAM2_END-SRAM2_START) - -; SDRAM -#define SDRAM_START 0x28000000 - -; Internal FLASHA -#define FLASHA_START 0x1A000000 -#define FLASHA_END 0x1A040000 -#define FLASHA_SIZE (FLASHA_END-FLASHA_START) - -; Internal FLASHB -#define FLASHB_START 0x1B000000 -#define FLASHB_END 0x1B040000 -#define FLASHB_SIZE (FLASHB_END-FLASHB_START) - -LR1 FLASHA_START FLASHA_SIZE { - ER1 FLASHA_START FLASHA_SIZE { - *(RESET, +FIRST) - *(InRoot$$Sections) - *.o (+RO) - } - ER2 SRAM0_START SRAM0_SIZE { - *.o (+RW +ZI) - } - - ER4 (SRAM1_START) SRAM1_SIZE { - *(HEAP) - *(STACK) - } -} - diff --git a/platforms_examples/armcc/LPC1833/LPC1833.jflash b/platforms_examples/armcc/LPC1833/LPC1833.jflash deleted file mode 100644 index f5ecff1af..000000000 --- a/platforms_examples/armcc/LPC1833/LPC1833.jflash +++ /dev/null @@ -1,83 +0,0 @@ - AppVersion = 46202 -[GENERAL] - ConnectMode = 0 - CurrentFile = "objs\can_eth.hex" - DataFileSAddr = 0x00000000 - GUIMode = 0 - HostName = "" - TargetIF = 0 - USBPort = 0 - USBSerialNo = 0x00000000 -[JTAG] - IRLen = 0 - MultipleTargets = 0 - NumDevices = 0 - Speed0 = 5 - Speed1 = 4000 - TAP_Number = 0 - UseAdaptive0 = 0 - UseAdaptive1 = 0 - UseMaxSpeed0 = 1 - UseMaxSpeed1 = 1 -[CPU] - CheckCoreID = 1 - ChipName = "NXP LPC1833" - ClockSpeed = 0x016E3600 - Core = 0x030000FF - CoreID = 0x4BA00477 - CoreIDMask = 0x0F000FFF - DeviceFamily = 0x00000003 - EndianMode = 0 - HasInternalFlash = 1 - InitStep0_Action = "Reset" - InitStep0_Comment = "Reset and halt target" - InitStep0_Value0 = 0x00000000 - InitStep0_Value1 = 0x00000000 - NumExitSteps = 0 - NumInitSteps = 1 - RAMAddr = 0x10080000 - RAMSize = 0x00008000 - ScriptFile = "" - UseAutoSpeed = 0x00000001 - UseRAM = 1 - UseScriptFile = 0 -[FLASH] - aSectorSel[22] = 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 - AutoDetect = 0 - BankName = "" - BankSelMode = 0 - BaseAddr = 0x1A000000 - CheckId = 0 - CustomRAMCode = "" - DeviceName = "LPC1833 internal" - EndBank = 21 - NumBanks = 1 - OrgNumBits = 32 - OrgNumChips = 1 - StartBank = 0 - UseCustomRAMCode = 0 -[PRODUCTION] - AutoPerformsErase = 1 - AutoPerformsHardLock = 0 - AutoPerformsHardUnlock = 0 - AutoPerformsProgram = 1 - AutoPerformsSecure = 0 - AutoPerformsSoftLock = 0 - AutoPerformsSoftUnlock = 1 - AutoPerformsStartApp = 1 - AutoPerformsUnsecure = 0 - AutoPerformsVerify = 1 - EnableProductionMode = 0 - EnableTargetPower = 0 - EraseType = 1 - ProductionDelay = 0x000001F4 - ProductionThreshold = 0x00000BB8 - ProgramSN = 0 - SerialFile = "" - SNAddr = 0x00000000 - SNInc = 0x00000001 - SNLen = 0x00000008 - SNListFile = "" - SNValue = 0x00000001 - TargetPowerDelay = 0x00000014 - VerifyType = 1 diff --git a/platforms_examples/armcc/LPC1833/src/dummy.c b/platforms_examples/armcc/LPC1833/src/dummy.c deleted file mode 100644 index 99dbb9749..000000000 --- a/platforms_examples/armcc/LPC1833/src/dummy.c +++ /dev/null @@ -1,3 +0,0 @@ -/* this file is requred to build application library, armar.exe can't build - * libraries without at least one object input file. -*/ diff --git a/platforms_examples/armcc/LPC1833/tests/main.cpp b/platforms_examples/armcc/LPC1833/tests/main.cpp deleted file mode 100644 index f1299259f..000000000 --- a/platforms_examples/armcc/LPC1833/tests/main.cpp +++ /dev/null @@ -1,38 +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); - - return CommandLineTestRunner::RunAllTests(ac, av); -} - diff --git a/platforms_examples/armcc/LPC1833/tests/test1.cpp b/platforms_examples/armcc/LPC1833/tests/test1.cpp deleted file mode 100644 index cbbfad965..000000000 --- a/platforms_examples/armcc/LPC1833/tests/test1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "CppUTest/TestHarness.h" - -TEST_GROUP(start) -{ -}; - -TEST(start, first) -{ - FAIL("Start here!"); -} diff --git a/scripts/CppUnitTemplates/ClassName.cpp b/scripts/CppUnitTemplates/ClassName.cpp deleted file mode 100644 index c80207946..000000000 --- a/scripts/CppUnitTemplates/ClassName.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ClassName.h" - -ClassName::ClassName() -{ -} - -ClassName::~ClassName() -{ -} - diff --git a/scripts/CppUnitTemplates/ClassName.h b/scripts/CppUnitTemplates/ClassName.h deleted file mode 100644 index 88803e2ec..000000000 --- a/scripts/CppUnitTemplates/ClassName.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ClassName is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// - -class ClassName - { - public: - explicit ClassName(); - virtual ~ClassName(); - - private: - - ClassName(const ClassName&); - ClassName& operator=(const ClassName&); - - }; - -#endif // D_ClassName_H diff --git a/scripts/CppUnitTemplates/ClassNameC.c b/scripts/CppUnitTemplates/ClassNameC.c deleted file mode 100644 index eb0cae7cf..000000000 --- a/scripts/CppUnitTemplates/ClassNameC.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "ClassName.h" -#include -#include - -//static local variables - - -void ClassName_Create(void) -{ -} - -void ClassName_Destroy(void) -{ -} - - diff --git a/scripts/CppUnitTemplates/ClassNameC.h b/scripts/CppUnitTemplates/ClassNameC.h deleted file mode 100644 index 475355cb7..000000000 --- a/scripts/CppUnitTemplates/ClassNameC.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ClassName is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// -void ClassName_Create(void); -void ClassName_Destroy(void); - -#endif // D_ClassName_H diff --git a/scripts/CppUnitTemplates/ClassNameCMultipleInstance.c b/scripts/CppUnitTemplates/ClassNameCMultipleInstance.c deleted file mode 100644 index 13d6941d3..000000000 --- a/scripts/CppUnitTemplates/ClassNameCMultipleInstance.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "ClassName.h" -#include -#include - -//static local variables -typedef struct _ClassName -{ - int placeHolderForHiddenStructElements; -}; - -ClassName* ClassName_Create(void) -{ - ClassName* self = malloc(sizeof(ClassName)); - memset(self, 0, sizeof(ClassName)); - return self; -} - -void ClassName_Destroy(ClassName* self) -{ - free(self); -} - - diff --git a/scripts/CppUnitTemplates/ClassNameCMultipleInstance.h b/scripts/CppUnitTemplates/ClassNameCMultipleInstance.h deleted file mode 100644 index 01f27edaa..000000000 --- a/scripts/CppUnitTemplates/ClassNameCMultipleInstance.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ClassName is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// - -typedef struct _ClassName Classname; - -ClassName* ClassName_Create(void); -void ClassName_Destroy(ClassName*); -void ClassName_VirtualFunction_impl(ClassName*); - -#endif // D_ClassName_H diff --git a/scripts/CppUnitTemplates/ClassNameCMultipleInstanceTest.cpp b/scripts/CppUnitTemplates/ClassNameCMultipleInstanceTest.cpp deleted file mode 100644 index bbde2c413..000000000 --- a/scripts/CppUnitTemplates/ClassNameCMultipleInstanceTest.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "CppUTest/TestHarness.h" - -static int fakeRan = 0; - -extern "C" -{ -#include "ClassName.h" - void virtualFunction_renameThis_fake(ClassName*) - { - fakeRan = 1; - } -} - -TEST_GROUP(ClassName) -{ - ClassName* aClassName; - - void setup() - { - aClassName = ClassName_Create(); - fakeRan = 0; - aClassName->virtualFunction_renameThis = virtualFunction_renameThis_fake; - } - - void teardown() - { - ClassName_Destroy(aClassName); - } -}; - -TEST(ClassName, Fake) -{ - aClassName->virtualFunction_renameThis(aClassName); - LONGS_EQUAL(1, fakeRan); -} - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/CppUnitTemplates/ClassNameCPolymorphic.c b/scripts/CppUnitTemplates/ClassNameCPolymorphic.c deleted file mode 100644 index 13d6941d3..000000000 --- a/scripts/CppUnitTemplates/ClassNameCPolymorphic.c +++ /dev/null @@ -1,23 +0,0 @@ -#include "ClassName.h" -#include -#include - -//static local variables -typedef struct _ClassName -{ - int placeHolderForHiddenStructElements; -}; - -ClassName* ClassName_Create(void) -{ - ClassName* self = malloc(sizeof(ClassName)); - memset(self, 0, sizeof(ClassName)); - return self; -} - -void ClassName_Destroy(ClassName* self) -{ - free(self); -} - - diff --git a/scripts/CppUnitTemplates/ClassNameCPolymorphic.h b/scripts/CppUnitTemplates/ClassNameCPolymorphic.h deleted file mode 100644 index 2eba3275b..000000000 --- a/scripts/CppUnitTemplates/ClassNameCPolymorphic.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ClassName is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// - -typedef struct _ClassName ClassnamePiml; - - - -ClassName* ClassName_Create(void); -void ClassName_Destroy(ClassName*); -void ClassName_VirtualFunction_impl(ClassName*); - -#endif // D_ClassName_H diff --git a/scripts/CppUnitTemplates/ClassNameCTest.cpp b/scripts/CppUnitTemplates/ClassNameCTest.cpp deleted file mode 100644 index be4f1f935..000000000 --- a/scripts/CppUnitTemplates/ClassNameCTest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "CppUTest/TestHarness.h" - -extern "C" -{ -#include "ClassName.h" -} - -TEST_GROUP(ClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/CppUnitTemplates/ClassNameTest.cpp b/scripts/CppUnitTemplates/ClassNameTest.cpp deleted file mode 100644 index d27f86ddc..000000000 --- a/scripts/CppUnitTemplates/ClassNameTest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include "ClassName.h" - -class ClassNameTest: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(ClassNameTest); - CPPUNIT_TEST(testCreate); - CPPUNIT_TEST_SUITE_END(); - - ClassName* aClassName; - -public: - - void setUp() - { - aClassName = new ClassName(); - } - - void tearDown() - { - delete aClassName; - } - - void testCreate() - { - CPPUNIT_FAIL("Start here"); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(ClassNameTest); - - diff --git a/scripts/CppUnitTemplates/InterfaceCTest.cpp b/scripts/CppUnitTemplates/InterfaceCTest.cpp deleted file mode 100644 index b0b9906b8..000000000 --- a/scripts/CppUnitTemplates/InterfaceCTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "CppUTest/TestHarness.h" - -extern "C" -{ -#include "FakeClassName.h" -} - -TEST_GROUP(FakeClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(FakeClassName, Create) -{ - FAIL("Start here"); -} diff --git a/scripts/CppUnitTemplates/InterfaceTest.cpp b/scripts/CppUnitTemplates/InterfaceTest.cpp deleted file mode 100644 index a2b9362cc..000000000 --- a/scripts/CppUnitTemplates/InterfaceTest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include "ClassName.h" -#include "MockClassName.h" - -class MockClassNameTest: public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(MockClassNameTest); - CPPUNIT_TEST(testCreate); - CPPUNIT_TEST_SUITE_END(); - - ClassName* aClassName; - MockClassName* mockClassName; - -public: - - void setUp() - { - mockClassName = new MockClassName(); - aClassName = mockClassName; - } - - void tearDown() - { - delete aClassName; - } - - void testCreate() - { - CPPUNIT_FAIL("Start here"); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(MockClassNameTest); diff --git a/scripts/CppUnitTemplates/MockClassName.h b/scripts/CppUnitTemplates/MockClassName.h deleted file mode 100644 index 0e6778928..000000000 --- a/scripts/CppUnitTemplates/MockClassName.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef D_MockClassName_H -#define D_MockClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// MockClassName.h -// -// MockClassName is responsible for providing a test stub for ClassName -// -/////////////////////////////////////////////////////////////////////////////// -#include "ClassName.h" - - -class MockClassName : public ClassName - { - public: - explicit MockClassName() - {} - virtual ~MockClassName() - {} - - private: - - MockClassName(const MockClassName&); - MockClassName& operator=(const MockClassName&); - - }; - -#endif // D_MockClassName_H diff --git a/scripts/CppUnitTemplates/MockClassNameC.c b/scripts/CppUnitTemplates/MockClassNameC.c deleted file mode 100644 index eb0cae7cf..000000000 --- a/scripts/CppUnitTemplates/MockClassNameC.c +++ /dev/null @@ -1,16 +0,0 @@ -#include "ClassName.h" -#include -#include - -//static local variables - - -void ClassName_Create(void) -{ -} - -void ClassName_Destroy(void) -{ -} - - diff --git a/scripts/CppUnitTemplates/MockClassNameC.h b/scripts/CppUnitTemplates/MockClassNameC.h deleted file mode 100644 index 85146b645..000000000 --- a/scripts/CppUnitTemplates/MockClassNameC.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef D_FakeClassName_H -#define D_FakeClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// FakeClassName.h -// -// FakeClassName is responsible for providing a test stub for ClassName -// -/////////////////////////////////////////////////////////////////////////////// -#include "ClassName.h" - -#endif // D_FakeClassName_H diff --git a/scripts/CppUnitTemplates/ProjectTemplate/ProjectMakefile b/scripts/CppUnitTemplates/ProjectTemplate/ProjectMakefile deleted file mode 100644 index 3bd22d407..000000000 --- a/scripts/CppUnitTemplates/ProjectTemplate/ProjectMakefile +++ /dev/null @@ -1,48 +0,0 @@ -#Set this to @ to keep the makefile quiet -SILENCE = @ - -#---- Outputs ----# -COMPONENT_NAME = Project -TARGET_LIB = \ - lib/lib$(COMPONENT_NAME).a - -TEST_TARGET = \ - $(COMPONENT_NAME)_tests - -#--- Inputs ----# -PROJECT_HOME_DIR = . -CPPUTEST_HOME = ../CppUTest -CPPUNIT_HOME = ../cppunit -CPP_PLATFORM = Gcc - -#CFLAGS are set to override malloc and free to get memory leak detection in C programs -CFLAGS = -Dmalloc=cpputest_malloc -Dfree=cpputest_free -CPPFLAGS = -#GCOVFLAGS = -fprofile-arcs -ftest-coverage - -#SRC_DIRS is a list of source directories that make up the target library -#If test files are in these directories, their IMPORT_TEST_GROUPs need -#to be included in main to force them to be linked in. By convention -#put them into an AllTests.h file in each directory -SRC_DIRS = \ - src/util - -#TEST_SRC_DIRS is a list of directories including -# - A test main (AllTests.cpp by convention) -# - OBJ files in these directories are included in the TEST_TARGET -# - Consequently - AllTests.h containing the IMPORT_TEST_GROUPS is not needed -# - -TEST_SRC_DIRS = \ - tests \ - tests/util - -#includes for all compiles -INCLUDES =\ - -I.\ - -Iinclude/util\ - -I$(CPPUTEST_HOME)/include/ - -#Flags to pass to ld -LDFLAGS += $(CPPUNIT_HOME)/lib/libcppunit.a - -include $(CPPUTEST_HOME)/build/ComponentMakefile diff --git a/scripts/CppUnitTemplates/ProjectTemplate/include/util/ProjectBuildTime.h b/scripts/CppUnitTemplates/ProjectTemplate/include/util/ProjectBuildTime.h deleted file mode 100644 index b951739a2..000000000 --- a/scripts/CppUnitTemplates/ProjectTemplate/include/util/ProjectBuildTime.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef D_ProjectBuildTime_H -#define D_ProjectBuildTime_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ProjectBuildTime is responsible for recording and reporting when -// this project library was built -// -/////////////////////////////////////////////////////////////////////////////// - -class ProjectBuildTime - { - public: - explicit ProjectBuildTime(); - virtual ~ProjectBuildTime(); - - const char* GetDateTime(); - - private: - - const char* dateTime; - - ProjectBuildTime(const ProjectBuildTime&); - ProjectBuildTime& operator=(const ProjectBuildTime&); - - }; - -#endif // D_ProjectBuildTime_H diff --git a/scripts/CppUnitTemplates/ProjectTemplate/src/util/ProjectBuildTime.cpp b/scripts/CppUnitTemplates/ProjectTemplate/src/util/ProjectBuildTime.cpp deleted file mode 100644 index 483a5e44d..000000000 --- a/scripts/CppUnitTemplates/ProjectTemplate/src/util/ProjectBuildTime.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "ProjectBuildTime.h" - -ProjectBuildTime::ProjectBuildTime() -: dateTime(__DATE__ " " __TIME__) -{ -} - -ProjectBuildTime::~ProjectBuildTime() -{ -} - -const char* ProjectBuildTime::GetDateTime() -{ - return dateTime; -} - diff --git a/scripts/CppUnitTemplates/ProjectTemplate/tests/AllTests.cpp b/scripts/CppUnitTemplates/ProjectTemplate/tests/AllTests.cpp deleted file mode 100644 index 3932fd103..000000000 --- a/scripts/CppUnitTemplates/ProjectTemplate/tests/AllTests.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "CppUTest/CommandLineTestRunner.h" - -int main(int ac, char** av) -{ - return CommandLineTestRunner::RunAllTests(ac, av); -} - diff --git a/scripts/CppUnitTemplates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp b/scripts/CppUnitTemplates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp deleted file mode 100644 index f3e1bcdae..000000000 --- a/scripts/CppUnitTemplates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "ProjectBuildTime.h" - -TEST_GROUP(ProjectBuildTime) -{ - ProjectBuildTime* projectBuildTime; - - void setup() - { - projectBuildTime = new ProjectBuildTime(); - } - void teardown() - { - delete projectBuildTime; - } -}; - -TEST(ProjectBuildTime, Create) -{ - CHECK(0 != projectBuildTime->GetDateTime()); -} - diff --git a/scripts/GenerateSrcFiles.sh b/scripts/GenerateSrcFiles.sh deleted file mode 100755 index 58b88dd21..000000000 --- a/scripts/GenerateSrcFiles.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/bash -x -#$1 is the template root file name -#$2 is the kind of file to create (c or cpp) -#$3 is Mock if a mock version should be created, Fake for a fake C version -#$4 is the class/module name -#$5 is the package name - -#Test for env var set. -checkForCppUTestToolsEnvVariable() { - if [ -z "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set. You must set CPPUTEST_HOME to the top level CppUTest directory" - exit 1 - fi - if [ ! -d "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set to a directory. You must set CPPUTEST_HOME to the top level CppUTest directory" - exit 2 - fi -} - -checkForCppUTestToolsEnvVariable - -templateRootName=$1 -srcSuffix=$2 -mock=$3 -className=$4 -packageName=$5 -testSuffix=Test - -#CPP_SOURCE_TEMPLATES can point to templates you write -#identify the template files -if [ "$CPP_SOURCE_TEMPLATES" == "" ] - then - TEMPLATE_DIR=$CPPUTEST_HOME/scripts/templates - else - TEMPLATE_DIR=$CPP_SOURCE_TEMPLATES -fi - -templateHFile=$TEMPLATE_DIR/$templateRootName.h -templateSrcFile=$TEMPLATE_DIR/$templateRootName.$srcSuffix -if [ "$mock" == "Mock" ] ; then - templateTestFile=$TEMPLATE_DIR/Interface$testSuffix.cpp -elif [ "$mock" == "Fake" ] ; then - templateTestFile=$TEMPLATE_DIR/InterfaceC$testSuffix.cpp -else - templateTestFile=$TEMPLATE_DIR/$templateRootName$testSuffix.cpp -fi -templateMockFile=$TEMPLATE_DIR/Mock$templateRootName.h - -#indentify the class and instance names -instanceName=$(echo $className | cut -c1 | tr A-Z a-z)$(echo $className | cut -c 2-) -className=$(echo $className | cut -c1 | tr a-z A-Z)$(echo $className | cut -c 2-) - -#if a package is specified, set the directories -if [ ! "$packageName" == "" ] - then - srcDir=src/$packageName/ - includeDir=include/$packageName/ - testsDir=tests/$packageName/ - fi - -#identify the files being created -hFile=${includeDir}${className}.h -srcFile=${srcDir}${className}.${srcSuffix} -testFile=${testsDir}${className}${testSuffix}.cpp -if [ "$mock" != "NoMock" ] ; then - mockFile=${testsDir}${mock}${className}.h - testFile=${testsDir}${mock}${className}${testSuffix}.cpp - if [ "$srcSuffix" == "c" ] ; then - srcFile=${testsDir}${mock}${className}.${srcSuffix} - fi -else - mockFile= -fi - -sedCommands="-e s/aClassName/$instanceName/g -e s/ClassName/$className/g" - -generateFileIfNotAlreadyThere() { - if [ -e $2 ] - then - echo "${2} already exists, skipping" - else - echo "creating ${2}" - sed $sedCommands $1 | tr -d "\r" >$2 - fi -} - -generateFileIfNotAlreadyThere $templateHFile $hFile -generateFileIfNotAlreadyThere $templateSrcFile $srcFile -generateFileIfNotAlreadyThere $templateTestFile $testFile -if [ "$mock" != "NoMock" ] ; then - generateFileIfNotAlreadyThere $templateMockFile $mockFile -# sed $sedCommands $templateMockFile | tr -d "\r" >$mockFile -fi - diff --git a/scripts/InstallScripts.sh b/scripts/InstallScripts.sh deleted file mode 100755 index 1c632e718..000000000 --- a/scripts/InstallScripts.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -x -FirstLetter=${0:0:1} -if [[ $FirstLetter == "/" ]] ; then - CPPUTEST_HOME=${0%/scripts/*} -else - file=$(pwd)/${0} - CPPUTEST_HOME="${file%/scripts/*}" -fi - -EXE_DIR=${EXE_DIR:-/usr/local/bin} -test -f ${EXE_DIR} || mkdir -p ${EXE_DIR} - -NEW_SCRIPTS="NewCIoDriver NewClass NewInterface NewCModule NewCmiModule NewProject NewLibrary NewPackageDirs NewCInterface NewCFunction NewHelp" - - -for file in $NEW_SCRIPTS ; do - rm -f ${EXE_DIR}/${file} - ln -s ${CPPUTEST_HOME}/scripts/${file}.sh ${EXE_DIR}/${file} - chmod a+x ${EXE_DIR}/${file} -done diff --git a/scripts/NewCBaseModule.sh b/scripts/NewCBaseModule.sh deleted file mode 100755 index d7cf741ed..000000000 --- a/scripts/NewCBaseModule.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassNameC c NoMock $1 $2 - diff --git a/scripts/NewCFunction.sh b/scripts/NewCFunction.sh deleted file mode 100755 index 0d832ed8d..000000000 --- a/scripts/NewCFunction.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh FunctionNameC c NoMock $1 $2 - diff --git a/scripts/NewCInterface.sh b/scripts/NewCInterface.sh deleted file mode 100755 index c55f9b54c..000000000 --- a/scripts/NewCInterface.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassNameC c Fake $1 $2 - diff --git a/scripts/NewCIoDriver.sh b/scripts/NewCIoDriver.sh deleted file mode 100755 index d444c6608..000000000 --- a/scripts/NewCIoDriver.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassNameCIoDriver c NoMock $1 $2 - diff --git a/scripts/NewCModule.sh b/scripts/NewCModule.sh deleted file mode 100755 index d7cf741ed..000000000 --- a/scripts/NewCModule.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassNameC c NoMock $1 $2 - diff --git a/scripts/NewClass.sh b/scripts/NewClass.sh deleted file mode 100755 index 0fe53af01..000000000 --- a/scripts/NewClass.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassName cpp NoMock $1 $2 - diff --git a/scripts/NewCmiModule.sh b/scripts/NewCmiModule.sh deleted file mode 100755 index 254bd8c28..000000000 --- a/scripts/NewCmiModule.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassNameCMultipleInstance c NoMock $1 $2 - diff --git a/scripts/NewHelp.sh b/scripts/NewHelp.sh deleted file mode 100755 index 78864e8f7..000000000 --- a/scripts/NewHelp.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -NEW_SCRIPTS=" \ - NewClass \ - NewInterface \ - NewCModule \ - NewCmiModule \ - NewCInterface \ - NewCFunction" - -for file in $NEW_SCRIPTS ; do - echo ${file} name package - rm -f ${EXE_DIR}/${file} - ln -s ${CPPUTEST_HOME}/scripts/${file}.sh ${EXE_DIR}/${file} - chmod a+x ${EXE_DIR}/${file} -done - diff --git a/scripts/NewInterface.sh b/scripts/NewInterface.sh deleted file mode 100755 index 7d1095abd..000000000 --- a/scripts/NewInterface.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -source ${CPPUTEST_HOME}/scripts/GenerateSrcFiles.sh ClassName cpp Mock $1 $2 diff --git a/scripts/NewLibrary.sh b/scripts/NewLibrary.sh deleted file mode 100755 index 3d1023027..000000000 --- a/scripts/NewLibrary.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -x -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -LIBRARY=$1 - -if [ -e ${LIBRARY} ] ; then - echo "The directory ${LIBRARY} already exists" - exit 1; -fi - -echo "Copy template project to ${LIBRARY}" -cp -R ${TEMPLATE_DIR}/ProjectTemplate/Project ${LIBRARY} -find ${LIBRARY} -name \.svn | xargs rm -rf - -echo "Update to the new LIBRARY name" -substituteProjectName="-e s/Project/${LIBRARY}/g -i .bak" - -cd ${LIBRARY} - -sed ${substituteProjectName} *.* -sed ${substituteProjectName} Makefile - -for name in BuildTime.h BuildTime.cpp BuildTimeTest.cpp ; do - mv Project${name} ${LIBRARY}${name} -done - -cd .. - -sed -e "s/DIRS = /DIRS = ${LIBRARY} /g" -i .bak Makefile - -find ${LIBRARY} -name \*.bak | xargs rm -f - -echo "#include \"../${LIBRARY}/AllTests.h\"" >> AllTests/AllTests.cpp - -echo "You have to manually add the library reference to the AllTests Makefile" -echo "and maybe change the order of the library builds in the main Makefile" diff --git a/scripts/NewPackageDirs.sh b/scripts/NewPackageDirs.sh deleted file mode 100755 index a32be4a45..000000000 --- a/scripts/NewPackageDirs.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -package=$1 - -for dir in src include tests ; do - packageDir=${dir}/${package} - if [ ! -d "$packageDir" ] ; then - echo "creating $packageDir" - mkdir $packageDir - fi -done - diff --git a/scripts/NewProject.sh b/scripts/NewProject.sh deleted file mode 100644 index e0623c39a..000000000 --- a/scripts/NewProject.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -PROJECT_NAME=$1 -CODE_LEGAL_PROJECT_NAME=$(echo $PROJECT_NAME | sed 's/-/_/g') -TEMPLATE_DIR=${CPPUTEST_HOME}/scripts/templates -ORIGINAL_DIR=$(pwd) - -if [ -e ${PROJECT_NAME} ] ; then - echo "The directory ${PROJECT_NAME} already exists" - exit 1; -fi - -echo "Copy template project" -cp -R ${TEMPLATE_DIR}/ProjectTemplate ${PROJECT_NAME} -find ${PROJECT_NAME} -name \.svn | xargs rm -rf - -cd ${PROJECT_NAME} - -ls - -changeProjectName() { - echo Change Name $1/Project$2 to $3$2 - sed "-e s/Project/$3/g" $1/Project$2 | tr -d "\r" >$1/$3$2 - rm $1/Project$2 -} - -changeProjectName . Makefile ${CODE_LEGAL_PROJECT_NAME} -changeProjectName . .project ${PROJECT_NAME} -changeProjectName src/util BuildTime.cpp ${CODE_LEGAL_PROJECT_NAME} -changeProjectName include/util BuildTime.h ${CODE_LEGAL_PROJECT_NAME} -changeProjectName tests/util BuildTimeTest.cpp ${CODE_LEGAL_PROJECT_NAME} -mv ${CODE_LEGAL_PROJECT_NAME}Makefile Makefile -mv ${PROJECT_NAME}.project .project -mv Project.cproject .cproject - -cd ${ORIGINAL_DIR} -echo "You might want to modify the path for CPPUTEST_HOME in the Makefile." diff --git a/scripts/README.txt b/scripts/README.txt deleted file mode 100644 index c6adab6f0..000000000 --- a/scripts/README.txt +++ /dev/null @@ -1,30 +0,0 @@ -The New*.sh scripts are helpful for creating the initial files for a new class... - NewClass.sh - for TDDing a new C++ class - NewInterface.sh - for TDDing a new interface along with its Mock - NewCModule.sh - for TDDing a C module - NewCmiModule.sh - for TDDing a C module where there will be multiple - instances of the module's data structure - -Run InstallScripts.sh to - 1) Copy the scripts to /usr/local/bin - 2) Define symbolic links for each of the scripts - -Like this: - ./scripts/InstallScripts.sh - -You might have to add the execute privilege to the shell scripts. -Like this: - chmod +x *.sh - -Using NewClass for example: - cd to the directory where you want the files located - NewClass SomeClass - -The script gets you ready for TDD and saves a lot of tedious typing - Creates SomeClass.h SomeClass.cpp SomeClassTest.cpp - with the class and test essentials in place - (If the file already exists, no file is generated) - - -These scripts are written in bash. - diff --git a/scripts/RefactorRenameIncludeFile.sh b/scripts/RefactorRenameIncludeFile.sh deleted file mode 100755 index 705370714..000000000 --- a/scripts/RefactorRenameIncludeFile.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash +x -dirs_to_look_in="src tests include mocks" -from_name=$1 -to_name=$2 -SVN=svn - -findFilesWithInclude() -{ - files_with_include=$(find $dirs_to_look_in -name "*.[hc]" -o -name "*.cpp" | xargs grep -l "#include \"$1\"") - if [ "$files_with_include" != "" ] - then - files_with_include+=" " - fi - - files_with_include+=$(find $dirs_to_look_in -name "*.[hc]" -o -name "*.cpp" | xargs grep -l "#include <$1>") - echo $files_with_include -} - -checkForPriorNameUseIncludes() -{ - files=$(findFilesWithInclude $1) - - if [ "$files" != "" ] - then - echo "name already included: $1 included in ${files}" - exit - fi -} - -checkForFileNameExists() -{ - files=$(find $dirs_to_look_in -name $1) - if [ "$files" != "" ] - then - echo "name already in use: $1 found in ${files}" - exit - fi -} - -searchAndReplaceIncludes() -{ - files=$(findFilesWithInclude $1) - if [ "$files" = "" ] - then - echo "No files found including $1" - exit - fi - echo "Changing include $1 to $2 in: $files" - set -x - sed -i "" -e "s/#include \"$1\"/#include \"$2\"/g" $files - sed -i "" -e "s/#include <$1>/#include <$2>/g" $files - set +x -} - -renameIncludeFile() -{ - file=$(find $dirs_to_look_in -name $1) - if [ $(echo $file | wc -l) != 1 ] - then - echo "More than one potential file to rename $file" - exit - fi - set -x - from_module_name=$(basename $1 .h) - to_module_name=$(basename $2 .h) - sed -i "" -e "s/$from_module_name/$to_module_name/g" $file - path=$(dirname $file) - $SVN mv $file $path/$2 - set +x -} - -checkForFileNameExists $to_name -checkForPriorNameUseIncludes $to_name -searchAndReplaceIncludes $from_name $to_name -renameIncludeFile $1 $2 diff --git a/scripts/ReleaseCppUTest.sh b/scripts/ReleaseCppUTest.sh deleted file mode 100755 index 61aa3d424..000000000 --- a/scripts/ReleaseCppUTest.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/bash -#source in release generator script - -echo "Do not use this anymore, please use \"configure; make dist\"" -exit - -if [ ! -d "scripts" ]; then - echo "You have to run this script from the CPPUTEST_HOME directory!"; - exit -fi - -GENERATED_FILES="" -release_dir=Releases -scripts_dir=scripts -version=v3.3 -zip_root=CppUTest-${version} -tar_root=CppUTest-${version}_tar -clean_unzip_root=${zip_root}_clean_unzip -clean_untar_root=${zip_root}_clean_untar -zip_file=${zip_root}.zip -tar_file=${zip_root}.tar.gz - -exitIfFileExists() { - if [ -e $1 ] - then - echo "${1} already exists, exiting." - exit - fi -} - -generateMakeScript() { - filename=$1 - dateTime=$2 - version=$3 - target=$4 - exitIfFileExists $filename.sh - echo "#Generated file - ${filename}.sh" >$filename.sh - echo "echo \"Running ${filename} for CppUTest ${version} created on ${dateTime}\"" >>$filename.sh - echo "export CPPUTEST_HOME=\$(pwd)" >>$filename.sh - echo "echo \"export CPPUTEST_HOME=\$(pwd)/\"" >>$filename.sh - echo "make $target" >>$filename.sh - - chmod +x $filename.sh - GENERATED_FILES+=" $filename.sh" -} - -generateVersionFile() { - version=$1 - dateTime=$2 - versionFile=version.txt - echo "CppUTest ${version} created on ${dateTime}" > $versionFile - GENERATED_FILES+=$versionFile -} - -zipIt() { - mkdir -p ${release_dir} - zip -r ${release_dir}/${zip_file} \ - $GENERATED_FILES \ - .\ - -x@${scripts_dir}/zipExclude.txt - tar -cvpzf ${release_dir}/${tar_file} \ - -X ./${scripts_dir}/zipExclude.txt \ - $GENERATED_FILES \ - . -} - -cleanUp() { - rm -f $GENERATED_FILES -} - -generateCppUTestRelease() { - dateTime=$(date +%F-%H-%M) - generateVersionFile $version $dateTime - generateMakeScript makeAll $dateTime $version everythingInstall - generateMakeScript cleanAll $dateTime $version cleanEverythingInstall - zipIt $version - cleanUp -} - -openAndMakeRelease() -{ - cd ${release_dir} - - # unzip and untar the code and make sure it is the same - rm -rf ${clean_unzip_root} - unzip ${zip_file} -d ${clean_unzip_root} - rm -rf ${clean_untar_root} - mkdir ${clean_untar_root} - tar -xvzpf ${tar_file} -C ${clean_untar_root} - - rm -rf ${zip_root} - unzip ${zip_file} -d ${zip_root} - cd ${zip_root} - ./makeAll.sh - cd .. - - rm -rf ${tar_root} - mkdir ${tar_root} - tar -xvzpf ${tar_file} -C ${tar_root} - cd ${tar_root} - ./makeAll.sh - cd ../.. -} - - -#Main -generateCppUTestRelease -openAndMakeRelease diff --git a/scripts/UnityTemplates/ClassNameCIoDriverTest.cpp b/scripts/UnityTemplates/ClassNameCIoDriverTest.cpp deleted file mode 100644 index ca12b28b9..000000000 --- a/scripts/UnityTemplates/ClassNameCIoDriverTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -extern "C" { -#include "ClassName.h" -#include "MockIO.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - Reset_Mock_IO(); - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - Assert_No_Unused_Expectations(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/UnityTemplates/ClassNameCMultipleInstanceTest.cpp b/scripts/UnityTemplates/ClassNameCMultipleInstanceTest.cpp deleted file mode 100644 index 77af385ed..000000000 --- a/scripts/UnityTemplates/ClassNameCMultipleInstanceTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - ClassName aClassName; - - void setup() - { - aClassName = ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(aClassName); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/UnityTemplates/ClassNameCTest.cpp b/scripts/UnityTemplates/ClassNameCTest.cpp deleted file mode 100644 index 9a64d058b..000000000 --- a/scripts/UnityTemplates/ClassNameCTest.cpp +++ /dev/null @@ -1,26 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/UnityTemplates/FunctionNameCTest.cpp b/scripts/UnityTemplates/FunctionNameCTest.cpp deleted file mode 100644 index afa8db4c5..000000000 --- a/scripts/UnityTemplates/FunctionNameCTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - } - - void teardown() - { - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/UnityTemplates/InterfaceCTest.cpp b/scripts/UnityTemplates/InterfaceCTest.cpp deleted file mode 100644 index 8052f8156..000000000 --- a/scripts/UnityTemplates/InterfaceCTest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -extern "C" -{ -#include "FakeClassName.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} diff --git a/scripts/VS2010Templates/CppUTest_VS2010.props b/scripts/VS2010Templates/CppUTest_VS2010.props deleted file mode 100644 index 7655261a1..000000000 --- a/scripts/VS2010Templates/CppUTest_VS2010.props +++ /dev/null @@ -1,46 +0,0 @@ - - - - - $(CPPUTEST_HOME)\include;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGTest;$(CPPUTEST_HOME)\include\CppUTestExt\CppUTestGMock - $(CPPUTEST_HOME)\lib - $(CPPUTEST_HOME)\include\CppUTest\MemoryLeakDetectorMallocMacros.h; - CppUTest.lib - - - - - $(CPPUTEST_INCLUDE_PATHS);%(AdditionalIncludeDirectories) - $(CPPUTEST_FORCED_INCLUDES);%(ForcedIncludeFiles) - - - $(CPPUTEST_LIB_DEPENDENCIES);%(AdditionalDependencies) - $(CPPUTEST_LIB_PATHS);%(AdditionalLibraryDirectories) - - - $(TargetPath) - - - - - $(CPPUTEST_HOME) - true - - - $(CPPUTEST_INCLUDE_PATHS) - true - - - $(CPPUTEST_LIB_PATHS) - true - - - $(CPPUTEST_FORCED_INCLUDES) - true - - - $(CPPUTEST_LIB_DEPENDENCIES) - true - - - \ No newline at end of file diff --git a/scripts/VS2010Templates/README.txt b/scripts/VS2010Templates/README.txt deleted file mode 100644 index 47f90691b..000000000 --- a/scripts/VS2010Templates/README.txt +++ /dev/null @@ -1,8 +0,0 @@ -**Intro** -The CppUTest_VS2010.props property sheet sets the needed compiler and linker options for your unit test project. - -**Instructions** -1) Create a system environment variable, CPPUTEST_HOME and set it to the path of your CppUTest distribution. -2) Add the CppUTest_VS2010.props property sheet to your unit test project and you are good to go. -3) See the WalkThrough_VS2010 guide in the docs section for details. - diff --git a/scripts/appveyor_ci_build.ps1 b/scripts/appveyor_ci_build.ps1 deleted file mode 100644 index 5f33eacd6..000000000 --- a/scripts/appveyor_ci_build.ps1 +++ /dev/null @@ -1,118 +0,0 @@ - -# 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 = `$?" - Write-Host $command - - Push-Location $directory - Invoke-Expression $command_wrapped - - if ($LASTEXITCODE -ne 0) - { - Pop-Location - Write-Host "Command Returned error: $LASTEXITCODE" - Exit $LASTEXITCODE - } - - Pop-Location -} - -function Invoke-CygwinCommand($command, $directory = '.') -{ - # Assume cygwin is located at C:\cygwin on x86 and C:\cygwin64 on x64 for now - $cygwin_bin = Get-CygwinBin - - $cygwin_directory = (. "${cygwin_bin}\cygpath.exe" (Resolve-Path $directory)) - $command_wrapped = "${cygwin_bin}\bash.exe --login -c 'cd $cygwin_directory ; $command'" - - Write-Host "Executing <$command> in <$cygwin_directory>" - Invoke-Expression $command_wrapped - - if ($LASTEXITCODE -ne 0) - { - Write-Host "Command Returned error: $LASTEXITCODE" - Exit $LASTEXITCODE - } -} - -# The project files that will get built -$VS2008ProjectFiles = @( 'CppUTest.vcproj' , 'tests\AllTests.vcproj' ) -$VS2010ProjectFiles = @( 'CppUTest.vcxproj', 'tests\AllTests.vcxproj' ) - -if ($env:APPVEYOR) -{ - $logger_arg = '/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"' -} -else -{ - $logger_arg = '' -} - -# Clean up some paths for any configuration -Remove-PathFolder "C:\MinGW\bin" -Remove-PathFolder "C:\Program Files\Git\bin" -Remove-PathFolder "C:\Program Files\Git\cmd" -Remove-PathFolder "C:\Program Files\Git\usr\bin" -Remove-PathFolder "C:\Program Files (x86)\Git\bin" -Remove-PathFolder "C:\Program Files (x86)\Git\cmd" -Remove-PathFolder "C:\Program Files (x86)\Git\usr\bin" - -switch -Wildcard ($env:Platform) -{ - 'Cygwin*' - { - Invoke-CygwinCommand "autoreconf -i .." "cpputest_build" - Invoke-CygwinCommand "../configure" "cpputest_build" - Invoke-CygwinCommand "make CppUTestTests.exe CppUTestExtTests.exe" "cpputest_build" - } - - 'MinGW*' - { - $mingw_path = Get-MinGWBin - - if ($env:Platform -like 'MinGWClang*') - { - $toolchain_filename = Get-ClangToolchainFilename - $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 - Add-PathFolder $mingw_path - - Invoke-BuildCommand "cmake --version" - Invoke-BuildCommand "cmake -G 'MinGW Makefiles' -DCMAKE_CXX_STANDARD=17 $toolchain .." 'cpputest_build' - Invoke-BuildCommand "mingw32-make all" 'cpputest_build' - - Remove-PathFolder $mingw_path - } - - default # Assume that anything else uses Visual C++ - { - if ($env:PlatformToolset -eq 'v90') - { - # Load environment variables from vsvars32.bat - $vsvarspath = Join-Path $env:VS90COMNTOOLS vsvars32.bat - Get-BatchFile($vsvarspath) - - $VS2008ProjectFiles | foreach { - Invoke-BuildCommand "vcbuild /upgrade $_" - } - - $VS2008ProjectFiles | foreach { - Invoke-BuildCommand "vcbuild $_ $env:CONFIGURATION" - } - } - else - { - $VS2010ProjectFiles | foreach { - Invoke-BuildCommand "msbuild /ToolsVersion:14.0 $logger_arg $_" - } - } - } -} diff --git a/scripts/appveyor_ci_test.ps1 b/scripts/appveyor_ci_test.ps1 deleted file mode 100644 index 830542932..000000000 --- a/scripts/appveyor_ci_test.ps1 +++ /dev/null @@ -1,118 +0,0 @@ - -# Load functions from the helper file -. (Join-Path (Split-Path $MyInvocation.MyCommand.Path) 'appveyor_helpers.ps1') - -function Publish-TestResults($files) -{ - $anyFailures = $FALSE - - # Upload results to AppVeyor one by one - $files | foreach { - $testsuite = ([xml](get-content $_.Name)).testsuite - - foreach ($testcase in $testsuite.testcase) { - if ($testcase.failure) { - Add-AppveyorTest $testcase.name -Outcome Failed -FileName $testsuite.name -ErrorMessage $testcase.failure.message - Add-AppveyorMessage "$($testcase.name) failed" -Category Error - $anyFailures = $TRUE - } - elseif ($testcase.skipped) { - Add-AppveyorTest $testcase.name -Outcome Ignored -Filename $testsuite.name - } - else { - Add-AppveyorTest $testcase.name -Outcome Passed -FileName $testsuite.name - } - } - - Remove-Item $_.Name - } - - if ($anyFailures -eq $TRUE){ - write-host "Failing build as there are broken tests" - $host.SetShouldExit(1) - } -} - -function Invoke-Tests($executable) -{ - # Run tests and output the results using junit - $TestCommand = "$executable -ojunit" - Write-Host $TestCommand -NoNewline - Invoke-Expression $TestCommand - Write-Host " - return code: $LASTEXITCODE" - if ($LASTEXITCODE -lt 0) { - Write-Error "Runtime Exception during test execution" - } -} - -function Invoke-CygwinTests($executable) -{ - # Assume cygwin is located at C:\cygwin for now - $cygwin_bin = Get-CygwinBin - - # Get the full path to the executable - $cygwin_folder = . "${cygwin_bin}\cygpath.exe" (Resolve-Path ".") - $cygwin_exe = . "${cygwin_bin}\cygpath.exe" $executable - - # Run tests from the cygwin prompt - $test_command = "${cygwin_exe} -ojunit" - $cygwin_command = "${cygwin_bin}\bash.exe --login -c 'cd ${cygwin_folder} ; ${test_command}'" - - Write-Host $test_command - Invoke-Expression $cygwin_command -} - -$TestCount = 0 - -if (-not $env:APPVEYOR) -{ - function Add-AppVeyorTest() - { - # Wacky way to access a script variable, but it works - $count = Get-Variable -Name TestCount -Scope script - Set-Variable -Name TestCount -Scope script -Value ($count.Value + 1) - } - - function Add-AppVeyorMessage($Message, $Category) - { - if ($Category -eq 'Error') - { - Write-Error $Message - } - else - { - Write-Host $Message - } - } -} - -switch -Wildcard ($env:Platform) -{ - 'Cygwin*' - { - Invoke-CygwinTests 'cpputest_build\CppUTestTests.exe' - Invoke-CygwinTests 'cpputest_build\CppUTestExtTests.exe' - } - - 'MinGW*' - { - $mingw_path = Get-MinGWBin - - Set-Path "$mingw_path;C:\Windows;C:\Windows\System32" - Invoke-Tests '.\cpputest_build\tests\CppUTest\CppUTestTests.exe' - Invoke-Tests '.\cpputest_build\tests\CppUTestExt\CppUTestExtTests.exe' - Restore-Path - } - - default - { - Invoke-Tests '.\cpputest_build\AllTests.exe' - } -} - -Publish-TestResults (Get-ChildItem 'cpputest_*.xml') - -if (-not $env:APPVEYOR) -{ - Write-Host "Tests Ran: $TestCount" -} diff --git a/scripts/appveyor_helpers.ps1 b/scripts/appveyor_helpers.ps1 deleted file mode 100644 index af08f21ca..000000000 --- a/scripts/appveyor_helpers.ps1 +++ /dev/null @@ -1,96 +0,0 @@ - -# Helper function to extract vars out of the vsvars batch file -function Get-Batchfile ($file) { - $cmd = "`"$file`" & set" - cmd /c $cmd | Foreach-Object { - $p, $v = $_.split('=') - Set-Item -path env:$p -value $v - } -} - -# Helper function to provide the bin-folder path to mingw -function Get-MinGWBin() { - if ($env:Platform -like '*64') { - Write-Output 'C:\Tools\mingw64\bin' - } - else { - Write-Output 'C:\Tools\mingw32\bin' - } -} - -# Helper function to provide the toolchain file for clang -function Get-ClangToolchainFilename() { - if ($env:Platform -like '*64') { - Write-Output 'clang+mingw-win64.toolchain.cmake' - } - else { - Write-Output 'clang+mingw-win32.toolchain.cmake' - } -} - -# Helper function to provide the bin-folder path to cygwin -function Get-CygwinBin() { - if ($env:Platform -like '*64') { - Write-Output 'C:\cygwin64\bin' - } - else { - Write-Output 'C:\cygwin\bin' - } -} - -function Add-PathFolder($folder) -{ - if (-not (Test-Path $folder)) - { - Write-Host "Not adding $folder to the PATH, it does not exist" - } - - [bool]$alreadyInPath = $false - [System.Collections.ArrayList]$pathFolders = New-Object System.Collections.ArrayList - $env:Path -split ";" | foreach { $pathFolders.Add($_) | Out-Null } - - for ([int]$i = 0; $i -lt $pathFolders.Count; $i++) - { - if ([string]::Compare($pathFolders[$i], $folder, $true) -eq 0) - { - $alreadyInPath = $true - break - } - } - - if (-not $alreadyInPath) - { - Write-Host "Adding $folder to the PATH" - $pathFolders.Insert(0, $folder) - $env:Path = $pathFolders -join ";" - } -} - -function Remove-PathFolder($folder) -{ - [System.Collections.ArrayList]$pathFolders = New-Object System.Collections.ArrayList - $env:Path -split ";" | foreach { $pathFolders.Add($_) | Out-Null } - - for ([int]$i = 0; $i -lt $pathFolders.Count; $i++) - { - if ([string]::Compare($pathFolders[$i], $folder, $true) -eq 0) - { - Write-Host "Removing $folder from the PATH" - $pathFolders.RemoveAt($i) - $i-- - } - } - - $env:Path = $pathFolders -join ";" -} - -function Set-Path($newPath) -{ - $env:RestorePath = $env:Path - $env:Path = $newPath -} - -function Restore-Path() -{ - $env:Path = $env:RestorePath -} diff --git a/scripts/checkForCppUTestEnvVariable.sh b/scripts/checkForCppUTestEnvVariable.sh deleted file mode 100755 index dfd4d8cdf..000000000 --- a/scripts/checkForCppUTestEnvVariable.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -checkForCppUTestEnvVariable() { - if [ -z "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set" - exit 1 - fi - if [ ! -d "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set to a directory" - exit 2 - fi -} diff --git a/scripts/convertToUnity/README.txt b/scripts/convertToUnity/README.txt deleted file mode 100644 index 36e87bfd2..000000000 --- a/scripts/convertToUnity/README.txt +++ /dev/null @@ -1,25 +0,0 @@ -Convert CppUTest files to Unity test files ------------------------------------------- - -To convert a CppUTest test file to Unity, enter a command like this - -CONVERT=$CPPUTEST_HOME/scripts/convertToUnity/cpp_u_test_to_unity.rb - -ruby $CONVERT tests/some/dir/or/dirs/MyThink.cpp - -This will create two files like this - - unity/some/dir/or/dirs/MyThing.c - unity/some/dir/or/dirs/MyThing_runner.c - -Things that need to be done manually once to your -unity test environment: - - Create directory 'unity/some/dir/or/dirs' - Adjust unity makefile to refer to the needed files - Unity main needs to call RUN_TEST_GROUP(MyThing) - -Things not supported in converted test cases: - CppUMock - Hand built mocks that use CppUTest macros. - Formatting conventions can cause the script to fail diff --git a/scripts/convertToUnity/cpp_u_test_to_unity.rb b/scripts/convertToUnity/cpp_u_test_to_unity.rb deleted file mode 100755 index 1f2209a01..000000000 --- a/scripts/convertToUnity/cpp_u_test_to_unity.rb +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env ruby -require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb') -include CppUTestToUnityUtils - -in_file = ARGV[0] -unity_filename = convert_test_filename_to_unity_filename(in_file) -unity_runner_filename = convert_test_filename_to_unity_testrunner_filename(in_file) -puts "Converting :" + in_file + "\n" -puts " To :" + unity_filename + "\n" - -test_lines = File.open(in_file).readlines -out_unity_file = File.open(unity_filename, 'w') -out_unity_runner_file = File.open(unity_runner_filename, 'w') - -test_groups = get_test_groups(test_lines) -adjust_tabs(test_lines) -remove_extern_c(test_lines) -demote_group(/TEST_GROUP/, test_lines) -convert_macros(test_lines, test_groups) -group_runners = generate_group_runners(test_groups, test_lines) -write_lines_to_file(out_unity_file, test_lines) -write_lines_to_file(out_unity_runner_file, group_runners) -out_unity_file.close() -out_unity_runner_file.close() diff --git a/scripts/convertToUnity/cpp_u_test_to_unity_utils.rb b/scripts/convertToUnity/cpp_u_test_to_unity_utils.rb deleted file mode 100644 index 09e57f002..000000000 --- a/scripts/convertToUnity/cpp_u_test_to_unity_utils.rb +++ /dev/null @@ -1,247 +0,0 @@ -module CppUTestToUnityUtils - - def convert_test_filename_to_unity_filename(testpath) - testpath.sub(/tests\/(.*)\.cpp/, "unity/\\1.c") - end - - def convert_test_filename_to_unity_testrunner_filename(testpath) - testpath.sub(/tests\/(.*)\.cpp/, "unity/\\1_runner.c") - end - - def convert_one_liners(line, group) - line.sub!(/#include "CppUTest\/TestHarness.h\"/, "#include \"unity_fixture.h\"" ) - line.sub!(/FAIL\(/, 'TEST_FAIL(') - line.sub!(/CHECK\(/, "TEST_ASSERT_TRUE(") - line.sub!(/CHECK_TRUE\(/, "TEST_ASSERT_TRUE(") - line.sub!(/CHECK_FALSE\(/, "TEST_ASSERT_FALSE(") - line.sub!(/LONGS_EQUAL\(/, "TEST_ASSERT_EQUAL(") - line.sub!(/BYTES_EQUAL\(/, "TEST_ASSERT_EQUAL_HEX8(") - line.sub!(/STRCMP_EQUAL\(/, "TEST_ASSERT_EQUAL_STRING(") - line.sub!(/DOUBLES_EQUAL\(/, "TEST_ASSERT_FLOAT_WITHIN(") - line.sub!(/ POINTERS_EQUAL\(/, " TEST_ASSERT_POINTERS_EQUAL(") - line.sub!(/CHECK_EQUAL\(true,/, "TEST_ASSERT_TRUE(") - line.sub!(/CHECK_EQUAL\(false,/, "TEST_ASSERT_FALSE(") - line.sub!(/CHECK_EQUAL\(/, "TEST_ASSERT_EQUAL(") - #line.sub!(/static void setup\(/, "TEST_SETUP(" + group) - #line.sub!(/static void teardown\(/, "TEST_TEAR_DOWN(" + group) - end - - def convert_setup(lines, group) - lines.each do | line | - if line.sub!(/static void setup\(/, "TEST_SETUP(" + group) - return - end - end - end - - def convert_teardown(lines, group) - lines.each do | line | - if line.sub!(/static void teardown\(/, "TEST_TEAR_DOWN(" + group) - return - end - end - end - - def convert_macros(lines, groups) - groups.each do | group | - lines.each do | line | - convert_one_liners(line, group) - end - convert_setup(lines, group) - convert_teardown(lines, group) - end - end - - def get_test_group(lines) - @test_group = "None" - lines.each do | line | - if /TEST_GROUP/ =~ line - @test_group = line.split(/[()]/)[1] - end - end - @test_group - end - - def get_test_groups(lines) - @test_groups = [] - i = 0 - lines.each do | line | - if /TEST_GROUP/ =~ line - @test_groups[i] = line.split(/[()]/)[1] - i = i + 1 - end - end - @test_groups - end - - def adjust_tabs(lines) - lines.each do | line | - - line.gsub!(/^ {2,3}(\w+)/, " \\1") - line.gsub!(/\t/, " ") - end - end - - def include_line?(line) - /\#include/ =~ line - end - - def convert_member_to_static(line) - line.gsub!(/^\s*(\w)/, "static \\1") - end - - def add_semicolon_to_end_of_test_group_line(line) - line.gsub!(/\)/, ");") - end - - def consume_closing_curley_brace(line) - line.gsub!(/\}\;*[ \t]*(.*)/, "\\1") - end - - def outdent(line) - line.gsub!(/^ /, "") - end - - def consume_opening_curley_brace(line) - line.gsub!(/\{/, "") - end - - def demote_group(group, lines) - test_group = "None" - scope_level = 0 - in_test_group = false - lines.each do | line | - next if include_line?(line) - - if !in_test_group - if line.match(group) - add_semicolon_to_end_of_test_group_line(line) - in_test_group = true - end - next - end - - if line.include?("}") - scope_level -= 1 - elsif line.include?("{") - scope_level += 1 - end - - outdent(line) - - if scope_level == 1 - convert_member_to_static(line) - consume_opening_curley_brace(line) - end - if scope_level == 0 - consume_closing_curley_brace(line) - in_test_group = false - end - end - end - -def search_and_destroy(pattern, lines) - lines.each do | line | - line.gsub!(pattern, "") - end -end - -def extern_c_line?(line) - line.match(/extern \"C\"/) -end - -def remove_extern_c(lines) - in_extern_c = false; - scope_level = 0 - - lines.each do | line | - if !in_extern_c - if extern_c_line?(line) - in_extern_c = true - line.gsub!(/extern \"C\"/, "") - end - next - end - - # next if ! in_extern_c and ! extern_c_line?(line) - # - # in_extern_c = true - if line.include?("{") - scope_level += 1 - elsif line.include?("}") - scope_level -= 1 - end - - if scope_level == 1 - consume_opening_curley_brace(line) - end - - if scope_level == 0 and line.include?("}") - in_extern_c = false - consume_closing_curley_brace(line) - end - end -end - - - def test_declaration?(line, group) - /TEST\(#{group}/ =~ line - end - - def generate_group_runner(group, lines) - group_runner = [] - group_runner << "/* Make sure you invoke RUN_TEST_GROUP(" + group + ") from unity main */\n\n" - group_runner << "TEST_GROUP_RUNNER(" + group + ")\n" - group_runner << "{\n" - lines.each do | line | - if test_declaration?(line, group) - temp = line.clone - temp.sub!(/\n/, "") - temp.sub!(/^IGNORE_/, "") - temp.sub!(/^TEST/, " RUN_TEST_CASE") - group_runner << temp + ";\n" - end - end - group_runner << "}\n\n" - end - - def generate_group_runners(groups, lines) - group_runners = [] - group_runners << "/* Generated code, edit at your own risk */\n\n" - group_runners << "#include \"unity_fixture.h\"\n\n" - groups.each do | group | - group_runners.concat generate_group_runner(group, lines) - end - group_runners - end - - def generate_group_runner_plainUnity(group, lines) - prototypes = [] - callers = [] - group_runner = [] - lines.each do | line | - if /void test.*\(.*\)/ =~ line - temp = line.clone - temp.sub!(/\n/, "") - prototypes << temp + ";" - temp.sub!(/void /, " ") - temp.sub!(/\(void\)/, "()") - callers << temp - end - end - group_runner << "\n" - group_runner << "//Generated code, edit at your own risk\n\n" - group_runner << "\#include \"unity_fixture.h\"\n\n" - group_runner << prototypes - group_runner << "\n\nTEST_GROUP_RUNNER(" + group + ")\n" - group_runner << "{\n" - group_runner << callers - group_runner << "}\n" - end - - def write_lines_to_file(file, lines) - lines.each do | line | - file.write(line) - end - end -end \ No newline at end of file diff --git a/scripts/convertToUnity/cpp_u_test_to_unity_utils_tests.rb b/scripts/convertToUnity/cpp_u_test_to_unity_utils_tests.rb deleted file mode 100755 index 797d98014..000000000 --- a/scripts/convertToUnity/cpp_u_test_to_unity_utils_tests.rb +++ /dev/null @@ -1,506 +0,0 @@ -#!/usr/bin/env ruby - -require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb') -include CppUTestToUnityUtils - -test_lines = Array.new -expected_lines = Array.new - - -def check(theTest, expected, actual) - unless (expected == actual) - puts theTest + " failed" - puts "Actual:\n" - show(actual) - puts "unmatched lines" - show(expected - actual) - puts("Expected: " + expected.inspect) - puts(" Actual: " + actual.inspect) - end -end - -#--------------------------------------------------- - -test_lines = -[ - "\n", - "TEST_GROUP(mygroup)\n", - "{\n", - "}\n", - "\n", - "\n", - "TEST_GROUP(yourgroup)\n", - "{\n", - "}\n", - "\n" -] - - -groups = get_test_groups(test_lines) -unless /mygroup/ =~ groups[0] - puts "Expected mygroup, but got #{groups[0]}" -end - -unless /yourgroup/ =~ groups[1] - puts "Expected yourgroup, but got #{groups[1]}" -end - -#--------------------------------------------------- - -test_lines = -["\n", -"TEST_GROUP(mygroup)\n", -"{\n", -" int xxxx;\n", -" void yyyy()\n", -" {\n", -" int i = 0;\n", -" }\n", -"};\n", -"\n", -" void f()\n" -] - -expected_lines = -["\n", -"TEST_GROUP(mygroup);\n", -"\n", -"static int xxxx;\n", -"static void yyyy()\n", -"{\n", -" int i = 0;\n", -"}\n", -"\n", -"\n", -" void f()\n" -] - -def show(lines) - lines.each do | line | - puts line - end -end - - -demote_group(/TEST_GROUP/, test_lines) -check("demote_group", expected_lines, test_lines) -#--------------------------------- - -test_lines = -[ - "\n", - "TEST_GROUP(mygroup)\n", - "{\n", - "}\n", - ";\n", - "\n", - "TEST_GROUP(yourgroup)\n", - "{\n", - "}\n", - ";\n" -] - -expected_lines = -[ - "\n", - "TEST_GROUP(mygroup);\n", - "\n", - "\n", - ";\n", - "\n", - "TEST_GROUP(yourgroup);\n", - "\n", - "\n", - ";\n" -] - -demote_group(/TEST_GROUP/, test_lines) -check("demote_group", expected_lines, test_lines) - -#--------------------------------- - -test_lines = -["\n", -"TEST_GROUP(mygroup)\n", -"{\n", -" int xxxx;\n", -" void yyyy()\n", -" {\n", -" int i = 0;\n", -" }\n", -"}; //End TEST_GROUP\n", -"\n" -] - -expected_lines = -["\n", -"TEST_GROUP(mygroup);\n", -"\n", -"static int xxxx;\n", -"static void yyyy()\n", -"{\n", -" int i = 0;\n", -"}\n", -"//End TEST_GROUP\n", -"\n" -] - -demote_group(/TEST_GROUP/, test_lines) -check("demote_group", expected_lines, test_lines) - -#--------------------------------------------------- - -test_lines = -["\n", -"extern \"C\"\n", -"{\n", -"\#include \"heythere.h\"\n", -"int xxxx;\n", -"void yyyy()\n", -"{\n", -" int i = 0;\n", -"}\n", -"}\n", -"int foo()\n", -"{\n", -" int aaaa;\n", -"}\n" -] - -expected_lines = -["\n", -"\n", -"\n", -"\#include \"heythere.h\"\n", -"int xxxx;\n", -"void yyyy()\n", -"{\n", -" int i = 0;\n", -"}\n", -"\n", -"int foo()\n", -"{\n", -" int aaaa;\n", -"}\n" -] - -remove_extern_c(test_lines) -check("remove_extern_c", expected_lines, test_lines) - -#--------------------------------------------------- - -test_lines = -["\n", -"extern \"C\"\n", -"{\n", -"#include \"LightScheduler.h\"\n", -"#include \"FakeLightController.h\"\n", -"#include \"FakeTimeService.h\"\n", -"#include \"FakeRandomMinute.h\"\n", -"}\n", -"#include \"CppUTest/TestHarness.h\"\n" -] - -expected_lines = -["\n", -"\n", -"\n", -"#include \"LightScheduler.h\"\n", -"#include \"FakeLightController.h\"\n", -"#include \"FakeTimeService.h\"\n", -"#include \"FakeRandomMinute.h\"\n", -"\n", -"#include \"CppUTest/TestHarness.h\"\n" -] - -remove_extern_c(test_lines) -check("remove_extern_c", expected_lines, test_lines) - -#--------------------------------------------------- - -test_lines = -[ -"\n", -"#include \"unity_fixture.h\" expected\n", -"#include \"CppUTest\/TestHarness.h\"\n", -"\n", -"TEST_SETUP(theGroup) expected\n", -"static void setup()\n", -"{\n", -" x = 1;\n", -"}\n", -"TEST_TEAR_DOWN(theGroup) expected\n", -"static void teardown()\n", -"{\n", -" y = 0;\n", -"}\n", -"TEST(LedDriver, Create)\n", -"{\n", -" FAIL(\"Start here\");\n", -"}\n", -"\n", -"IGNORE_TEST(LedDriver, ignore)\n", -"{\n", -" TEST_ASSERT_TRUE(0 == 0); expected\n", -" CHECK(0 == 0);\n", -"\n", -" TEST_ASSERT_TRUE(0 == 0); expected\n", -" CHECK_TRUE(0 == 0);\n", -"\n", -" TEST_ASSERT_FALSE(0 != 0); expected\n", -" CHECK_FALSE(0 != 0);\n", -"\n", -" TEST_ASSERT_EQUAL(1,1); expected\n", -" LONGS_EQUAL(1,1);\n", -"\n", -" TEST_ASSERT_EQUAL_HEX8(0xab,0xab); expected\n", -" BYTES_EQUAL(0xab,0xab);\n", -"\n", -" TEST_ASSERT_EQUAL(100,100); expected\n", -" CHECK_EQUAL(100,100);\n", -"\n", -" TEST_ASSERT_TRUE(true); expected\n", -" CHECK_EQUAL(true,true);\n", -"\n", -" TEST_ASSERT_FALSE(false); expected\n", -" CHECK_EQUAL(false,false);\n", -"\n", -" TEST_ASSERT_EQUAL_STRING(\"THIS\", \"THIS\"); expected\n", -" STRCMP_EQUAL(\"THIS\", \"THIS\");\n", -"\n", -" TEST_ASSERT_FLOAT_WITHIN(1.0, 1.0, .01); expected\n", -" DOUBLES_EQUAL(1.0, 1.0, .01);\n", -"\n", -" TEST_ASSERT_POINTERS_EQUAL(this, this); expected\n", -" POINTERS_EQUAL(this, this);\n", -"}\n" -] - -expected_lines = -[ -"\n", -"#include \"unity_fixture.h\" expected\n", -"#include \"unity_fixture.h\"\n", -"\n", -"TEST_SETUP(theGroup) expected\n", -"TEST_SETUP(theGroup)\n", -"{\n", -" x = 1;\n", -"}\n", -"TEST_TEAR_DOWN(theGroup) expected\n", -"TEST_TEAR_DOWN(theGroup)\n", -"{\n", -" y = 0;\n", -"}\n", -"TEST(LedDriver, Create)\n", -"{\n", -" TEST_FAIL(\"Start here\");\n", -"}\n", -"\n", -"IGNORE_TEST(LedDriver, ignore)\n", -"{\n", -" TEST_ASSERT_TRUE(0 == 0); expected\n", -" TEST_ASSERT_TRUE(0 == 0);\n", -"\n", -" TEST_ASSERT_TRUE(0 == 0); expected\n", -" TEST_ASSERT_TRUE(0 == 0);\n", -"\n", -" TEST_ASSERT_FALSE(0 != 0); expected\n", -" TEST_ASSERT_FALSE(0 != 0);\n", -"\n", -" TEST_ASSERT_EQUAL(1,1); expected\n", -" TEST_ASSERT_EQUAL(1,1);\n", -"\n", -" TEST_ASSERT_EQUAL_HEX8(0xab,0xab); expected\n", -" TEST_ASSERT_EQUAL_HEX8(0xab,0xab);\n", -"\n", -" TEST_ASSERT_EQUAL(100,100); expected\n", -" TEST_ASSERT_EQUAL(100,100);\n", -"\n", -" TEST_ASSERT_TRUE(true); expected\n", -" TEST_ASSERT_TRUE(true);\n", -"\n", -" TEST_ASSERT_FALSE(false); expected\n", -" TEST_ASSERT_FALSE(false);\n", -"\n", -" TEST_ASSERT_EQUAL_STRING(\"THIS\", \"THIS\"); expected\n", -" TEST_ASSERT_EQUAL_STRING(\"THIS\", \"THIS\");\n", -"\n", -" TEST_ASSERT_FLOAT_WITHIN(1.0, 1.0, .01); expected\n", -" TEST_ASSERT_FLOAT_WITHIN(1.0, 1.0, .01);\n", -"\n", -" TEST_ASSERT_POINTERS_EQUAL(this, this); expected\n", -" TEST_ASSERT_POINTERS_EQUAL(this, this);\n", -"}\n" -] - -convert_macros(test_lines, ["theGroup"]) -check("convert_macros", expected_lines, test_lines) - -#--------------------------------------------------- - -test_lines = -[ - "TEST_SETUP(group1) expected\n", - "static void setup()\n", - "TEST_TEAR_DOWN(group1) expected\n", - "static void teardown()\n", - "TEST(group1, Create)\n", - "IGNORE_TEST(group1, ignore)\n", - "TEST_SETUP(group2) expected\n", - "static void setup()\n", - "TEST_TEAR_DOWN(group2) expected\n", - "static void teardown()\n", - "TEST(group2, Create)\n", - "IGNORE_TEST(group2, ignore)\n" -] - -expected_lines = -[ - "TEST_SETUP(group1) expected\n", - "TEST_SETUP(group1)\n", - "TEST_TEAR_DOWN(group1) expected\n", - "TEST_TEAR_DOWN(group1)\n", - "TEST(group1, Create)\n", - "IGNORE_TEST(group1, ignore)\n", - "TEST_SETUP(group2) expected\n", - "TEST_SETUP(group2)\n", - "TEST_TEAR_DOWN(group2) expected\n", - "TEST_TEAR_DOWN(group2)\n", - "TEST(group2, Create)\n", - "IGNORE_TEST(group2, ignore)\n", -] - -convert_macros(test_lines, ["group1", "group2"]) -check("convert_macros", expected_lines, test_lines) - -#--------------------------------------------------- - -test_lines = -[ - " aaaa expected\n", - "\taaa\n", - " bbbb expected\n", - "\t\t\t\tbbbb\n", - " int a3; expected\n", - " int a3;\n", - " int a4; expected\n", - " int a4;\n" -] - -expected_lines = -[ - " aaaa expected\n", - " aaa\n", - " bbbb expected\n", - " bbbb\n", - " int a3; expected\n", - " int a3;\n", - " int a4; expected\n", - " int a4;\n" -] - -adjust_tabs(test_lines) -check("adjust_tabs", expected_lines, test_lines) - - -#--------------------------------------------------- - -test_lines = -[ - "TEST(LedDriver, Create)\n", - "{\n", - " FAIL(\"Start here\");\n", - "}\n", - "\n", - "TEST(LedDriver, XXXXX)\n", - "{\n", - " FAIL(\"Start here\");\n", - "}\n", - "\n", - "IGNORE_TEST(LedDriver, ignore)\n", - "{\n", - " TEST_ASSERT_TRUE(0 == 0); expected\n", - "}\n" -] - -expected_group_runner = -[ - "/* Make sure you invoke RUN_TEST_GROUP(LedDriver) from unity main */\n\n", - "TEST_GROUP_RUNNER(LedDriver)\n", - "{\n", - " RUN_TEST_CASE(LedDriver, Create);\n", - " RUN_TEST_CASE(LedDriver, XXXXX);\n", - " RUN_TEST_CASE(LedDriver, ignore);\n", - "}\n\n" -] - -group_runner = generate_group_runner("LedDriver", test_lines) -check("generate_group_runner", expected_group_runner, group_runner) - - - #--------------------------------------------------- - - test_lines = - [ - "TEST(LedDriverGroup1, Create)\n", - "{\n", - " FAIL(\"Start here\");\n", - "}\n", - "\n", - "TEST(LedDriverGroup2, XXXXX)\n", - "{\n", - " FAIL(\"Start here\");\n", - "}\n", - "\n" - ] - - expected_group_runners = - [ - "/* Generated code, edit at your own risk */\n\n", - "#include \"unity_fixture.h\"\n\n", - "/* Make sure you invoke RUN_TEST_GROUP(LedDriverGroup1) from unity main */\n\n", - "TEST_GROUP_RUNNER(LedDriverGroup1)\n", - "{\n", - " RUN_TEST_CASE(LedDriverGroup1, Create);\n", - "}\n\n", - "/* Make sure you invoke RUN_TEST_GROUP(LedDriverGroup2) from unity main */\n\n", - "TEST_GROUP_RUNNER(LedDriverGroup2)\n", - "{\n", - " RUN_TEST_CASE(LedDriverGroup2, XXXXX);\n", - "}\n\n" - ] - - runners = generate_group_runners(["LedDriverGroup1", "LedDriverGroup2"], test_lines) - check("generate_group_runners", expected_group_runners, runners) - - -#--------------------------------------------------- - -test_filename = "prefix/tests/pooltable/EightballTest.cpp" -expected_unity_filename = "prefix/unity/pooltable/EightballTest.c" - -unity_filename = convert_test_filename_to_unity_filename(test_filename) - -if expected_unity_filename != unity_filename - puts("Failure in: convert_test_path_to_unity_path") - puts("Expected: " + expected_unity_filename.inspect) - puts(" Actual: " + unity_filename.inspect) -end - -#--------------------------------------------------- - -test_filename = "tests/pool/table/EightballTest.cpp" -expected_unity_runner_filename = "unity/pool/table/EightballTest_runner.c" - -unity_runner_filename = convert_test_filename_to_unity_testrunner_filename(test_filename) - -if expected_unity_runner_filename != unity_runner_filename - puts("Failure in: convert_test_path_to_unity_path") - puts("Expected: " + expected_unity_runner_filename.inspect) - puts(" Actual: " + unity_runner_filename.inspect) -end - - - - diff --git a/scripts/convertToUnity/create_group_runner.rb b/scripts/convertToUnity/create_group_runner.rb deleted file mode 100755 index 120be21bb..000000000 --- a/scripts/convertToUnity/create_group_runner.rb +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env ruby - -require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb') -include CppUTestToUnityUtils - -in_file = ARGV[0] -create_group_runner_file(in_file) -unity_runner_filename = convert_test_filename_to_unity_testrunner_filename(in_file) -puts "Creating test runner for :" + in_file + "\n" -puts " Generating :" + unity_filename + "\n" - -test_lines = File.open(in_file).readlines -out_unity_runner_file = File.open(unity_runner_filename, 'w') - -test_group = get_test_group(test_lines) -group_runner = generate_group_runner(test_group, test_lines) -write_lines_to_file(out_unity_runner_file, group_runner) -out_unity_runner_file.close() diff --git a/scripts/convertToUnity/create_unity_test_runner.rb b/scripts/convertToUnity/create_unity_test_runner.rb deleted file mode 100755 index 711437b64..000000000 --- a/scripts/convertToUnity/create_unity_test_runner.rb +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env ruby - -require File.join(File.dirname(__FILE__), 'cpp_u_test_to_unity_utils.rb') -include CppUTestToUnityUtils - -in_file = ARGV[0] -test_lines = File.open(in_file).collect -out_file = File.open(File.basename(in_file, ".c") + "_runner.c", 'w') - -group_runner = generate_group_runner_plainUnity("unity", test_lines) -write_lines_to_file(out_file, group_runner) -out_file.close() - diff --git a/scripts/create_docker_images_and_containers b/scripts/create_docker_images_and_containers deleted file mode 100755 index ab4ec05b6..000000000 --- a/scripts/create_docker_images_and_containers +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -#$1 is the container name - -checkForCppUTestToolsEnvVariable() { - if [ -z "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set. You must set CPPUTEST_HOME to the top level CppUTest directory" - exit 1 - fi - if [ ! -d "$CPPUTEST_HOME" ] ; then - echo "CPPUTEST_HOME not set to a directory. You must set CPPUTEST_HOME to the top level CppUTest directory" - exit 2 - fi -} - -checkForImageNameParameter() { - if [ -z "$container" ] ; then - echo "Container name parameter not set. Check the docker directory. It should be the extension of the Dockerfile. e.g. ubuntu" - exit 1 - fi - if [ ! -f "$CPPUTEST_HOME/docker/Dockerfile.$container" ] ; then - echo "The Dockerfile docker/Dockerfile.$container doesn't exist. Typo?" - exit 2 - fi -} - - -container=$1 -checkForCppUTestToolsEnvVariable -checkForImageNameParameter - -docker build -f $CPPUTEST_HOME/docker/Dockerfile.$container --tag cpputest/$container:latest . -docker container rm cpputest_$container -docker create -it -v$CPPUTEST_HOME:/cpputest -e "CPPUTEST_HOME=/cpputest" --name cpputest_$container cpputest/$container:latest - -echo "You can run your container through: docker start -i cpputest_. E.g. docker start -i cpputest_$container" - - diff --git a/scripts/dos_build_test.sh b/scripts/dos_build_test.sh deleted file mode 100755 index cf10fe5a9..000000000 --- a/scripts/dos_build_test.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# get current dir even if the script is sourced -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" - -export CPPUTEST_HOME="$DIR/../" -export WATCOM=./watcom -export PATH=$PATH:$WATCOM/binl - -if [ ! -d "$WATCOM" ]; then - git clone https://github.com/cpputest/watcom-compiler.git "$WATCOM" -fi - -make -f "$CPPUTEST_HOME/platforms/Dos/Makefile" clean -make -f "$CPPUTEST_HOME/platforms/Dos/Makefile" -make -f "$CPPUTEST_HOME/platforms/Dos/Makefile" test diff --git a/scripts/filterGcov.sh b/scripts/filterGcov.sh deleted file mode 100755 index b3ff67fee..000000000 --- a/scripts/filterGcov.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -INPUT_FILE=$1 -TEMP_FILE1=${INPUT_FILE}1.tmp -TEMP_FILE2=${INPUT_FILE}2.tmp -TEMP_FILE3=${INPUT_FILE}3.tmp -ERROR_FILE=$2 -OUTPUT_FILE=$3 -HTML_OUTPUT_FILE=$3.html -TEST_RESULTS=$4 - -flattenGcovOutput() { -while read line1 -do - read line2 - echo $line2 " " $line1 - read junk - read junk -done < ${INPUT_FILE} -} - -getRidOfCruft() { -sed '-e s/^Lines.*://g' \ - '-e s/^[0-9]\./ &/g' \ - '-e s/^[0-9][0-9]\./ &/g' \ - '-e s/of.\w[^'File']*File/ /g' \ - "-e s/'//g" \ - '-e s/^.*\/usr\/.*$//g' \ - '-e s/^.*\.$//g' -} - -flattenPaths() { -sed \ - -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \ - -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \ - -e 's/\/[^/][^/]*\/[^/][^/]*\/\.\.\/\.\.\//\//g' \ - -e 's/\/[^/][^/]*\/\.\.\//\//g' -} - -getFileNameRootFromErrorFile() { -sed '-e s/gc..:cannot open .* file//g' ${ERROR_FILE} -} - -writeEachNoTestCoverageFile() { -while read line -do - echo " 0.00% " ${line} -done -} - -createHtmlOutput() { - echo "" - echo "" - sed "-e s/.*% /
CoverageFile
&<\/td>/" \ - "-e s/[a-zA-Z0-9_]*\.[ch][a-z]*/&<\/a><\/td><\/tr>/" - echo "
" - sed "-e s/.*/&
/g" < ${TEST_RESULTS} -} - -flattenGcovOutput | getRidOfCruft | flattenPaths > ${TEMP_FILE1} -getFileNameRootFromErrorFile | writeEachNoTestCoverageFile | flattenPaths > ${TEMP_FILE2} -cat ${TEMP_FILE1} ${TEMP_FILE2} | sort | uniq > ${OUTPUT_FILE} -createHtmlOutput < ${OUTPUT_FILE} > ${HTML_OUTPUT_FILE} -rm -f ${TEMP_FILE1} ${TEMP_FILE2} diff --git a/scripts/generate_junit_report_ant.xml b/scripts/generate_junit_report_ant.xml deleted file mode 100644 index debaeb32f..000000000 --- a/scripts/generate_junit_report_ant.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/scripts/reformat.sh b/scripts/reformat.sh deleted file mode 100755 index f118561af..000000000 --- a/scripts/reformat.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e -ASTYLE_OPTIONS="--convert-tabs --indent=spaces=4 --indent-classes --indent-switches --indent-preprocessor --style=ansi" - -find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" | -while read filename; do - tmpfile=${filename}.astyle.cpp - astyle ${ASTYLE_OPTIONS} <"${filename}" > "${tmpfile}" - mv "${tmpfile}" "${filename}" -done diff --git a/scripts/squeeze.sh b/scripts/squeeze.sh deleted file mode 100755 index 18a4153d5..000000000 --- a/scripts/squeeze.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sed -f -s/[ ][ ]*/ /g diff --git a/scripts/svnignore.txt b/scripts/svnignore.txt deleted file mode 100644 index 1368c0d56..000000000 --- a/scripts/svnignore.txt +++ /dev/null @@ -1,31 +0,0 @@ -doxygen -*.d -*/Debug/* -*.exe -*.obj -*.o -*.a -*.ncb -*.opt -*.plg -*.idb -*.pdb -*.lib -.settings -*doxygen* -*.gcov -*.gcno -*.gcda -*_tests -*_cslim -*a.out -*.zip -tmp -pdfs -*.map -gcov -objs -lib -*_tests.txt -gcov*.html -Releases \ No newline at end of file diff --git a/scripts/templates/ClassName.cpp b/scripts/templates/ClassName.cpp deleted file mode 100644 index c80207946..000000000 --- a/scripts/templates/ClassName.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ClassName.h" - -ClassName::ClassName() -{ -} - -ClassName::~ClassName() -{ -} - diff --git a/scripts/templates/ClassName.h b/scripts/templates/ClassName.h deleted file mode 100644 index 88803e2ec..000000000 --- a/scripts/templates/ClassName.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ClassName is responsible for ... -// -/////////////////////////////////////////////////////////////////////////////// - -class ClassName - { - public: - explicit ClassName(); - virtual ~ClassName(); - - private: - - ClassName(const ClassName&); - ClassName& operator=(const ClassName&); - - }; - -#endif // D_ClassName_H diff --git a/scripts/templates/ClassNameC.c b/scripts/templates/ClassNameC.c deleted file mode 100644 index ffde4228a..000000000 --- a/scripts/templates/ClassNameC.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "ClassName.h" - -void ClassName_Create(void) -{ -} - -void ClassName_Destroy(void) -{ -} - - diff --git a/scripts/templates/ClassNameC.h b/scripts/templates/ClassNameC.h deleted file mode 100644 index af39b2e37..000000000 --- a/scripts/templates/ClassNameC.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/********************************************************** - * - * ClassName is responsible for ... - * - **********************************************************/ - -void ClassName_Create(void); -void ClassName_Destroy(void); - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/ClassNameCIoDriver.c b/scripts/templates/ClassNameCIoDriver.c deleted file mode 100644 index 4c2d2c453..000000000 --- a/scripts/templates/ClassNameCIoDriver.c +++ /dev/null @@ -1,12 +0,0 @@ -#include "ClassName.h" -#include "IO.h" - -void ClassName_Create(void) -{ -} - -void ClassName_Destroy(void) -{ -} - - diff --git a/scripts/templates/ClassNameCIoDriver.h b/scripts/templates/ClassNameCIoDriver.h deleted file mode 100644 index c10c17785..000000000 --- a/scripts/templates/ClassNameCIoDriver.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/********************************************************** - * - * ClassName is responsible for ... - * - **********************************************************/ -#include - -void ClassName_Create(void); -void ClassName_Destroy(void); - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/ClassNameCIoDriverTest.cpp b/scripts/templates/ClassNameCIoDriverTest.cpp deleted file mode 100644 index b4933e487..000000000 --- a/scripts/templates/ClassNameCIoDriverTest.cpp +++ /dev/null @@ -1,27 +0,0 @@ -extern "C" { -#include "ClassName.h" -#include "MockIO.h" -} - -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - Reset_Mock_IO(); - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - Assert_No_Unused_Expectations(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/templates/ClassNameCMultipleInstance.c b/scripts/templates/ClassNameCMultipleInstance.c deleted file mode 100644 index 5cd99e784..000000000 --- a/scripts/templates/ClassNameCMultipleInstance.c +++ /dev/null @@ -1,21 +0,0 @@ -#include "ClassName.h" -#include -#include - -typedef struct ClassNameStruct -{ - int placeHolderForHiddenStructElements; -} ClassNameStruct; - -ClassName ClassName_Create(void) -{ - ClassName self = calloc(1, sizeof(ClassNameStruct)); - return self; -} - -void ClassName_Destroy(ClassName self) -{ - free(self); -} - - diff --git a/scripts/templates/ClassNameCMultipleInstance.h b/scripts/templates/ClassNameCMultipleInstance.h deleted file mode 100644 index c7103cc2f..000000000 --- a/scripts/templates/ClassNameCMultipleInstance.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/********************************************************************** - * - * ClassName is responsible for ... - * - **********************************************************************/ - -typedef struct ClassNameStruct * ClassName; - -ClassName ClassName_Create(void); -void ClassName_Destroy(ClassName); - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/ClassNameCMultipleInstanceTest.cpp b/scripts/templates/ClassNameCMultipleInstanceTest.cpp deleted file mode 100644 index c8fe499de..000000000 --- a/scripts/templates/ClassNameCMultipleInstanceTest.cpp +++ /dev/null @@ -1,27 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - ClassName aClassName; - - void setup() - { - aClassName = ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(aClassName); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/templates/ClassNameCPolymorphic.c b/scripts/templates/ClassNameCPolymorphic.c deleted file mode 100644 index cf839bf84..000000000 --- a/scripts/templates/ClassNameCPolymorphic.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "ClassName.h" -#include -#include - -typedef struct ClassName -{ - int placeHolderForHiddenStructElements; -}; - -ClassName* ClassName_Create(void) -{ - ClassName* self = malloc(sizeof(ClassName)); - memset(self, 0, sizeof(ClassName)); - return self; -} - -void ClassName_Destroy(ClassName* self) -{ - free(self); -} - - diff --git a/scripts/templates/ClassNameCPolymorphic.h b/scripts/templates/ClassNameCPolymorphic.h deleted file mode 100644 index af24a141c..000000000 --- a/scripts/templates/ClassNameCPolymorphic.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/********************************************************** - * - * ClassName is responsible for ... - * - **********************************************************/ - -typedef struct ClassName ClassNamePiml; - -ClassName* ClassName_Create(void); -void ClassName_Destroy(ClassName*); -void ClassName_VirtualFunction_impl(ClassName*); - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/ClassNameCTest.cpp b/scripts/templates/ClassNameCTest.cpp deleted file mode 100644 index 49e8b48e9..000000000 --- a/scripts/templates/ClassNameCTest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/templates/ClassNameTest.cpp b/scripts/templates/ClassNameTest.cpp deleted file mode 100644 index 5b0780150..000000000 --- a/scripts/templates/ClassNameTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ClassName.h" - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - ClassName* aClassName; - - void setup() - { - aClassName = new ClassName(); - } - void teardown() - { - delete aClassName; - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/templates/FunctionNameC.c b/scripts/templates/FunctionNameC.c deleted file mode 100644 index 6c8cc20d5..000000000 --- a/scripts/templates/FunctionNameC.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "ClassName.h" - -void ClassName() -{ -} diff --git a/scripts/templates/FunctionNameC.h b/scripts/templates/FunctionNameC.h deleted file mode 100644 index 39cbf2f08..000000000 --- a/scripts/templates/FunctionNameC.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef D_ClassName_H -#define D_ClassName_H - -/********************************************************** - * - * ClassName is responsible for ... - * - **********************************************************/ - -void ClassName(); - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/FunctionNameCTest.cpp b/scripts/templates/FunctionNameCTest.cpp deleted file mode 100644 index 07cc16428..000000000 --- a/scripts/templates/FunctionNameCTest.cpp +++ /dev/null @@ -1,23 +0,0 @@ -extern "C" -{ -#include "ClassName.h" -} - -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - } - - void teardown() - { - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} - diff --git a/scripts/templates/InterfaceCTest.cpp b/scripts/templates/InterfaceCTest.cpp deleted file mode 100644 index 8052f8156..000000000 --- a/scripts/templates/InterfaceCTest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -extern "C" -{ -#include "FakeClassName.h" -} - -//CppUTest includes should be after your and system includes -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - void setup() - { - ClassName_Create(); - } - - void teardown() - { - ClassName_Destroy(); - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} diff --git a/scripts/templates/InterfaceTest.cpp b/scripts/templates/InterfaceTest.cpp deleted file mode 100644 index 571336de9..000000000 --- a/scripts/templates/InterfaceTest.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "ClassName.h" -#include "MockClassName.h" - -#include "CppUTest/TestHarness.h" - -TEST_GROUP(ClassName) -{ - ClassName* aClassName; - MockClassName* mockClassName; - - void setup() - { - mockClassName = new MockClassName(); - aClassName = mockClassName; - } - void teardown() - { - delete aClassName; - } -}; - -TEST(ClassName, Create) -{ - FAIL("Start here"); -} diff --git a/scripts/templates/MockClassName.h b/scripts/templates/MockClassName.h deleted file mode 100644 index 0e6778928..000000000 --- a/scripts/templates/MockClassName.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef D_MockClassName_H -#define D_MockClassName_H - -/////////////////////////////////////////////////////////////////////////////// -// -// MockClassName.h -// -// MockClassName is responsible for providing a test stub for ClassName -// -/////////////////////////////////////////////////////////////////////////////// -#include "ClassName.h" - - -class MockClassName : public ClassName - { - public: - explicit MockClassName() - {} - virtual ~MockClassName() - {} - - private: - - MockClassName(const MockClassName&); - MockClassName& operator=(const MockClassName&); - - }; - -#endif // D_MockClassName_H diff --git a/scripts/templates/MockClassNameC.c b/scripts/templates/MockClassNameC.c deleted file mode 100644 index ffde4228a..000000000 --- a/scripts/templates/MockClassNameC.c +++ /dev/null @@ -1,11 +0,0 @@ -#include "ClassName.h" - -void ClassName_Create(void) -{ -} - -void ClassName_Destroy(void) -{ -} - - diff --git a/scripts/templates/MockClassNameC.h b/scripts/templates/MockClassNameC.h deleted file mode 100644 index a9059d83c..000000000 --- a/scripts/templates/MockClassNameC.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef D_FakeClassName_H -#define D_FakeClassName_H - -/********************************************************** - * - * FakeClassName is responsible for providing a - * test stub for ClassName - * - **********************************************************/ - -#include "ClassName.h" - -#endif /* D_FakeClassName_H */ diff --git a/scripts/templates/ProjectTemplate/Project.cproject b/scripts/templates/ProjectTemplate/Project.cproject deleted file mode 100644 index a3fb56605..000000000 --- a/scripts/templates/ProjectTemplate/Project.cproject +++ /dev/null @@ -1,373 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/scripts/templates/ProjectTemplate/Project.project b/scripts/templates/ProjectTemplate/Project.project deleted file mode 100644 index 98a6acddb..000000000 --- a/scripts/templates/ProjectTemplate/Project.project +++ /dev/null @@ -1,77 +0,0 @@ - - - Project - - - - - - 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 - - - - - - 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/scripts/templates/ProjectTemplate/ProjectMakefile b/scripts/templates/ProjectTemplate/ProjectMakefile deleted file mode 100644 index f426016c8..000000000 --- a/scripts/templates/ProjectTemplate/ProjectMakefile +++ /dev/null @@ -1,41 +0,0 @@ -#Set this to @ to keep the makefile quiet -SILENCE = @ - -#---- Outputs ----# -COMPONENT_NAME = Project -#Set this to @ to keep the makefile quiet -SILENCE = @ - -#--- Inputs ----# -PROJECT_HOME_DIR = . -ifeq "$(CPPUTEST_HOME)" "" - CPPUTEST_HOME = ../CppUTest -endif -CPP_PLATFORM = Gcc - -SRC_DIRS = \ - src\ - src/* - -# to pick specific files (rather than directories) use this: -SRC_FILES = - -TEST_SRC_DIRS = \ - tests \ - tests/* - -MOCKS_SRC_DIRS = \ - mocks \ - -INCLUDE_DIRS =\ - .\ - include \ - include/* \ - $(CPPUTEST_HOME)/include/ \ - mocks - -CPPUTEST_WARNINGFLAGS = -Wall -Werror -Wswitch-default -CPPUTEST_WARNINGFLAGS += -Wconversion -Wswitch-enum - -include $(CPPUTEST_HOME)/build/MakefileWorker.mk - diff --git a/scripts/templates/ProjectTemplate/include/util/ProjectBuildTime.h b/scripts/templates/ProjectTemplate/include/util/ProjectBuildTime.h deleted file mode 100644 index b951739a2..000000000 --- a/scripts/templates/ProjectTemplate/include/util/ProjectBuildTime.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef D_ProjectBuildTime_H -#define D_ProjectBuildTime_H - -/////////////////////////////////////////////////////////////////////////////// -// -// ProjectBuildTime is responsible for recording and reporting when -// this project library was built -// -/////////////////////////////////////////////////////////////////////////////// - -class ProjectBuildTime - { - public: - explicit ProjectBuildTime(); - virtual ~ProjectBuildTime(); - - const char* GetDateTime(); - - private: - - const char* dateTime; - - ProjectBuildTime(const ProjectBuildTime&); - ProjectBuildTime& operator=(const ProjectBuildTime&); - - }; - -#endif // D_ProjectBuildTime_H diff --git a/scripts/templates/ProjectTemplate/src/util/ProjectBuildTime.cpp b/scripts/templates/ProjectTemplate/src/util/ProjectBuildTime.cpp deleted file mode 100644 index 483a5e44d..000000000 --- a/scripts/templates/ProjectTemplate/src/util/ProjectBuildTime.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "ProjectBuildTime.h" - -ProjectBuildTime::ProjectBuildTime() -: dateTime(__DATE__ " " __TIME__) -{ -} - -ProjectBuildTime::~ProjectBuildTime() -{ -} - -const char* ProjectBuildTime::GetDateTime() -{ - return dateTime; -} - diff --git a/scripts/templates/ProjectTemplate/tests/AllTests.cpp b/scripts/templates/ProjectTemplate/tests/AllTests.cpp deleted file mode 100644 index 3932fd103..000000000 --- a/scripts/templates/ProjectTemplate/tests/AllTests.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "CppUTest/CommandLineTestRunner.h" - -int main(int ac, char** av) -{ - return CommandLineTestRunner::RunAllTests(ac, av); -} - diff --git a/scripts/templates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp b/scripts/templates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp deleted file mode 100644 index f3e1bcdae..000000000 --- a/scripts/templates/ProjectTemplate/tests/util/ProjectBuildTimeTest.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "ProjectBuildTime.h" - -TEST_GROUP(ProjectBuildTime) -{ - ProjectBuildTime* projectBuildTime; - - void setup() - { - projectBuildTime = new ProjectBuildTime(); - } - void teardown() - { - delete projectBuildTime; - } -}; - -TEST(ProjectBuildTime, Create) -{ - CHECK(0 != projectBuildTime->GetDateTime()); -} - diff --git a/scripts/zipExclude.txt b/scripts/zipExclude.txt deleted file mode 100644 index be591585b..000000000 --- a/scripts/zipExclude.txt +++ /dev/null @@ -1,29 +0,0 @@ -*.metadata* -*.sh~ -*.obj -*.zip -*.a -*.d -*.o -*.lib -*.ncb -*.opt -*.plg -*/Debug/* -*.svn* -*/Alltests -*.gcov -*.gcda -*.gcno -*.html -*doxygen* -*_tests -*/*.class -*Doxyfile -*Releases* -*UnityTemplates* -*platforms* -*.DS_Store -*.git* -*.gitignore -*.swp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index 8bee1d9b8..000000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_subdirectory(CppUTest) -if (CPPUTEST_EXTENSIONS) - add_subdirectory(CppUTestExt) -endif () diff --git a/src/CppUTest/CMakeIntegration-README.md b/src/CppUTest/CMakeIntegration-README.md deleted file mode 100644 index 74ec44aaa..000000000 --- a/src/CppUTest/CMakeIntegration-README.md +++ /dev/null @@ -1,110 +0,0 @@ -# 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.10) -project(trying_CppUtest) - -SET(CppUTestRootDirectory /path/to/cpputest) - -# Either set CPPUTEST_PLATFORM to one of the provided platforms under -# /src/Platforms/, or provide a project-specific -# platform.cpp (as shown below) -set(CPPUTEST_PLATFORM OFF CACHE BOOL "Platform implementation") -add_subdirectory(${CppUTestRootDirectory} CppUTest) -target_sources(CppUTest - PRIVATE - ${PROJECT_SOURCE_DIR}/UtestPlatform.cpp -) - -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) -``` diff --git a/src/CppUTest/CMakeLists.txt b/src/CppUTest/CMakeLists.txt deleted file mode 100644 index f7c737b0c..000000000 --- a/src/CppUTest/CMakeLists.txt +++ /dev/null @@ -1,127 +0,0 @@ -add_library(CppUTest - CommandLineArguments.cpp - MemoryLeakWarningPlugin.cpp - TestHarness_c.cpp - TestRegistry.cpp - CommandLineTestRunner.cpp - SimpleString.cpp - SimpleStringInternalCache.cpp - TestMemoryAllocator.cpp - TestResult.cpp - JUnitTestOutput.cpp - TeamCityTestOutput.cpp - TestFailure.cpp - TestOutput.cpp - MemoryLeakDetector.cpp - TestFilter.cpp - TestPlugin.cpp - 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 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 - ${CMAKE_CURRENT_LIST_DIR}/../Platforms/${CPPUTEST_PLATFORM}/UtestPlatform.cpp - ) -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(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads) - -target_link_libraries(CppUTest - PRIVATE - $<$:winmm> - $<$:${CMAKE_THREAD_LIBS_INIT}> -) - -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() - -# 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 deleted file mode 100644 index e3d1a8cbe..000000000 --- a/src/CppUTest/CommandLineArguments.cpp +++ /dev/null @@ -1,438 +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/TestHarness.h" -#include "CppUTest/CommandLineArguments.h" -#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), 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) -{ -} - -CommandLineArguments::~CommandLineArguments() -{ - while(groupFilters_) { - TestFilter* current = groupFilters_; - groupFilters_ = groupFilters_->getNext(); - delete current; - } - while(nameFilters_) { - TestFilter* current = nameFilters_; - nameFilters_ = nameFilters_->getNext(); - delete current; - } -} - -bool CommandLineArguments::parse(TestPlugin* plugin) -{ - bool correctParameters = true; - for (int i = 1; i < ac_; i++) { - SimpleString argument = av_[i]; - - if (argument == "-h") { - needHelp_ = true; - correctParameters = false; - } - else if (argument == "-v") verbose_ = true; - else if (argument == "-vv") veryVerbose_ = true; - else if (argument == "-c") color_ = true; - else if (argument == "-p") runTestsAsSeperateProcess_ = true; - 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, "-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); - else if (argument.startsWith("-n")) addNameFilter(ac_, av_, i); - else if (argument.startsWith("-sn")) addStrictNameFilter(ac_, av_, i); - else if (argument.startsWith("-xn")) addExcludeNameFilter(ac_, av_, i); - else if (argument.startsWith("-xsn")) addExcludeStrictNameFilter(ac_, av_, i); - else if (argument.startsWith("-s")) correctParameters = setShuffle(ac_, av_, i); - else if (argument.startsWith("TEST(")) addTestToRunBasedOnVerboseOutput(ac_, av_, i, "TEST("); - else if (argument.startsWith("IGNORE_TEST(")) addTestToRunBasedOnVerboseOutput(ac_, av_, i, "IGNORE_TEST("); - else if (argument.startsWith("-o")) correctParameters = setOutputType(ac_, av_, i); - else if (argument.startsWith("-p")) correctParameters = plugin->parseAllArguments(ac_, av_, i); - else if (argument.startsWith("-k")) setPackageName(ac_, av_, i); - else correctParameters = false; - - if (correctParameters == false) { - return false; - } - } - return true; -} - -const char* CommandLineArguments::usage() const -{ - 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 -{ - return - "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" - " -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" - " -v - verbose, print each test name as it runs\n" - " -vv - very verbose, print internal information during test run\n" - "\n" - "Options that change the output location:\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 - 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 [] - 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 -{ - return needHelp_; -} - -bool CommandLineArguments::isVerbose() const -{ - return verbose_; -} - -bool CommandLineArguments::isVeryVerbose() const -{ - return veryVerbose_; -} - -bool CommandLineArguments::isColor() const -{ - return color_; -} - -bool CommandLineArguments::isListingTestGroupNames() const -{ - return listTestGroupNames_; -} - -bool CommandLineArguments::isListingTestGroupAndCaseNames() const -{ - return listTestGroupAndCaseNames_; -} - -bool CommandLineArguments::isListingTestLocations() const -{ - return listTestLocations_; -} - -bool CommandLineArguments::isRunIgnored() const -{ - return runIgnored_; -} - -bool CommandLineArguments::runTestsInSeperateProcess() const -{ - return runTestsAsSeperateProcess_; -} - - -size_t CommandLineArguments::getRepeatCount() const -{ - return repeat_; -} - -bool CommandLineArguments::isReversing() const -{ - return reversing_; -} - -bool CommandLineArguments::isCrashingOnFail() const -{ - return crashOnFail_; -} - -bool CommandLineArguments::isRethrowingExceptions() const -{ - return rethrowExceptions_; -} - -bool CommandLineArguments::isShuffling() const -{ - return shuffling_; -} - -size_t CommandLineArguments::getShuffleSeed() const -{ - return shuffleSeed_; -} - -const TestFilter* CommandLineArguments::getGroupFilters() const -{ - return groupFilters_; -} - -const TestFilter* CommandLineArguments::getNameFilters() const -{ - return nameFilters_; -} - -void CommandLineArguments::setRepeatCount(int ac, const char *const *av, int& i) -{ - repeat_ = 0; - - SimpleString repeatParameter(av[i]); - if (repeatParameter.size() > 2) repeat_ = (size_t) (SimpleString::AtoI(av[i] + 2)); - else if (i + 1 < ac) { - repeat_ = (size_t) (SimpleString::AtoI(av[i + 1])); - if (repeat_ != 0) i++; - } - - if (0 == repeat_) repeat_ = 2; - -} - -bool CommandLineArguments::setShuffle(int ac, const char * const *av, int& i) -{ - shuffling_ = true; - shuffleSeed_ = (unsigned int)GetPlatformSpecificTimeInMillis(); - if (shuffleSeed_ == 0) shuffleSeed_++; - - SimpleString shuffleParameter = av[i]; - if (shuffleParameter.size() > 2) { - shufflingPreSeeded_ = true; - shuffleSeed_ = SimpleString::AtoU(av[i] + 2); - } else if (i + 1 < ac) { - unsigned int parsedParameter = SimpleString::AtoU(av[i + 1]); - if (parsedParameter != 0) - { - shufflingPreSeeded_ = true; - shuffleSeed_ = parsedParameter; - i++; - } - } - return (shuffleSeed_ != 0); -} - -SimpleString CommandLineArguments::getParameterField(int ac, const char * const *av, int& i, const SimpleString& parameterName) -{ - size_t parameterLength = parameterName.size(); - SimpleString parameter(av[i]); - if (parameter.size() > parameterLength) return av[i] + parameterLength; - else if (i + 1 < ac) return av[++i]; - return ""; -} - -void CommandLineArguments::addGroupFilter(int ac, const char *const *av, int& i) -{ - TestFilter* groupFilter = new TestFilter(getParameterField(ac, av, i, "-g")); - groupFilters_ = groupFilter->add(groupFilters_); -} - -bool CommandLineArguments::addGroupDotNameFilter(int ac, const char *const *av, int& i, const SimpleString& parameterName, - bool strict, bool exclude) -{ - SimpleString groupDotName = getParameterField(ac, av, i, parameterName); - SimpleStringCollection collection; - groupDotName.split(".", collection); - - if (collection.size() != 2) return false; - - 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; -} - -void CommandLineArguments::addStrictGroupFilter(int ac, const char *const *av, int& i) -{ - TestFilter* groupFilter = new TestFilter(getParameterField(ac, av, i, "-sg")); - groupFilter->strictMatching(); - groupFilters_ = groupFilter->add(groupFilters_); -} - -void CommandLineArguments::addExcludeGroupFilter(int ac, const char *const *av, int& i) -{ - TestFilter* groupFilter = new TestFilter(getParameterField(ac, av, i, "-xg")); - groupFilter->invertMatching(); - groupFilters_ = groupFilter->add(groupFilters_); -} - -void CommandLineArguments::addExcludeStrictGroupFilter(int ac, const char *const *av, int& i) -{ - TestFilter* groupFilter = new TestFilter(getParameterField(ac, av, i, "-xsg")); - groupFilter->strictMatching(); - groupFilter->invertMatching(); - groupFilters_ = groupFilter->add(groupFilters_); -} - -void CommandLineArguments::addNameFilter(int ac, const char *const *av, int& i) -{ - TestFilter* nameFilter = new TestFilter(getParameterField(ac, av, i, "-n")); - nameFilters_ = nameFilter->add(nameFilters_); -} - -void CommandLineArguments::addStrictNameFilter(int ac, const char *const *av, int& index) -{ - TestFilter* nameFilter = new TestFilter(getParameterField(ac, av, index, "-sn")); - nameFilter->strictMatching(); - nameFilters_= nameFilter->add(nameFilters_); -} - -void CommandLineArguments::addExcludeNameFilter(int ac, const char *const *av, int& index) -{ - TestFilter* nameFilter = new TestFilter(getParameterField(ac, av, index, "-xn")); - nameFilter->invertMatching(); - nameFilters_= nameFilter->add(nameFilters_); -} - -void CommandLineArguments::addExcludeStrictNameFilter(int ac, const char *const *av, int& index) -{ - TestFilter* nameFilter = new TestFilter(getParameterField(ac, av, index, "-xsn")); - nameFilter->invertMatching(); - nameFilter->strictMatching(); - nameFilters_= nameFilter->add(nameFilters_); -} - -void CommandLineArguments::addTestToRunBasedOnVerboseOutput(int ac, const char *const *av, int& index, const char* parameterName) -{ - SimpleString wholename = getParameterField(ac, av, index, parameterName); - SimpleString testname = wholename.subStringFromTill(',', ')'); - testname = testname.subString(2); - TestFilter* namefilter = new TestFilter(testname); - TestFilter* groupfilter = new TestFilter(wholename.subStringFromTill(wholename.at(0), ',')); - namefilter->strictMatching(); - groupfilter->strictMatching(); - groupFilters_ = groupfilter->add(groupFilters_); - nameFilters_ = namefilter->add(nameFilters_); -} - -void CommandLineArguments::setPackageName(int ac, const char *const *av, int& i) -{ - SimpleString packageName = getParameterField(ac, av, i, "-k"); - if (packageName.size() == 0) return; - - packageName_ = packageName; -} - -bool CommandLineArguments::setOutputType(int ac, const char *const *av, int& i) -{ - SimpleString outputType = getParameterField(ac, av, i, "-o"); - if (outputType.size() == 0) return false; - - if (outputType == "normal" || outputType == "eclipse") { - outputType_ = OUTPUT_ECLIPSE; - return true; - } - if (outputType == "junit") { - outputType_ = OUTPUT_JUNIT; - return true; - } - if (outputType == "teamcity") { - outputType_ = OUTPUT_TEAMCITY; - return true; - } - - return false; -} - -bool CommandLineArguments::isEclipseOutput() const -{ - return outputType_ == OUTPUT_ECLIPSE; -} - -bool CommandLineArguments::isJUnitOutput() const -{ - return outputType_ == OUTPUT_JUNIT; -} - -bool CommandLineArguments::isTeamCityOutput() const -{ - return outputType_ == OUTPUT_TEAMCITY; -} - -const SimpleString& CommandLineArguments::getPackageName() const -{ - return packageName_; -} - diff --git a/src/CppUTest/CommandLineTestRunner.cpp b/src/CppUTest/CommandLineTestRunner.cpp deleted file mode 100644 index b50e897e7..000000000 --- a/src/CppUTest/CommandLineTestRunner.cpp +++ /dev/null @@ -1,201 +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/TestHarness.h" -#include "CppUTest/CommandLineTestRunner.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/JUnitTestOutput.h" -#include "CppUTest/TeamCityTestOutput.h" -#include "CppUTest/TestRegistry.h" - -int CommandLineTestRunner::RunAllTests(int ac, char** av) -{ - return RunAllTests(ac, (const char *const *) av); -} - -int CommandLineTestRunner::RunAllTests(int ac, const char *const *av) -{ - int result = 0; - ConsoleTestOutput backupOutput; - - MemoryLeakWarningPlugin memLeakWarn(DEF_PLUGIN_MEM_LEAK); - memLeakWarn.destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(true); - TestRegistry::getCurrentRegistry()->installPlugin(&memLeakWarn); - - { - CommandLineTestRunner runner(ac, av, TestRegistry::getCurrentRegistry()); - result = runner.runAllTestsMain(); - } - - if (result == 0) { - backupOutput << memLeakWarn.FinalReport(0); - } - TestRegistry::getCurrentRegistry()->removePluginByName(DEF_PLUGIN_MEM_LEAK); - return result; -} - -CommandLineTestRunner::CommandLineTestRunner(int ac, const char *const *av, TestRegistry* registry) : - output_(NULLPTR), arguments_(NULLPTR), registry_(registry) -{ - arguments_ = new CommandLineArguments(ac, av); -} - -CommandLineTestRunner::~CommandLineTestRunner() -{ - delete arguments_; - delete output_; -} - -int CommandLineTestRunner::runAllTestsMain() -{ - int testResult = 1; - - SetPointerPlugin pPlugin(DEF_PLUGIN_SET_POINTER); - registry_->installPlugin(&pPlugin); - - if (parseArguments(registry_->getFirstPlugin())) - testResult = runAllTests(); - - registry_->removePluginByName(DEF_PLUGIN_SET_POINTER); - return testResult; -} - -void CommandLineTestRunner::initializeTestRun() -{ - registry_->setGroupFilters(arguments_->getGroupFilters()); - registry_->setNameFilters(arguments_->getNameFilters()); - - if (arguments_->isVerbose()) output_->verbose(TestOutput::level_verbose); - if (arguments_->isVeryVerbose()) output_->verbose(TestOutput::level_veryVerbose); - 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() -{ - initializeTestRun(); - size_t loopCount = 0; - size_t failedTestCount = 0; - size_t failedExecutionCount = 0; - size_t repeatCount = arguments_->getRepeatCount(); - - if (arguments_->isListingTestGroupNames()) - { - TestResult tr(*output_); - registry_->listTestGroupNames(tr); - return 0; - } - - if (arguments_->isListingTestGroupAndCaseNames()) - { - TestResult tr(*output_); - registry_->listTestGroupAndCaseNames(tr); - return 0; - } - - if (arguments_->isListingTestLocations()) - { - TestResult tr(*output_); - registry_->listTestLocations(tr); - return 0; - } - - if (arguments_->isReversing()) - registry_->reverseTests(); - - if (arguments_->isShuffling()) - { - output_->print("Test order shuffling enabled with seed: "); - output_->print(arguments_->getShuffleSeed()); - output_->print("\n"); - } - while (loopCount++ < repeatCount) { - - if (arguments_->isShuffling()) - registry_->shuffleTests(arguments_->getShuffleSeed()); - - output_->printTestRun(loopCount, repeatCount); - TestResult tr(*output_); - registry_->runAllTests(tr); - failedTestCount += tr.getFailureCount(); - if (tr.isFailure()) { - failedExecutionCount++; - } - } - return (int) (failedTestCount != 0 ? failedTestCount : failedExecutionCount); -} - -TestOutput* CommandLineTestRunner::createTeamCityOutput() -{ - return new TeamCityTestOutput; -} - -TestOutput* CommandLineTestRunner::createJUnitOutput(const SimpleString& packageName) -{ - JUnitTestOutput* junitOutput = new JUnitTestOutput; - if (junitOutput != NULLPTR) { - junitOutput->setPackageName(packageName); - } - return junitOutput; -} - -TestOutput* CommandLineTestRunner::createConsoleOutput() -{ - return new ConsoleTestOutput; -} - -TestOutput* CommandLineTestRunner::createCompositeOutput(TestOutput* outputOne, TestOutput* outputTwo) -{ - CompositeTestOutput* composite = new CompositeTestOutput; - composite->setOutputOne(outputOne); - composite->setOutputTwo(outputTwo); - return composite; -} - -bool CommandLineTestRunner::parseArguments(TestPlugin* plugin) -{ - if (!arguments_->parse(plugin)) { - output_ = createConsoleOutput(); - output_->print((arguments_->needHelp()) ? arguments_->help() : arguments_->usage()); - return false; - } - - if (arguments_->isJUnitOutput()) { - output_= createJUnitOutput(arguments_->getPackageName()); - if (arguments_->isVerbose() || arguments_->isVeryVerbose()) - output_ = createCompositeOutput(output_, createConsoleOutput()); - } else if (arguments_->isTeamCityOutput()) { - output_ = createTeamCityOutput(); - } else - output_ = createConsoleOutput(); - return true; -} - diff --git a/src/CppUTest/JUnitTestOutput.cpp b/src/CppUTest/JUnitTestOutput.cpp deleted file mode 100644 index f509d9b72..000000000 --- a/src/CppUTest/JUnitTestOutput.cpp +++ /dev/null @@ -1,325 +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/TestHarness.h" -#include "CppUTest/JUnitTestOutput.h" -#include "CppUTest/TestResult.h" -#include "CppUTest/TestFailure.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -struct JUnitTestCaseResultNode -{ - JUnitTestCaseResultNode() : - execTime_(0), failure_(NULLPTR), ignored_(false), lineNumber_ (0), checkCount_ (0), next_(NULLPTR) - { - } - - SimpleString name_; - size_t execTime_; - TestFailure* failure_; - bool ignored_; - SimpleString file_; - size_t lineNumber_; - size_t checkCount_; - JUnitTestCaseResultNode* next_; -}; - -struct JUnitTestGroupResult -{ - JUnitTestGroupResult() : - testCount_(0), failureCount_(0), totalCheckCount_(0), startTime_(0), groupExecTime_(0), head_(NULLPTR), tail_(NULLPTR) - { - } - - size_t testCount_; - size_t failureCount_; - size_t totalCheckCount_; - size_t startTime_; - size_t groupExecTime_; - SimpleString group_; - JUnitTestCaseResultNode* head_; - JUnitTestCaseResultNode* tail_; -}; - -struct JUnitTestOutputImpl -{ - JUnitTestGroupResult results_; - PlatformSpecificFile file_; - SimpleString package_; - SimpleString stdOutput_; -}; - -JUnitTestOutput::JUnitTestOutput() : - impl_(new JUnitTestOutputImpl) -{ -} - -JUnitTestOutput::~JUnitTestOutput() -{ - resetTestGroupResult(); - delete impl_; -} - -void JUnitTestOutput::resetTestGroupResult() -{ - impl_->results_.testCount_ = 0; - impl_->results_.failureCount_ = 0; - impl_->results_.group_ = ""; - JUnitTestCaseResultNode* cur = impl_->results_.head_; - while (cur) { - JUnitTestCaseResultNode* tmp = cur->next_; - delete cur->failure_; - delete cur; - cur = tmp; - } - impl_->results_.head_ = NULLPTR; - impl_->results_.tail_ = NULLPTR; -} - -void JUnitTestOutput::printTestsStarted() -{ -} - -void JUnitTestOutput::printCurrentGroupStarted(const UtestShell& /*test*/) -{ -} - -void JUnitTestOutput::printCurrentTestEnded(const TestResult& result) -{ - impl_->results_.tail_->execTime_ = result.getCurrentTestTotalExecutionTime(); - impl_->results_.tail_->checkCount_ = result.getCheckCount(); -} - -void JUnitTestOutput::printTestsEnded(const TestResult& /*result*/) -{ -} - -void JUnitTestOutput::printCurrentGroupEnded(const TestResult& result) -{ - impl_->results_.groupExecTime_ = result.getCurrentGroupTotalExecutionTime(); - writeTestGroupToFile(); - resetTestGroupResult(); -} - -void JUnitTestOutput::printCurrentTestStarted(const UtestShell& test) -{ - impl_->results_.testCount_++; - impl_->results_.group_ = test.getGroup(); - impl_->results_.startTime_ = (size_t) GetPlatformSpecificTimeInMillis(); - - if (impl_->results_.tail_ == NULLPTR) { - impl_->results_.head_ = impl_->results_.tail_ - = new JUnitTestCaseResultNode; - } - else { - impl_->results_.tail_->next_ = new JUnitTestCaseResultNode; - impl_->results_.tail_ = impl_->results_.tail_->next_; - } - impl_->results_.tail_->name_ = test.getName(); - impl_->results_.tail_->file_ = test.getFile(); - impl_->results_.tail_->lineNumber_ = test.getLineNumber(); - if (!test.willRun()) { - impl_->results_.tail_->ignored_ = true; - } -} - -SimpleString JUnitTestOutput::createFileName(const SimpleString& group) -{ - SimpleString fileName = "cpputest_"; - if (!impl_->package_.isEmpty()) { - fileName += impl_->package_; - fileName += "_"; - } - fileName += group; - return encodeFileName(fileName) + ".xml"; -} - -SimpleString JUnitTestOutput::encodeFileName(const SimpleString& fileName) -{ - // special character list based on: https://en.wikipedia.org/wiki/Filename - static const char* const forbiddenCharacters = "/\\?%*:|\"<>"; - - SimpleString result = fileName; - for (const char* sym = forbiddenCharacters; *sym; ++sym) { - result.replace(*sym, '_'); - } - return result; -} - -void JUnitTestOutput::setPackageName(const SimpleString& package) -{ - if (impl_ != NULLPTR) { - impl_->package_ = package; - } -} - -void JUnitTestOutput::writeXmlHeader() -{ - writeToFile("\n"); -} - -void JUnitTestOutput::writeTestSuiteSummary() -{ - SimpleString - buf = - StringFromFormat( - "\n", - (int)impl_->results_.failureCount_, - impl_->results_.group_.asCharString(), - (int) impl_->results_.testCount_, - (int) (impl_->results_.groupExecTime_ / 1000), (int) (impl_->results_.groupExecTime_ % 1000), - GetPlatformSpecificTimeString()); - writeToFile(buf.asCharString()); -} - -void JUnitTestOutput::writeProperties() -{ - writeToFile("\n"); - writeToFile("\n"); -} - -SimpleString JUnitTestOutput::encodeXmlText(const SimpleString& textbody) -{ - SimpleString buf = textbody.asCharString(); - buf.replace("&", "&"); - buf.replace("\"", """); - buf.replace("<", "<"); - buf.replace(">", ">"); - buf.replace("\r", " "); - buf.replace("\n", " "); - return buf; -} - -void JUnitTestOutput::writeTestCases() -{ - JUnitTestCaseResultNode* cur = impl_->results_.head_; - - while (cur) { - SimpleString buf = StringFromFormat( - "\n", - impl_->package_.asCharString(), - impl_->package_.isEmpty() ? "" : ".", - impl_->results_.group_.asCharString(), - cur->name_.asCharString(), - (int) (cur->checkCount_ - impl_->results_.totalCheckCount_), - (int) (cur->execTime_ / 1000), (int)(cur->execTime_ % 1000), - cur->file_.asCharString(), - (int) cur->lineNumber_); - writeToFile(buf.asCharString()); - - impl_->results_.totalCheckCount_ = cur->checkCount_; - - if (cur->failure_) { - writeFailure(cur); - } - else if (cur->ignored_) { - writeToFile("\n"); - } - writeToFile("\n"); - cur = cur->next_; - } -} - -void JUnitTestOutput::writeFailure(JUnitTestCaseResultNode* node) -{ - SimpleString buf = StringFromFormat( - "\n", - node->failure_->getFileName().asCharString(), - (int) node->failure_->getFailureLineNumber(), - encodeXmlText(node->failure_->getMessage()).asCharString()); - writeToFile(buf.asCharString()); - writeToFile("\n"); -} - - -void JUnitTestOutput::writeFileEnding() -{ - writeToFile(""); - writeToFile(encodeXmlText(impl_->stdOutput_)); - writeToFile("\n"); - writeToFile("\n"); - writeToFile("\n"); -} - -void JUnitTestOutput::writeTestGroupToFile() -{ - openFileForWrite(createFileName(impl_->results_.group_)); - writeXmlHeader(); - writeTestSuiteSummary(); - writeProperties(); - writeTestCases(); - writeFileEnding(); - closeFile(); -} - -// LCOV_EXCL_START - -void JUnitTestOutput::printBuffer(const char*) -{ -} - -void JUnitTestOutput::print(const char *output) -{ - impl_->stdOutput_ += output; -} - -void JUnitTestOutput::print(long) -{ -} - -void JUnitTestOutput::print(size_t) -{ -} - -void JUnitTestOutput::flush() -{ -} - -// LCOV_EXCL_STOP - -void JUnitTestOutput::printFailure(const TestFailure& failure) -{ - if (impl_->results_.tail_->failure_ == NULLPTR) { - impl_->results_.failureCount_++; - impl_->results_.tail_->failure_ = new TestFailure(failure); - } -} - -void JUnitTestOutput::openFileForWrite(const SimpleString& fileName) -{ - impl_->file_ = PlatformSpecificFOpen(fileName.asCharString(), "w"); -} - -void JUnitTestOutput::writeToFile(const SimpleString& buffer) -{ - PlatformSpecificFPuts(buffer.asCharString(), impl_->file_); -} - -void JUnitTestOutput::closeFile() -{ - PlatformSpecificFClose(impl_->file_); -} diff --git a/src/CppUTest/MemoryLeakDetector.cpp b/src/CppUTest/MemoryLeakDetector.cpp deleted file mode 100644 index 89e45908e..000000000 --- a/src/CppUTest/MemoryLeakDetector.cpp +++ /dev/null @@ -1,756 +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/TestHarness.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/SimpleMutex.h" - -static const char* UNKNOWN = ""; - -static const char GuardBytes[] = {'B','A','S'}; - -SimpleStringBuffer::SimpleStringBuffer() : - positions_filled_(0), write_limit_(SIMPLE_STRING_BUFFER_LEN-1) -{ - buffer_[0] = '\0'; -} - -void SimpleStringBuffer::clear() -{ - positions_filled_ = 0; - buffer_[0] = '\0'; -} - -void SimpleStringBuffer::add(const char* format, ...) -{ - const size_t positions_left = write_limit_ - positions_filled_; - if (positions_left == 0) return; - - va_list arguments; - va_start(arguments, format); - const int count = PlatformSpecificVSNprintf(buffer_ + positions_filled_, positions_left+1, format, arguments); - if (count > 0) positions_filled_ += (size_t) count; - if (positions_filled_ > write_limit_) positions_filled_ = write_limit_; - va_end(arguments); -} - -void SimpleStringBuffer::addMemoryDump(const void* memory, size_t memorySize) -{ - const unsigned char* byteMemory = (const unsigned char*)memory; - const size_t maxLineBytes = 16; - size_t currentPos = 0; - size_t p; - - while (currentPos < memorySize) { - add(" %04lx: ", (unsigned long) currentPos); - size_t bytesInLine = memorySize - currentPos; - if (bytesInLine > maxLineBytes) { - bytesInLine = maxLineBytes; - } - const size_t leftoverBytes = maxLineBytes - bytesInLine; - - for (p = 0; p < bytesInLine; p++) { - add("%02hx ", (unsigned short) byteMemory[currentPos + p]); - if (p == ((maxLineBytes / 2) - 1)) { - add(" "); - } - } - for (p = 0; p < leftoverBytes; p++) { - add(" "); - } - if (leftoverBytes > (maxLineBytes/2)) { - add(" "); - } - - add("|"); - for (p = 0; p < bytesInLine; p++) { - char toAdd = (char)byteMemory[currentPos + p]; - if (toAdd < ' ' || toAdd > '~') { - toAdd = '.'; - } - add("%c", (int)toAdd); - } - add("|\n"); - currentPos += bytesInLine; - } -} - -char* SimpleStringBuffer::toString() -{ - return buffer_; -} - -void SimpleStringBuffer::setWriteLimit(size_t write_limit) -{ - write_limit_ = write_limit; - if (write_limit_ > SIMPLE_STRING_BUFFER_LEN-1) - write_limit_ = SIMPLE_STRING_BUFFER_LEN-1; -} -void SimpleStringBuffer::resetWriteLimit() -{ - write_limit_ = SIMPLE_STRING_BUFFER_LEN-1; -} - -bool SimpleStringBuffer::reachedItsCapacity() -{ - return positions_filled_ >= write_limit_; -} - -//////////////////////// - -#define MEM_LEAK_TOO_MUCH "\netc etc etc etc. !!!! Too many memory leaks to report. Bailing out\n" -#define MEM_LEAK_FOOTER "Total number of leaks: " -#define MEM_LEAK_ADDITION_MALLOC_WARNING "NOTE:\n" \ - "\tMemory leak reports about malloc and free can be caused by allocating using the cpputest version of malloc,\n" \ - "\tbut deallocate using the standard free.\n" \ - "\tIf this is the case, check whether your malloc/free replacements are working (#define malloc cpputest_malloc etc).\n" - -MemoryLeakOutputStringBuffer::MemoryLeakOutputStringBuffer() - : total_leaks_(0), giveWarningOnUsingMalloc_(false) -{ -} - -void MemoryLeakOutputStringBuffer::addAllocationLocation(const char* allocationFile, size_t allocationLineNumber, size_t allocationSize, TestMemoryAllocator* allocator) -{ - outputBuffer_.add(" allocated at file: %s line: %d size: %lu type: %s\n", allocationFile, (int) allocationLineNumber, (unsigned long) allocationSize, allocator->alloc_name()); -} - -void MemoryLeakOutputStringBuffer::addDeallocationLocation(const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* allocator) -{ - outputBuffer_.add(" deallocated at file: %s line: %d type: %s\n", freeFile, (int) freeLineNumber, allocator->free_name()); -} - -void MemoryLeakOutputStringBuffer::addNoMemoryLeaksMessage() -{ - outputBuffer_.add("No memory leaks were detected."); -} - -void MemoryLeakOutputStringBuffer::startMemoryLeakReporting() -{ - giveWarningOnUsingMalloc_ = false; - total_leaks_ = 0; - - size_t memory_leak_normal_footer_size = sizeof(MEM_LEAK_FOOTER) + 10 + sizeof(MEM_LEAK_TOO_MUCH); /* the number of leaks */ - size_t memory_leak_foot_size_with_malloc_warning = memory_leak_normal_footer_size + sizeof(MEM_LEAK_ADDITION_MALLOC_WARNING); - - outputBuffer_.setWriteLimit(SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN - memory_leak_foot_size_with_malloc_warning); -} - -void MemoryLeakOutputStringBuffer::reportMemoryLeak(MemoryLeakDetectorNode* leak) -{ - if (total_leaks_ == 0) { - addMemoryLeakHeader(); - } - - total_leaks_++; - outputBuffer_.add("Alloc num (%u) Leak size: %lu Allocated at: %s and line: %d. Type: \"%s\"\n\tMemory: <%p> Content:\n", - leak->number_, (unsigned long) leak->size_, leak->file_, (int) leak->line_, leak->allocator_->alloc_name(), (void*) leak->memory_); - outputBuffer_.addMemoryDump(leak->memory_, leak->size_); - - if (SimpleString::StrCmp(leak->allocator_->alloc_name(), (const char*) "malloc") == 0) - giveWarningOnUsingMalloc_ = true; -} - -void MemoryLeakOutputStringBuffer::stopMemoryLeakReporting() -{ - if (total_leaks_ == 0) { - addNoMemoryLeaksMessage(); - return; - } - - bool buffer_reached_its_capacity = outputBuffer_.reachedItsCapacity(); - outputBuffer_.resetWriteLimit(); - - if (buffer_reached_its_capacity) - addErrorMessageForTooMuchLeaks(); - - addMemoryLeakFooter(total_leaks_); - - if (giveWarningOnUsingMalloc_) - addWarningForUsingMalloc(); - -} - -void MemoryLeakOutputStringBuffer::addMemoryLeakHeader() -{ - outputBuffer_.add("Memory leak(s) found.\n"); -} - -void MemoryLeakOutputStringBuffer::addErrorMessageForTooMuchLeaks() -{ - outputBuffer_.add(MEM_LEAK_TOO_MUCH); -} - -void MemoryLeakOutputStringBuffer::addMemoryLeakFooter(size_t amountOfLeaks) -{ - outputBuffer_.add("%s %d\n", MEM_LEAK_FOOTER, (int) amountOfLeaks); -} - -void MemoryLeakOutputStringBuffer::addWarningForUsingMalloc() -{ - outputBuffer_.add(MEM_LEAK_ADDITION_MALLOC_WARNING); -} - -void MemoryLeakOutputStringBuffer::reportDeallocateNonAllocatedMemoryFailure(const char* freeFile, size_t freeLine, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter) -{ - reportFailure("Deallocating non-allocated memory\n", "", 0, 0, NullUnknownAllocator::defaultAllocator(), freeFile, freeLine, freeAllocator, reporter); -} - -void MemoryLeakOutputStringBuffer::reportAllocationDeallocationMismatchFailure(MemoryLeakDetectorNode* node, const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter) -{ - reportFailure("Allocation/deallocation type mismatch\n", node->file_, node->line_, node->size_, node->allocator_, freeFile, freeLineNumber, freeAllocator, reporter); -} - -void MemoryLeakOutputStringBuffer::reportMemoryCorruptionFailure(MemoryLeakDetectorNode* node, const char* freeFile, size_t freeLineNumber, TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter) -{ - reportFailure("Memory corruption (written out of bounds?)\n", node->file_, node->line_, node->size_, node->allocator_, freeFile, freeLineNumber, freeAllocator, reporter); -} - -void MemoryLeakOutputStringBuffer::reportFailure(const char* message, const char* allocFile, size_t allocLine, size_t allocSize, TestMemoryAllocator* allocAllocator, const char* freeFile, size_t freeLine, - TestMemoryAllocator* freeAllocator, MemoryLeakFailure* reporter) -{ - outputBuffer_.add("%s", message); - addAllocationLocation(allocFile, allocLine, allocSize, allocAllocator); - addDeallocationLocation(freeFile, freeLine, freeAllocator); - reporter->fail(toString()); -} - - -char* MemoryLeakOutputStringBuffer::toString() -{ - return outputBuffer_.toString(); -} - -void MemoryLeakOutputStringBuffer::clear() -{ - outputBuffer_.clear(); -} - -//////////////////////// - -void MemoryLeakDetectorNode::init(char* memory, unsigned number, size_t size, TestMemoryAllocator* allocator, MemLeakPeriod period, unsigned char allocation_stage, const char* file, size_t line) -{ - number_ = number; - memory_ = memory; - size_ = size; - allocator_ = allocator; - period_ = period; - allocation_stage_ = allocation_stage; - file_ = file; - line_ = line; -} - -/////////////////////// - -bool MemoryLeakDetectorList::isInPeriod(MemoryLeakDetectorNode* node, MemLeakPeriod period) -{ - return period == mem_leak_period_all || node->period_ == period || (node->period_ != mem_leak_period_disabled && period == mem_leak_period_enabled); -} - -bool MemoryLeakDetectorList::isInAllocationStage(MemoryLeakDetectorNode* node, unsigned char allocation_stage) -{ - return node->allocation_stage_ == allocation_stage; -} - -void MemoryLeakDetectorList::clearAllAccounting(MemLeakPeriod period) -{ - MemoryLeakDetectorNode* cur = head_; - MemoryLeakDetectorNode* prev = NULLPTR; - - while (cur) { - if (isInPeriod(cur, period)) { - if (prev) { - prev->next_ = cur->next_; - cur = prev; - } - else { - head_ = cur->next_; - cur = head_; - continue; - } - } - prev = cur; - cur = cur->next_; - } -} - -void MemoryLeakDetectorList::addNewNode(MemoryLeakDetectorNode* node) -{ - node->next_ = head_; - head_ = node; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::removeNode(char* memory) -{ - MemoryLeakDetectorNode* cur = head_; - MemoryLeakDetectorNode* prev = NULLPTR; - while (cur) { - if (cur->memory_ == memory) { - if (prev) { - prev->next_ = cur->next_; - return cur; - } - else { - head_ = cur->next_; - return cur; - } - } - prev = cur; - cur = cur->next_; - } - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::retrieveNode(char* memory) -{ - MemoryLeakDetectorNode* cur = head_; - while (cur) { - if (cur->memory_ == memory) - return cur; - cur = cur->next_; - } - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getLeakFrom(MemoryLeakDetectorNode* node, MemLeakPeriod period) -{ - for (MemoryLeakDetectorNode* cur = node; cur; cur = cur->next_) - if (isInPeriod(cur, period)) return cur; - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getLeakForAllocationStageFrom(MemoryLeakDetectorNode* node, unsigned char allocation_stage) -{ - for (MemoryLeakDetectorNode* cur = node; cur; cur = cur->next_) - if (isInAllocationStage(cur, allocation_stage)) return cur; - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getFirstLeak(MemLeakPeriod period) -{ - return getLeakFrom(head_, period); -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getFirstLeakForAllocationStage(unsigned char allocation_stage) -{ - return getLeakForAllocationStageFrom(head_, allocation_stage); -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getNextLeak(MemoryLeakDetectorNode* node, MemLeakPeriod period) -{ - return getLeakFrom(node->next_, period); -} - -MemoryLeakDetectorNode* MemoryLeakDetectorList::getNextLeakForAllocationStage(MemoryLeakDetectorNode* node, unsigned char allocation_stage) -{ - return getLeakForAllocationStageFrom(node->next_, allocation_stage); -} - - - -size_t MemoryLeakDetectorList::getTotalLeaks(MemLeakPeriod period) -{ - size_t total_leaks = 0; - for (MemoryLeakDetectorNode* node = head_; node; node = node->next_) { - if (isInPeriod(node, period)) total_leaks++; - } - return total_leaks; -} - -///////////////////////////////////////////////////////////// - -unsigned long MemoryLeakDetectorTable::hash(char* memory) -{ - return (unsigned long)((size_t)memory % hash_prime); -} - -void MemoryLeakDetectorTable::clearAllAccounting(MemLeakPeriod period) -{ - for (int i = 0; i < hash_prime; i++) - table_[i].clearAllAccounting(period); -} - -void MemoryLeakDetectorTable::addNewNode(MemoryLeakDetectorNode* node) -{ - table_[hash(node->memory_)].addNewNode(node); -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::removeNode(char* memory) -{ - return table_[hash(memory)].removeNode(memory); -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::retrieveNode(char* memory) -{ - return table_[hash(memory)].retrieveNode(memory); -} - -size_t MemoryLeakDetectorTable::getTotalLeaks(MemLeakPeriod period) -{ - size_t total_leaks = 0; - for (int i = 0; i < hash_prime; i++) - total_leaks += table_[i].getTotalLeaks(period); - return total_leaks; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::getFirstLeak(MemLeakPeriod period) -{ - for (int i = 0; i < hash_prime; i++) { - MemoryLeakDetectorNode* node = table_[i].getFirstLeak(period); - if (node) return node; - } - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::getFirstLeakForAllocationStage(unsigned char allocation_stage) -{ - for (int i = 0; i < hash_prime; i++) { - MemoryLeakDetectorNode* node = table_[i].getFirstLeakForAllocationStage(allocation_stage); - if (node) return node; - } - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::getNextLeak(MemoryLeakDetectorNode* leak, MemLeakPeriod period) -{ - unsigned long i = hash(leak->memory_); - MemoryLeakDetectorNode* node = table_[i].getNextLeak(leak, period); - if (node) return node; - - for (++i; i < hash_prime; i++) { - node = table_[i].getFirstLeak(period); - if (node) return node; - } - return NULLPTR; -} - -MemoryLeakDetectorNode* MemoryLeakDetectorTable::getNextLeakForAllocationStage(MemoryLeakDetectorNode* leak, unsigned char allocation_stage) -{ - unsigned long i = hash(leak->memory_); - MemoryLeakDetectorNode* node = table_[i].getNextLeakForAllocationStage(leak, allocation_stage); - if (node) return node; - - for (++i; i < hash_prime; i++) { - node = table_[i].getFirstLeakForAllocationStage(allocation_stage); - if (node) return node; - } - return NULLPTR; -} - -///////////////////////////////////////////////////////////// - -MemoryLeakDetector::MemoryLeakDetector(MemoryLeakFailure* reporter) -{ - doAllocationTypeChecking_ = true; - allocationSequenceNumber_ = 1; - current_period_ = mem_leak_period_disabled; - current_allocation_stage_ = 0; - reporter_ = reporter; - mutex_ = new SimpleMutex; -} - -MemoryLeakDetector::~MemoryLeakDetector() -{ - if (mutex_) - { - delete mutex_; - } -} - -void MemoryLeakDetector::clearAllAccounting(MemLeakPeriod period) -{ - memoryTable_.clearAllAccounting(period); -} - -void MemoryLeakDetector::startChecking() -{ - outputBuffer_.clear(); - current_period_ = mem_leak_period_checking; -} - -void MemoryLeakDetector::stopChecking() -{ - current_period_ = mem_leak_period_enabled; -} - -unsigned char MemoryLeakDetector::getCurrentAllocationStage() const -{ - return current_allocation_stage_; -} - -void MemoryLeakDetector::enable() -{ - current_period_ = mem_leak_period_enabled; -} - -void MemoryLeakDetector::disable() -{ - current_period_ = mem_leak_period_disabled; -} - -void MemoryLeakDetector::disableAllocationTypeChecking() -{ - doAllocationTypeChecking_ = false; -} - -void MemoryLeakDetector::enableAllocationTypeChecking() -{ - doAllocationTypeChecking_ = true; -} - -unsigned MemoryLeakDetector::getCurrentAllocationNumber() -{ - return allocationSequenceNumber_; -} - -void MemoryLeakDetector::increaseAllocationStage() -{ - current_allocation_stage_++; -} - -void MemoryLeakDetector::decreaseAllocationStage() -{ - current_allocation_stage_--; -} - -SimpleMutex *MemoryLeakDetector::getMutex() -{ - return mutex_; -} - -static size_t calculateVoidPointerAlignedSize(size_t size) -{ -#ifndef CPPUTEST_DISABLE_MEM_CORRUPTION_CHECK - return (sizeof(void*) - (size % sizeof(void*))) + size; -#else - return size; -#endif -} - -size_t MemoryLeakDetector::sizeOfMemoryWithCorruptionInfo(size_t size) -{ - return calculateVoidPointerAlignedSize(size + memory_corruption_buffer_size); -} - -MemoryLeakDetectorNode* MemoryLeakDetector::getNodeFromMemoryPointer(char* memory, size_t memory_size) -{ - return (MemoryLeakDetectorNode*) (void*) (memory + sizeOfMemoryWithCorruptionInfo(memory_size)); -} - -void MemoryLeakDetector::storeLeakInformation(MemoryLeakDetectorNode * node, char *new_memory, size_t size, TestMemoryAllocator *allocator, const char *file, size_t line) -{ - node->init(new_memory, allocationSequenceNumber_++, size, allocator, current_period_, current_allocation_stage_, file, line); - addMemoryCorruptionInformation(node->memory_ + node->size_); - memoryTable_.addNewNode(node); -} - -char* MemoryLeakDetector::reallocateMemoryAndLeakInformation(TestMemoryAllocator* allocator, char* memory, size_t size, const char* file, size_t line, bool allocatNodesSeperately) -{ - char* new_memory = reallocateMemoryWithAccountingInformation(allocator, memory, size, file, line, allocatNodesSeperately); - if (new_memory == NULLPTR) return NULLPTR; - - MemoryLeakDetectorNode *node = createMemoryLeakAccountingInformation(allocator, size, new_memory, allocatNodesSeperately); - storeLeakInformation(node, new_memory, size, allocator, file, line); - return node->memory_; -} - -void MemoryLeakDetector::invalidateMemory(char* memory) -{ -#ifndef CPPUTEST_DISABLE_HEAP_POISON - MemoryLeakDetectorNode* node = memoryTable_.retrieveNode(memory); - if (node) - PlatformSpecificMemset(memory, 0xCD, node->size_); -#endif -} - -void MemoryLeakDetector::addMemoryCorruptionInformation(char* memory) -{ - for (size_t i=0; iisOfEqualType(alloc_allocator); -} - -void MemoryLeakDetector::checkForCorruption(MemoryLeakDetectorNode* node, const char* file, size_t line, TestMemoryAllocator* allocator, bool allocateNodesSeperately) -{ - if (!matchingAllocation(node->allocator_->actualAllocator(), allocator->actualAllocator())) - outputBuffer_.reportAllocationDeallocationMismatchFailure(node, file, line, allocator->actualAllocator(), reporter_); - else if (!validMemoryCorruptionInformation(node->memory_ + node->size_)) - outputBuffer_.reportMemoryCorruptionFailure(node, file, line, allocator->actualAllocator(), reporter_); - else if (allocateNodesSeperately) - allocator->freeMemoryLeakNode((char*) node); -} - -char* MemoryLeakDetector::allocMemory(TestMemoryAllocator* allocator, size_t size, bool allocatNodesSeperately) -{ - return allocMemory(allocator, size, UNKNOWN, 0, allocatNodesSeperately); -} - -char* MemoryLeakDetector::allocateMemoryWithAccountingInformation(TestMemoryAllocator* allocator, size_t size, const char* file, size_t line, bool allocatNodesSeperately) -{ - if (allocatNodesSeperately) return allocator->alloc_memory(sizeOfMemoryWithCorruptionInfo(size), file, line); - else return allocator->alloc_memory(sizeOfMemoryWithCorruptionInfo(size) + sizeof(MemoryLeakDetectorNode), file, line); -} - -char* MemoryLeakDetector::reallocateMemoryWithAccountingInformation(TestMemoryAllocator* /*allocator*/, char* memory, size_t size, const char* /*file*/, size_t /*line*/, bool allocatNodesSeperately) -{ - if (allocatNodesSeperately) return (char*) PlatformSpecificRealloc(memory, sizeOfMemoryWithCorruptionInfo(size)); - else return (char*) PlatformSpecificRealloc(memory, sizeOfMemoryWithCorruptionInfo(size) + sizeof(MemoryLeakDetectorNode)); -} - -MemoryLeakDetectorNode* MemoryLeakDetector::createMemoryLeakAccountingInformation(TestMemoryAllocator* allocator, size_t size, char* memory, bool allocatNodesSeperately) -{ - if (allocatNodesSeperately) return (MemoryLeakDetectorNode*) (void*) allocator->allocMemoryLeakNode(sizeof(MemoryLeakDetectorNode)); - else return getNodeFromMemoryPointer(memory, size); -} - -char* MemoryLeakDetector::allocMemory(TestMemoryAllocator* allocator, size_t size, const char* file, size_t line, bool allocatNodesSeperately) -{ -#ifdef CPPUTEST_DISABLE_MEM_CORRUPTION_CHECK - allocatNodesSeperately = true; -#endif - /* With malloc, it is harder to guarantee that the allocator free is called. - * This is because operator new is overloaded via linker symbols, but malloc just via #defines. - * If the same allocation is used and the wrong free is called, it will deallocate the memory leak information - * without the memory leak detector ever noticing it! - * So, for malloc, we'll allocate the memory separately so we can detect this and give a proper error. - */ - - char* memory = allocateMemoryWithAccountingInformation(allocator, size, file, line, allocatNodesSeperately); - if (memory == NULLPTR) return NULLPTR; - MemoryLeakDetectorNode* node = createMemoryLeakAccountingInformation(allocator, size, memory, allocatNodesSeperately); - - storeLeakInformation(node, memory, size, allocator, file, line); - return node->memory_; -} - -void MemoryLeakDetector::removeMemoryLeakInformationWithoutCheckingOrDeallocatingTheMemoryButDeallocatingTheAccountInformation(TestMemoryAllocator* allocator, void* memory, bool allocatNodesSeperately) -{ - MemoryLeakDetectorNode* node = memoryTable_.removeNode((char*) memory); - if (allocatNodesSeperately) allocator->freeMemoryLeakNode( (char*) node); -} - -void MemoryLeakDetector::deallocMemory(TestMemoryAllocator* allocator, void* memory, const char* file, size_t line, bool allocatNodesSeperately) -{ - if (memory == NULLPTR) return; - - MemoryLeakDetectorNode* node = memoryTable_.removeNode((char*) memory); - if (node == NULLPTR) { - outputBuffer_.reportDeallocateNonAllocatedMemoryFailure(file, line, allocator, reporter_); - return; - } -#ifdef CPPUTEST_DISABLE_MEM_CORRUPTION_CHECK - allocatNodesSeperately = true; -#endif - if (!allocator->hasBeenDestroyed()) { - size_t size = node->size_; - checkForCorruption(node, file, line, allocator, allocatNodesSeperately); - allocator->free_memory((char*) memory, size, file, line); - } -} - -void MemoryLeakDetector::deallocMemory(TestMemoryAllocator* allocator, void* memory, bool allocatNodesSeperately) -{ - deallocMemory(allocator, (char*) memory, UNKNOWN, 0, allocatNodesSeperately); -} - -void MemoryLeakDetector::deallocAllMemoryInCurrentAllocationStage() -{ - char* memory = NULLPTR; - MemoryLeakDetectorNode* node = memoryTable_.getFirstLeakForAllocationStage(current_allocation_stage_); - while (node) { - memory = node->memory_; - TestMemoryAllocator* allocator = node->allocator_; - node = memoryTable_.getNextLeakForAllocationStage(node, current_allocation_stage_); - deallocMemory(allocator, memory, __FILE__, __LINE__); - } -} - -char* MemoryLeakDetector::reallocMemory(TestMemoryAllocator* allocator, char* memory, size_t size, const char* file, size_t line, bool allocatNodesSeperately) -{ -#ifdef CPPUTEST_DISABLE_MEM_CORRUPTION_CHECK - allocatNodesSeperately = true; -#endif - if (memory) { - MemoryLeakDetectorNode* node = memoryTable_.removeNode(memory); - if (node == NULLPTR) { - outputBuffer_.reportDeallocateNonAllocatedMemoryFailure(file, line, allocator, reporter_); - return NULLPTR; - } - checkForCorruption(node, file, line, allocator, allocatNodesSeperately); - } - return reallocateMemoryAndLeakInformation(allocator, memory, size, file, line, allocatNodesSeperately); -} - -void MemoryLeakDetector::ConstructMemoryLeakReport(MemLeakPeriod period) -{ - MemoryLeakDetectorNode* leak = memoryTable_.getFirstLeak(period); - - outputBuffer_.startMemoryLeakReporting(); - - while (leak) { - outputBuffer_.reportMemoryLeak(leak); - leak = memoryTable_.getNextLeak(leak, period); - } - - outputBuffer_.stopMemoryLeakReporting(); -} - -const char* MemoryLeakDetector::report(MemLeakPeriod period) -{ - ConstructMemoryLeakReport(period); - - return outputBuffer_.toString(); -} - -void MemoryLeakDetector::markCheckingPeriodLeaksAsNonCheckingPeriod() -{ - MemoryLeakDetectorNode* leak = memoryTable_.getFirstLeak(mem_leak_period_checking); - while (leak) { - if (leak->period_ == mem_leak_period_checking) leak->period_ = mem_leak_period_enabled; - leak = memoryTable_.getNextLeak(leak, mem_leak_period_checking); - } -} - -size_t MemoryLeakDetector::totalMemoryLeaks(MemLeakPeriod period) -{ - return memoryTable_.getTotalLeaks(period); -} diff --git a/src/CppUTest/MemoryLeakWarningPlugin.cpp b/src/CppUTest/MemoryLeakWarningPlugin.cpp deleted file mode 100644 index e954d6338..000000000 --- a/src/CppUTest/MemoryLeakWarningPlugin.cpp +++ /dev/null @@ -1,665 +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/TestHarness.h" -#include "CppUTest/MemoryLeakWarningPlugin.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/SimpleMutex.h" - -/********** Enabling and disabling for C also *********/ - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -class MemLeakScopedMutex -{ -public: - MemLeakScopedMutex() : lock(MemoryLeakWarningPlugin::getGlobalDetector()->getMutex()) { } -private: - ScopedMutexLock lock; -}; - -static void* threadsafe_mem_leak_malloc(size_t size, const char* file, size_t line) -{ - MemLeakScopedMutex lock; - return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentMallocAllocator(), size, file, line, true); -} - -static void threadsafe_mem_leak_free(void* buffer, const char* file, size_t line) -{ - MemLeakScopedMutex lock; - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) buffer); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentMallocAllocator(), (char*) buffer, file, line, true); -} - -static void* threadsafe_mem_leak_realloc(void* memory, size_t size, const char* file, size_t line) -{ - MemLeakScopedMutex lock; - return MemoryLeakWarningPlugin::getGlobalDetector()->reallocMemory(getCurrentMallocAllocator(), (char*) memory, size, file, line, true); -} - - -static void* mem_leak_malloc(size_t size, const char* file, size_t line) -{ - return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentMallocAllocator(), size, file, line, true); -} - -static void mem_leak_free(void* buffer, const char* file, size_t line) -{ - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) buffer); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentMallocAllocator(), (char*) buffer, file, line, true); -} - -static void* mem_leak_realloc(void* memory, size_t size, const char* file, size_t line) -{ - return MemoryLeakWarningPlugin::getGlobalDetector()->reallocMemory(getCurrentMallocAllocator(), (char*) memory, size, file, line, true); -} - -#endif - -static void* normal_malloc(size_t size, const char*, size_t) -{ - return PlatformSpecificMalloc(size); -} - -static void* normal_realloc(void* memory, size_t size, const char*, size_t) -{ - return PlatformSpecificRealloc(memory, size); -} - -static void normal_free(void* buffer, const char*, size_t) -{ - PlatformSpecificFree(buffer); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION -static void *(*malloc_fptr)(size_t size, const char* file, size_t line) = mem_leak_malloc; -static void (*free_fptr)(void* mem, const char* file, size_t line) = mem_leak_free; -static void*(*realloc_fptr)(void* memory, size_t size, const char* file, size_t line) = mem_leak_realloc; -static void *(*saved_malloc_fptr)(size_t size, const char* file, size_t line) = mem_leak_malloc; -static void (*saved_free_fptr)(void* mem, const char* file, size_t line) = mem_leak_free; -static void*(*saved_realloc_fptr)(void* memory, size_t size, const char* file, size_t line) = mem_leak_realloc; -#else -static void *(*malloc_fptr)(size_t size, const char* file, size_t line) = normal_malloc; -static void (*free_fptr)(void* mem, const char* file, size_t line) = normal_free; -static void*(*realloc_fptr)(void* memory, size_t size, const char* file, size_t line) = normal_realloc; -#endif - -void* cpputest_malloc_location_with_leak_detection(size_t size, const char* file, size_t line) -{ - return malloc_fptr(size, file, line); -} - -void* cpputest_realloc_location_with_leak_detection(void* memory, size_t size, const char* file, size_t line) -{ - return realloc_fptr(memory, size, file, line); -} - -void cpputest_free_location_with_leak_detection(void* buffer, const char* file, size_t line) -{ - free_fptr(buffer, file, line); -} - -/********** C++ *************/ - -#if CPPUTEST_USE_MEM_LEAK_DETECTION -#undef new - -#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(CPPUTEST_BAD_ALLOC) -{ - MemLeakScopedMutex lock; - void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -static void* threadsafe_mem_leak_operator_new_nothrow (size_t size) UT_NOTHROW -{ - MemLeakScopedMutex lock; - 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(CPPUTEST_BAD_ALLOC) -{ - MemLeakScopedMutex lock; - void *memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewAllocator(), size, file, line); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -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); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -static void* threadsafe_mem_leak_operator_new_array_nothrow (size_t size) UT_NOTHROW -{ - MemLeakScopedMutex lock; - 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(CPPUTEST_BAD_ALLOC) -{ - MemLeakScopedMutex lock; - void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size, file, line); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -static void threadsafe_mem_leak_operator_delete (void* mem) UT_NOTHROW -{ - MemLeakScopedMutex lock; - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) mem); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewAllocator(), (char*) mem); -} - -static void threadsafe_mem_leak_operator_delete_array (void* mem) UT_NOTHROW -{ - MemLeakScopedMutex lock; - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) mem); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewArrayAllocator(), (char*) mem); -} - - -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); - return memory; -} - -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(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(CPPUTEST_BAD_ALLOC) -{ - void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -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(CPPUTEST_BAD_ALLOC) -{ - void* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(getCurrentNewArrayAllocator(), size, file, line); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -static void mem_leak_operator_delete (void* mem) UT_NOTHROW -{ - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) mem); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewAllocator(), (char*) mem); -} - -static void mem_leak_operator_delete_array (void* mem) UT_NOTHROW -{ - MemoryLeakWarningPlugin::getGlobalDetector()->invalidateMemory((char*) mem); - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewArrayAllocator(), (char*) mem); -} - -static void* normal_operator_new (size_t size) UT_THROW(CPPUTEST_BAD_ALLOC) -{ - void* memory = PlatformSpecificMalloc(size); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -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(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(CPPUTEST_BAD_ALLOC) -{ - void* memory = PlatformSpecificMalloc(size); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -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(CPPUTEST_BAD_ALLOC) -{ - void* memory = PlatformSpecificMalloc(size); - UT_THROW_BAD_ALLOC_WHEN_NULL(memory); - return memory; -} - -static void normal_operator_delete (void* mem) UT_NOTHROW -{ - PlatformSpecificFree(mem); -} - -static void normal_operator_delete_array (void* mem) UT_NOTHROW -{ - PlatformSpecificFree(mem); -} - -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(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(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(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(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(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(CPPUTEST_BAD_ALLOC) -{ - return operator_new_fptr(size); -} - -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); -} - -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); -} - -#if __cplusplus >= 201402L -void operator delete (void* mem, size_t) UT_NOTHROW -{ - operator_delete_fptr(mem); -} -#endif - -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, 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); -} - -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); -} - -#if __cplusplus >= 201402L -void operator delete[] (void* mem, size_t) UT_NOTHROW -{ - operator_delete_array_fptr(mem); -} -#endif - -#if CPPUTEST_USE_STD_CPP_LIB - -void* operator new(size_t size, const std::nothrow_t&) UT_NOTHROW -{ - return operator_new_nothrow_fptr(size); -} - -void operator delete(void* mem, const std::nothrow_t&) UT_NOTHROW -{ - operator_delete_fptr(mem); -} - -void* operator new[](size_t size, const std::nothrow_t&) UT_NOTHROW -{ - return operator_new_array_nothrow_fptr(size); -} - -void operator delete[](void* mem, const std::nothrow_t&) UT_NOTHROW -{ - operator_delete_array_fptr(mem); -} - -#else - -/* Have a similar method. This avoid unused operator_new_nothrow_fptr warning */ - -extern void* operator_new_nothrow(size_t size) UT_NOTHROW; -extern void* operator_new_array_nothrow(size_t size) UT_NOTHROW; - -void* operator_new_nothrow(size_t size) UT_NOTHROW -{ - return operator_new_nothrow_fptr(size); -} - -void* operator_new_array_nothrow(size_t size) UT_NOTHROW -{ - return operator_new_array_nothrow_fptr(size); -} - -#endif -#endif - -void MemoryLeakWarningPlugin::turnOffNewDeleteOverloads() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - operator_new_fptr = normal_operator_new; - operator_new_nothrow_fptr = normal_operator_new_nothrow; - operator_new_debug_fptr = normal_operator_new_debug; - operator_new_array_fptr = normal_operator_new_array; - operator_new_array_nothrow_fptr = normal_operator_new_array_nothrow; - operator_new_array_debug_fptr = normal_operator_new_array_debug; - operator_delete_fptr = normal_operator_delete; - operator_delete_array_fptr = normal_operator_delete_array; - malloc_fptr = normal_malloc; - realloc_fptr = normal_realloc; - free_fptr = normal_free; - -#endif -} - -void MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - operator_new_fptr = mem_leak_operator_new; - operator_new_nothrow_fptr = mem_leak_operator_new_nothrow; - operator_new_debug_fptr = mem_leak_operator_new_debug; - operator_new_array_fptr = mem_leak_operator_new_array; - operator_new_array_nothrow_fptr = mem_leak_operator_new_array_nothrow; - operator_new_array_debug_fptr = mem_leak_operator_new_array_debug; - operator_delete_fptr = mem_leak_operator_delete; - operator_delete_array_fptr = mem_leak_operator_delete_array; - malloc_fptr = mem_leak_malloc; - realloc_fptr = mem_leak_realloc; - free_fptr = mem_leak_free; -#endif -} - -void MemoryLeakWarningPlugin::turnOnThreadSafeNewDeleteOverloads() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - operator_new_fptr = threadsafe_mem_leak_operator_new; - operator_new_nothrow_fptr = threadsafe_mem_leak_operator_new_nothrow; - operator_new_debug_fptr = threadsafe_mem_leak_operator_new_debug; - operator_new_array_fptr = threadsafe_mem_leak_operator_new_array; - operator_new_array_nothrow_fptr = threadsafe_mem_leak_operator_new_array_nothrow; - operator_new_array_debug_fptr = threadsafe_mem_leak_operator_new_array_debug; - operator_delete_fptr = threadsafe_mem_leak_operator_delete; - operator_delete_array_fptr = threadsafe_mem_leak_operator_delete_array; - malloc_fptr = threadsafe_mem_leak_malloc; - realloc_fptr = threadsafe_mem_leak_realloc; - free_fptr = threadsafe_mem_leak_free; -#endif -} - -bool MemoryLeakWarningPlugin::areNewDeleteOverloaded() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - return operator_new_fptr == mem_leak_operator_new || operator_new_fptr == threadsafe_mem_leak_operator_new; -#else - return false; -#endif -} - -void MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - if (++save_counter > 1) return; - saved_operator_new_fptr = operator_new_fptr; - saved_operator_new_nothrow_fptr = operator_new_nothrow_fptr; - saved_operator_new_debug_fptr = operator_new_debug_fptr; - saved_operator_new_array_fptr = operator_new_array_fptr; - saved_operator_new_array_nothrow_fptr = operator_new_array_nothrow_fptr; - saved_operator_new_array_debug_fptr = operator_new_array_debug_fptr; - saved_operator_delete_fptr = operator_delete_fptr; - saved_operator_delete_array_fptr = operator_delete_array_fptr; - saved_malloc_fptr = malloc_fptr; - saved_realloc_fptr = realloc_fptr; - saved_free_fptr = free_fptr; - turnOffNewDeleteOverloads(); -#endif -} - -void MemoryLeakWarningPlugin::restoreNewDeleteOverloads() -{ -#if CPPUTEST_USE_MEM_LEAK_DETECTION - if (--save_counter > 0) return; - operator_new_fptr = saved_operator_new_fptr; - operator_new_nothrow_fptr = saved_operator_new_nothrow_fptr; - operator_new_debug_fptr = saved_operator_new_debug_fptr; - operator_new_array_fptr = saved_operator_new_array_fptr; - operator_new_array_nothrow_fptr = saved_operator_new_array_nothrow_fptr; - operator_new_array_debug_fptr = saved_operator_new_array_debug_fptr; - operator_delete_fptr = saved_operator_delete_fptr; - operator_delete_array_fptr = saved_operator_delete_array_fptr; - malloc_fptr = saved_malloc_fptr; - realloc_fptr = saved_realloc_fptr; - free_fptr = saved_free_fptr; -#endif -} - -void crash_on_allocation_number(unsigned alloc_number) -{ - static CrashOnAllocationAllocator crashAllocator; - crashAllocator.setNumberToCrashOn(alloc_number); - setCurrentMallocAllocator(&crashAllocator); - setCurrentNewAllocator(&crashAllocator); - setCurrentNewArrayAllocator(&crashAllocator); -} - -class MemoryLeakWarningReporter: public MemoryLeakFailure -{ -public: - virtual ~MemoryLeakWarningReporter() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - virtual void fail(char* fail_string) CPPUTEST_OVERRIDE - { - UtestShell* currentTest = UtestShell::getCurrent(); - currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(), currentTest->getLineNumber(), fail_string), UtestShell::getCurrentTestTerminatorWithoutExceptions()); - } // LCOV_EXCL_LINE -}; - -static MemoryLeakFailure* globalReporter = NULLPTR; -static MemoryLeakDetector* globalDetector = NULLPTR; - -MemoryLeakDetector* MemoryLeakWarningPlugin::getGlobalDetector() -{ - if (globalDetector == NULLPTR) { - saveAndDisableNewDeleteOverloads(); - - globalReporter = new MemoryLeakWarningReporter; - globalDetector = new MemoryLeakDetector(globalReporter); - - restoreNewDeleteOverloads(); - } - return globalDetector; -} - -MemoryLeakFailure* MemoryLeakWarningPlugin::getGlobalFailureReporter() -{ - return globalReporter; -} - -void MemoryLeakWarningPlugin::destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(bool des) -{ - destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_ = des; -} - -void MemoryLeakWarningPlugin::setGlobalDetector(MemoryLeakDetector* detector, MemoryLeakFailure* reporter) -{ - globalDetector = detector; - globalReporter = reporter; -} - -void MemoryLeakWarningPlugin::destroyGlobalDetector() -{ - turnOffNewDeleteOverloads(); - delete globalDetector; - delete globalReporter; - globalDetector = NULLPTR; -} - - -MemoryLeakWarningPlugin* MemoryLeakWarningPlugin::firstPlugin_ = NULLPTR; - -MemoryLeakWarningPlugin* MemoryLeakWarningPlugin::getFirstPlugin() -{ - return firstPlugin_; -} - -MemoryLeakDetector* MemoryLeakWarningPlugin::getMemoryLeakDetector() -{ - return memLeakDetector_; -} - -void MemoryLeakWarningPlugin::ignoreAllLeaksInTest() -{ - ignoreAllWarnings_ = true; -} - -void MemoryLeakWarningPlugin::expectLeaksInTest(size_t n) -{ - expectedLeaks_ = n; -} - -MemoryLeakWarningPlugin::MemoryLeakWarningPlugin(const SimpleString& name, MemoryLeakDetector* localDetector) : - TestPlugin(name), ignoreAllWarnings_(false), destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_(false), expectedLeaks_(0) -{ - if (firstPlugin_ == NULLPTR) firstPlugin_ = this; - - if (localDetector) memLeakDetector_ = localDetector; - else memLeakDetector_ = getGlobalDetector(); - - memLeakDetector_->enable(); -} - -MemoryLeakWarningPlugin::~MemoryLeakWarningPlugin() -{ - if (destroyGlobalDetectorAndTurnOfMemoryLeakDetectionInDestructor_) { - MemoryLeakWarningPlugin::turnOffNewDeleteOverloads(); - MemoryLeakWarningPlugin::destroyGlobalDetector(); - } -} - -void MemoryLeakWarningPlugin::preTestAction(UtestShell& /*test*/, TestResult& result) -{ - memLeakDetector_->startChecking(); - failureCount_ = result.getFailureCount(); -} - -void MemoryLeakWarningPlugin::postTestAction(UtestShell& test, TestResult& result) -{ - memLeakDetector_->stopChecking(); - size_t leaks = memLeakDetector_->totalMemoryLeaks(mem_leak_period_checking); - - if (!ignoreAllWarnings_ && expectedLeaks_ != leaks && failureCount_ == result.getFailureCount()) { - if(MemoryLeakWarningPlugin::areNewDeleteOverloaded()) { - TestFailure f(&test, memLeakDetector_->report(mem_leak_period_checking)); - result.addFailure(f); - } else if(expectedLeaks_ > 0) { - result.print(StringFromFormat("Warning: Expected %d leak(s), but leak detection was disabled", (int) expectedLeaks_).asCharString()); - } - } - memLeakDetector_->markCheckingPeriodLeaksAsNonCheckingPeriod(); - ignoreAllWarnings_ = false; - expectedLeaks_ = 0; -} - -const char* MemoryLeakWarningPlugin::FinalReport(size_t toBeDeletedLeaks) -{ - size_t leaks = memLeakDetector_->totalMemoryLeaks(mem_leak_period_enabled); - if (leaks != toBeDeletedLeaks) return memLeakDetector_->report(mem_leak_period_enabled); - return ""; -} - - diff --git a/src/CppUTest/SimpleMutex.cpp b/src/CppUTest/SimpleMutex.cpp deleted file mode 100644 index 8fd9c887f..000000000 --- a/src/CppUTest/SimpleMutex.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014, Michael Feathers, James Grenning, Bas Vodde and Chen YewMing - * 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/TestHarness.h" -#include "CppUTest/SimpleMutex.h" - - -SimpleMutex::SimpleMutex(void) -{ - psMtx = PlatformSpecificMutexCreate(); -} - -SimpleMutex::~SimpleMutex(void) -{ - PlatformSpecificMutexDestroy(psMtx); -} - -void SimpleMutex::Lock(void) -{ - PlatformSpecificMutexLock(psMtx); -} - -void SimpleMutex::Unlock(void) -{ - PlatformSpecificMutexUnlock(psMtx); -} - - -ScopedMutexLock::ScopedMutexLock(SimpleMutex *mtx) : - mutex(mtx) -{ - mutex->Lock(); -} - -ScopedMutexLock::~ScopedMutexLock() -{ - mutex->Unlock(); -} - - diff --git a/src/CppUTest/SimpleString.cpp b/src/CppUTest/SimpleString.cpp deleted file mode 100644 index a62491e32..000000000 --- a/src/CppUTest/SimpleString.cpp +++ /dev/null @@ -1,1082 +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/TestHarness.h" -#include "CppUTest/SimpleString.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestMemoryAllocator.h" - -GlobalSimpleStringAllocatorStash::GlobalSimpleStringAllocatorStash() - : originalAllocator_(NULLPTR) -{ -} - -void GlobalSimpleStringAllocatorStash::save() -{ - originalAllocator_ = SimpleString::getStringAllocator(); -} - -void GlobalSimpleStringAllocatorStash::restore() -{ - SimpleString::setStringAllocator(originalAllocator_); -} - - -GlobalSimpleStringMemoryAccountant::GlobalSimpleStringMemoryAccountant() - : allocator_(NULLPTR) -{ - accountant_ = new MemoryAccountant(); -} - -GlobalSimpleStringMemoryAccountant::~GlobalSimpleStringMemoryAccountant() -{ - restoreAllocator(); - - delete accountant_; - delete allocator_; -} - -void GlobalSimpleStringMemoryAccountant::restoreAllocator() -{ - if (allocator_ && (SimpleString::getStringAllocator() == allocator_)) - SimpleString::setStringAllocator(allocator_->originalAllocator()); -} - -void GlobalSimpleStringMemoryAccountant::useCacheSizes(size_t cacheSizes[], size_t length) -{ - accountant_->useCacheSizes(cacheSizes, length); -} - -void GlobalSimpleStringMemoryAccountant::start() -{ - if (allocator_ != NULLPTR) - return; - - allocator_ = new AccountingTestMemoryAllocator(*accountant_, SimpleString::getStringAllocator()); - - SimpleString::setStringAllocator(allocator_); -} - -void GlobalSimpleStringMemoryAccountant::stop() -{ - if (allocator_ == NULLPTR) - FAIL("Global SimpleString allocator stopped without starting"); - - if (SimpleString::getStringAllocator() != allocator_) - FAIL("GlobalStrimpleStringMemoryAccountant: allocator has changed between start and stop!"); - - restoreAllocator(); -} - -SimpleString GlobalSimpleStringMemoryAccountant::report() -{ - return accountant_->report(); -} - -AccountingTestMemoryAllocator* GlobalSimpleStringMemoryAccountant::getAllocator() -{ - return allocator_; -} - -TestMemoryAllocator* SimpleString::stringAllocator_ = NULLPTR; - -TestMemoryAllocator* SimpleString::getStringAllocator() -{ - if (stringAllocator_ == NULLPTR) - return defaultNewArrayAllocator(); - return stringAllocator_; -} - -void SimpleString::setStringAllocator(TestMemoryAllocator* allocator) -{ - stringAllocator_ = allocator; -} - -/* Avoid using the memory leak detector INSIDE SimpleString as its used inside the detector */ -char* SimpleString::allocStringBuffer(size_t _size, const char* file, size_t line) -{ - return getStringAllocator()->alloc_memory(_size, file, line); -} - -void SimpleString::deallocStringBuffer(char* str, size_t size, const char* file, size_t line) -{ - getStringAllocator()->free_memory(str, size, file, line); -} - -char* SimpleString::getEmptyString() const -{ - char* empty = allocStringBuffer(1, __FILE__, __LINE__); - empty[0] = '\0'; - return empty; -} - -// does not support + or - prefixes -unsigned SimpleString::AtoU(const char* str) -{ - while (isSpace(*str)) str++; - - unsigned result = 0; - for(; isDigit(*str) && *str >= '0'; str++) - { - result *= 10; - result += static_cast(*str - '0'); - } - return result; -} - -int SimpleString::AtoI(const char* str) -{ - while (isSpace(*str)) str++; - - char first_char = *str; - if (first_char == '-' || first_char == '+') str++; - - int result = 0; - for(; isDigit(*str); str++) - { - result *= 10; - result += *str - '0'; - } - return (first_char == '-') ? -result : result; -} - -int SimpleString::StrCmp(const char* s1, const char* s2) -{ - while(*s1 && *s1 == *s2) { - ++s1; - ++s2; - } - return *(const unsigned char *) s1 - *(const unsigned char *) s2; -} - -size_t SimpleString::StrLen(const char* str) -{ - size_t n = (size_t)-1; - do n++; while (*str++); - return n; -} - -int SimpleString::StrNCmp(const char* s1, const char* s2, size_t n) -{ - while (n && *s1 && *s1 == *s2) { - --n; - ++s1; - ++s2; - } - return n ? *(const unsigned char *) s1 - *(const unsigned char *) s2 : 0; -} - -char* SimpleString::StrNCpy(char* s1, const char* s2, size_t n) -{ - char* result = s1; - - if((NULLPTR == s1) || (0 == n)) return result; - - *s1 = *s2; - while ((--n != 0) && *s1){ - *++s1 = *++s2; - } - return result; -} - -const char* SimpleString::StrStr(const char* s1, const char* s2) -{ - if(!*s2) return s1; - for (; *s1; s1++) - if (StrNCmp(s1, s2, StrLen(s2)) == 0) - return s1; - return NULLPTR; -} - -char SimpleString::ToLower(char ch) -{ - return isUpper(ch) ? (char)((int)ch + ('a' - 'A')) : ch; -} - -int SimpleString::MemCmp(const void* s1, const void *s2, size_t n) -{ - const unsigned char* p1 = (const unsigned char*) s1; - const unsigned char* p2 = (const unsigned char*) s2; - - while (n--) - if (*p1 != *p2) { - return *p1 - *p2; - } else { - ++p1; - ++p2; - } - return 0; -} - -void SimpleString::deallocateInternalBuffer() -{ - if (buffer_) { - deallocStringBuffer(buffer_, bufferSize_, __FILE__, __LINE__); - buffer_ = NULLPTR; - bufferSize_ = 0; - } -} - -void SimpleString::setInternalBufferAsEmptyString() -{ - deallocateInternalBuffer(); - - bufferSize_ = 1; - buffer_ = getEmptyString(); -} - -void SimpleString::copyBufferToNewInternalBuffer(const char* otherBuffer, size_t bufferSize) -{ - deallocateInternalBuffer(); - - bufferSize_ = bufferSize; - buffer_ = copyToNewBuffer(otherBuffer, bufferSize_); -} - -void SimpleString::setInternalBufferToNewBuffer(size_t bufferSize) -{ - deallocateInternalBuffer(); - - bufferSize_ = bufferSize; - buffer_ = allocStringBuffer(bufferSize_, __FILE__, __LINE__); - buffer_[0] = '\0'; -} - -void SimpleString::setInternalBufferTo(char* buffer, size_t bufferSize) -{ - deallocateInternalBuffer(); - - bufferSize_ = bufferSize; - buffer_ = buffer; -} - -void SimpleString::copyBufferToNewInternalBuffer(const SimpleString& otherBuffer) -{ - copyBufferToNewInternalBuffer(otherBuffer.buffer_, otherBuffer.size() + 1); -} - -void SimpleString::copyBufferToNewInternalBuffer(const char* otherBuffer) -{ - copyBufferToNewInternalBuffer(otherBuffer, StrLen(otherBuffer) + 1); -} - -const char* SimpleString::getBuffer() const -{ - return buffer_; -} - -SimpleString::SimpleString(const char *otherBuffer) - : buffer_(NULLPTR), bufferSize_(0) -{ - if (otherBuffer == NULLPTR) - setInternalBufferAsEmptyString(); - else - copyBufferToNewInternalBuffer(otherBuffer); -} - -SimpleString::SimpleString(const char *other, size_t repeatCount) - : buffer_(NULLPTR), bufferSize_(0) -{ - size_t otherStringLength = StrLen(other); - setInternalBufferToNewBuffer(otherStringLength * repeatCount + 1); - - char* next = buffer_; - for (size_t i = 0; i < repeatCount; i++) { - StrNCpy(next, other, otherStringLength + 1); - next += otherStringLength; - } - *next = 0; -} - -SimpleString::SimpleString(const SimpleString& other) - : buffer_(NULLPTR), bufferSize_(0) -{ - copyBufferToNewInternalBuffer(other.getBuffer()); -} - -SimpleString& SimpleString::operator=(const SimpleString& other) -{ - if (this != &other) - copyBufferToNewInternalBuffer(other); - return *this; -} - -bool SimpleString::contains(const SimpleString& other) const -{ - return StrStr(getBuffer(), other.getBuffer()) != NULLPTR; -} - -bool SimpleString::containsNoCase(const SimpleString& other) const -{ - return lowerCase().contains(other.lowerCase()); -} - -bool SimpleString::startsWith(const SimpleString& other) const -{ - if (other.size() == 0) return true; - else if (size() == 0) return false; - else return StrStr(getBuffer(), other.getBuffer()) == getBuffer(); -} - -bool SimpleString::endsWith(const SimpleString& other) const -{ - size_t length = size(); - size_t other_length = other.size(); - - if (other_length == 0) return true; - if (length == 0) return false; - if (length < other_length) return false; - - return StrCmp(getBuffer() + length - other_length, other.getBuffer()) == 0; -} - -size_t SimpleString::count(const SimpleString& substr) const -{ - size_t num = 0; - const char* str = 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; -} - -void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const -{ - size_t num = count(delimiter); - size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1U; - col.allocate(num + extraEndToken); - - const char* str = getBuffer(); - const char* prev; - for (size_t i = 0; i < num; ++i) { - prev = str; - str = StrStr(str, delimiter.getBuffer()) + 1; - col[i] = SimpleString(prev).subString(0, size_t (str - prev)); - } - if (extraEndToken) { - col[num] = str; - } -} - -void SimpleString::replace(char to, char with) -{ - size_t s = size(); - for (size_t i = 0; i < s; i++) { - if (getBuffer()[i] == to) buffer_[i] = with; - } -} - -void SimpleString::replace(const char* to, const char* with) -{ - size_t c = count(to); - if (c == 0) { - return; - } - size_t len = size(); - size_t tolen = StrLen(to); - size_t withlen = StrLen(with); - - size_t newsize = len + (withlen * c) - (tolen * c) + 1; - - if (newsize > 1) { - char* newbuf = allocStringBuffer(newsize, __FILE__, __LINE__); - for (size_t i = 0, j = 0; i < len;) { - if (StrNCmp(&getBuffer()[i], to, tolen) == 0) { - StrNCpy(&newbuf[j], with, withlen + 1); - j += withlen; - i += tolen; - } - else { - newbuf[j] = getBuffer()[i]; - j++; - i++; - } - } - newbuf[newsize - 1] = '\0'; - setInternalBufferTo(newbuf, newsize); - } - else - 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); - - size_t str_size = str.size(); - for (size_t i = 0; i < str_size; i++) - str.buffer_[i] = ToLower(str.getBuffer()[i]); - - return str; -} - -const char *SimpleString::asCharString() const -{ - return getBuffer(); -} - -size_t SimpleString::size() const -{ - return StrLen(getBuffer()); -} - -bool SimpleString::isEmpty() const -{ - return size() == 0; -} - -SimpleString::~SimpleString() -{ - deallocateInternalBuffer(); -} - -bool operator==(const SimpleString& left, const SimpleString& right) -{ - return 0 == SimpleString::StrCmp(left.asCharString(), right.asCharString()); -} - -bool SimpleString::equalsNoCase(const SimpleString& str) const -{ - return lowerCase() == str.lowerCase(); -} - - -bool operator!=(const SimpleString& left, const SimpleString& right) -{ - return !(left == right); -} - -SimpleString SimpleString::operator+(const SimpleString& rhs) const -{ - SimpleString t(getBuffer()); - t += rhs.getBuffer(); - return t; -} - -SimpleString& SimpleString::operator+=(const SimpleString& rhs) -{ - return operator+=(rhs.getBuffer()); -} - -SimpleString& SimpleString::operator+=(const char* rhs) -{ - size_t originalSize = this->size(); - size_t additionalStringSize = StrLen(rhs) + 1; - size_t sizeOfNewString = originalSize + additionalStringSize; - char* tbuffer = copyToNewBuffer(this->getBuffer(), sizeOfNewString); - StrNCpy(tbuffer + originalSize, rhs, additionalStringSize); - - setInternalBufferTo(tbuffer, sizeOfNewString); - return *this; -} - -void SimpleString::padStringsToSameLength(SimpleString& str1, SimpleString& str2, char padCharacter) -{ - if (str1.size() > str2.size()) { - padStringsToSameLength(str2, str1, padCharacter); - return; - } - - char pad[2]; - pad[0] = padCharacter; - pad[1] = 0; - str1 = SimpleString(pad, str2.size() - str1.size()) + str1; -} - -SimpleString SimpleString::subString(size_t beginPos, size_t amount) const -{ - if (beginPos > size()-1) return ""; - - SimpleString newString = getBuffer() + beginPos; - - if (newString.size() > amount) - newString.buffer_[amount] = '\0'; - - return newString; -} - -SimpleString SimpleString::subString(size_t beginPos) const -{ - return subString(beginPos, npos); -} - -char SimpleString::at(size_t pos) const -{ - return getBuffer()[pos]; -} - -size_t SimpleString::find(char ch) const -{ - return findFrom(0, ch); -} - -size_t SimpleString::findFrom(size_t starting_position, char ch) const -{ - size_t length = size(); - for (size_t i = starting_position; i < length; i++) - if (at(i) == ch) return i; - return npos; -} - -SimpleString SimpleString::subStringFromTill(char startChar, char lastExcludedChar) const -{ - size_t beginPos = find(startChar); - if (beginPos == npos) return ""; - - size_t endPos = findFrom(beginPos, lastExcludedChar); - if (endPos == npos) return subString(beginPos); - - return subString(beginPos, endPos - beginPos); -} - -char* SimpleString::copyToNewBuffer(const char* bufferToCopy, size_t bufferSize) -{ - char* newBuffer = allocStringBuffer(bufferSize, __FILE__, __LINE__); - StrNCpy(newBuffer, bufferToCopy, bufferSize); - newBuffer[bufferSize-1] = '\0'; - return newBuffer; -} - - -void SimpleString::copyToBuffer(char* bufferToCopy, size_t bufferSize) const -{ - if (bufferToCopy == NULLPTR || bufferSize == 0) return; - - size_t sizeToCopy = (bufferSize-1 < size()) ? (bufferSize-1) : size(); - - StrNCpy(bufferToCopy, getBuffer(), sizeToCopy); - bufferToCopy[sizeToCopy] = '\0'; -} - -bool SimpleString::isDigit(char ch) -{ - return '0' <= ch && '9' >= ch; -} - -bool SimpleString::isSpace(char ch) -{ - return (ch == ' ') || (0x08 < ch && 0x0E > ch); -} - -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")); -} - -SimpleString StringFrom(const char *value) -{ - return SimpleString(value); -} - -SimpleString StringFromOrNull(const char * expected) -{ - return (expected) ? StringFrom(expected) : StringFrom("(null)"); -} - -SimpleString PrintableStringFromOrNull(const char * expected) -{ - return (expected) ? StringFrom(expected).printable() : StringFrom("(null)"); -} - -SimpleString StringFrom(int value) -{ - return StringFromFormat("%d", value); -} - -SimpleString StringFrom(long value) -{ - return StringFromFormat("%ld", value); -} - -SimpleString StringFrom(const void* value) -{ - return SimpleString("0x") + HexStringFrom(value); -} - -SimpleString StringFrom(void (*value)()) -{ - return SimpleString("0x") + HexStringFrom(value); -} - -SimpleString HexStringFrom(long value) -{ - return HexStringFrom((unsigned long)value); -} - -SimpleString HexStringFrom(int value) -{ - return HexStringFrom((unsigned int)value); -} - -SimpleString HexStringFrom(signed char value) -{ - SimpleString result = StringFromFormat("%x", value); - if(value < 0) { - size_t size = result.size(); - result = result.subString(size-(CPPUTEST_CHAR_BIT/4)); - } - return result; -} - -SimpleString HexStringFrom(unsigned long value) -{ - return StringFromFormat("%lx", value); -} - -SimpleString HexStringFrom(unsigned int value) -{ - return StringFromFormat("%x", value); -} - -SimpleString BracketsFormattedHexStringFrom(int value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - -SimpleString BracketsFormattedHexStringFrom(unsigned int value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - -SimpleString BracketsFormattedHexStringFrom(long value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - - -SimpleString BracketsFormattedHexStringFrom(unsigned long value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - -SimpleString BracketsFormattedHexStringFrom(signed char value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - -SimpleString BracketsFormattedHexString(SimpleString hexString) -{ - return SimpleString("(0x") + hexString + ")" ; -} - -/* - * ARM compiler has only partial support for C++11. - * Specifically nullptr_t is not officially supported - */ -#if __cplusplus > 199711L && !defined __arm__ && CPPUTEST_USE_STD_CPP_LIB -SimpleString StringFrom(const std::nullptr_t value) -{ - (void) value; - return "(null)"; -} -#endif - -#if CPPUTEST_USE_LONG_LONG - -SimpleString StringFrom(cpputest_longlong value) -{ - return StringFromFormat("%lld", value); -} - -SimpleString StringFrom(cpputest_ulonglong value) -{ - return StringFromFormat("%llu", value); -} - -SimpleString HexStringFrom(cpputest_longlong value) -{ - return HexStringFrom((cpputest_ulonglong)value); -} - -SimpleString HexStringFrom(cpputest_ulonglong value) -{ - return StringFromFormat("%llx", value); -} - -SimpleString HexStringFrom(const void* value) -{ - return HexStringFrom((cpputest_ulonglong) value); -} - -SimpleString HexStringFrom(void (*value)()) -{ - return HexStringFrom((cpputest_ulonglong) value); -} - -SimpleString BracketsFormattedHexStringFrom(cpputest_longlong value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - - -SimpleString BracketsFormattedHexStringFrom(cpputest_ulonglong value) -{ - return BracketsFormattedHexString(HexStringFrom(value)); -} - -#else /* CPPUTEST_USE_LONG_LONG */ - -static long convertPointerToLongValue(const void* value) -{ - /* - * This way of converting also can convert a 64bit pointer in a 32bit integer by truncating. - * This isn't the right way to convert pointers values and need to change by implementing a - * proper portable way to convert pointers to strings. - */ - long* long_value = (long*) &value; - return *long_value; -} - -static long convertFunctionPointerToLongValue(void (*value)()) -{ - /* - * This way of converting also can convert a 64bit pointer in a 32bit integer by truncating. - * This isn't the right way to convert pointers values and need to change by implementing a - * proper portable way to convert pointers to strings. - */ - long* long_value = (long*) &value; - return *long_value; -} - -SimpleString StringFrom(cpputest_longlong) -{ - return ""; -} - -SimpleString StringFrom(cpputest_ulonglong) -{ - return ""; -} - -SimpleString HexStringFrom(cpputest_longlong) -{ - return ""; -} - -SimpleString HexStringFrom(cpputest_ulonglong) -{ - return ""; -} - -SimpleString HexStringFrom(const void* value) -{ - return StringFromFormat("%lx", convertPointerToLongValue(value)); -} - -SimpleString HexStringFrom(void (*value)()) -{ - return StringFromFormat("%lx", convertFunctionPointerToLongValue(value)); -} - -SimpleString BracketsFormattedHexStringFrom(cpputest_longlong) -{ - return ""; -} - - -SimpleString BracketsFormattedHexStringFrom(cpputest_ulonglong) -{ - return ""; -} - -#endif /* CPPUTEST_USE_LONG_LONG */ - -SimpleString StringFrom(double value, int precision) -{ - if (PlatformSpecificIsNan(value)) - return "Nan - Not a number"; - else if (PlatformSpecificIsInf(value)) - return "Inf - Infinity"; - else - return StringFromFormat("%.*g", precision, value); -} - -SimpleString StringFrom(char value) -{ - return StringFromFormat("%c", value); -} - -SimpleString StringFrom(const SimpleString& value) -{ - return SimpleString(value); -} - -SimpleString StringFromFormat(const char* format, ...) -{ - SimpleString resultString; - va_list arguments; - va_start(arguments, format); - - resultString = VStringFromFormat(format, arguments); - va_end(arguments); - return resultString; -} - -SimpleString StringFrom(unsigned int i) -{ - return StringFromFormat("%u", i); -} - -#if CPPUTEST_USE_STD_CPP_LIB - -#include - -SimpleString StringFrom(const std::string& value) -{ - return SimpleString(value.c_str()); -} - -#endif - -SimpleString StringFrom(unsigned long i) -{ - return StringFromFormat("%lu", i); -} - -SimpleString VStringFromFormat(const char* format, va_list args) -{ - va_list argsCopy; - va_copy(argsCopy, args); - enum - { - sizeOfdefaultBuffer = 100 - }; - char defaultBuffer[sizeOfdefaultBuffer]; - SimpleString resultString; - - size_t size = (size_t)PlatformSpecificVSNprintf(defaultBuffer, sizeOfdefaultBuffer, format, args); - if (size < sizeOfdefaultBuffer) { - resultString = SimpleString(defaultBuffer); - } - else { - size_t newBufferSize = size + 1; - char* newBuffer = SimpleString::allocStringBuffer(newBufferSize, __FILE__, __LINE__); - PlatformSpecificVSNprintf(newBuffer, newBufferSize, format, argsCopy); - resultString = SimpleString(newBuffer); - - SimpleString::deallocStringBuffer(newBuffer, newBufferSize, __FILE__, __LINE__); - } - va_end(argsCopy); - return resultString; -} - -SimpleString StringFromBinary(const unsigned char* value, size_t size) -{ - SimpleString result; - - for (size_t i = 0; i < size; i++) { - result += StringFromFormat("%02X ", value[i]); - } - result = result.subString(0, result.size() - 1); - - return result; -} - -SimpleString StringFromBinaryOrNull(const unsigned char* value, size_t size) -{ - return (value) ? StringFromBinary(value, size) : StringFrom("(null)"); -} - -SimpleString StringFromBinaryWithSize(const unsigned char* value, size_t size) -{ - SimpleString result = StringFromFormat("Size = %u | HexContents = ", (unsigned) size); - size_t displayedSize = ((size > 128) ? 128 : size); - result += StringFromBinaryOrNull(value, displayedSize); - if (size > displayedSize) - { - result += " ..."; - } - return result; -} - -SimpleString StringFromBinaryWithSizeOrNull(const unsigned char* value, size_t size) -{ - return (value) ? StringFromBinaryWithSize(value, size) : StringFrom("(null)"); -} - -SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_t byteCount) -{ - SimpleString result; - size_t bitCount = (byteCount > sizeof(unsigned long)) ? (sizeof(unsigned long) * CPPUTEST_CHAR_BIT) : (byteCount * CPPUTEST_CHAR_BIT); - const unsigned long msbMask = (((unsigned long) 1) << (bitCount - 1)); - - for (size_t i = 0; i < bitCount; i++) { - if (mask & msbMask) { - result += (value & msbMask) ? "1" : "0"; - } - else { - result += "x"; - } - - if (((i % 8) == 7) && (i != (bitCount - 1))) { - result += " "; - } - - value <<= 1; - mask <<= 1; - } - - return result; -} - -SimpleString StringFromOrdinalNumber(unsigned int number) -{ - 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); -} - -SimpleStringCollection::SimpleStringCollection() -{ - collection_ = NULLPTR; - size_ = 0; -} - -void SimpleStringCollection::allocate(size_t _size) -{ - delete[] collection_; - - size_ = _size; - collection_ = new SimpleString[size_]; -} - -SimpleStringCollection::~SimpleStringCollection() -{ - delete[] (collection_); -} - -size_t SimpleStringCollection::size() const -{ - return size_; -} - -SimpleString& SimpleStringCollection::operator[](size_t index) -{ - if (index >= size_) { - empty_ = ""; - return empty_; - } - - return collection_[index]; -} diff --git a/src/CppUTest/SimpleStringInternalCache.cpp b/src/CppUTest/SimpleStringInternalCache.cpp deleted file mode 100644 index 2964a2d2c..000000000 --- a/src/CppUTest/SimpleStringInternalCache.cpp +++ /dev/null @@ -1,312 +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/TestHarness.h" -#include "CppUTest/SimpleStringInternalCache.h" - -struct SimpleStringMemoryBlock -{ - SimpleStringMemoryBlock* next_; - char* memory_; -}; - -struct SimpleStringInternalCacheNode -{ - size_t size_; - SimpleStringMemoryBlock* freeMemoryHead_; - SimpleStringMemoryBlock* usedMemoryHead_; -}; - -SimpleStringInternalCache::SimpleStringInternalCache() - : allocator_(defaultMallocAllocator()), cache_(NULLPTR), nonCachedAllocations_(NULLPTR), hasWarnedAboutDeallocations(false) -{ - cache_ = createInternalCacheNodes(); -} - -SimpleStringInternalCache::~SimpleStringInternalCache() -{ - allocator_ = defaultMallocAllocator(); - destroyInternalCacheNode(cache_); -} - -void SimpleStringInternalCache::setAllocator(TestMemoryAllocator* allocator) -{ - allocator_ = allocator; -} - -SimpleStringInternalCacheNode* SimpleStringInternalCache::createInternalCacheNodes() -{ - SimpleStringInternalCacheNode* node = (SimpleStringInternalCacheNode*) (void*) allocator_->alloc_memory(sizeof(SimpleStringInternalCacheNode) * amountOfInternalCacheNodes, __FILE__, __LINE__); - - for (int i = 0; i < amountOfInternalCacheNodes; i++) { - node[i].freeMemoryHead_ = NULLPTR; - node[i].usedMemoryHead_ = NULLPTR; - } - node[0].size_ = 32; - node[1].size_ = 64; - node[2].size_ = 96; - node[3].size_ = 128; - node[4].size_ = 256; - return node; -} - -bool SimpleStringInternalCache::isCached(size_t size) -{ - return size <= 256; -} - -size_t SimpleStringInternalCache::getIndexForCache(size_t size) -{ - for (size_t i = 0; i < amountOfInternalCacheNodes; i++) - if (size <= cache_[i].size_) - return i; - return 0; // LCOV_EXCL_LINE -} - -SimpleStringInternalCacheNode* SimpleStringInternalCache::getCacheNodeFromSize(size_t size) -{ - size_t index = getIndexForCache(size); - return &cache_[index]; -} - -void SimpleStringInternalCache::destroyInternalCacheNode(SimpleStringInternalCacheNode * node) -{ - allocator_->free_memory((char*) node, sizeof(SimpleStringInternalCacheNode) * amountOfInternalCacheNodes, __FILE__, __LINE__); -} - -SimpleStringMemoryBlock* SimpleStringInternalCache::createSimpleStringMemoryBlock(size_t size, SimpleStringMemoryBlock* next) -{ - SimpleStringMemoryBlock* block = (SimpleStringMemoryBlock*) (void*) allocator_->alloc_memory(sizeof(SimpleStringMemoryBlock) , __FILE__, __LINE__); - block->memory_ = allocator_->alloc_memory(size , __FILE__, __LINE__); - block->next_ = next; - return block; -} - -void SimpleStringInternalCache::destroySimpleStringMemoryBlock(SimpleStringMemoryBlock * block, size_t size) -{ - allocator_->free_memory(block->memory_, size, __FILE__, __LINE__); - allocator_->free_memory((char*) block, sizeof(SimpleStringMemoryBlock), __FILE__, __LINE__); -} - -void SimpleStringInternalCache::destroySimpleStringMemoryBlockList(SimpleStringMemoryBlock * block, size_t size) -{ - SimpleStringMemoryBlock* current = block; - while (current) { - SimpleStringMemoryBlock* next = current->next_; - destroySimpleStringMemoryBlock(current, size); - current = next; - } -} - -SimpleStringMemoryBlock* SimpleStringInternalCache::addToSimpleStringMemoryBlockList(SimpleStringMemoryBlock* newBlock, SimpleStringMemoryBlock* previousHead) -{ - newBlock->next_ = previousHead; - return newBlock; -} - -bool SimpleStringInternalCache::hasFreeBlocksOfSize(size_t size) -{ - return getCacheNodeFromSize(size)->freeMemoryHead_ != NULLPTR; -} - -SimpleStringMemoryBlock* SimpleStringInternalCache::reserveCachedBlockFrom(SimpleStringInternalCacheNode* node) -{ - SimpleStringMemoryBlock* block = node->freeMemoryHead_; - node->freeMemoryHead_ = block->next_; - node->usedMemoryHead_ = addToSimpleStringMemoryBlockList(block, node->usedMemoryHead_); - return block; -} - -SimpleStringMemoryBlock* SimpleStringInternalCache::allocateNewCacheBlockFrom(SimpleStringInternalCacheNode* node) -{ - SimpleStringMemoryBlock* block = createSimpleStringMemoryBlock(node->size_, node->usedMemoryHead_); - node->usedMemoryHead_ = addToSimpleStringMemoryBlockList(block, node->usedMemoryHead_); - return block; -} - -void SimpleStringInternalCache::printDeallocatingUnknownMemory(char* memory) -{ - if (!hasWarnedAboutDeallocations) { - hasWarnedAboutDeallocations = true; - UtestShell::getCurrent()->print(StringFromFormat("\nWARNING: Attempting to deallocate a String buffer that was allocated while not caching. Ignoring it!\n" - "This is likely due statics and will cause problems.\n" - "Only warning once to avoid recursive warnings.\n" - "String we are deallocating: \"%s\"\n", memory).asCharString(), __FILE__, __LINE__); - } -} - -void SimpleStringInternalCache::releaseCachedBlockFrom(char* memory, SimpleStringInternalCacheNode* node) -{ - if (node->usedMemoryHead_ && node->usedMemoryHead_->memory_ == memory) { - SimpleStringMemoryBlock* block = node->usedMemoryHead_; - node->usedMemoryHead_ = node->usedMemoryHead_->next_; - node->freeMemoryHead_ = addToSimpleStringMemoryBlockList(block, node->freeMemoryHead_); - return; - } - - for (SimpleStringMemoryBlock* block = node->usedMemoryHead_; block; block = block->next_) { - if (block->next_ && block->next_->memory_ == memory) { - SimpleStringMemoryBlock* blockToFree = block->next_; - block->next_ = block->next_->next_; - node->freeMemoryHead_ = addToSimpleStringMemoryBlockList(blockToFree, node->freeMemoryHead_); - return; - } - } - printDeallocatingUnknownMemory(memory); - -} - -void SimpleStringInternalCache::releaseNonCachedMemory(char* memory, size_t size) -{ - if (nonCachedAllocations_ && nonCachedAllocations_->memory_ == memory) { - SimpleStringMemoryBlock* block = nonCachedAllocations_; - nonCachedAllocations_ = block->next_; - destroySimpleStringMemoryBlock(block, size); - return; - } - - for (SimpleStringMemoryBlock* block = nonCachedAllocations_; block; block = block->next_) { - if (block->next_ && block->next_->memory_ == memory) { - SimpleStringMemoryBlock* blockToFree = block->next_; - block->next_ = block->next_->next_; - destroySimpleStringMemoryBlock(blockToFree, size); - return; - } - } - - printDeallocatingUnknownMemory(memory); -} - -char* SimpleStringInternalCache::alloc(size_t size) -{ - if (isCached(size)) { - if (hasFreeBlocksOfSize(size)) - return reserveCachedBlockFrom(getCacheNodeFromSize(size))->memory_; - else - return allocateNewCacheBlockFrom(getCacheNodeFromSize(size))->memory_; - } - - nonCachedAllocations_ = createSimpleStringMemoryBlock(size, nonCachedAllocations_); - return nonCachedAllocations_->memory_; -} - -void SimpleStringInternalCache::dealloc(char* memory, size_t size) -{ - if (isCached(size)) { - size_t index = getIndexForCache(size); - SimpleStringInternalCacheNode* cacheNode = &cache_[index]; - releaseCachedBlockFrom(memory, cacheNode); - return; - } - releaseNonCachedMemory(memory, size); -} - -void SimpleStringInternalCache::clearCache() -{ - for (size_t i = 0; i < amountOfInternalCacheNodes; i++) { - destroySimpleStringMemoryBlockList(cache_[i].freeMemoryHead_, cache_[i].size_); - cache_[i].freeMemoryHead_ = NULLPTR; - } -} - -void SimpleStringInternalCache::clearAllIncludingCurrentlyUsedMemory() -{ - for (size_t i = 0; i < amountOfInternalCacheNodes; i++) { - destroySimpleStringMemoryBlockList(cache_[i].freeMemoryHead_, cache_[i].size_); - destroySimpleStringMemoryBlockList(cache_[i].usedMemoryHead_, cache_[i].size_); - cache_[i].freeMemoryHead_ = NULLPTR; - cache_[i].usedMemoryHead_ = NULLPTR; - } - - destroySimpleStringMemoryBlockList(nonCachedAllocations_, 0); - nonCachedAllocations_ = NULLPTR; -} - -GlobalSimpleStringCache::GlobalSimpleStringCache() -{ - allocator_ = new SimpleStringCacheAllocator(cache_, SimpleString::getStringAllocator()); - SimpleString::setStringAllocator(allocator_); -} - -GlobalSimpleStringCache::~GlobalSimpleStringCache() -{ - SimpleString::setStringAllocator(allocator_->originalAllocator()); - cache_.clearAllIncludingCurrentlyUsedMemory(); - delete allocator_; -} - -TestMemoryAllocator* GlobalSimpleStringCache::getAllocator() -{ - return allocator_; -} - -SimpleStringCacheAllocator::SimpleStringCacheAllocator(SimpleStringInternalCache& cache, TestMemoryAllocator* origAllocator) - : cache_(cache), originalAllocator_(origAllocator) -{ - cache_.setAllocator(origAllocator); -} - -SimpleStringCacheAllocator::~SimpleStringCacheAllocator() -{ - cache_.setAllocator(NULLPTR); -} - -char* SimpleStringCacheAllocator::alloc_memory(size_t size, const char*, size_t) -{ - return cache_.alloc(size); -} - -void SimpleStringCacheAllocator::free_memory(char* memory, size_t size, const char*, size_t) -{ - cache_.dealloc(memory, size); -} - -const char* SimpleStringCacheAllocator::name() const -{ - return "SimpleStringCacheAllocator"; -} - -const char* SimpleStringCacheAllocator::alloc_name() const -{ - return originalAllocator_->alloc_name(); -} - -const char* SimpleStringCacheAllocator::free_name() const -{ - return originalAllocator_->free_name(); -} - -TestMemoryAllocator* SimpleStringCacheAllocator::actualAllocator() -{ - return originalAllocator_->actualAllocator(); -} - -TestMemoryAllocator* SimpleStringCacheAllocator::originalAllocator() -{ - return originalAllocator_; -} - diff --git a/src/CppUTest/TeamCityTestOutput.cpp b/src/CppUTest/TeamCityTestOutput.cpp deleted file mode 100644 index faa775363..000000000 --- a/src/CppUTest/TeamCityTestOutput.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "CppUTest/TeamCityTestOutput.h" - -TeamCityTestOutput::TeamCityTestOutput() : currtest_(NULLPTR), currGroup_() -{ -} - -TeamCityTestOutput::~TeamCityTestOutput() -{ -} - -void TeamCityTestOutput::printCurrentTestStarted(const UtestShell& test) -{ - print("##teamcity[testStarted name='"); - printEscaped(test.getName().asCharString()); - print("']\n"); - if (!test.willRun()) { - print("##teamcity[testIgnored name='"); - printEscaped(test.getName().asCharString()); - print("']\n"); - } - currtest_ = &test; -} - -void TeamCityTestOutput::printCurrentTestEnded(const TestResult& res) -{ - if (!currtest_) - return; - - print("##teamcity[testFinished name='"); - printEscaped(currtest_->getName().asCharString()); - print("' duration='"); - print(res.getCurrentTestTotalExecutionTime()); - print("']\n"); -} - -void TeamCityTestOutput::printCurrentGroupStarted(const UtestShell& test) -{ - currGroup_ = test.getGroup(); - print("##teamcity[testSuiteStarted name='"); - printEscaped(currGroup_.asCharString()); - print("']\n"); -} - -void TeamCityTestOutput::printCurrentGroupEnded(const TestResult& /*res*/) -{ - if (currGroup_ == "") - return; - - print("##teamcity[testSuiteFinished name='"); - printEscaped(currGroup_.asCharString()); - print("']\n"); -} - -void TeamCityTestOutput::printEscaped(const char* s) -{ - while (*s) { - char str[3]; - if ((*s == '\'') || (*s == '|') || (*s == '[') || (*s == ']')) { - str[0] = '|'; - str[1] = *s; - str[2] = 0; - } else if (*s == '\r') { - str[0] = '|'; - str[1] = 'r'; - str[2] = 0; - } else if (*s == '\n') { - str[0] = '|'; - str[1] = 'n'; - str[2] = 0; - } else { - str[0] = *s; - str[1] = 0; - } - printBuffer(str); - s++; - } -} - -void TeamCityTestOutput::printFailure(const TestFailure& failure) -{ - print("##teamcity[testFailed name='"); - printEscaped(failure.getTestNameOnly().asCharString()); - print("' message='"); - if (failure.isOutsideTestFile() || failure.isInHelperFunction()) { - print("TEST failed ("); - print(failure.getTestFileName().asCharString()); - print(":"); - print(failure.getTestLineNumber()); - print("): "); - } - - printEscaped(failure.getFileName().asCharString()); - print(":"); - print(failure.getFailureLineNumber()); - - print("' details='"); - printEscaped(failure.getMessage().asCharString()); - print("']\n"); -} diff --git a/src/CppUTest/TestFailure.cpp b/src/CppUTest/TestFailure.cpp deleted file mode 100644 index a3a9bb82e..000000000 --- a/src/CppUTest/TestFailure.cpp +++ /dev/null @@ -1,432 +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/TestHarness.h" -#include "CppUTest/TestFailure.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/SimpleString.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -#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) -{ -} - -TestFailure::TestFailure(UtestShell* test, const SimpleString& theMessage) : - testName_(test->getFormattedName()), testNameOnly_(test->getName()), fileName_(test->getFile()), lineNumber_(test->getLineNumber()), testFileName_(test->getFile()), testLineNumber_(test->getLineNumber()), message_(theMessage) -{ -} - -TestFailure::TestFailure(UtestShell* test, const char* fileName, size_t lineNum) : - testName_(test->getFormattedName()), testNameOnly_(test->getName()), fileName_(fileName), lineNumber_(lineNum), testFileName_(test->getFile()), testLineNumber_(test->getLineNumber()), message_("no message") -{ -} - -TestFailure::TestFailure(const TestFailure& f) : - testName_(f.testName_), testNameOnly_(f.testNameOnly_), fileName_(f.fileName_), lineNumber_(f.lineNumber_), testFileName_(f.testFileName_), testLineNumber_(f.testLineNumber_), message_(f.message_) -{ -} - - -TestFailure::~TestFailure() -{ -} - -SimpleString TestFailure::getFileName() const -{ - return fileName_; -} - -SimpleString TestFailure::getTestFileName() const -{ - return testFileName_; -} - -SimpleString TestFailure::getTestName() const -{ - return testName_; -} - -SimpleString TestFailure::getTestNameOnly() const -{ - return testNameOnly_; -} - -size_t TestFailure::getFailureLineNumber() const -{ - return lineNumber_; -} - -size_t TestFailure::getTestLineNumber() const -{ - return testLineNumber_; -} - -SimpleString TestFailure::getMessage() const -{ - return message_; -} - -bool TestFailure::isOutsideTestFile() const -{ - return testFileName_ != fileName_; -} - -bool TestFailure::isInHelperFunction() const -{ - return lineNumber_ < testLineNumber_; -} - -SimpleString TestFailure::createButWasString(const SimpleString& expected, const SimpleString& actual) -{ - return StringFromFormat("expected <%s>\n\tbut was <%s>", expected.asCharString(), actual.asCharString()); -} - -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; - - SimpleString paddingForPreventingOutOfBounds (" ", halfOfExtraCharactersWindow); - SimpleString actualString = paddingForPreventingOutOfBounds + actual + paddingForPreventingOutOfBounds; - SimpleString differentString = StringFromFormat("difference starts at position %lu at: <", (unsigned long) reportedPosition); - - result += "\n"; - result += StringFromFormat("\t%s%s>\n", differentString.asCharString(), actualString.subString(offset, extraCharactersWindow).asCharString()); - - - result += StringFromFormat("\t%s^", SimpleString(" ", (differentString.size() + halfOfExtraCharactersWindow)).asCharString()); - return result; -} - -SimpleString TestFailure::createUserText(const SimpleString& text) -{ - SimpleString userMessage = ""; - if (!text.isEmpty()) - { - //This is a kludge to turn off "Message: " for this case. - //I don't think "Message: " adds anything, as you get to see the - //message. I propose we remove "Message: " lead in - if (!text.startsWith("LONGS_EQUAL")) - userMessage += "Message: "; - userMessage += text; - userMessage += "\n\t"; - } - return userMessage; -} - -EqualsFailure::EqualsFailure(UtestShell* test, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text) : - TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += createButWasString(StringFromOrNull(expected), StringFromOrNull(actual)); -} - -EqualsFailure::EqualsFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) - : TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += createButWasString(expected, actual); -} - -DoublesEqualFailure::DoublesEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, double expected, double actual, double threshold, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += createButWasString(StringFrom(expected, 7), StringFrom(actual, 7)); - message_ += " threshold used was <"; - message_ += StringFrom(threshold, 7); - message_ += ">"; - - if (PlatformSpecificIsNan(expected) || PlatformSpecificIsNan(actual) || PlatformSpecificIsNan(threshold)) - message_ += "\n\tCannot make comparisons with Nan"; -} - -CheckEqualFailure::CheckEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString printableExpected = PrintableStringFromOrNull(expected.asCharString()); - SimpleString printableActual = PrintableStringFromOrNull(actual.asCharString()); - - message_ += createButWasString(printableExpected, printableActual); - - size_t failStart; - for (failStart = 0; actual.at(failStart) == expected.at(failStart); 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) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - message_ += checkString; - message_ += "("; - message_ += comparisonString; - message_ += ") failed"; -} - -ContainsFailure::ContainsFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& expected, const SimpleString& actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += StringFromFormat("actual <%s>\n\tdid not contain <%s>", actual.asCharString(), expected.asCharString()); -} - -CheckFailure::CheckFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& checkString, const SimpleString& conditionString, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += checkString; - message_ += "("; - message_ += conditionString; - message_ += ") failed"; -} - -FailFailure::FailFailure(UtestShell* test, const char* fileName, size_t lineNumber, const SimpleString& message) : TestFailure(test, fileName, lineNumber) -{ - message_ = message; -} - -LongsEqualFailure::LongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, long expected, long actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString aDecimal = StringFrom(actual); - SimpleString eDecimal = StringFrom(expected); - - SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); - - SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); - SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); - message_ += createButWasString(expectedReported, actualReported); -} - -UnsignedLongsEqualFailure::UnsignedLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, unsigned long expected, unsigned long actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString aDecimal = StringFrom(actual); - SimpleString eDecimal = StringFrom(expected); - - SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); - - SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); - SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); - - message_ += createButWasString(expectedReported, actualReported); -} - -LongLongsEqualFailure::LongLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, cpputest_longlong expected, cpputest_longlong actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString aDecimal = StringFrom(actual); - SimpleString eDecimal = StringFrom(expected); - - SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); - - SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); - SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); - message_ += createButWasString(expectedReported, actualReported); -} - -UnsignedLongLongsEqualFailure::UnsignedLongLongsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, cpputest_ulonglong expected, cpputest_ulonglong actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString aDecimal = StringFrom(actual); - SimpleString eDecimal = StringFrom(expected); - - SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); - - SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); - SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); - message_ += createButWasString(expectedReported, actualReported); -} - -SignedBytesEqualFailure::SignedBytesEqualFailure (UtestShell* test, const char* fileName, size_t lineNumber, signed char expected, signed char actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - SimpleString aDecimal = StringFrom((int)actual); - SimpleString eDecimal = StringFrom((int)expected); - - SimpleString::padStringsToSameLength(aDecimal, eDecimal, ' '); - - SimpleString actualReported = aDecimal + " " + BracketsFormattedHexStringFrom(actual); - SimpleString expectedReported = eDecimal + " " + BracketsFormattedHexStringFrom(expected); - message_ += createButWasString(expectedReported, actualReported); -} - -StringEqualFailure::StringEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - 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++) - ; - size_t failStartPrintable; - for (failStartPrintable = 0; printableActual.at(failStartPrintable) == printableExpected.at(failStartPrintable); failStartPrintable++) - ; - message_ += createDifferenceAtPosString(printableActual, failStartPrintable, failStart); - } -} - -StringEqualNoCaseFailure::StringEqualNoCaseFailure(UtestShell* test, const char* fileName, size_t lineNumber, const char* expected, const char* actual, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - 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++) - ; - size_t failStartPrintable; - for (failStartPrintable = 0; - SimpleString::ToLower(printableActual.at(failStartPrintable)) == SimpleString::ToLower(printableExpected.at(failStartPrintable)); - failStartPrintable++) - ; - message_ += createDifferenceAtPosString(printableActual, failStartPrintable, failStart); - } -} - -BinaryEqualFailure::BinaryEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, const unsigned char* expected, - const unsigned char* actual, size_t size, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - 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(actualHex, (failStart * 3 + 1), failStart); - } -} - -BitsEqualFailure::BitsEqualFailure(UtestShell* test, const char* fileName, size_t lineNumber, unsigned long expected, unsigned long actual, - unsigned long mask, size_t byteCount, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - message_ += createButWasString(StringFromMaskedBits(expected, mask, byteCount), StringFromMaskedBits(actual, mask, byteCount)); -} - -FeatureUnsupportedFailure::FeatureUnsupportedFailure(UtestShell* test, const char* fileName, size_t lineNumber, - const SimpleString& featureName, const SimpleString& text) -: TestFailure(test, fileName, lineNumber) -{ - message_ = createUserText(text); - - 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 deleted file mode 100644 index 326767afc..000000000 --- a/src/CppUTest/TestFilter.cpp +++ /dev/null @@ -1,107 +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/CppUTestConfig.h" -#include "CppUTest/TestFilter.h" - -TestFilter::TestFilter() : strictMatching_(false), invertMatching_(false), next_(NULLPTR) -{ -} - -TestFilter::TestFilter(const SimpleString& filter) : strictMatching_(false), invertMatching_(false), next_(NULLPTR) -{ - filter_ = filter; -} - -TestFilter::TestFilter(const char* filter) : strictMatching_(false), invertMatching_(false), next_(NULLPTR) -{ - filter_ = filter; -} - -TestFilter* TestFilter::add(TestFilter* filter) -{ - next_ = filter; - return this; -} - -TestFilter* TestFilter::getNext() const -{ - return next_; -} - -void TestFilter::strictMatching() -{ - strictMatching_ = true; -} - -void TestFilter::invertMatching() -{ - invertMatching_ = true; -} - -bool TestFilter::match(const SimpleString& name) const -{ - bool matches = false; - - if(strictMatching_) - matches = name == filter_; - else - matches = name.contains(filter_); - - return invertMatching_ ? !matches : matches; -} - -bool TestFilter::operator==(const TestFilter& filter) const -{ - return (filter_ == filter.filter_ && - strictMatching_ == filter.strictMatching_ && - invertMatching_ == filter.invertMatching_); -} - -bool TestFilter::operator!=(const TestFilter& filter) const -{ - return !(filter == *this); -} - -SimpleString TestFilter::asString() const -{ - SimpleString textFilter = StringFromFormat("TestFilter: \"%s\"", filter_.asCharString()); - if (strictMatching_ && invertMatching_) - textFilter += " with strict, invert matching"; - else if (strictMatching_) - textFilter += " with strict matching"; - else if (invertMatching_) - textFilter += " with invert matching"; - - return textFilter; -} - -SimpleString StringFrom(const TestFilter& filter) -{ - return filter.asString(); -} - diff --git a/src/CppUTest/TestHarness_c.cpp b/src/CppUTest/TestHarness_c.cpp deleted file mode 100644 index 149c8fbb6..000000000 --- a/src/CppUTest/TestHarness_c.cpp +++ /dev/null @@ -1,263 +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/TestHarness.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestHarness_c.h" - -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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, UtestShell::getCurrentTestTerminatorWithoutExceptions()); -} - -void FAIL_TEXT_C_LOCATION(const char* text, const char* fileName, size_t lineNumber) -{ - 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, 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, UtestShell::getCurrentTestTerminatorWithoutExceptions()); -} - -enum { NO_COUNTDOWN = -1, OUT_OF_MEMORRY = 0 }; -static int malloc_out_of_memory_counter = NO_COUNTDOWN; -static int malloc_count = 0; - -void cpputest_malloc_count_reset(void) -{ - malloc_count = 0; -} - -int cpputest_malloc_get_count() -{ - return malloc_count; -} - -static TestMemoryAllocator* originalAllocator = NULLPTR; - -void cpputest_malloc_set_out_of_memory() -{ - if (originalAllocator == NULLPTR) - originalAllocator = getCurrentMallocAllocator(); - setCurrentMallocAllocator(NullUnknownAllocator::defaultAllocator()); -} - -void cpputest_malloc_set_not_out_of_memory() -{ - malloc_out_of_memory_counter = NO_COUNTDOWN; - setCurrentMallocAllocator(originalAllocator); - originalAllocator = NULLPTR; -} - -void cpputest_malloc_set_out_of_memory_countdown(int count) -{ - malloc_out_of_memory_counter = count; - if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) - cpputest_malloc_set_out_of_memory(); -} - -void* cpputest_malloc(size_t size) -{ - return cpputest_malloc_location(size, "", 0); -} - -char* cpputest_strdup(const char* str) -{ - return cpputest_strdup_location(str, "", 0); -} - -char* cpputest_strndup(const char* str, size_t n) -{ - return cpputest_strndup_location(str, n, "", 0); -} - -void* cpputest_calloc(size_t num, size_t size) -{ - return cpputest_calloc_location(num, size, "", 0); -} - -void* cpputest_realloc(void* ptr, size_t size) -{ - return cpputest_realloc_location(ptr, size, "", 0); -} - -void cpputest_free(void* buffer) -{ - cpputest_free_location(buffer, "", 0); -} - -static void countdown() -{ - if (malloc_out_of_memory_counter <= NO_COUNTDOWN) - return; - - if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) - return; - - malloc_out_of_memory_counter--; - - if (malloc_out_of_memory_counter == OUT_OF_MEMORRY) - cpputest_malloc_set_out_of_memory(); -} - -void* cpputest_malloc_location(size_t size, const char* file, size_t line) -{ - countdown(); - malloc_count++; - return cpputest_malloc_location_with_leak_detection(size, file, line); -} - -static size_t test_harness_c_strlen(const char * str) -{ - size_t n = 0; - while (*str++) n++; - return n; -} - -static char* strdup_alloc(const char * str, size_t size, const char* file, size_t line) -{ - char* result = (char*) cpputest_malloc_location(size, file, line); - PlatformSpecificMemCpy(result, str, size); - result[size-1] = '\0'; - return result; -} - -char* cpputest_strdup_location(const char * str, const char* file, size_t line) -{ - size_t length = 1 + test_harness_c_strlen(str); - return strdup_alloc(str, length, file, line); -} - -char* cpputest_strndup_location(const char * str, size_t n, const char* file, size_t line) -{ - size_t length = test_harness_c_strlen(str); - length = length < n ? length : n; - length = length + 1; - return strdup_alloc(str, length, file, line); -} - - -void* cpputest_calloc_location(size_t num, size_t size, const char* file, size_t line) -{ - void* mem = cpputest_malloc_location(num * size, file, line); - if (mem) - PlatformSpecificMemset(mem, 0, num*size); - return mem; -} - -void* cpputest_realloc_location(void* memory, size_t size, const char* file, size_t line) -{ - return cpputest_realloc_location_with_leak_detection(memory, size, file, line); -} - -void cpputest_free_location(void* buffer, const char* file, size_t line) -{ - cpputest_free_location_with_leak_detection(buffer, file, line); -} - -} diff --git a/src/CppUTest/TestMemoryAllocator.cpp b/src/CppUTest/TestMemoryAllocator.cpp deleted file mode 100644 index 71e3a7ca6..000000000 --- a/src/CppUTest/TestMemoryAllocator.cpp +++ /dev/null @@ -1,792 +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/TestHarness.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/MemoryLeakDetector.h" - -static char* checkedMalloc(size_t size) -{ - char* mem = (char*) PlatformSpecificMalloc(size); - if (mem == NULLPTR) - FAIL("malloc returned null pointer"); - return mem; -} - -static TestMemoryAllocator* currentNewAllocator = NULLPTR; -static TestMemoryAllocator* currentNewArrayAllocator = NULLPTR; -static TestMemoryAllocator* currentMallocAllocator = NULLPTR; - -void setCurrentNewAllocator(TestMemoryAllocator* allocator) -{ - currentNewAllocator = allocator; -} - -TestMemoryAllocator* getCurrentNewAllocator() -{ - if (currentNewAllocator == NULLPTR) setCurrentNewAllocatorToDefault(); - return currentNewAllocator; -} - -void setCurrentNewAllocatorToDefault() -{ - currentNewAllocator = defaultNewAllocator(); -} - -TestMemoryAllocator* defaultNewAllocator() -{ - static TestMemoryAllocator allocator("Standard New Allocator", "new", "delete"); - return &allocator; -} - -void setCurrentNewArrayAllocator(TestMemoryAllocator* allocator) -{ - currentNewArrayAllocator = allocator; -} - -TestMemoryAllocator* getCurrentNewArrayAllocator() -{ - if (currentNewArrayAllocator == NULLPTR) setCurrentNewArrayAllocatorToDefault(); - return currentNewArrayAllocator; -} - -void setCurrentNewArrayAllocatorToDefault() -{ - currentNewArrayAllocator = defaultNewArrayAllocator(); -} - -TestMemoryAllocator* defaultNewArrayAllocator() -{ - static TestMemoryAllocator allocator("Standard New [] Allocator", "new []", "delete []"); - return &allocator; -} - -void setCurrentMallocAllocator(TestMemoryAllocator* allocator) -{ - currentMallocAllocator = allocator; -} - -TestMemoryAllocator* getCurrentMallocAllocator() -{ - if (currentMallocAllocator == NULLPTR) setCurrentMallocAllocatorToDefault(); - return currentMallocAllocator; -} - -void setCurrentMallocAllocatorToDefault() -{ - currentMallocAllocator = defaultMallocAllocator(); -} - -TestMemoryAllocator* defaultMallocAllocator() -{ - static TestMemoryAllocator allocator("Standard Malloc Allocator", "malloc", "free"); - return &allocator; -} - -///////////////////////////////////////////// - -GlobalMemoryAllocatorStash::GlobalMemoryAllocatorStash() - : originalMallocAllocator(NULLPTR), originalNewAllocator(NULLPTR), originalNewArrayAllocator(NULLPTR) -{ -} - -void GlobalMemoryAllocatorStash::save() -{ - originalMallocAllocator = getCurrentMallocAllocator(); - originalNewAllocator = getCurrentNewAllocator(); - originalNewArrayAllocator = getCurrentNewArrayAllocator(); -} - -void GlobalMemoryAllocatorStash::restore() -{ - if (originalMallocAllocator) setCurrentMallocAllocator(originalMallocAllocator); - if (originalNewAllocator) setCurrentNewAllocator(originalNewAllocator); - if (originalNewArrayAllocator) setCurrentNewArrayAllocator(originalNewArrayAllocator); -} - -TestMemoryAllocator::TestMemoryAllocator(const char* name_str, const char* alloc_name_str, const char* free_name_str) - : name_(name_str), alloc_name_(alloc_name_str), free_name_(free_name_str), hasBeenDestroyed_(false) -{ -} - -TestMemoryAllocator::~TestMemoryAllocator() -{ - hasBeenDestroyed_ = true; -} - -bool TestMemoryAllocator::hasBeenDestroyed() -{ - return hasBeenDestroyed_; -} - -bool TestMemoryAllocator::isOfEqualType(TestMemoryAllocator* allocator) -{ - return SimpleString::StrCmp(this->name(), allocator->name()) == 0; -} - -char* TestMemoryAllocator::allocMemoryLeakNode(size_t size) -{ - return alloc_memory(size, "MemoryLeakNode", 1); -} - -void TestMemoryAllocator::freeMemoryLeakNode(char* memory) -{ - free_memory(memory, 0, "MemoryLeakNode", 1); -} - -char* TestMemoryAllocator::alloc_memory(size_t size, const char*, size_t) -{ - return checkedMalloc(size); -} - -void TestMemoryAllocator::free_memory(char* memory, size_t, const char*, size_t) -{ - PlatformSpecificFree(memory); -} - -const char* TestMemoryAllocator::name() const -{ - return name_; -} - -const char* TestMemoryAllocator::alloc_name() const -{ - return alloc_name_; -} - -const char* TestMemoryAllocator::free_name() const -{ - return free_name_; -} - -TestMemoryAllocator* TestMemoryAllocator::actualAllocator() -{ - return this; -} - -MemoryLeakAllocator::MemoryLeakAllocator(TestMemoryAllocator* originalAllocator) - : originalAllocator_(originalAllocator) -{ -} - -MemoryLeakAllocator::~MemoryLeakAllocator() -{ -} - -char* MemoryLeakAllocator::alloc_memory(size_t size, const char* file, size_t line) -{ - return MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(originalAllocator_, size, file, line); -} - -void MemoryLeakAllocator::free_memory(char* memory, size_t, const char* file, size_t line) -{ - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(originalAllocator_, memory, file, line); -} - -const char* MemoryLeakAllocator::name() const -{ - return "MemoryLeakAllocator"; -} - -const char* MemoryLeakAllocator::alloc_name() const -{ - return originalAllocator_->alloc_name(); -} - -const char* MemoryLeakAllocator::free_name() const -{ - return originalAllocator_->free_name(); -} - -TestMemoryAllocator* MemoryLeakAllocator::actualAllocator() -{ - return originalAllocator_->actualAllocator(); -} - -CrashOnAllocationAllocator::CrashOnAllocationAllocator() : allocationToCrashOn_(0) -{ -} - -CrashOnAllocationAllocator::~CrashOnAllocationAllocator() -{ -} - -void CrashOnAllocationAllocator::setNumberToCrashOn(unsigned allocationToCrashOn) -{ - allocationToCrashOn_ = allocationToCrashOn; -} - -char* CrashOnAllocationAllocator::alloc_memory(size_t size, const char* file, size_t line) -{ - if (MemoryLeakWarningPlugin::getGlobalDetector()->getCurrentAllocationNumber() == allocationToCrashOn_) - UT_CRASH(); - - return TestMemoryAllocator::alloc_memory(size, file, line); -} - - -NullUnknownAllocator::~NullUnknownAllocator() -{ -} - -char* NullUnknownAllocator::alloc_memory(size_t /*size*/, const char*, size_t) -{ - return NULLPTR; -} - -void NullUnknownAllocator::free_memory(char* /*memory*/, size_t, const char*, size_t) -{ -} - -NullUnknownAllocator::NullUnknownAllocator() - : TestMemoryAllocator("Null Allocator", "unknown", "unknown") -{ -} - - -TestMemoryAllocator* NullUnknownAllocator::defaultAllocator() -{ - static NullUnknownAllocator allocator; - return &allocator; -} - -class LocationToFailAllocNode -{ - public: - int allocNumberToFail_; - int actualAllocNumber_; - const char* file_; - size_t line_; - LocationToFailAllocNode* next_; - - void failAtAllocNumber(int number, LocationToFailAllocNode* next) - { - init(next); - allocNumberToFail_ = number; - } - - void failNthAllocAt(int allocationNumber, const char* file, size_t line, LocationToFailAllocNode* next) - { - init(next); - allocNumberToFail_ = allocationNumber; - file_ = file; - line_ = line; - } - - bool shouldFail(int allocationNumber, const char* file, size_t line) - { - if (file_ && SimpleString::StrCmp(file, file_) == 0 && line == line_) { - actualAllocNumber_++; - return actualAllocNumber_ == allocNumberToFail_; - } - if (allocationNumber == allocNumberToFail_) - return true; - return false; - } - - private: - void init(LocationToFailAllocNode* next = NULLPTR) - { - allocNumberToFail_ = 0; - actualAllocNumber_ = 0; - file_ = NULLPTR; - line_ = 0; - next_ = next; - } - -}; - -FailableMemoryAllocator::~FailableMemoryAllocator() -{ -} - -FailableMemoryAllocator::FailableMemoryAllocator(const char* name_str, const char* alloc_name_str, const char* free_name_str) -: TestMemoryAllocator(name_str, alloc_name_str, free_name_str), head_(NULLPTR), currentAllocNumber_(0) -{ -} - -void FailableMemoryAllocator::failAllocNumber(int number) -{ - LocationToFailAllocNode* newNode = (LocationToFailAllocNode*) (void*) allocMemoryLeakNode(sizeof(LocationToFailAllocNode)); - newNode->failAtAllocNumber(number, head_); - head_ = newNode; -} - -void FailableMemoryAllocator::failNthAllocAt(int allocationNumber, const char* file, size_t line) -{ - LocationToFailAllocNode* newNode = (LocationToFailAllocNode*) (void*) allocMemoryLeakNode(sizeof(LocationToFailAllocNode)); - newNode->failNthAllocAt(allocationNumber, file, line, head_); - head_ = newNode; -} - -char* FailableMemoryAllocator::alloc_memory(size_t size, const char* file, size_t line) -{ - currentAllocNumber_++; - LocationToFailAllocNode* current = head_; - LocationToFailAllocNode* previous = NULLPTR; - - while (current) { - if (current->shouldFail(currentAllocNumber_, file, line)) { - if (previous) previous->next_ = current->next_; - else head_ = current->next_; - - free_memory((char*) current, size, __FILE__, __LINE__); - return NULLPTR; - } - previous = current; - current = current->next_; - } - return TestMemoryAllocator::alloc_memory(size, file, line); -} - -char* FailableMemoryAllocator::allocMemoryLeakNode(size_t size) -{ - return (char*)PlatformSpecificMalloc(size); -} - -void FailableMemoryAllocator::checkAllFailedAllocsWereDone() -{ - if (head_) { - UtestShell* currentTest = UtestShell::getCurrent(); - SimpleString failText; - if (head_->file_) - failText = StringFromFormat("Expected failing alloc at %s:%d was never done", head_->file_, (int) head_->line_); - else - failText = StringFromFormat("Expected allocation number %d was never done", (int) head_->allocNumberToFail_); - - currentTest->failWith(FailFailure(currentTest, currentTest->getName().asCharString(), currentTest->getLineNumber(), failText)); - } -} - -void FailableMemoryAllocator::clearFailedAllocs() -{ - LocationToFailAllocNode* current = head_; - while (current) { - head_ = current->next_; - free_memory((char*) current, 0, __FILE__, __LINE__); - current = head_; - } - currentAllocNumber_ = 0; -} - -struct MemoryAccountantAllocationNode -{ - size_t size_; - size_t allocations_; - size_t deallocations_; - size_t maxAllocations_; - size_t currentAllocations_; - MemoryAccountantAllocationNode* next_; -}; - -MemoryAccountantAllocationNode* MemoryAccountant::createNewAccountantAllocationNode(size_t size, MemoryAccountantAllocationNode* next) const -{ - MemoryAccountantAllocationNode* node = (MemoryAccountantAllocationNode*) (void*) allocator_->alloc_memory(sizeof(MemoryAccountantAllocationNode), __FILE__, __LINE__); - node->size_ = size; - node->allocations_ = 0; - node->deallocations_ = 0; - node->maxAllocations_ = 0; - node->currentAllocations_ = 0; - node->next_ = next; - return node; -} - -void MemoryAccountant::destroyAccountantAllocationNode(MemoryAccountantAllocationNode* node) const -{ - allocator_->free_memory((char*) node, sizeof(*node), __FILE__, __LINE__); -} - -MemoryAccountant::MemoryAccountant() - : head_(NULLPTR), allocator_(defaultMallocAllocator()), useCacheSizes_(false) -{ -} - -MemoryAccountant::~MemoryAccountant() -{ - clear(); -} - -void MemoryAccountant::createCacheSizeNodes(size_t sizes[], size_t length) -{ - for (size_t i = 0; i < length; i++) - findOrCreateNodeOfSize(sizes[i]); - - if (head_ == NULLPTR) - head_ = createNewAccountantAllocationNode(0, NULLPTR); - else { - for (MemoryAccountantAllocationNode* lastNode = head_; lastNode; lastNode = lastNode->next_) { - if (lastNode->next_ == NULLPTR) { - lastNode->next_ = createNewAccountantAllocationNode(0, NULLPTR); - break; - } - } - } -} - - -void MemoryAccountant::useCacheSizes(size_t sizes[], size_t length) -{ - if (head_) - FAIL("MemoryAccountant: Cannot set cache sizes as allocations already occured!"); - - createCacheSizeNodes(sizes, length); - useCacheSizes_ = true; -} - -void MemoryAccountant::setAllocator(TestMemoryAllocator* allocator) -{ - allocator_ = allocator; -} - -void MemoryAccountant::clear() -{ - MemoryAccountantAllocationNode* node = head_; - MemoryAccountantAllocationNode* to_be_deleted = NULLPTR; - while (node) { - to_be_deleted = node; - node = node->next_; - destroyAccountantAllocationNode(to_be_deleted); - } - head_ = NULLPTR; -} - -MemoryAccountantAllocationNode* MemoryAccountant::findNodeOfSize(size_t size) const -{ - if (useCacheSizes_) { - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) { - if (((size > node->size_) && (node->next_ == NULLPTR)) - || ((size <= node->size_) && - !((node->next_->size_ != 0) && (node->next_->size_ <= size)))) - return node; - } - } - else - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) - if (node->size_ == size) - return node; - return NULLPTR; -} - -MemoryAccountantAllocationNode* MemoryAccountant::findOrCreateNodeOfSize(size_t size) -{ - if (useCacheSizes_) - return findNodeOfSize(size); - - if (head_ && head_->size_ > size) - head_ = createNewAccountantAllocationNode(size, head_); - - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) { - if (node->size_ == size) - return node; - if (node->next_ == NULLPTR || node->next_->size_ > size) - node->next_ = createNewAccountantAllocationNode(size, node->next_); - } - head_ = createNewAccountantAllocationNode(size, head_); - return head_; -} - -void MemoryAccountant::alloc(size_t size) -{ - MemoryAccountantAllocationNode* node = findOrCreateNodeOfSize(size); - node->allocations_++; - node->currentAllocations_++; - node->maxAllocations_ = (node->currentAllocations_ > node->maxAllocations_) ? node->currentAllocations_ : node->maxAllocations_; -} - -void MemoryAccountant::dealloc(size_t size) -{ - MemoryAccountantAllocationNode* node = findOrCreateNodeOfSize(size); - node->deallocations_++; - if (node->currentAllocations_) - node->currentAllocations_--; -} - -size_t MemoryAccountant::totalAllocationsOfSize(size_t size) const -{ - MemoryAccountantAllocationNode* node = findNodeOfSize(size); - if (node) - return node->allocations_; - return 0; -} - -size_t MemoryAccountant::totalDeallocationsOfSize(size_t size) const -{ - MemoryAccountantAllocationNode* node = findNodeOfSize(size); - if (node) - return node->deallocations_; - return 0; -} - -size_t MemoryAccountant::maximumAllocationAtATimeOfSize(size_t size) const -{ - MemoryAccountantAllocationNode* node = findNodeOfSize(size); - if (node) - return node->maxAllocations_; - return 0; -} - -size_t MemoryAccountant::totalAllocations() const -{ - size_t theTotalAllocations = 0; - - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) - theTotalAllocations += node->allocations_; - - return theTotalAllocations; -} - -size_t MemoryAccountant::totalDeallocations() const -{ - size_t theTotalDeallocations = 0; - - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) - theTotalDeallocations += node->deallocations_; - - return theTotalDeallocations; -} - -SimpleString MemoryAccountant::reportNoAllocations() const -{ - return SimpleString("CppUTest Memory Accountant has not noticed any allocations or deallocations. Sorry\n"); -} - -SimpleString MemoryAccountant::reportTitle() const -{ - if (useCacheSizes_) - return "CppUTest Memory Accountant report (with cache sizes):\n"; - return "CppUTest Memory Accountant report:\n"; -} - -SimpleString MemoryAccountant::reportHeader() const -{ - if (useCacheSizes_) - return "Cache size # allocations # deallocations max # allocations at one time\n"; - return "Allocation size # allocations # deallocations max # allocations at one time\n"; -} - -#define MEMORY_ACCOUNTANT_ROW_FORMAT "%s %5d %5d %5d\n" - -SimpleString MemoryAccountant::reportFooter() const -{ - return SimpleString(" Thank you for your business\n"); -} - -SimpleString MemoryAccountant::stringSize(size_t size) const -{ - return (size == 0) ? StringFrom("other") : StringFromFormat("%5d", (int) size); -} - -SimpleString MemoryAccountant::report() const -{ - if (head_ == NULLPTR) - return reportNoAllocations(); - - SimpleString accountantReport = reportTitle() + reportHeader(); - - for (MemoryAccountantAllocationNode* node = head_; node; node = node->next_) - accountantReport += StringFromFormat(MEMORY_ACCOUNTANT_ROW_FORMAT, stringSize(node->size_).asCharString(), (int) node->allocations_, (int) node->deallocations_, (int) node->maxAllocations_); - - return accountantReport + reportFooter(); -} - -AccountingTestMemoryAllocator::AccountingTestMemoryAllocator(MemoryAccountant& accountant, TestMemoryAllocator* origAllocator) - : accountant_(accountant), originalAllocator_(origAllocator), head_(NULLPTR) -{ -} - -AccountingTestMemoryAllocator::~AccountingTestMemoryAllocator() -{ -} - -struct AccountingTestMemoryAllocatorMemoryNode -{ - char* memory_; - size_t size_; - AccountingTestMemoryAllocatorMemoryNode* next_; -}; - -void AccountingTestMemoryAllocator::addMemoryToMemoryTrackingToKeepTrackOfSize(char* memory, size_t size) -{ - AccountingTestMemoryAllocatorMemoryNode* node = (AccountingTestMemoryAllocatorMemoryNode*) (void*) originalAllocator_->alloc_memory(sizeof(AccountingTestMemoryAllocatorMemoryNode), __FILE__, __LINE__); - node->memory_ = memory; - node->size_ = size; - node->next_ = head_; - head_ = node; -} - -size_t AccountingTestMemoryAllocator::removeNextNodeAndReturnSize(AccountingTestMemoryAllocatorMemoryNode* node) -{ - AccountingTestMemoryAllocatorMemoryNode* foundNode = node->next_; - node->next_ = node->next_->next_; - - size_t size = foundNode->size_; - originalAllocator_->free_memory((char*) foundNode, size, __FILE__, __LINE__); - return size; -} - -size_t AccountingTestMemoryAllocator::removeHeadAndReturnSize() -{ - AccountingTestMemoryAllocatorMemoryNode* foundNode = head_; - head_ = head_->next_; - - size_t size = foundNode->size_; - originalAllocator_->free_memory((char*) foundNode, size, __FILE__, __LINE__); - return size; -} - -size_t AccountingTestMemoryAllocator::removeMemoryFromTrackingAndReturnAllocatedSize(char* memory) -{ - if (head_ && head_->memory_ == memory) - return removeHeadAndReturnSize(); - - for (AccountingTestMemoryAllocatorMemoryNode* node = head_; node; node = node->next_) { - if (node->next_ && node->next_->memory_ == memory) - return removeNextNodeAndReturnSize(node); - } - - return 0; -} - -char* AccountingTestMemoryAllocator::alloc_memory(size_t size, const char* file, size_t line) -{ - accountant_.alloc(size); - char* memory = originalAllocator_->alloc_memory(size, file, line); - addMemoryToMemoryTrackingToKeepTrackOfSize(memory, size); - return memory; -} - -void AccountingTestMemoryAllocator::free_memory(char* memory, size_t, const char* file, size_t line) -{ - size_t size = removeMemoryFromTrackingAndReturnAllocatedSize(memory); - accountant_.dealloc(size); - originalAllocator_->free_memory(memory, size, file, line); -} - -TestMemoryAllocator* AccountingTestMemoryAllocator::actualAllocator() -{ - return originalAllocator_->actualAllocator(); -} - -TestMemoryAllocator* AccountingTestMemoryAllocator::originalAllocator() -{ - return originalAllocator_; -} - -const char* AccountingTestMemoryAllocator::alloc_name() const -{ - return originalAllocator_->alloc_name(); -} - -const char* AccountingTestMemoryAllocator::free_name() const -{ - return originalAllocator_->free_name(); -} - -GlobalMemoryAccountant::GlobalMemoryAccountant() - : mallocAllocator_(NULLPTR), newAllocator_(NULLPTR), newArrayAllocator_(NULLPTR) -{ -} - -GlobalMemoryAccountant::~GlobalMemoryAccountant() -{ - restoreMemoryAllocators(); - delete mallocAllocator_; - delete newAllocator_; - delete newArrayAllocator_; -} - -void GlobalMemoryAccountant::useCacheSizes(size_t sizes[], size_t length) -{ - accountant_.useCacheSizes(sizes, length); -} - -void GlobalMemoryAccountant::start() -{ - if (mallocAllocator_ != NULLPTR) - FAIL("Global allocator start called twice!"); - - mallocAllocator_ = new AccountingTestMemoryAllocator(accountant_, getCurrentMallocAllocator()); - newAllocator_ = new AccountingTestMemoryAllocator(accountant_, getCurrentNewAllocator()); - newArrayAllocator_ = new AccountingTestMemoryAllocator(accountant_, getCurrentNewArrayAllocator()); - - accountant_.setAllocator(getCurrentMallocAllocator()); - - setCurrentMallocAllocator(mallocAllocator_); - setCurrentNewAllocator(newAllocator_); - setCurrentNewArrayAllocator(newArrayAllocator_); -} - -void GlobalMemoryAccountant::restoreMemoryAllocators() -{ - if (getCurrentMallocAllocator() == mallocAllocator_) - setCurrentMallocAllocator(mallocAllocator_->originalAllocator()); - - if (getCurrentNewAllocator() == newAllocator_) - setCurrentNewAllocator(newAllocator_->originalAllocator()); - - if (getCurrentNewArrayAllocator() == newArrayAllocator_) - setCurrentNewArrayAllocator(newArrayAllocator_->originalAllocator()); -} - -void GlobalMemoryAccountant::stop() -{ - if (mallocAllocator_ == NULLPTR) - FAIL("GlobalMemoryAccount: Stop called without starting"); - - if (getCurrentMallocAllocator() != mallocAllocator_) - FAIL("GlobalMemoryAccountant: Malloc memory allocator has been changed while accounting for memory"); - - if (getCurrentNewAllocator() != newAllocator_) - FAIL("GlobalMemoryAccountant: New memory allocator has been changed while accounting for memory"); - - if (getCurrentNewArrayAllocator() != newArrayAllocator_) - FAIL("GlobalMemoryAccountant: New Array memory allocator has been changed while accounting for memory"); - - restoreMemoryAllocators(); -} - -SimpleString GlobalMemoryAccountant::report() -{ - return accountant_.report(); -} - -TestMemoryAllocator* GlobalMemoryAccountant::getMallocAllocator() -{ - return mallocAllocator_; -} - -TestMemoryAllocator* GlobalMemoryAccountant::getNewAllocator() -{ - return newAllocator_; -} - -TestMemoryAllocator* GlobalMemoryAccountant::getNewArrayAllocator() -{ - return newArrayAllocator_; -} - diff --git a/src/CppUTest/TestOutput.cpp b/src/CppUTest/TestOutput.cpp deleted file mode 100644 index cb4ced54e..000000000 --- a/src/CppUTest/TestOutput.cpp +++ /dev/null @@ -1,414 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -TestOutput::WorkingEnvironment TestOutput::workingEnvironment_ = TestOutput::detectEnvironment; - -void TestOutput::setWorkingEnvironment(TestOutput::WorkingEnvironment workEnvironment) -{ - workingEnvironment_ = workEnvironment; -} - -TestOutput::WorkingEnvironment TestOutput::getWorkingEnvironment() -{ - if (workingEnvironment_ == TestOutput::detectEnvironment) - return PlatformSpecificGetWorkingEnvironment(); - return workingEnvironment_; -} - - -TestOutput::TestOutput() : - dotCount_(0), verbose_(level_quiet), color_(false), progressIndication_(".") -{ -} - -TestOutput::~TestOutput() -{ -} - -void TestOutput::verbose(VerbosityLevel level) -{ - verbose_ = level; -} - -void TestOutput::color() -{ - color_ = true; -} - -void TestOutput::print(const char* str) -{ - printBuffer(str); -} - -void TestOutput::print(long n) -{ - print(StringFrom(n).asCharString()); -} - -void TestOutput::print(size_t n) -{ - print(StringFrom(n).asCharString()); -} - -void TestOutput::printDouble(double d) -{ - print(StringFrom(d).asCharString()); -} - -TestOutput& operator<<(TestOutput& p, const char* s) -{ - p.print(s); - return p; -} - -TestOutput& operator<<(TestOutput& p, long int i) -{ - p.print(i); - return p; -} - -void TestOutput::printCurrentTestStarted(const UtestShell& test) -{ - if (verbose_ > level_quiet) print(test.getFormattedName().asCharString()); - - if (test.willRun()) { - setProgressIndicator("."); - } - else { - setProgressIndicator("!"); - } -} - -void TestOutput::printCurrentTestEnded(const TestResult& res) -{ - if (verbose_ > level_quiet) { - print(" - "); - print(res.getCurrentTestTotalExecutionTime()); - print(" ms\n"); - } - else { - printProgressIndicator(); - } -} - -void TestOutput::printProgressIndicator() -{ - print(progressIndication_); - if (++dotCount_ % 50 == 0) print("\n"); -} - -void TestOutput::setProgressIndicator(const char* indicator) -{ - progressIndication_ = indicator; -} - -void TestOutput::printTestsStarted() -{ -} - -void TestOutput::printCurrentGroupStarted(const UtestShell& /*test*/) -{ -} - -void TestOutput::printCurrentGroupEnded(const TestResult& /*res*/) -{ -} - -void TestOutput::printTestsEnded(const TestResult& result) -{ - print("\n"); - const bool isFailure = result.isFailure(); - const size_t failureCount = result.getFailureCount(); - if (isFailure) { - if (color_) { - print("\033[31;1m"); - } - print("Errors ("); - if (failureCount > 0) { - print(failureCount); - print(" failures, "); - } - else { - print("ran nothing, "); - } - } - else { - if (color_) { - print("\033[32;1m"); - } - print("OK ("); - } - print(result.getTestCount()); - print(" tests, "); - print(result.getRunCount()); - print(" ran, "); - print(result.getCheckCount()); - print(" checks, "); - print(result.getIgnoredCount()); - print(" ignored, "); - print(result.getFilteredOutCount()); - print(" filtered out, "); - print(result.getTotalExecutionTime()); - print(" ms)"); - if (color_) { - print("\033[m"); - } - if (isFailure && failureCount == 0) { - print("\nNote: test run failed because no tests were run or ignored. Assuming something went wrong. " - "This often happens because of linking errors or typos in test filter."); - } - print("\n\n"); - - dotCount_ = 0; -} - -void TestOutput::printTestRun(size_t number, size_t total) -{ - if (total > 1) { - print("Test run "); - print(number); - print(" of "); - print(total); - print("\n"); - } -} - -void TestOutput::printFailure(const TestFailure& failure) -{ - if (failure.isOutsideTestFile() || failure.isInHelperFunction()) - printFileAndLineForTestAndFailure(failure); - else - printFileAndLineForFailure(failure); - - printFailureMessage(failure.getMessage()); -} - -void TestOutput::printFileAndLineForTestAndFailure(const TestFailure& failure) -{ - printErrorInFileOnLineFormattedForWorkingEnvironment(failure.getTestFileName(), failure.getTestLineNumber()); - printFailureInTest(failure.getTestName()); - printErrorInFileOnLineFormattedForWorkingEnvironment(failure.getFileName(), failure.getFailureLineNumber()); -} - -void TestOutput::printFileAndLineForFailure(const TestFailure& failure) -{ - printErrorInFileOnLineFormattedForWorkingEnvironment(failure.getFileName(), failure.getFailureLineNumber()); - printFailureInTest(failure.getTestName()); -} - -void TestOutput::printFailureInTest(SimpleString testName) -{ - print(" Failure in "); - print(testName.asCharString()); -} - -void TestOutput::printFailureMessage(SimpleString reason) -{ - print("\n"); - print("\t"); - print(reason.asCharString()); - print("\n\n"); -} - -void TestOutput::printErrorInFileOnLineFormattedForWorkingEnvironment(SimpleString file, size_t lineNumber) -{ - if (TestOutput::getWorkingEnvironment() == TestOutput::visualStudio) - printVisualStudioErrorInFileOnLine(file, lineNumber); - else - printEclipseErrorInFileOnLine(file, lineNumber); -} - -void TestOutput::printEclipseErrorInFileOnLine(SimpleString file, size_t lineNumber) -{ - print("\n"); - print(file.asCharString()); - print(":"); - print(lineNumber); - print(":"); - print(" error:"); -} - -void TestOutput::printVisualStudioErrorInFileOnLine(SimpleString file, size_t lineNumber) -{ - print("\n"); - print(file.asCharString()); - print("("); - print(lineNumber); - print("):"); - print(" error:"); -} - -void TestOutput::printVeryVerbose(const char* str) -{ - if(verbose_ == level_veryVerbose) - printBuffer(str); -} - - -void ConsoleTestOutput::printBuffer(const char* s) -{ - PlatformSpecificFPuts(s, PlatformSpecificStdOut); - flush(); -} - -void ConsoleTestOutput::flush() -{ - PlatformSpecificFlush(); -} - -StringBufferTestOutput::~StringBufferTestOutput() -{ -} - -CompositeTestOutput::CompositeTestOutput() - : outputOne_(NULLPTR), outputTwo_(NULLPTR) -{ -} - -CompositeTestOutput::~CompositeTestOutput() -{ - delete outputOne_; - delete outputTwo_; -} - -void CompositeTestOutput::setOutputOne(TestOutput* output) -{ - delete outputOne_; - outputOne_ = output; -} - -void CompositeTestOutput::setOutputTwo(TestOutput* output) -{ - delete outputTwo_; - outputTwo_ = output; -} - -void CompositeTestOutput::printTestsStarted() -{ - if (outputOne_) outputOne_->printTestsStarted(); - if (outputTwo_) outputTwo_->printTestsStarted(); -} - -void CompositeTestOutput::printTestsEnded(const TestResult& result) -{ - if (outputOne_) outputOne_->printTestsEnded(result); - if (outputTwo_) outputTwo_->printTestsEnded(result); -} - -void CompositeTestOutput::printCurrentTestStarted(const UtestShell& test) -{ - if (outputOne_) outputOne_->printCurrentTestStarted(test); - if (outputTwo_) outputTwo_->printCurrentTestStarted(test); -} - -void CompositeTestOutput::printCurrentTestEnded(const TestResult& res) -{ - if (outputOne_) outputOne_->printCurrentTestEnded(res); - if (outputTwo_) outputTwo_->printCurrentTestEnded(res); -} - -void CompositeTestOutput::printCurrentGroupStarted(const UtestShell& test) -{ - if (outputOne_) outputOne_->printCurrentGroupStarted(test); - if (outputTwo_) outputTwo_->printCurrentGroupStarted(test); -} - -void CompositeTestOutput::printCurrentGroupEnded(const TestResult& res) -{ - if (outputOne_) outputOne_->printCurrentGroupEnded(res); - if (outputTwo_) outputTwo_->printCurrentGroupEnded(res); -} - -void CompositeTestOutput::verbose(VerbosityLevel level) -{ - if (outputOne_) outputOne_->verbose(level); - if (outputTwo_) outputTwo_->verbose(level); -} - -void CompositeTestOutput::color() -{ - if (outputOne_) outputOne_->color(); - if (outputTwo_) outputTwo_->color(); -} - -void CompositeTestOutput::printBuffer(const char* buffer) -{ - if (outputOne_) outputOne_->printBuffer(buffer); - if (outputTwo_) outputTwo_->printBuffer(buffer); -} - -void CompositeTestOutput::print(const char* buffer) -{ - if (outputOne_) outputOne_->print(buffer); - if (outputTwo_) outputTwo_->print(buffer); -} - -void CompositeTestOutput::print(long number) -{ - if (outputOne_) outputOne_->print(number); - if (outputTwo_) outputTwo_->print(number); -} - -void CompositeTestOutput::print(size_t number) -{ - if (outputOne_) outputOne_->print(number); - if (outputTwo_) outputTwo_->print(number); -} - -void CompositeTestOutput::printDouble(double number) -{ - if (outputOne_) outputOne_->printDouble(number); - if (outputTwo_) outputTwo_->printDouble(number); -} - -void CompositeTestOutput::printFailure(const TestFailure& failure) -{ - if (outputOne_) outputOne_->printFailure(failure); - if (outputTwo_) outputTwo_->printFailure(failure); -} - -void CompositeTestOutput::setProgressIndicator(const char* indicator) -{ - if (outputOne_) outputOne_->setProgressIndicator(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(); - if (outputTwo_) outputTwo_->flush(); -} - diff --git a/src/CppUTest/TestPlugin.cpp b/src/CppUTest/TestPlugin.cpp deleted file mode 100644 index 29aa38bcf..000000000 --- a/src/CppUTest/TestPlugin.cpp +++ /dev/null @@ -1,169 +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/TestHarness.h" -#include "CppUTest/TestPlugin.h" - -TestPlugin::TestPlugin(const SimpleString& name) : - next_(NullTestPlugin::instance()), name_(name), enabled_(true) -{ -} - -TestPlugin::TestPlugin(TestPlugin* next) : - next_(next), name_("null"), enabled_(true) -{ -} - -TestPlugin::~TestPlugin() -{ -} - -TestPlugin* TestPlugin::addPlugin(TestPlugin* plugin) -{ - next_ = plugin; - return this; -} - -void TestPlugin::runAllPreTestAction(UtestShell& test, TestResult& result) -{ - if (enabled_) preTestAction(test, result); - next_->runAllPreTestAction(test, result); -} - -void TestPlugin::runAllPostTestAction(UtestShell& test, TestResult& result) -{ - next_ ->runAllPostTestAction(test, result); - if (enabled_) postTestAction(test, result); -} - -bool TestPlugin::parseAllArguments(int ac, char** av, int index) -{ - return parseAllArguments(ac, const_cast (av), index); -} - -bool TestPlugin::parseAllArguments(int ac, const char *const *av, int index) -{ - if (parseArguments(ac, av, index)) return true; - if (next_) return next_->parseAllArguments(ac, av, index); - return false; -} - -const SimpleString& TestPlugin::getName() -{ - return name_; -} - -TestPlugin* TestPlugin::getPluginByName(const SimpleString& name) -{ - if (name == name_) return this; - if (next_) return next_->getPluginByName(name); - return (next_); -} - -TestPlugin* TestPlugin::getNext() -{ - return next_; -} -TestPlugin* TestPlugin::removePluginByName(const SimpleString& name) -{ - TestPlugin* removed = NULLPTR; - if (next_ && next_->getName() == name) { - removed = next_; - next_ = next_->next_; - } - return removed; -} - -void TestPlugin::disable() -{ - enabled_ = false; -} - -void TestPlugin::enable() -{ - enabled_ = true; -} - -bool TestPlugin::isEnabled() -{ - return enabled_; -} - -struct cpputest_pair -{ - void **orig; - void *orig_value; -}; - -//////// SetPlugin - -static int pointerTableIndex; -static cpputest_pair setlist[SetPointerPlugin::MAX_SET]; - -SetPointerPlugin::SetPointerPlugin(const SimpleString& name) : - TestPlugin(name) -{ - pointerTableIndex = 0; -} - -void CppUTestStore(void**function) -{ - if (pointerTableIndex >= SetPointerPlugin::MAX_SET) { - FAIL("Maximum number of function pointers installed!"); - } - setlist[pointerTableIndex].orig_value = *function; - setlist[pointerTableIndex].orig = function; - pointerTableIndex++; -} - -void SetPointerPlugin::postTestAction(UtestShell& /*test*/, TestResult& /*result*/) -{ - for (int i = pointerTableIndex - 1; i >= 0; i--) - *((void**) setlist[i].orig) = setlist[i].orig_value; - pointerTableIndex = 0; -} - -//////// NullPlugin - -NullTestPlugin::NullTestPlugin() : - TestPlugin(NULLPTR) -{ -} - -NullTestPlugin* NullTestPlugin::instance() -{ - static NullTestPlugin _instance; - return &_instance; -} - -void NullTestPlugin::runAllPreTestAction(UtestShell&, TestResult&) -{ -} - -void NullTestPlugin::runAllPostTestAction(UtestShell&, TestResult&) -{ -} diff --git a/src/CppUTest/TestRegistry.cpp b/src/CppUTest/TestRegistry.cpp deleted file mode 100644 index 542ab51a8..000000000 --- a/src/CppUTest/TestRegistry.cpp +++ /dev/null @@ -1,293 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -TestRegistry::TestRegistry() : - tests_(NULLPTR), nameFilters_(NULLPTR), groupFilters_(NULLPTR), firstPlugin_(NullTestPlugin::instance()), runInSeperateProcess_(false), currentRepetition_(0), runIgnored_(false) -{ -} - -TestRegistry::~TestRegistry() -{ -} - -void TestRegistry::addTest(UtestShell *test) -{ - tests_ = test->addTest(tests_); -} - -void TestRegistry::runAllTests(TestResult& result) -{ - bool groupStart = true; - - result.testsStarted(); - for (UtestShell *test = tests_; test != NULLPTR; test = test->getNext()) { - if (runInSeperateProcess_) test->setRunInSeperateProcess(); - if (runIgnored_) test->setRunIgnored(); - - if (groupStart) { - result.currentGroupStarted(test); - groupStart = false; - } - - result.countTest(); - if (testShouldRun(test, result)) { - result.currentTestStarted(test); - test->runOneTest(firstPlugin_, result); - result.currentTestEnded(test); - } - - if (endOfGroup(test)) { - groupStart = true; - result.currentGroupEnded(test); - } - } - result.testsEnded(); - currentRepetition_++; -} - -void TestRegistry::listTestGroupNames(TestResult& result) -{ - SimpleString groupList; - - for (UtestShell *test = tests_; test != NULLPTR; test = test->getNext()) { - SimpleString gname; - gname += "#"; - gname += test->getGroup(); - gname += "#"; - - if (!groupList.contains(gname)) { - groupList += gname; - groupList += " "; - } - } - - groupList.replace("#", ""); - - if (groupList.endsWith(" ")) - groupList = groupList.subString(0, groupList.size() - 1); - result.print(groupList.asCharString()); -} - -void TestRegistry::listTestGroupAndCaseNames(TestResult& result) -{ - SimpleString groupAndNameList; - - for (UtestShell *test = tests_; test != NULLPTR; test = test->getNext()) { - if (testShouldRun(test, result)) { - SimpleString groupAndName; - groupAndName += "#"; - groupAndName += test->getGroup(); - groupAndName += "."; - groupAndName += test->getName(); - groupAndName += "#"; - - if (!groupAndNameList.contains(groupAndName)) { - groupAndNameList += groupAndName; - groupAndNameList += " "; - } - } - } - - groupAndNameList.replace("#", ""); - - if (groupAndNameList.endsWith(" ")) - groupAndNameList = groupAndNameList.subString(0, groupAndNameList.size() - 1); - 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()); -} - -size_t TestRegistry::countTests() -{ - return tests_ ? tests_->countTests() : 0; -} - -TestRegistry* TestRegistry::currentRegistry_ = NULLPTR; - -TestRegistry* TestRegistry::getCurrentRegistry() -{ - static TestRegistry registry; - return (currentRegistry_ == NULLPTR) ? ®istry : currentRegistry_; -} - -void TestRegistry::setCurrentRegistry(TestRegistry* registry) -{ - currentRegistry_ = registry; -} - -void TestRegistry::unDoLastAddTest() -{ - tests_ = tests_ ? tests_->getNext() : NULLPTR; - -} - -void TestRegistry::setNameFilters(const TestFilter* filters) -{ - nameFilters_ = filters; -} - -void TestRegistry::setGroupFilters(const TestFilter* filters) -{ - groupFilters_ = filters; -} - -void TestRegistry::setRunIgnored() -{ - runIgnored_ = true; -} - -void TestRegistry::setRunTestsInSeperateProcess() -{ - runInSeperateProcess_ = true; -} - -int TestRegistry::getCurrentRepetition() -{ - return currentRepetition_; -} - -bool TestRegistry::testShouldRun(UtestShell* test, TestResult& result) -{ - if (test->shouldRun(groupFilters_, nameFilters_)) return true; - else { - result.countFilteredOut(); - return false; - } -} - -void TestRegistry::resetPlugins() -{ - firstPlugin_ = NullTestPlugin::instance(); -} - -void TestRegistry::installPlugin(TestPlugin* plugin) -{ - firstPlugin_ = plugin->addPlugin(firstPlugin_); -} - -TestPlugin* TestRegistry::getFirstPlugin() -{ - return firstPlugin_; -} - -TestPlugin* TestRegistry::getPluginByName(const SimpleString& name) -{ - return firstPlugin_->getPluginByName(name); -} - -void TestRegistry::removePluginByName(const SimpleString& name) -{ - if (firstPlugin_->removePluginByName(name) == firstPlugin_) firstPlugin_ = firstPlugin_->getNext(); - if (firstPlugin_->getName() == name) firstPlugin_ = firstPlugin_->getNext(); - firstPlugin_->removePluginByName(name); -} - -int TestRegistry::countPlugins() -{ - int count = 0; - for (TestPlugin* plugin = firstPlugin_; plugin != NullTestPlugin::instance(); plugin = plugin->getNext()) - count++; - return count; -} - - -UtestShell* TestRegistry::getFirstTest() -{ - return tests_; -} - -void TestRegistry::shuffleTests(size_t seed) -{ - UtestShellPointerArray array(getFirstTest()); - array.shuffle(seed); - tests_ = array.getFirstTest(); -} - -void TestRegistry::reverseTests() -{ - UtestShellPointerArray array(getFirstTest()); - array.reverse(); - tests_ = array.getFirstTest(); -} - -UtestShell* TestRegistry::getTestWithNext(UtestShell* test) -{ - UtestShell* current = tests_; - while (current && current->getNext() != test) - current = current->getNext(); - return current; -} - -UtestShell* TestRegistry::findTestWithName(const SimpleString& name) -{ - UtestShell* current = tests_; - while (current) { - if (current->getName() == name) - return current; - current = current->getNext(); - } - return NULLPTR; -} - -UtestShell* TestRegistry::findTestWithGroup(const SimpleString& group) -{ - UtestShell* current = tests_; - while (current) { - if (current->getGroup() == group) - return current; - current = current->getNext(); - } - return NULLPTR; -} - diff --git a/src/CppUTest/TestResult.cpp b/src/CppUTest/TestResult.cpp deleted file mode 100644 index 37ff57f84..000000000 --- a/src/CppUTest/TestResult.cpp +++ /dev/null @@ -1,142 +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/TestHarness.h" -#include "CppUTest/TestResult.h" -#include "CppUTest/TestFailure.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -TestResult::TestResult(TestOutput& p) : - output_(p), testCount_(0), runCount_(0), checkCount_(0), failureCount_(0), filteredOutCount_(0), ignoredCount_(0), totalExecutionTime_(0), timeStarted_(0), currentTestTimeStarted_(0), - currentTestTotalExecutionTime_(0), currentGroupTimeStarted_(0), currentGroupTotalExecutionTime_(0) -{ -} - -TestResult::~TestResult() -{ -} - -void TestResult::currentGroupStarted(UtestShell* test) -{ - output_.printCurrentGroupStarted(*test); - currentGroupTimeStarted_ = (size_t) GetPlatformSpecificTimeInMillis(); -} - -void TestResult::currentGroupEnded(UtestShell* /*test*/) -{ - currentGroupTotalExecutionTime_ = (size_t) GetPlatformSpecificTimeInMillis() - currentGroupTimeStarted_; - output_.printCurrentGroupEnded(*this); -} - -void TestResult::currentTestStarted(UtestShell* test) -{ - output_.printCurrentTestStarted(*test); - currentTestTimeStarted_ = (size_t) GetPlatformSpecificTimeInMillis(); -} - -void TestResult::print(const char* text) -{ - output_.print(text); -} - -void TestResult::printVeryVerbose(const char* text) -{ - output_.printVeryVerbose(text); -} - -void TestResult::currentTestEnded(UtestShell* /*test*/) -{ - currentTestTotalExecutionTime_ = (size_t) GetPlatformSpecificTimeInMillis() - currentTestTimeStarted_; - output_.printCurrentTestEnded(*this); - -} - -void TestResult::addFailure(const TestFailure& failure) -{ - output_.printFailure(failure); - failureCount_++; -} - -void TestResult::countTest() -{ - testCount_++; -} - -void TestResult::countRun() -{ - runCount_++; -} - -void TestResult::countCheck() -{ - checkCount_++; -} - -void TestResult::countFilteredOut() -{ - filteredOutCount_++; -} - -void TestResult::countIgnored() -{ - ignoredCount_++; -} - -void TestResult::testsStarted() -{ - timeStarted_ = (size_t) GetPlatformSpecificTimeInMillis(); - output_.printTestsStarted(); -} - -void TestResult::testsEnded() -{ - size_t timeEnded = (size_t) GetPlatformSpecificTimeInMillis(); - totalExecutionTime_ = timeEnded - timeStarted_; - output_.printTestsEnded(*this); -} - -size_t TestResult::getTotalExecutionTime() const -{ - return totalExecutionTime_; -} - -void TestResult::setTotalExecutionTime(size_t exTime) -{ - totalExecutionTime_ = exTime; -} - -size_t TestResult::getCurrentTestTotalExecutionTime() const -{ - return currentTestTotalExecutionTime_; -} - -size_t TestResult::getCurrentGroupTotalExecutionTime() const -{ - return currentGroupTotalExecutionTime_; -} - diff --git a/src/CppUTest/TestTestingFixture.cpp b/src/CppUTest/TestTestingFixture.cpp deleted file mode 100644 index a5e73d33e..000000000 --- a/src/CppUTest/TestTestingFixture.cpp +++ /dev/null @@ -1,194 +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/TestHarness.h" -#include "CppUTest/TestTestingFixture.h" - -bool TestTestingFixture::lineOfCodeExecutedAfterCheck = false; - -TestTestingFixture::TestTestingFixture() -{ - output_ = new StringBufferTestOutput(); - result_ = new TestResult(*output_); - genTest_ = new ExecFunctionTestShell(); - registry_ = new TestRegistry(); - ownsExecFunction_ = false; - - registry_->setCurrentRegistry(registry_); - registry_->addTest(genTest_); - - lineOfCodeExecutedAfterCheck = false; -} - -void TestTestingFixture::flushOutputAndResetResult() -{ - output_->flush(); - delete result_; - result_ = new TestResult(*output_); -} - -TestTestingFixture::~TestTestingFixture() -{ - registry_->setCurrentRegistry(NULLPTR); - clearExecFunction(); - delete registry_; - delete result_; - delete output_; - delete genTest_; -} - -void TestTestingFixture::clearExecFunction() -{ - if (genTest_->testFunction_ && ownsExecFunction_) - delete genTest_->testFunction_; -} - -void TestTestingFixture::addTest(UtestShell * test) -{ - registry_->addTest(test); -} - -void TestTestingFixture::setTestFunction(void(*testFunction)()) -{ - clearExecFunction(); - - genTest_->testFunction_ = new ExecFunctionWithoutParameters(testFunction); - ownsExecFunction_ = true; -} - -void TestTestingFixture::setTestFunction(ExecFunction* testFunction) -{ - clearExecFunction(); - - genTest_->testFunction_ = testFunction; - - ownsExecFunction_ = false; -} - -void TestTestingFixture::setSetup(void(*setupFunction)()) -{ - genTest_->setup_ = setupFunction; -} - -void TestTestingFixture::setTeardown(void(*teardownFunction)()) -{ - genTest_->teardown_ = teardownFunction; -} - -void TestTestingFixture::installPlugin(TestPlugin* plugin) -{ - registry_->installPlugin(plugin); -} - -void TestTestingFixture::setRunTestsInSeperateProcess() -{ - registry_->setRunTestsInSeperateProcess(); -} - -void TestTestingFixture::setOutputVerbose() -{ - output_->verbose(TestOutput::level_verbose); -} - -void TestTestingFixture::runTestWithMethod(void(*method)()) -{ - setTestFunction(method); - runAllTests(); -} - -void TestTestingFixture::runAllTests() -{ - registry_->runAllTests(*result_); -} - -size_t TestTestingFixture::getFailureCount() -{ - return result_->getFailureCount(); -} - -size_t TestTestingFixture::getCheckCount() -{ - return result_->getCheckCount(); -} - -size_t TestTestingFixture::getTestCount() -{ - return result_->getTestCount(); -} - -size_t TestTestingFixture::getIgnoreCount() -{ - return result_->getIgnoredCount(); -} - -TestRegistry* TestTestingFixture::getRegistry() -{ - return registry_; -} - -bool TestTestingFixture::hasTestFailed() -{ - return genTest_->hasFailed(); -} - -void TestTestingFixture::assertPrintContains(const SimpleString& contains) -{ - STRCMP_CONTAINS(contains.asCharString(), getOutput().asCharString()); -} - -void TestTestingFixture::assertPrintContainsNot(const SimpleString& contains) -{ - CHECK(! getOutput().contains(contains)); -} - - -const SimpleString& TestTestingFixture::getOutput() -{ - return output_->getOutput(); -} - -size_t TestTestingFixture::getRunCount() -{ - return result_->getRunCount(); -} - -void TestTestingFixture::lineExecutedAfterCheck() -{ - lineOfCodeExecutedAfterCheck = true; -} - -void TestTestingFixture::checkTestFailsWithProperTestLocation(const char* text, const char* file, size_t line) -{ - if (getFailureCount() != 1) - FAIL_LOCATION(StringFromFormat("Expected one test failure, but got %d amount of test failures", (int) getFailureCount()).asCharString(), file, line); - - STRCMP_CONTAINS_LOCATION(text, output_->getOutput().asCharString(), "", file, line); - - if (lineOfCodeExecutedAfterCheck) - FAIL_LOCATION("The test should jump/throw on failure and not execute the next line. However, the next line was executed.", file, line); -} - diff --git a/src/CppUTest/Utest.cpp b/src/CppUTest/Utest.cpp deleted file mode 100644 index d74a87c79..000000000 --- a/src/CppUTest/Utest.cpp +++ /dev/null @@ -1,986 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#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)) - return false; - - if (PlatformSpecificIsInf(d1) && PlatformSpecificIsInf(d2)) - { - return true; - } - - return PlatformSpecificFabs(d1 - d2) <= threshold; -} - -/* Sometimes stubs use the CppUTest assertions. - * Its not correct to do so, but this small helper class will prevent a segmentation fault and instead - * will give an error message and also the file/line of the check that was executed outside the tests. - */ -class OutsideTestRunnerUTest: public UtestShell -{ -public: - static OutsideTestRunnerUTest& instance(); - virtual TestResult& getTestResult() - { - return defaultTestResult; - } - virtual ~OutsideTestRunnerUTest() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } -private: - OutsideTestRunnerUTest() : - UtestShell("\n\t NOTE: Assertion happened without being in a test run (perhaps in main?)", "\n\t Something is very wrong. Check this assertion and fix", "unknown file", 0), - defaultTestResult(defaultOutput) - { - } - ConsoleTestOutput defaultOutput; - TestResult defaultTestResult; -}; - -OutsideTestRunnerUTest& OutsideTestRunnerUTest::instance() -{ - static OutsideTestRunnerUTest instance_; - return instance_; -} - -/* - * Below helpers are used for the PlatformSpecificSetJmp and LongJmp. They pass a method for what needs to happen after - * the jump, so that the stack stays right. - * - */ - -extern "C" { - - static void helperDoTestSetup(void* data) - { - ((Utest*)data)->setup(); - } - - static void helperDoTestBody(void* data) - { - ((Utest*)data)->testBody(); - } - - static void helperDoTestTeardown(void* data) - { - ((Utest*)data)->teardown(); - } - - struct HelperTestRunInfo - { - HelperTestRunInfo(UtestShell* shell, TestPlugin* plugin, TestResult* result) : shell_(shell), plugin_(plugin), result_(result){} - - UtestShell* shell_; - TestPlugin* plugin_; - TestResult* result_; - }; - - static void helperDoRunOneTestInCurrentProcess(void* data) - { - HelperTestRunInfo* runInfo = (HelperTestRunInfo*) data; - - UtestShell* shell = runInfo->shell_; - TestPlugin* plugin = runInfo->plugin_; - TestResult* result = runInfo->result_; - - shell->runOneTestInCurrentProcess(plugin, *result); - } - - static void helperDoRunOneTestSeperateProcess(void* data) - { - HelperTestRunInfo* runInfo = (HelperTestRunInfo*) data; - - UtestShell* shell = runInfo->shell_; - TestPlugin* plugin = runInfo->plugin_; - TestResult* result = runInfo->result_; - PlatformSpecificRunTestInASeperateProcess(shell, plugin, result); - } - -} - -/******************************** */ - -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) -{ -} - -UtestShell::UtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber) : - group_(groupName), name_(testName), file_(fileName), lineNumber_(lineNumber), next_(NULLPTR), isRunAsSeperateProcess_(false), hasFailed_(false) -{ -} - -UtestShell::UtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber, UtestShell* nextTest) : - group_(groupName), name_(testName), file_(fileName), lineNumber_(lineNumber), next_(nextTest), isRunAsSeperateProcess_(false), hasFailed_(false) -{ -} - -UtestShell::~UtestShell() -{ -} - -static void (*pleaseCrashMeRightNow) () = PlatformSpecificAbort; - -void UtestShell::setCrashMethod(void (*crashme)()) -{ - pleaseCrashMeRightNow = crashme; -} - -void UtestShell::resetCrashMethod() -{ - pleaseCrashMeRightNow = PlatformSpecificAbort; -} - -void UtestShell::crash() -{ - pleaseCrashMeRightNow(); -} - -void UtestShell::runOneTest(TestPlugin* plugin, TestResult& result) -{ - hasFailed_ = false; - result.countRun(); - HelperTestRunInfo runInfo(this, plugin, &result); - if (isRunInSeperateProcess()) - PlatformSpecificSetJmp(helperDoRunOneTestSeperateProcess, &runInfo); - else - PlatformSpecificSetJmp(helperDoRunOneTestInCurrentProcess, &runInfo); -} - -Utest* UtestShell::createTest() -{ - return new Utest(); -} - -void UtestShell::destroyTest(Utest* test) -{ - delete test; -} - -void UtestShell::runOneTestInCurrentProcess(TestPlugin* plugin, TestResult& result) -{ - result.printVeryVerbose("\n-- before runAllPreTestAction: "); - plugin->runAllPreTestAction(*this, result); - result.printVeryVerbose("\n-- after runAllPreTestAction: "); - - //save test context, so that test class can be tested - UtestShell* savedTest = UtestShell::getCurrent(); - TestResult* savedResult = UtestShell::getTestResult(); - - UtestShell::setTestResult(&result); - UtestShell::setCurrentTest(this); - - Utest* testToRun = NULLPTR; - -#if CPPUTEST_HAVE_EXCEPTIONS - try - { -#endif - result.printVeryVerbose("\n---- before createTest: "); - testToRun = createTest(); - result.printVeryVerbose("\n---- after createTest: "); - - 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); - result.printVeryVerbose("\n---- after destroyTest: "); - - result.printVeryVerbose("\n-- before runAllPostTestAction: "); - plugin->runAllPostTestAction(*this, result); - result.printVeryVerbose("\n-- after runAllPostTestAction: "); -} - -UtestShell *UtestShell::getNext() const -{ - return next_; -} - -UtestShell* UtestShell::addTest(UtestShell *test) -{ - next_ = test; - return this; -} - -size_t UtestShell::countTests() -{ - return next_ ? next_->countTests() + 1 : 1; -} - -SimpleString UtestShell::getMacroName() const -{ - return "TEST"; -} - -const SimpleString UtestShell::getName() const -{ - return SimpleString(name_); -} - -const SimpleString UtestShell::getGroup() const -{ - return SimpleString(group_); -} - -SimpleString UtestShell::getFormattedName() const -{ - SimpleString formattedName(getMacroName()); - formattedName += "("; - formattedName += group_; - formattedName += ", "; - formattedName += name_; - formattedName += ")"; - - return formattedName; -} - -bool UtestShell::hasFailed() const -{ - return hasFailed_; -} - -void UtestShell::countCheck() -{ - getTestResult()->countCheck(); -} - -bool UtestShell::willRun() const -{ - return true; -} - -bool UtestShell::isRunInSeperateProcess() const -{ - return isRunAsSeperateProcess_; -} - -void UtestShell::setRunInSeperateProcess() -{ - isRunAsSeperateProcess_ = true; -} - - -void UtestShell::setRunIgnored() -{ - -} - -void UtestShell::setFileName(const char* fileName) -{ - file_ = fileName; -} - -void UtestShell::setLineNumber(size_t lineNumber) -{ - lineNumber_ = lineNumber; -} - -void UtestShell::setGroupName(const char* groupName) -{ - group_ = groupName; -} - -void UtestShell::setTestName(const char* testName) -{ - name_ = testName; -} - -const SimpleString UtestShell::getFile() const -{ - return SimpleString(file_); -} - -size_t UtestShell::getLineNumber() const -{ - return lineNumber_; -} - -bool UtestShell::match(const char* target, const TestFilter* filters) const -{ - if(filters == NULLPTR) return true; - - for(; filters != NULLPTR; filters = filters->getNext()) - if(filters->match(target)) return true; - - return false; -} - -bool UtestShell::shouldRun(const TestFilter* groupFilters, const TestFilter* nameFilters) const -{ - return match(group_, groupFilters) && match(name_, nameFilters); -} - -void UtestShell::failWith(const TestFailure& failure) -{ - failWith(failure, getCurrentTestTerminator()); -} // LCOV_EXCL_LINE - -void UtestShell::failWith(const TestFailure& failure, const TestTerminator& terminator) -{ - 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(); -} // LCOV_EXCL_LINE - -void UtestShell::assertTrue(bool condition, const char *checkString, const char *conditionString, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (!condition) - failWith(CheckFailure(this, fileName, lineNumber, checkString, conditionString, text), testTerminator); -} - -void UtestShell::fail(const char *text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - failWith(FailFailure(this, fileName, lineNumber, text), testTerminator); -} // LCOV_EXCL_LINE - -void UtestShell::assertCstrEqual(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); - if (SimpleString::StrCmp(expected, actual) != 0) - failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); -} - -void UtestShell::assertCstrNEqual(const char* expected, const char* actual, size_t length, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); - if (SimpleString::StrNCmp(expected, actual, length) != 0) - failWith(StringEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); -} - -void UtestShell::assertCstrNoCaseEqual(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber) -{ - getTestResult()->countCheck(); - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text)); - if (!SimpleString(expected).equalsNoCase(actual)) - failWith(StringEqualNoCaseFailure(this, fileName, lineNumber, expected, actual, text)); -} - -void UtestShell::assertCstrContains(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber) -{ - getTestResult()->countCheck(); - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text)); - if (!SimpleString(actual).contains(expected)) - failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text)); -} - -void UtestShell::assertCstrNoCaseContains(const char* expected, const char* actual, const char* text, const char* fileName, size_t lineNumber) -{ - getTestResult()->countCheck(); - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text)); - if (!SimpleString(actual).containsNoCase(expected)) - failWith(ContainsFailure(this, fileName, lineNumber, expected, actual, text)); -} - -void UtestShell::assertLongsEqual(long expected, long actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (expected != actual) - failWith(LongsEqualFailure (this, fileName, lineNumber, expected, actual, text), testTerminator); -} - -void UtestShell::assertUnsignedLongsEqual(unsigned long expected, unsigned long actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (expected != actual) - failWith(UnsignedLongsEqualFailure (this, fileName, lineNumber, expected, actual, text), testTerminator); -} - -void UtestShell::assertLongLongsEqual(cpputest_longlong expected, cpputest_longlong actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); -#if CPPUTEST_USE_LONG_LONG - if (expected != actual) - failWith(LongLongsEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); -#else - (void)expected; - (void)actual; - failWith(FeatureUnsupportedFailure(this, fileName, lineNumber, "CPPUTEST_USE_LONG_LONG", text), testTerminator); -#endif -} - -void UtestShell::assertUnsignedLongLongsEqual(cpputest_ulonglong expected, cpputest_ulonglong actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); -#if CPPUTEST_USE_LONG_LONG - if (expected != actual) - failWith(UnsignedLongLongsEqualFailure(this, fileName, lineNumber, expected, actual, text), testTerminator); -#else - (void)expected; - (void)actual; - failWith(FeatureUnsupportedFailure(this, fileName, lineNumber, "CPPUTEST_USE_LONG_LONG", text), testTerminator); -#endif -} - -void UtestShell::assertSignedBytesEqual(signed char expected, signed char actual, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (expected != actual) - failWith(SignedBytesEqualFailure (this, fileName, lineNumber, expected, actual, text), testTerminator); -} - -void UtestShell::assertPointersEqual(const void* expected, const void* actual, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (expected != actual) - failWith(EqualsFailure(this, fileName, lineNumber, StringFrom(expected), StringFrom(actual), text), testTerminator); -} - -void UtestShell::assertFunctionPointersEqual(void (*expected)(), void (*actual)(), const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (expected != actual) - failWith(EqualsFailure(this, fileName, lineNumber, StringFrom(expected), StringFrom(actual), text), testTerminator); -} - -void UtestShell::assertDoublesEqual(double expected, double actual, double threshold, const char* text, const char* fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (!doubles_equal(expected, actual, threshold)) - failWith(DoublesEqualFailure(this, fileName, lineNumber, expected, actual, threshold, text), testTerminator); -} - -void UtestShell::assertBinaryEqual(const void *expected, const void *actual, size_t length, const char* text, const char *fileName, size_t lineNumber, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (length == 0) return; - if (actual == NULLPTR && expected == NULLPTR) return; - if (actual == NULLPTR || expected == NULLPTR) - failWith(BinaryEqualFailure(this, fileName, lineNumber, (const unsigned char *) expected, (const unsigned char *) actual, length, text), testTerminator); - if (SimpleString::MemCmp(expected, actual, length) != 0) - failWith(BinaryEqualFailure(this, fileName, lineNumber, (const unsigned char *) expected, (const unsigned char *) actual, length, text), testTerminator); -} - -void UtestShell::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) -{ - getTestResult()->countCheck(); - if ((expected & mask) != (actual & mask)) - failWith(BitsEqualFailure(this, fileName, lineNumber, expected, actual, mask, byteCount, text), testTerminator); -} - -void UtestShell::assertEquals(bool failed, const char* expected, const char* actual, const char* text, const char* file, size_t line, const TestTerminator& testTerminator) -{ - getTestResult()->countCheck(); - if (failed) - failWith(CheckEqualFailure(this, file, line, expected, actual, text), testTerminator); -} - -void UtestShell::assertCompare(bool comparison, const char *checkString, const char *comparisonString, const char *text, const char *fileName, size_t lineNumber, const TestTerminator &testTerminator) -{ - getTestResult()->countCheck(); - if (!comparison) - failWith(ComparisonFailure(this, fileName, lineNumber, checkString, comparisonString, text), testTerminator); -} - -void UtestShell::print(const char *text, const char* fileName, size_t lineNumber) -{ - SimpleString stringToPrint = "\n"; - stringToPrint += fileName; - stringToPrint += ":"; - stringToPrint += StringFrom(lineNumber); - stringToPrint += " "; - stringToPrint += text; - getTestResult()->print(stringToPrint.asCharString()); -} - -void UtestShell::print(const SimpleString& text, const char* fileName, size_t lineNumber) -{ - print(text.asCharString(), fileName, lineNumber); -} - -void UtestShell::printVeryVerbose(const char* text) -{ - getTestResult()->printVeryVerbose(text); -} - -TestResult* UtestShell::testResult_ = NULLPTR; -UtestShell* UtestShell::currentTest_ = NULLPTR; - -void UtestShell::setTestResult(TestResult* result) -{ - testResult_ = result; -} - -void UtestShell::setCurrentTest(UtestShell* test) -{ - currentTest_ = test; -} - -TestResult* UtestShell::getTestResult() -{ - if (testResult_ == NULLPTR) - return &OutsideTestRunnerUTest::instance().getTestResult(); - return testResult_; -} - -UtestShell* UtestShell::getCurrent() -{ - if (currentTest_ == NULLPTR) - return &OutsideTestRunnerUTest::instance(); - 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() -{ -} - -////////////// Utest //////////// - -Utest::Utest() -{ -} - -Utest::~Utest() -{ -} - -#if CPPUTEST_HAVE_EXCEPTIONS - -void Utest::run() -{ - UtestShell* current = UtestShell::getCurrent(); - int jumpResult = 0; - try { - current->printVeryVerbose("\n-------- before setup: "); - jumpResult = PlatformSpecificSetJmp(helperDoTestSetup, this); - current->printVeryVerbose("\n-------- after setup: "); - - if (jumpResult) { - current->printVeryVerbose("\n---------- before body: "); - PlatformSpecificSetJmp(helperDoTestBody, this); - current->printVeryVerbose("\n---------- after body: "); - } - } - catch (CppUTestFailedException&) - { - 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: "); - PlatformSpecificSetJmp(helperDoTestTeardown, this); - current->printVeryVerbose("\n-------- after teardown: "); - } - catch (CppUTestFailedException&) - { - 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 - -void Utest::run() -{ - if (PlatformSpecificSetJmp(helperDoTestSetup, this)) { - PlatformSpecificSetJmp(helperDoTestBody, this); - } - PlatformSpecificSetJmp(helperDoTestTeardown, this); -} - -#endif - -void Utest::setup() -{ -} - -void Utest::testBody() -{ -} - -void Utest::teardown() -{ -} - - -/////////////////// Terminators - -TestTerminator::~TestTerminator() -{ -} - -void NormalTestTerminator::exitCurrentTest() const -{ - #if CPPUTEST_HAVE_EXCEPTIONS - throw CppUTestFailedException(); - #else - TestTerminatorWithoutExceptions().exitCurrentTest(); - #endif -} - -NormalTestTerminator::~NormalTestTerminator() -{ -} - -void TestTerminatorWithoutExceptions::exitCurrentTest() const -{ - PlatformSpecificLongJmp(); -} // LCOV_EXCL_LINE - -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() -{ -} - -ExecFunction::~ExecFunction() -{ -} - -ExecFunctionWithoutParameters::ExecFunctionWithoutParameters(void(*testFunction)()) - : testFunction_(testFunction) -{ -} - -ExecFunctionWithoutParameters::~ExecFunctionWithoutParameters() -{ -} - -void ExecFunctionWithoutParameters::exec() -{ - if (testFunction_) - testFunction_(); -} - -//////////////////// ExecFunctionTest - -ExecFunctionTest::ExecFunctionTest(ExecFunctionTestShell* shell) - : shell_(shell) -{ -} - -void ExecFunctionTest::testBody() -{ - if (shell_->testFunction_) shell_->testFunction_->exec(); -} - -void ExecFunctionTest::setup() -{ - if (shell_->setup_) shell_->setup_(); -} - -void ExecFunctionTest::teardown() -{ - if (shell_->teardown_) shell_->teardown_(); -} - -/////////////// IgnoredUtestShell ///////////// -IgnoredUtestShell::IgnoredUtestShell(): runIgnored_(false) -{ -} - -IgnoredUtestShell::IgnoredUtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber) : - UtestShell(groupName, testName, fileName, lineNumber), runIgnored_(false) -{ -} - -IgnoredUtestShell::~IgnoredUtestShell() -{ -} - -bool IgnoredUtestShell::willRun() const -{ - if (runIgnored_) return UtestShell::willRun(); - - return false; -} - -SimpleString IgnoredUtestShell::getMacroName() const -{ - if (runIgnored_) return "TEST"; - - return "IGNORE_TEST"; -} - -void IgnoredUtestShell::runOneTest(TestPlugin* plugin, TestResult& result) -{ - if (runIgnored_) - { - UtestShell::runOneTest(plugin, result); - return; - } - - result.countIgnored(); -} - -void IgnoredUtestShell::setRunIgnored() -{ - runIgnored_ = true; -} - -//////////////////// UtestShellPointerArray - -UtestShellPointerArray::UtestShellPointerArray(UtestShell* firstTest) - : arrayOfTests_(NULLPTR), count_(0) -{ - count_ = (firstTest) ? firstTest->countTests() : 0; - if (count_ == 0) return; - - arrayOfTests_ = new UtestShell*[count_]; - - UtestShell*currentTest = firstTest; - for (size_t i = 0; i < count_; i++) - { - arrayOfTests_[i] = currentTest; - currentTest = currentTest->getNext(); - } -} - -UtestShellPointerArray::~UtestShellPointerArray() -{ - delete [] arrayOfTests_; -} - -void UtestShellPointerArray::swap(size_t index1, size_t index2) -{ - UtestShell* e2 = arrayOfTests_[index2]; - UtestShell* e1 = arrayOfTests_[index1]; - arrayOfTests_[index1] = e2; - arrayOfTests_[index2] = e1; -} - -void UtestShellPointerArray::shuffle(size_t seed) -{ - if (count_ == 0) return; - - PlatformSpecificSrand((unsigned int) seed); - - for (size_t i = count_ - 1; i >= 1; --i) - { - if (count_ == 0) return; - - const size_t j = ((size_t)PlatformSpecificRand()) % (i + 1); // distribution biased by modulo, but good enough for shuffling - swap(i, j); - } - relinkTestsInOrder(); -} - -void UtestShellPointerArray::reverse() -{ - if (count_ == 0) return; - - size_t halfCount = count_ / 2; - for (size_t i = 0; i < halfCount; i++) - { - size_t j = count_ - i - 1; - swap(i, j); - } - relinkTestsInOrder(); -} - -void UtestShellPointerArray::relinkTestsInOrder() -{ - UtestShell *tests = NULLPTR; - for (size_t i = 0; i < count_; i++) - tests = arrayOfTests_[count_ - i - 1]->addTest(tests); -} - -UtestShell* UtestShellPointerArray::getFirstTest() const -{ - return get(0); -} - -UtestShell* UtestShellPointerArray::get(size_t index) const -{ - if (index >= count_) return NULLPTR; - return arrayOfTests_[index]; -} - - - -////////////// TestInstaller //////////// - -TestInstaller::TestInstaller(UtestShell& shell, const char* groupName, const char* testName, const char* fileName, size_t lineNumber) -{ - shell.setGroupName(groupName); - shell.setTestName(testName); - shell.setFileName(fileName); - shell.setLineNumber(lineNumber); - TestRegistry::getCurrentRegistry()->addTest(&shell); -} - -TestInstaller::~TestInstaller() -{ -} - -void TestInstaller::unDo() -{ - TestRegistry::getCurrentRegistry()->unDoLastAddTest(); -} diff --git a/src/CppUTestExt/CMakeLists.txt b/src/CppUTestExt/CMakeLists.txt deleted file mode 100644 index ec0f27586..000000000 --- a/src/CppUTestExt/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -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 -) - -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 - $ - $ -) - -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 deleted file mode 100644 index 57c1e4f96..000000000 --- a/src/CppUTestExt/CodeMemoryReportFormatter.cpp +++ /dev/null @@ -1,172 +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/TestHarness.h" -#include "CppUTestExt/CodeMemoryReportFormatter.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" - - -#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) - -struct CodeReportingAllocationNode -{ - char variableName_[MAX_VARIABLE_NAME_LENGTH + 1]; - void* memory_; - CodeReportingAllocationNode* next_; -}; - -CodeMemoryReportFormatter::CodeMemoryReportFormatter(TestMemoryAllocator* internalAllocator) - : codeReportingList_(NULLPTR), internalAllocator_(internalAllocator) -{ -} - -CodeMemoryReportFormatter::~CodeMemoryReportFormatter() -{ - clearReporting(); -} - -void CodeMemoryReportFormatter::clearReporting() -{ - while (codeReportingList_) { - CodeReportingAllocationNode* oldNode = codeReportingList_; - codeReportingList_ = codeReportingList_->next_; - internalAllocator_->free_memory((char*) oldNode, 0, __FILE__, __LINE__); - } -} - -void CodeMemoryReportFormatter::addNodeToList(const char* variableName, void* memory, CodeReportingAllocationNode* next) -{ - CodeReportingAllocationNode* newNode = (CodeReportingAllocationNode*) (void*) internalAllocator_->alloc_memory(sizeof(CodeReportingAllocationNode), __FILE__, __LINE__); - newNode->memory_ = memory; - newNode->next_ = next; - SimpleString::StrNCpy(newNode->variableName_, variableName, MAX_VARIABLE_NAME_LENGTH); - codeReportingList_ = newNode; -} - -CodeReportingAllocationNode* CodeMemoryReportFormatter::findNode(void* memory) -{ - - CodeReportingAllocationNode* current = codeReportingList_; - while (current && current->memory_ != memory) { - current = current->next_; - } - return current; -} - -static SimpleString extractFileNameFromPath(const char* file) -{ - const char* fileNameOnly = file + SimpleString::StrLen(file); - while (fileNameOnly != file && *fileNameOnly != '/') - fileNameOnly--; - if (*fileNameOnly == '/') fileNameOnly++; - return fileNameOnly; -} - -SimpleString CodeMemoryReportFormatter::createVariableNameFromFileLineInfo(const char *file, size_t line) -{ - SimpleString fileNameOnly = extractFileNameFromPath(file); - fileNameOnly.replace(".", "_"); - - for (int i = 1; i < 100; i++) { - SimpleString variableName = StringFromFormat("%s_%d_%d", fileNameOnly.asCharString(), (int) line, i); - if (!variableExists(variableName)) - return variableName; - } - return ""; -} - -bool CodeMemoryReportFormatter::isNewAllocator(TestMemoryAllocator* allocator) -{ - return SimpleString::StrCmp(allocator->alloc_name(), defaultNewAllocator()->alloc_name()) == 0 || SimpleString::StrCmp(allocator->alloc_name(), defaultNewArrayAllocator()->alloc_name()) == 0; -} - -bool CodeMemoryReportFormatter::variableExists(const SimpleString& variableName) -{ - CodeReportingAllocationNode* current = codeReportingList_; - while (current) { - if (variableName == current->variableName_) - return true; - current = current->next_; - } - return false; -} - -SimpleString CodeMemoryReportFormatter::getAllocationString(TestMemoryAllocator* allocator, const SimpleString& variableName, size_t size) -{ - if (isNewAllocator(allocator)) - return StringFromFormat("char* %s = new char[%lu]; /* using %s */", variableName.asCharString(), (unsigned long) size, allocator->alloc_name()); - else - return StringFromFormat("void* %s = malloc(%lu);", variableName.asCharString(), (unsigned long) size); -} - -SimpleString CodeMemoryReportFormatter::getDeallocationString(TestMemoryAllocator* allocator, const SimpleString& variableName, const char* file, size_t line) -{ - if (isNewAllocator(allocator)) - return StringFromFormat("delete [] %s; /* using %s at %s:%d */", variableName.asCharString(), allocator->free_name(), file, (int) line); - else - return StringFromFormat("free(%s); /* at %s:%d */", variableName.asCharString(), file, (int) line); -} - -void CodeMemoryReportFormatter::report_test_start(TestResult* result, UtestShell& test) -{ - clearReporting(); - result->print(StringFromFormat("*/\nTEST(%s_memoryReport, %s)\n{ /* at %s:%d */\n", - test.getGroup().asCharString(), test.getName().asCharString(), test.getFile().asCharString(), (int) test.getLineNumber()).asCharString()); -} - -void CodeMemoryReportFormatter::report_test_end(TestResult* result, UtestShell&) -{ - result->print("}/*"); -} - -void CodeMemoryReportFormatter::report_testgroup_start(TestResult* result, UtestShell& test) -{ - result->print(StringFromFormat("*/TEST_GROUP(%s_memoryReport)\n{\n};\n/*", - test.getGroup().asCharString()).asCharString()); -} - -void CodeMemoryReportFormatter::report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) -{ - SimpleString variableName = createVariableNameFromFileLineInfo(file, line); - result->print(StringFromFormat("\t%s\n", getAllocationString(allocator, variableName, size).asCharString()).asCharString()); - addNodeToList(variableName.asCharString(), memory, codeReportingList_); -} - -void CodeMemoryReportFormatter::report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) -{ - SimpleString variableName; - CodeReportingAllocationNode* node = findNode(memory); - - if (memory == NULLPTR) variableName = "NULL"; - else variableName = node->variableName_; - - result->print(StringFromFormat("\t%s\n", getDeallocationString(allocator, variableName, file, line).asCharString()).asCharString()); -} diff --git a/src/CppUTestExt/GTest.cpp b/src/CppUTestExt/GTest.cpp deleted file mode 100644 index 919866c39..000000000 --- a/src/CppUTestExt/GTest.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -#include "CppUTest/TestHarness.h" -#include "CppUTestExt/GTestSupport.h" - -void CppuTestGTestIgnoreLeaksInTest() -{ - IGNORE_ALL_LEAKS_IN_TEST(); -} - diff --git a/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp b/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp deleted file mode 100644 index 5b84a4862..000000000 --- a/src/CppUTestExt/IEEE754ExceptionsPlugin.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2015, Michael Feathers, James Grenning, Bas Vodde - * and Arnd R. Strube. 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/TestHarness.h" -#include "CppUTestExt/IEEE754ExceptionsPlugin.h" - -#if CPPUTEST_HAVE_FENV - -extern "C" { - #include -} - -#define IEEE754_CHECK_CLEAR(test, result, flag) ieee754Check(test, result, flag, #flag) - -bool IEEE754ExceptionsPlugin::inexactDisabled_ = true; - -IEEE754ExceptionsPlugin::IEEE754ExceptionsPlugin(const SimpleString& name) - : TestPlugin(name) -{ -} - -void IEEE754ExceptionsPlugin::preTestAction(UtestShell&, TestResult&) -{ - CHECK(!feclearexcept(FE_ALL_EXCEPT)); -} - -void IEEE754ExceptionsPlugin::postTestAction(UtestShell& test, TestResult& result) -{ - if(!test.hasFailed()) { - IEEE754_CHECK_CLEAR(test, result, FE_DIVBYZERO); - IEEE754_CHECK_CLEAR(test, result, FE_OVERFLOW); - IEEE754_CHECK_CLEAR(test, result, FE_UNDERFLOW); - IEEE754_CHECK_CLEAR(test, result, FE_INVALID); // LCOV_EXCL_LINE (not all platforms support this) - IEEE754_CHECK_CLEAR(test, result, FE_INEXACT); - } -} - -void IEEE754ExceptionsPlugin::disableInexact() -{ - inexactDisabled_ = true; -} - -void IEEE754ExceptionsPlugin::enableInexact() -{ - inexactDisabled_ = false; -} - -bool IEEE754ExceptionsPlugin::checkIeee754OverflowExceptionFlag() -{ - return fetestexcept(FE_OVERFLOW) != 0; -} - -bool IEEE754ExceptionsPlugin::checkIeee754UnderflowExceptionFlag() -{ - return fetestexcept(FE_UNDERFLOW) != 0; -} - -bool IEEE754ExceptionsPlugin::checkIeee754InexactExceptionFlag() -{ - return fetestexcept(FE_INEXACT) != 0; -} - -bool IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag() -{ - return fetestexcept(FE_DIVBYZERO) != 0; -} - -void IEEE754ExceptionsPlugin::ieee754Check(UtestShell& test, TestResult& result, int flag, const char* text) -{ - result.countCheck(); - if(inexactDisabled_) CHECK(!feclearexcept(FE_INEXACT)); - if(fetestexcept(flag)) { - CHECK(!feclearexcept(FE_ALL_EXCEPT)); - CheckFailure failure(&test, __FILE__, __LINE__, "IEEE754_CHECK_CLEAR", text); - result.addFailure(failure); - } -} - -#else - - -bool IEEE754ExceptionsPlugin::inexactDisabled_ = true; - -IEEE754ExceptionsPlugin::IEEE754ExceptionsPlugin(const SimpleString& name) - : TestPlugin(name) -{ -} - -void IEEE754ExceptionsPlugin::preTestAction(UtestShell&, TestResult&) -{ -} - -void IEEE754ExceptionsPlugin::postTestAction(UtestShell&, TestResult&) -{ -} - -void IEEE754ExceptionsPlugin::disableInexact() -{ -} - -void IEEE754ExceptionsPlugin::enableInexact() -{ -} - -bool IEEE754ExceptionsPlugin::checkIeee754OverflowExceptionFlag() -{ - return false; -} - -bool IEEE754ExceptionsPlugin::checkIeee754UnderflowExceptionFlag() -{ - return false; -} - -bool IEEE754ExceptionsPlugin::checkIeee754InexactExceptionFlag() -{ - return false; -} - -bool IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag() -{ - return false; -} - -void IEEE754ExceptionsPlugin::ieee754Check(UtestShell&, TestResult&, int, const char*) -{ -} - -#endif diff --git a/src/CppUTestExt/MemoryReportAllocator.cpp b/src/CppUTestExt/MemoryReportAllocator.cpp deleted file mode 100644 index f51b932ab..000000000 --- a/src/CppUTestExt/MemoryReportAllocator.cpp +++ /dev/null @@ -1,93 +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/TestHarness.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTestExt/MemoryReportFormatter.h" - -MemoryReportAllocator::MemoryReportAllocator() : result_(NULLPTR), realAllocator_(NULLPTR), formatter_(NULLPTR) -{ -} - -MemoryReportAllocator::~MemoryReportAllocator() -{ -} - -const char* MemoryReportAllocator::name() const -{ - return "MemoryReporterAllocator"; -} - -const char* MemoryReportAllocator::alloc_name() const -{ - return realAllocator_->alloc_name(); -} - -const char* MemoryReportAllocator::free_name() const -{ - return realAllocator_->free_name(); -} - -void MemoryReportAllocator::setRealAllocator(TestMemoryAllocator* allocator) -{ - realAllocator_ = allocator; -} - -TestMemoryAllocator* MemoryReportAllocator::getRealAllocator() -{ - return realAllocator_; -} - -TestMemoryAllocator* MemoryReportAllocator::actualAllocator() -{ - return realAllocator_->actualAllocator(); -} - -void MemoryReportAllocator::setTestResult(TestResult* result) -{ - result_ = result; -} - -void MemoryReportAllocator::setFormatter(MemoryReportFormatter* formatter) -{ - formatter_ = formatter; -} - -char* MemoryReportAllocator::alloc_memory(size_t size, const char* file, size_t line) -{ - char* memory = realAllocator_->alloc_memory(size, file, line); - if (result_ && formatter_) - formatter_->report_alloc_memory(result_, this, size, memory, file, line); - return memory; -} - -void MemoryReportAllocator::free_memory(char* memory, size_t size, const char* file, size_t line) -{ - realAllocator_->free_memory(memory, size, file, line); - if (result_ && formatter_) - formatter_->report_free_memory(result_, this, memory, file, line); -} diff --git a/src/CppUTestExt/MemoryReportFormatter.cpp b/src/CppUTestExt/MemoryReportFormatter.cpp deleted file mode 100644 index 13833e5d6..000000000 --- a/src/CppUTestExt/MemoryReportFormatter.cpp +++ /dev/null @@ -1,72 +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/TestHarness.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTestExt/MemoryReportFormatter.h" - -NormalMemoryReportFormatter::NormalMemoryReportFormatter() -{ -} - -NormalMemoryReportFormatter::~NormalMemoryReportFormatter() -{ -} - -void NormalMemoryReportFormatter::report_test_start(TestResult* result, UtestShell& test) -{ - result->print(StringFromFormat("TEST(%s, %s)\n", test.getGroup().asCharString(), test.getName().asCharString()).asCharString()); -} - -void NormalMemoryReportFormatter::report_test_end(TestResult* result, UtestShell& test) -{ - result->print(StringFromFormat("ENDTEST(%s, %s)\n", test.getGroup().asCharString(), test.getName().asCharString()).asCharString()); -} - -void NormalMemoryReportFormatter::report_alloc_memory(TestResult* result, TestMemoryAllocator* allocator, size_t size, char* memory, const char* file, size_t line) -{ - result->print(StringFromFormat("\tAllocation using %s of size: %lu pointer: %p at %s:%d\n", allocator->alloc_name(), (unsigned long) size, (void*) memory, file, (int) line).asCharString()); -} - -void NormalMemoryReportFormatter::report_free_memory(TestResult* result, TestMemoryAllocator* allocator, char* memory, const char* file, size_t line) -{ - result->print(StringFromFormat("\tDeallocation using %s of pointer: %p at %s:%d\n", allocator->free_name(), (void*) memory, file, (int) line).asCharString()); -} - -void NormalMemoryReportFormatter::report_testgroup_start(TestResult* result, UtestShell& test) -{ - const size_t line_size = 80; - - SimpleString groupName = StringFromFormat("TEST GROUP(%s)", test.getGroup().asCharString()); - size_t beginPos = (line_size/2) - (groupName.size()/2); - - SimpleString line("-", beginPos); - line += groupName; - line += SimpleString("-", line_size - line.size()); - line += "\n"; - result->print(line.asCharString()); -} diff --git a/src/CppUTestExt/MemoryReporterPlugin.cpp b/src/CppUTestExt/MemoryReporterPlugin.cpp deleted file mode 100644 index 8b81f5dc8..000000000 --- a/src/CppUTestExt/MemoryReporterPlugin.cpp +++ /dev/null @@ -1,146 +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/TestHarness.h" -#include "CppUTestExt/MemoryReporterPlugin.h" -#include "CppUTestExt/MemoryReportFormatter.h" -#include "CppUTestExt/CodeMemoryReportFormatter.h" - -MemoryReporterPlugin::MemoryReporterPlugin() - : TestPlugin("MemoryReporterPlugin"), formatter_(NULLPTR) -{ -} - -MemoryReporterPlugin::~MemoryReporterPlugin() -{ - removeGlobalMemoryReportAllocators(); - destroyMemoryFormatter(formatter_); -} - -bool MemoryReporterPlugin::parseArguments(int /* ac */, const char *const *av, int index) -{ - SimpleString argument (av[index]); - if (argument.contains("-pmemoryreport=")) { - argument.replace("-pmemoryreport=", ""); - - destroyMemoryFormatter(formatter_); - formatter_ = createMemoryFormatter(argument); - return true; - } - return false; -} - -MemoryReportFormatter* MemoryReporterPlugin::createMemoryFormatter(const SimpleString& type) -{ - if (type == "normal") { - return new NormalMemoryReportFormatter; - } - else if (type == "code") { - return new CodeMemoryReportFormatter(defaultMallocAllocator()); - } - return NULLPTR; -} - -void MemoryReporterPlugin::destroyMemoryFormatter(MemoryReportFormatter* formatter) -{ - delete formatter; -} - - -void MemoryReporterPlugin::setGlobalMemoryReportAllocators() -{ - mallocAllocator.setRealAllocator(getCurrentMallocAllocator()); - setCurrentMallocAllocator(&mallocAllocator); - - newAllocator.setRealAllocator(getCurrentNewAllocator()); - setCurrentNewAllocator(&newAllocator); - - newArrayAllocator.setRealAllocator(getCurrentNewArrayAllocator()); - setCurrentNewArrayAllocator(&newArrayAllocator); -} - -void MemoryReporterPlugin::removeGlobalMemoryReportAllocators() -{ - if (getCurrentNewAllocator() == &newAllocator) - setCurrentNewAllocator(newAllocator.getRealAllocator()); - - if (getCurrentNewArrayAllocator() == &newArrayAllocator) - setCurrentNewArrayAllocator(newArrayAllocator.getRealAllocator()); - - if (getCurrentMallocAllocator() == &mallocAllocator) - setCurrentMallocAllocator(mallocAllocator.getRealAllocator()); -} - -MemoryReportAllocator* MemoryReporterPlugin::getMallocAllocator() -{ - return &mallocAllocator; -} - -MemoryReportAllocator* MemoryReporterPlugin::getNewAllocator() -{ - return &newAllocator; -} - -MemoryReportAllocator* MemoryReporterPlugin::getNewArrayAllocator() -{ - return &newArrayAllocator; -} - -void MemoryReporterPlugin::initializeAllocator(MemoryReportAllocator* allocator, TestResult & result) -{ - allocator->setFormatter(formatter_); - allocator->setTestResult((&result)); -} - -void MemoryReporterPlugin::preTestAction(UtestShell& test, TestResult& result) -{ - if (formatter_ == NULLPTR) return; - - initializeAllocator(&mallocAllocator, result); - initializeAllocator(&newAllocator, result); - initializeAllocator(&newArrayAllocator, result); - - setGlobalMemoryReportAllocators(); - - if (test.getGroup() != currentTestGroup_) { - formatter_->report_testgroup_start(&result, test); - currentTestGroup_ = test.getGroup(); - } - - formatter_->report_test_start(&result, test); -} - -void MemoryReporterPlugin::postTestAction(UtestShell& test, TestResult& result) -{ - if (formatter_ == NULLPTR) return; - - removeGlobalMemoryReportAllocators(); - formatter_->report_test_end(&result, test); - - if (test.getNext() == NULLPTR || test.getNext()->getGroup() != currentTestGroup_) - formatter_->report_testgroup_end(&result, test); -} diff --git a/src/CppUTestExt/MockActualCall.cpp b/src/CppUTestExt/MockActualCall.cpp deleted file mode 100644 index 319e20a60..000000000 --- a/src/CppUTestExt/MockActualCall.cpp +++ /dev/null @@ -1,1032 +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/TestHarness.h" -#include "CppUTestExt/MockCheckedActualCall.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockFailure.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -MockActualCall::MockActualCall() -{ -} - -MockActualCall::~MockActualCall() -{ -} - -void MockCheckedActualCall::setName(const SimpleString& name) -{ - functionName_ = name; -} - -SimpleString MockCheckedActualCall::getName() const -{ - return functionName_; -} - -MockCheckedActualCall::MockCheckedActualCall(unsigned int callOrder, MockFailureReporter* reporter, const MockExpectedCallsList& allExpectations) - : callOrder_(callOrder), reporter_(reporter), state_(CALL_SUCCEED), expectationsChecked_(false), matchingExpectation_(NULLPTR), - allExpectations_(allExpectations), outputParameterExpectations_(NULLPTR) -{ - potentiallyMatchingExpectations_.addPotentiallyMatchingExpectations(allExpectations); -} - -MockCheckedActualCall::~MockCheckedActualCall() -{ - cleanUpOutputParameterList(); -} - -void MockCheckedActualCall::setMockFailureReporter(MockFailureReporter* reporter) -{ - reporter_ = reporter; -} - -UtestShell* MockCheckedActualCall::getTest() const -{ - return reporter_->getTestToFail(); -} - -void MockCheckedActualCall::failTest(const MockFailure& failure) -{ - if (!hasFailed()) { - setState(CALL_FAILED); - reporter_->failTest(failure); - } -} - -void MockCheckedActualCall::copyOutputParameters(MockCheckedExpectedCall* expectedCall) -{ - for (MockOutputParametersListNode* p = outputParameterExpectations_; p; p = p->next_) - { - MockNamedValue outputParameter = expectedCall->getOutputParameter(p->name_); - MockNamedValueCopier* copier = outputParameter.getCopier(); - if (copier) - { - copier->copy(p->ptr_, outputParameter.getConstObjectPointer()); - } - else if ((outputParameter.getType() == "const void*") && (p->type_ == "void*")) - { - const void* data = outputParameter.getConstPointerValue(); - size_t size = outputParameter.getSize(); - PlatformSpecificMemCpy(p->ptr_, data, size); - } - else if (outputParameter.getName() != "") - { - SimpleString type = expectedCall->getOutputParameter(p->name_).getType(); - MockNoWayToCopyCustomTypeFailure failure(getTest(), type); - failTest(failure); - } - } -} - -void MockCheckedActualCall::completeCallWhenMatchIsFound() -{ - // Expectations that don't ignore parameters have higher fulfillment preference than those that ignore parameters - - matchingExpectation_ = potentiallyMatchingExpectations_.removeFirstFinalizedMatchingExpectation(); - if (matchingExpectation_) { - copyOutputParameters(matchingExpectation_); - callHasSucceeded(); - } else { - MockCheckedExpectedCall* matchingExpectationWithIgnoredParameters = potentiallyMatchingExpectations_.getFirstMatchingExpectation(); - if (matchingExpectationWithIgnoredParameters) { - copyOutputParameters(matchingExpectationWithIgnoredParameters); - } - } -} - -void MockCheckedActualCall::callHasSucceeded() -{ - setState(CALL_SUCCEED); -} - -void MockCheckedActualCall::discardCurrentlyMatchingExpectations() -{ - if (matchingExpectation_) - { - matchingExpectation_->resetActualCallMatchingState(); - matchingExpectation_ = NULLPTR; - } - potentiallyMatchingExpectations_.onlyKeepUnmatchingExpectations(); -} - -MockActualCall& MockCheckedActualCall::withName(const SimpleString& name) -{ - setName(name); - setState(CALL_IN_PROGRESS); - - potentiallyMatchingExpectations_.onlyKeepExpectationsRelatedTo(name); - if (potentiallyMatchingExpectations_.isEmpty()) { - MockUnexpectedCallHappenedFailure failure(getTest(), name, allExpectations_); - failTest(failure); - return *this; - } - - completeCallWhenMatchIsFound(); - - return *this; -} - -MockActualCall& MockCheckedActualCall::withCallOrder(unsigned int) -{ - return *this; -} - -void MockCheckedActualCall::checkInputParameter(const MockNamedValue& actualParameter) -{ - if(hasFailed()) - { - return; - } - - setState(CALL_IN_PROGRESS); - discardCurrentlyMatchingExpectations(); - - potentiallyMatchingExpectations_.onlyKeepExpectationsWithInputParameter(actualParameter); - - if (potentiallyMatchingExpectations_.isEmpty()) { - MockUnexpectedInputParameterFailure failure(getTest(), getName(), actualParameter, allExpectations_); - failTest(failure); - return; - } - - potentiallyMatchingExpectations_.parameterWasPassed(actualParameter.getName()); - completeCallWhenMatchIsFound(); -} - -void MockCheckedActualCall::checkOutputParameter(const MockNamedValue& outputParameter) -{ - if(hasFailed()) - { - return; - } - - setState(CALL_IN_PROGRESS); - discardCurrentlyMatchingExpectations(); - - potentiallyMatchingExpectations_.onlyKeepExpectationsWithOutputParameter(outputParameter); - - if (potentiallyMatchingExpectations_.isEmpty()) { - MockUnexpectedOutputParameterFailure failure(getTest(), getName(), outputParameter, allExpectations_); - failTest(failure); - return; - } - - potentiallyMatchingExpectations_.outputParameterWasPassed(outputParameter.getName()); - completeCallWhenMatchIsFound(); -} - -MockActualCall& MockCheckedActualCall::withBoolParameter(const SimpleString& name, bool value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withUnsignedIntParameter(const SimpleString& name, unsigned int value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withIntParameter(const SimpleString& name, int value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withLongIntParameter(const SimpleString& name, long int value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -#if CPPUTEST_USE_LONG_LONG - -MockActualCall& MockCheckedActualCall::withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -#else - -MockActualCall& MockCheckedActualCall::withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return *this; -} - -MockActualCall& MockCheckedActualCall::withLongLongIntParameter(const SimpleString&, cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return *this; -} - -#endif - -MockActualCall& MockCheckedActualCall::withDoubleParameter(const SimpleString& name, double value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withStringParameter(const SimpleString& name, const char* value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withPointerParameter(const SimpleString& name, void* value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withConstPointerParameter(const SimpleString& name, const void* value) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withFunctionPointerParameter(const SimpleString& name, void (*value)()) -{ - MockNamedValue actualParameter(name); - actualParameter.setValue(value); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) -{ - MockNamedValue actualParameter(name); - actualParameter.setMemoryBuffer(value, size); - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withParameterOfType(const SimpleString& type, const SimpleString& name, const void* value) -{ - MockNamedValue actualParameter(name); - actualParameter.setConstObjectPointer(type, value); - - if (actualParameter.getComparator() == NULLPTR) { - MockNoWayToCompareCustomTypeFailure failure(getTest(), type); - failTest(failure); - return *this; - } - checkInputParameter(actualParameter); - return *this; -} - -MockActualCall& MockCheckedActualCall::withOutputParameter(const SimpleString& name, void* output) -{ - addOutputParameter(name, "void*", output); - - MockNamedValue outputParameter(name); - outputParameter.setValue(output); - checkOutputParameter(outputParameter); - - return *this; -} - -MockActualCall& MockCheckedActualCall::withOutputParameterOfType(const SimpleString& type, const SimpleString& name, void* output) -{ - addOutputParameter(name, type, output); - - MockNamedValue outputParameter(name); - outputParameter.setConstObjectPointer(type, output); - checkOutputParameter(outputParameter); - - return *this; -} - -bool MockCheckedActualCall::isFulfilled() const -{ - return state_ == CALL_SUCCEED; -} - -bool MockCheckedActualCall::hasFailed() const -{ - return state_ == CALL_FAILED; -} - -void MockCheckedActualCall::checkExpectations() -{ - if(expectationsChecked_) { - return; - } - - expectationsChecked_ = true; - - if (state_ != CALL_IN_PROGRESS) { - if(state_ == CALL_SUCCEED) { - matchingExpectation_->callWasMade(callOrder_); - } - potentiallyMatchingExpectations_.resetActualCallMatchingState(); - return; - } - - if (potentiallyMatchingExpectations_.hasFinalizedMatchingExpectations()) - FAIL("Actual call is in progress, but there are finalized matching expectations when checking expectations. This cannot happen."); // LCOV_EXCL_LINE - - matchingExpectation_ = potentiallyMatchingExpectations_.removeFirstMatchingExpectation(); - if (matchingExpectation_) { - matchingExpectation_->finalizeActualCallMatch(); - callHasSucceeded(); - matchingExpectation_->callWasMade(callOrder_); - potentiallyMatchingExpectations_.resetActualCallMatchingState(); - return; - } - - if (potentiallyMatchingExpectations_.hasUnmatchingExpectationsBecauseOfMissingParameters()) { - MockExpectedParameterDidntHappenFailure failure(getTest(), getName(), allExpectations_, potentiallyMatchingExpectations_); - failTest(failure); - } - else { - MockExpectedObjectDidntHappenFailure failure(getTest(), getName(), allExpectations_); - failTest(failure); - } -} - -void MockCheckedActualCall::setState(ActualCallState state) -{ - state_ = state; -} - -MockNamedValue MockCheckedActualCall::returnValue() -{ - checkExpectations(); - if (matchingExpectation_) - return matchingExpectation_->returnValue(); - return MockNamedValue("no return value"); -} - -bool MockCheckedActualCall::returnBoolValueOrDefault(bool default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnBoolValue(); -} - -bool MockCheckedActualCall::returnBoolValue() -{ - return returnValue().getBoolValue(); -} - -int MockCheckedActualCall::returnIntValueOrDefault(int default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnIntValue(); -} - -int MockCheckedActualCall::returnIntValue() -{ - return returnValue().getIntValue(); -} - -unsigned long int MockCheckedActualCall::returnUnsignedLongIntValue() -{ - return returnValue().getUnsignedLongIntValue(); -} - -unsigned long int MockCheckedActualCall::returnUnsignedLongIntValueOrDefault(unsigned long int default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnUnsignedLongIntValue(); -} - -long int MockCheckedActualCall::returnLongIntValue() -{ - return returnValue().getLongIntValue(); -} - -long int MockCheckedActualCall::returnLongIntValueOrDefault(long int default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnLongIntValue(); -} - -#if CPPUTEST_USE_LONG_LONG - -cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValue() -{ - return returnValue().getUnsignedLongLongIntValue(); -} - -cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnUnsignedLongLongIntValue(); -} - -cpputest_longlong MockCheckedActualCall::returnLongLongIntValue() -{ - return returnValue().getLongLongIntValue(); -} - -cpputest_longlong MockCheckedActualCall::returnLongLongIntValueOrDefault(cpputest_longlong default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnLongLongIntValue(); -} - -#else - -cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValue() -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -cpputest_ulonglong MockCheckedActualCall::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong default_value) -{ - FAIL("Unsigned Long Long type is not supported"); - return default_value; -} - -cpputest_longlong MockCheckedActualCall::returnLongLongIntValue() -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_longlong MockCheckedActualCall::returnLongLongIntValueOrDefault(cpputest_longlong default_value) -{ - FAIL("Long Long type is not supported"); - return default_value; -} - -#endif - -double MockCheckedActualCall::returnDoubleValue() -{ - return returnValue().getDoubleValue(); -} - -double MockCheckedActualCall::returnDoubleValueOrDefault(double default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnDoubleValue(); -} - -unsigned int MockCheckedActualCall::returnUnsignedIntValue() -{ - return returnValue().getUnsignedIntValue(); -} - -unsigned int MockCheckedActualCall::returnUnsignedIntValueOrDefault(unsigned int default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnUnsignedIntValue(); -} - -void * MockCheckedActualCall::returnPointerValueOrDefault(void * default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnPointerValue(); -} - -void * MockCheckedActualCall::returnPointerValue() -{ - return returnValue().getPointerValue(); -} - -const void * MockCheckedActualCall::returnConstPointerValue() -{ - return returnValue().getConstPointerValue(); -} - -const void * MockCheckedActualCall::returnConstPointerValueOrDefault(const void * default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnConstPointerValue(); -} - -void (*MockCheckedActualCall::returnFunctionPointerValue())() -{ - return returnValue().getFunctionPointerValue(); -} - -void (*MockCheckedActualCall::returnFunctionPointerValueOrDefault(void (*default_value)()))() -{ - if (!hasReturnValue()) { - return default_value; - } - return returnFunctionPointerValue(); -} - -const char * MockCheckedActualCall::returnStringValueOrDefault(const char * default_value) -{ - if (!hasReturnValue()) { - return default_value; - } - return returnStringValue(); -} - -const char * MockCheckedActualCall::returnStringValue() -{ - return returnValue().getStringValue(); -} - -bool MockCheckedActualCall::hasReturnValue() -{ - return ! returnValue().getName().isEmpty(); -} - -MockActualCall& MockCheckedActualCall::onObject(const void* objectPtr) -{ - if(hasFailed()) { - return *this; - } - - // Currently matching expectations are not discarded because the passed object - // is ignored if not specifically set in the expectation - - potentiallyMatchingExpectations_.onlyKeepExpectationsOnObject(objectPtr); - - if ((!matchingExpectation_) && potentiallyMatchingExpectations_.isEmpty()) { - MockUnexpectedObjectFailure failure(getTest(), getName(), objectPtr, allExpectations_); - failTest(failure); - return *this; - } - - potentiallyMatchingExpectations_.wasPassedToObject(); - - if (!matchingExpectation_) { - completeCallWhenMatchIsFound(); - } - - return *this; -} - -void MockCheckedActualCall::addOutputParameter(const SimpleString& name, const SimpleString& type, void* ptr) -{ - MockOutputParametersListNode* newNode = new MockOutputParametersListNode(name, type, ptr); - - if (outputParameterExpectations_ == NULLPTR) - outputParameterExpectations_ = newNode; - else { - MockOutputParametersListNode* lastNode = outputParameterExpectations_; - while (lastNode->next_) lastNode = lastNode->next_; - lastNode->next_ = newNode; - } -} - -void MockCheckedActualCall::cleanUpOutputParameterList() -{ - MockOutputParametersListNode* current = outputParameterExpectations_; - MockOutputParametersListNode* toBeDeleted = NULLPTR; - - while (current) { - toBeDeleted = current; - outputParameterExpectations_ = current = current->next_; - delete toBeDeleted; - } -} - - -MockActualCallTrace::MockActualCallTrace() -{ -} - -MockActualCallTrace::~MockActualCallTrace() -{ -} - -MockActualCall& MockActualCallTrace::withName(const SimpleString& name) -{ - traceBuffer_ += "\nFunction name:"; - traceBuffer_ += name; - return *this; -} - -MockActualCall& MockActualCallTrace::withCallOrder(unsigned int callOrder) -{ - traceBuffer_ += " withCallOrder:"; - traceBuffer_ += StringFrom(callOrder); - return *this; -} - -void MockActualCallTrace::addParameterName(const SimpleString& name) -{ - traceBuffer_ += " "; - traceBuffer_ += name; - traceBuffer_ += ":"; -} - -MockActualCall& MockActualCallTrace::withBoolParameter(const SimpleString& name, bool value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withUnsignedIntParameter(const SimpleString& name, unsigned int value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withIntParameter(const SimpleString& name, int value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withLongIntParameter(const SimpleString& name, long int value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -#if CPPUTEST_USE_LONG_LONG - -MockActualCall& MockActualCallTrace::withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value) + " " + BracketsFormattedHexStringFrom(value); - return *this; -} - -#else - -MockActualCall& MockActualCallTrace::withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return *this; -} - -MockActualCall& MockActualCallTrace::withLongLongIntParameter(const SimpleString&, cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return *this; -} - -#endif - -MockActualCall& MockActualCallTrace::withDoubleParameter(const SimpleString& name, double value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withStringParameter(const SimpleString& name, const char* value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withPointerParameter(const SimpleString& name, void* value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withConstPointerParameter(const SimpleString& name, const void* value) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withFunctionPointerParameter(const SimpleString& name, void (*value)()) -{ - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) -{ - addParameterName(name); - traceBuffer_ += StringFromBinaryWithSizeOrNull(value, size); - return *this; -} - -MockActualCall& MockActualCallTrace::withParameterOfType(const SimpleString& typeName, const SimpleString& name, const void* value) -{ - traceBuffer_ += " "; - traceBuffer_ += typeName; - addParameterName(name); - traceBuffer_ += StringFrom(value); - return *this; -} - -MockActualCall& MockActualCallTrace::withOutputParameter(const SimpleString& name, void* output) -{ - addParameterName(name); - traceBuffer_ += StringFrom(output); - return *this; -} - -MockActualCall& MockActualCallTrace::withOutputParameterOfType(const SimpleString& typeName, const SimpleString& name, void* output) -{ - traceBuffer_ += " "; - traceBuffer_ += typeName; - addParameterName(name); - traceBuffer_ += StringFrom(output); - return *this; -} - -bool MockActualCallTrace::hasReturnValue() -{ - return false; -} - -MockNamedValue MockActualCallTrace::returnValue() -{ - return MockNamedValue(""); -} - -long int MockActualCallTrace::returnLongIntValue() -{ - return 0; -} - -unsigned long int MockActualCallTrace::returnUnsignedLongIntValue() -{ - return 0; -} - -unsigned long int MockActualCallTrace::returnUnsignedLongIntValueOrDefault(unsigned long) -{ - return 0; -} - -long int MockActualCallTrace::returnLongIntValueOrDefault(long int) -{ - return 0; -} - -#if CPPUTEST_USE_LONG_LONG - -cpputest_longlong MockActualCallTrace::returnLongLongIntValue() -{ - return 0; -} - -cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValue() -{ - return 0; -} - -cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong) -{ - return 0; -} - -cpputest_longlong MockActualCallTrace::returnLongLongIntValueOrDefault(cpputest_longlong) -{ - return 0; -} - -#else - -cpputest_longlong MockActualCallTrace::returnLongLongIntValue() -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValue() -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -cpputest_ulonglong MockActualCallTrace::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -cpputest_longlong MockActualCallTrace::returnLongLongIntValueOrDefault(cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -#endif - -bool MockActualCallTrace::returnBoolValue() -{ - return false; -} - -bool MockActualCallTrace::returnBoolValueOrDefault(bool) -{ - return false; -} - -int MockActualCallTrace::returnIntValue() -{ - return 0; -} - -double MockActualCallTrace::returnDoubleValue() -{ - return 0.0; -} - -double MockActualCallTrace::returnDoubleValueOrDefault(double) -{ - return returnDoubleValue(); -} - -unsigned int MockActualCallTrace::returnUnsignedIntValue() -{ - return 0; -} - -void * MockActualCallTrace::returnPointerValue() -{ - return NULLPTR; -} - -const void * MockActualCallTrace::returnConstPointerValue() -{ - return NULLPTR; -} - -void (*MockActualCallTrace::returnFunctionPointerValue())() -{ - return NULLPTR; -} - -const void * MockActualCallTrace::returnConstPointerValueOrDefault(const void *) -{ - return returnConstPointerValue(); -} - -void * MockActualCallTrace::returnPointerValueOrDefault(void *) -{ - return returnPointerValue(); -} - -void (*MockActualCallTrace::returnFunctionPointerValueOrDefault(void (*)()))() -{ - return returnFunctionPointerValue(); -} - -const char * MockActualCallTrace::returnStringValue() -{ - return ""; -} - -const char * MockActualCallTrace::returnStringValueOrDefault(const char *) -{ - return returnStringValue(); -} - -int MockActualCallTrace::returnIntValueOrDefault(int) -{ - return 0; -} - -unsigned int MockActualCallTrace::returnUnsignedIntValueOrDefault(unsigned int) -{ - return returnUnsignedIntValue(); -} - -MockActualCall& MockActualCallTrace::onObject(const void* objectPtr) -{ - traceBuffer_ += " onObject:"; - traceBuffer_ += StringFrom(objectPtr); - return *this; -} - -void MockActualCallTrace::clear() -{ - traceBuffer_ = ""; -} - -const char* MockActualCallTrace::getTraceOutput() -{ - return traceBuffer_.asCharString(); -} - -MockActualCallTrace* MockActualCallTrace::instance_ = NULLPTR; - -MockActualCallTrace& MockActualCallTrace::instance() -{ - if (instance_ == NULLPTR) - instance_ = new MockActualCallTrace; - return *instance_; -} - -void MockActualCallTrace::clearInstance() -{ - delete instance_; - instance_ = NULLPTR; -} - -MockIgnoredActualCall& MockIgnoredActualCall::instance() -{ - static MockIgnoredActualCall call; - return call; -} - diff --git a/src/CppUTestExt/MockExpectedCall.cpp b/src/CppUTestExt/MockExpectedCall.cpp deleted file mode 100644 index 2e11e7385..000000000 --- a/src/CppUTestExt/MockExpectedCall.cpp +++ /dev/null @@ -1,618 +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/TestHarness.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" - -MockExpectedCall::MockExpectedCall() -{ -} - -MockExpectedCall::~MockExpectedCall() -{ -} - -SimpleString StringFrom(const MockNamedValue& parameter) -{ - return parameter.toString(); -} - -void MockCheckedExpectedCall::setName(const SimpleString& name) -{ - functionName_ = name; -} - -SimpleString MockCheckedExpectedCall::getName() const -{ - return functionName_; -} - -MockCheckedExpectedCall::MockCheckedExpectedCall() - : ignoreOtherParameters_(false), isActualCallMatchFinalized_(false), - initialExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), finalExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), - outOfOrder_(false), returnValue_(""), objectPtr_(NULLPTR), isSpecificObjectExpected_(false), wasPassedToObject_(true), - actualCalls_(0), expectedCalls_(1) -{ - inputParameters_ = new MockNamedValueList(); - outputParameters_ = new MockNamedValueList(); -} - -MockCheckedExpectedCall::MockCheckedExpectedCall(unsigned int numCalls) - : ignoreOtherParameters_(false), isActualCallMatchFinalized_(false), - initialExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), finalExpectedCallOrder_(NO_EXPECTED_CALL_ORDER), - outOfOrder_(false), returnValue_(""), objectPtr_(NULLPTR), isSpecificObjectExpected_(false), wasPassedToObject_(true), - actualCalls_(0), expectedCalls_(numCalls) -{ - inputParameters_ = new MockNamedValueList(); - outputParameters_ = new MockNamedValueList(); -} - -MockCheckedExpectedCall::~MockCheckedExpectedCall() -{ - inputParameters_->clear(); - delete inputParameters_; - outputParameters_->clear(); - delete outputParameters_; -} - -MockExpectedCall& MockCheckedExpectedCall::withName(const SimpleString& name) -{ - setName(name); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withBoolParameter(const SimpleString& name, bool value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withUnsignedIntParameter(const SimpleString& name, unsigned int value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withIntParameter(const SimpleString& name, int value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withLongIntParameter(const SimpleString& name, long int value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withUnsignedLongIntParameter(const SimpleString& name, unsigned long int value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -#if CPPUTEST_USE_LONG_LONG - -MockExpectedCall& MockCheckedExpectedCall::withLongLongIntParameter(const SimpleString& name, cpputest_longlong value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withUnsignedLongLongIntParameter(const SimpleString& name, cpputest_ulonglong value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -#else - -MockExpectedCall& MockCheckedExpectedCall::withLongLongIntParameter(const SimpleString&, cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withUnsignedLongLongIntParameter(const SimpleString&, cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return *this; -} - -#endif - -MockExpectedCall& MockCheckedExpectedCall::withDoubleParameter(const SimpleString& name, double value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withDoubleParameter(const SimpleString& name, double value, double tolerance) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value, tolerance); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withStringParameter(const SimpleString& name, const char* value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withPointerParameter(const SimpleString& name, void* value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withConstPointerParameter(const SimpleString& name, const void* value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withFunctionPointerParameter(const SimpleString& name, void (*value)()) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withMemoryBufferParameter(const SimpleString& name, const unsigned char* value, size_t size) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setMemoryBuffer(value, size); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withParameterOfType(const SimpleString& type, const SimpleString& name, const void* value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - inputParameters_->add(newParameter); - newParameter->setConstObjectPointer(type, value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withOutputParameterReturning(const SimpleString& name, const void* value, size_t size) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - outputParameters_->add(newParameter); - newParameter->setValue(value); - newParameter->setSize(size); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withOutputParameterOfTypeReturning(const SimpleString& type, const SimpleString& name, const void* value) -{ - MockNamedValue* newParameter = new MockExpectedFunctionParameter(name); - outputParameters_->add(newParameter); - newParameter->setConstObjectPointer(type, value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::withUnmodifiedOutputParameter(const SimpleString& name) -{ - return withOutputParameterReturning(name, NULLPTR, 0); -} - -SimpleString MockCheckedExpectedCall::getInputParameterType(const SimpleString& name) -{ - MockNamedValue * p = inputParameters_->getValueByName(name); - return (p) ? p->getType() : StringFrom(""); -} - -bool MockCheckedExpectedCall::hasInputParameterWithName(const SimpleString& name) -{ - MockNamedValue * p = inputParameters_->getValueByName(name); - return p != NULLPTR; -} - -bool MockCheckedExpectedCall::hasOutputParameterWithName(const SimpleString& name) -{ - MockNamedValue * p = outputParameters_->getValueByName(name); - return p != NULLPTR; -} - -MockNamedValue MockCheckedExpectedCall::getInputParameter(const SimpleString& name) -{ - MockNamedValue * p = inputParameters_->getValueByName(name); - return (p) ? *p : MockNamedValue(""); -} - -MockNamedValue MockCheckedExpectedCall::getOutputParameter(const SimpleString& name) -{ - MockNamedValue * p = outputParameters_->getValueByName(name); - return (p) ? *p : MockNamedValue(""); -} - -bool MockCheckedExpectedCall::areParametersMatchingActualCall() -{ - MockNamedValueListNode* p; - for (p = inputParameters_->begin(); p; p = p->next()) - if (! item(p)->isMatchingActualCall()) - return false; - for (p = outputParameters_->begin(); p; p = p->next()) - if (! item(p)->isMatchingActualCall()) - return false; - return true; -} - -MockExpectedCall& MockCheckedExpectedCall::ignoreOtherParameters() -{ - ignoreOtherParameters_ = true; - return *this; -} - -bool MockCheckedExpectedCall::isFulfilled() -{ - return (actualCalls_ == expectedCalls_); -} - -bool MockCheckedExpectedCall::canMatchActualCalls() -{ - return (actualCalls_ < expectedCalls_); -} - -bool MockCheckedExpectedCall::isMatchingActualCallAndFinalized() -{ - return isMatchingActualCall() && (!ignoreOtherParameters_ || isActualCallMatchFinalized_); -} - -bool MockCheckedExpectedCall::isMatchingActualCall() -{ - return areParametersMatchingActualCall() && wasPassedToObject_; -} - -void MockCheckedExpectedCall::callWasMade(unsigned int callOrder) -{ - actualCalls_++; - - if ( (initialExpectedCallOrder_ != NO_EXPECTED_CALL_ORDER) && - ((callOrder < initialExpectedCallOrder_) || (callOrder > finalExpectedCallOrder_)) ) { - outOfOrder_ = true; - } - - resetActualCallMatchingState(); -} - -void MockCheckedExpectedCall::finalizeActualCallMatch() -{ - isActualCallMatchFinalized_ = true; -} - - -void MockCheckedExpectedCall::wasPassedToObject() -{ - wasPassedToObject_ = true; -} - -void MockCheckedExpectedCall::resetActualCallMatchingState() -{ - wasPassedToObject_ = !isSpecificObjectExpected_; - isActualCallMatchFinalized_ = false; - - MockNamedValueListNode* p; - - for (p = inputParameters_->begin(); p; p = p->next()) - item(p)->setMatchesActualCall(false); - for (p = outputParameters_->begin(); p; p = p->next()) - item(p)->setMatchesActualCall(false); -} - -void MockCheckedExpectedCall::inputParameterWasPassed(const SimpleString& name) -{ - for (MockNamedValueListNode* p = inputParameters_->begin(); p; p = p->next()) { - if (p->getName() == name) - item(p)->setMatchesActualCall(true); - } -} - -void MockCheckedExpectedCall::outputParameterWasPassed(const SimpleString& name) -{ - for (MockNamedValueListNode* p = outputParameters_->begin(); p; p = p->next()) { - if (p->getName() == name) - item(p)->setMatchesActualCall(true); - } -} - -SimpleString MockCheckedExpectedCall::getInputParameterValueString(const SimpleString& name) -{ - MockNamedValue * p = inputParameters_->getValueByName(name); - return (p) ? StringFrom(*p) : StringFrom("failed"); -} - -bool MockCheckedExpectedCall::hasInputParameter(const MockNamedValue& parameter) -{ - MockNamedValue * p = inputParameters_->getValueByName(parameter.getName()); - return (p) ? p->equals(parameter) : ignoreOtherParameters_; -} - -bool MockCheckedExpectedCall::hasOutputParameter(const MockNamedValue& parameter) -{ - MockNamedValue * p = outputParameters_->getValueByName(parameter.getName()); - return (p) ? p->compatibleForCopying(parameter) : ignoreOtherParameters_; -} - -SimpleString MockCheckedExpectedCall::callToString() -{ - SimpleString str; - if (isSpecificObjectExpected_) - str = StringFromFormat("(object address: %p)::", objectPtr_); - - str += getName(); - str += " -> "; - if (initialExpectedCallOrder_ != NO_EXPECTED_CALL_ORDER) { - if (initialExpectedCallOrder_ == finalExpectedCallOrder_) { - str += StringFromFormat("expected call order: <%u> -> ", initialExpectedCallOrder_); - } else { - str += StringFromFormat("expected calls order: <%u..%u> -> ", initialExpectedCallOrder_, finalExpectedCallOrder_); - } - } - - if (inputParameters_->begin() == NULLPTR && outputParameters_->begin() == NULLPTR) { - str += (ignoreOtherParameters_) ? "all parameters ignored" : "no parameters"; - } else { - MockNamedValueListNode* p; - - for (p = inputParameters_->begin(); p; p = p->next()) { - str += StringFromFormat("%s %s: <%s>", p->getType().asCharString(), p->getName().asCharString(), getInputParameterValueString(p->getName()).asCharString()); - if (p->next()) str += ", "; - } - - if (inputParameters_->begin() && outputParameters_->begin()) - { - str += ", "; - } - - for (p = outputParameters_->begin(); p; p = p->next()) { - str += StringFromFormat("%s %s: ", p->getType().asCharString(), p->getName().asCharString()); - if (p->next()) str += ", "; - } - - if (ignoreOtherParameters_) - str += ", other parameters are ignored"; - } - - str += StringFromFormat(" (expected %u call%s, called %u time%s)", - expectedCalls_, (expectedCalls_ == 1) ? "" : "s", actualCalls_, (actualCalls_ == 1) ? "" : "s" ); - - return str; -} - -SimpleString MockCheckedExpectedCall::missingParametersToString() -{ - SimpleString str; - MockNamedValueListNode* p; - - for (p = inputParameters_->begin(); p; p = p->next()) { - if (! item(p)->isMatchingActualCall()) { - if (str != "") str += ", "; - str += StringFromFormat("%s %s", p->getType().asCharString(), p->getName().asCharString()); - } - } - for (p = outputParameters_->begin(); p; p = p->next()) { - if (! item(p)->isMatchingActualCall()) { - if (str != "") str += ", "; - str += StringFromFormat("%s %s", p->getType().asCharString(), p->getName().asCharString()); - } - } - return str; -} - -bool MockCheckedExpectedCall::relatesTo(const SimpleString& functionName) -{ - return functionName == getName(); -} - -bool MockCheckedExpectedCall::relatesToObject(const void* objectPtr) const -{ - return (!isSpecificObjectExpected_) || (objectPtr_ == objectPtr); -} - -MockCheckedExpectedCall::MockExpectedFunctionParameter* MockCheckedExpectedCall::item(MockNamedValueListNode* node) -{ - return (MockExpectedFunctionParameter*) node->item(); -} - -MockCheckedExpectedCall::MockExpectedFunctionParameter::MockExpectedFunctionParameter(const SimpleString& name) - : MockNamedValue(name), matchesActualCall_(false) -{ -} - -void MockCheckedExpectedCall::MockExpectedFunctionParameter::setMatchesActualCall(bool b) -{ - matchesActualCall_ = b; -} - -bool MockCheckedExpectedCall::MockExpectedFunctionParameter::isMatchingActualCall() const -{ - return matchesActualCall_; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(bool value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(unsigned int value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(int value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(long int value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(unsigned long int value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -#if CPPUTEST_USE_LONG_LONG - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(cpputest_longlong value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(cpputest_ulonglong value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -#else - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return *this; -} - -#endif - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(const char* value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(double value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(void* value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(const void* value) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::andReturnValue(void (*value)()) -{ - returnValue_.setName("returnValue"); - returnValue_.setValue(value); - return *this; -} - -MockExpectedCall& MockCheckedExpectedCall::onObject(void* objectPtr) -{ - isSpecificObjectExpected_ = true; - wasPassedToObject_ = false; - objectPtr_ = objectPtr; - return *this; -} - -MockNamedValue MockCheckedExpectedCall::returnValue() -{ - return returnValue_; -} - -MockExpectedCall& MockCheckedExpectedCall::withCallOrder(unsigned int initialCallOrder, unsigned int finalCallOrder) -{ - initialExpectedCallOrder_ = initialCallOrder; - finalExpectedCallOrder_ = finalCallOrder; - return *this; -} - -bool MockCheckedExpectedCall::isOutOfOrder() const -{ - return outOfOrder_; -} - -unsigned int MockCheckedExpectedCall::getActualCallsFulfilled() const -{ - return actualCalls_; -} - -MockExpectedCall& MockIgnoredExpectedCall::instance() -{ - static MockIgnoredExpectedCall call; - return call; -} diff --git a/src/CppUTestExt/MockExpectedCallsList.cpp b/src/CppUTestExt/MockExpectedCallsList.cpp deleted file mode 100644 index dd2970d7d..000000000 --- a/src/CppUTestExt/MockExpectedCallsList.cpp +++ /dev/null @@ -1,367 +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/TestHarness.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" - -MockExpectedCallsList::MockExpectedCallsList() : head_(NULLPTR) -{ -} - -MockExpectedCallsList::~MockExpectedCallsList() -{ - while (head_) { - MockExpectedCallsListNode* next = head_->next_; - delete head_; - head_ = next; - } -} - -bool MockExpectedCallsList::hasCallsOutOfOrder() const -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (p->expectedCall_->isOutOfOrder()) - return true; - return false; -} - -unsigned int MockExpectedCallsList::size() const -{ - unsigned int count = 0; - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - count++; - return count; -} - -bool MockExpectedCallsList::isEmpty() const -{ - return head_ == NULLPTR; -} - -unsigned int MockExpectedCallsList::amountOfActualCallsFulfilledFor(const SimpleString& name) const -{ - unsigned int count = 0; - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (p->expectedCall_->relatesTo(name)) { - count += p->expectedCall_->getActualCallsFulfilled(); - } - } - return count; -} - -unsigned int MockExpectedCallsList::amountOfUnfulfilledExpectations() const -{ - unsigned int count = 0; - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->isFulfilled()) count++; - return count; -} - -bool MockExpectedCallsList::hasFinalizedMatchingExpectations() const -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (p->expectedCall_->isMatchingActualCallAndFinalized()) { - return true; - } - } - return false; -} - -bool MockExpectedCallsList::hasUnfulfilledExpectations() const -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (!p->expectedCall_->isFulfilled()) { - return true; - } - } - return false; -} - -bool MockExpectedCallsList::hasExpectationWithName(const SimpleString& name) const -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (p->expectedCall_->relatesTo(name)) - return true; - return false; -} - -void MockExpectedCallsList::addExpectedCall(MockCheckedExpectedCall* call) -{ - MockExpectedCallsListNode* newCall = new MockExpectedCallsListNode(call); - - if (head_ == NULLPTR) - head_ = newCall; - else { - MockExpectedCallsListNode* lastCall = head_; - while (lastCall->next_) lastCall = lastCall->next_; - lastCall->next_ = newCall; - } -} - -void MockExpectedCallsList::addPotentiallyMatchingExpectations(const MockExpectedCallsList& list) -{ - for (MockExpectedCallsListNode* p = list.head_; p; p = p->next_) - if (p->expectedCall_->canMatchActualCalls()) - addExpectedCall(p->expectedCall_); -} - -void MockExpectedCallsList::addExpectationsRelatedTo(const SimpleString& name, const MockExpectedCallsList& list) -{ - for (MockExpectedCallsListNode* p = list.head_; p; p = p->next_) - if (p->expectedCall_->relatesTo(name)) - addExpectedCall(p->expectedCall_); -} - -void MockExpectedCallsList::addExpectations(const MockExpectedCallsList& list) -{ - for (MockExpectedCallsListNode* p = list.head_; p; p = p->next_) - addExpectedCall(p->expectedCall_); -} - -void MockExpectedCallsList::onlyKeepExpectationsRelatedTo(const SimpleString& name) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->relatesTo(name)) - p->expectedCall_ = NULLPTR; - - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepOutOfOrderExpectations() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (!p->expectedCall_->isOutOfOrder()) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepUnmatchingExpectations() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (p->expectedCall_->isMatchingActualCallAndFinalized()) - { - p->expectedCall_->resetActualCallMatchingState(); - p->expectedCall_ = NULLPTR; - } - - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepExpectationsWithInputParameterName(const SimpleString& name) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->hasInputParameterWithName(name)) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameterName(const SimpleString& name) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->hasOutputParameterWithName(name)) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepExpectationsWithInputParameter(const MockNamedValue& parameter) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->hasInputParameter(parameter)) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepExpectationsWithOutputParameter(const MockNamedValue& parameter) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->hasOutputParameter(parameter)) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -void MockExpectedCallsList::onlyKeepExpectationsOnObject(const void* objectPtr) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->relatesToObject(objectPtr)) - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); -} - -MockCheckedExpectedCall* MockExpectedCallsList::removeFirstFinalizedMatchingExpectation() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (p->expectedCall_->isMatchingActualCallAndFinalized()) { - MockCheckedExpectedCall* matchingCall = p->expectedCall_; - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); - return matchingCall; - } - } - return NULLPTR; -} - -MockCheckedExpectedCall* MockExpectedCallsList::getFirstMatchingExpectation() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (p->expectedCall_->isMatchingActualCall()) { - return p->expectedCall_; - } - } - return NULLPTR; -} - -MockCheckedExpectedCall* MockExpectedCallsList::removeFirstMatchingExpectation() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) { - if (p->expectedCall_->isMatchingActualCall()) { - MockCheckedExpectedCall* matchingCall = p->expectedCall_; - p->expectedCall_ = NULLPTR; - pruneEmptyNodeFromList(); - return matchingCall; - } - } - return NULLPTR; -} - -void MockExpectedCallsList::pruneEmptyNodeFromList() -{ - MockExpectedCallsListNode* current = head_; - MockExpectedCallsListNode* previous = NULLPTR; - MockExpectedCallsListNode* toBeDeleted = NULLPTR; - - while (current) { - if (current->expectedCall_ == NULLPTR) { - toBeDeleted = current; - if (previous == NULLPTR) - head_ = current = current->next_; - else - current = previous->next_ = current->next_; - delete toBeDeleted; - } - else { - previous = current; - current = current->next_; - } - } -} - -void MockExpectedCallsList::deleteAllExpectationsAndClearList() -{ - while (head_) { - MockExpectedCallsListNode* next = head_->next_; - delete head_->expectedCall_; - delete head_; - head_ = next; - } -} - -void MockExpectedCallsList::resetActualCallMatchingState() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - p->expectedCall_->resetActualCallMatchingState(); -} - -void MockExpectedCallsList::wasPassedToObject() -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - p->expectedCall_->wasPassedToObject(); -} - - -void MockExpectedCallsList::parameterWasPassed(const SimpleString& parameterName) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - p->expectedCall_->inputParameterWasPassed(parameterName); -} - -void MockExpectedCallsList::outputParameterWasPassed(const SimpleString& parameterName) -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - p->expectedCall_->outputParameterWasPassed(parameterName); -} - -static SimpleString stringOrNoneTextWhenEmpty(const SimpleString& inputString, const SimpleString& linePrefix) -{ - SimpleString str = inputString; - if (str == "") { - str += linePrefix; - str += ""; - } - return str; -} - -static SimpleString appendStringOnANewLine(const SimpleString& inputString, const SimpleString& linePrefix, const SimpleString& stringToAppend) -{ - SimpleString str = inputString; - if (str != "") str += "\n"; - str += linePrefix; - str += stringToAppend; - return str; -} - -SimpleString MockExpectedCallsList::unfulfilledCallsToString(const SimpleString& linePrefix) const -{ - SimpleString str; - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (!p->expectedCall_->isFulfilled()) - str = appendStringOnANewLine(str, linePrefix, p->expectedCall_->callToString()); - return stringOrNoneTextWhenEmpty(str, linePrefix); -} - -SimpleString MockExpectedCallsList::fulfilledCallsToString(const SimpleString& linePrefix) const -{ - SimpleString str; - - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (p->expectedCall_->isFulfilled()) - str = appendStringOnANewLine(str, linePrefix, p->expectedCall_->callToString()); - - return stringOrNoneTextWhenEmpty(str, linePrefix); -} - -SimpleString MockExpectedCallsList::callsWithMissingParametersToString(const SimpleString& linePrefix, - const SimpleString& missingParametersPrefix) const -{ - SimpleString str; - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - { - str = appendStringOnANewLine(str, linePrefix, p->expectedCall_->callToString()); - str = appendStringOnANewLine(str, linePrefix + missingParametersPrefix, p->expectedCall_->missingParametersToString()); - } - - return stringOrNoneTextWhenEmpty(str, linePrefix); -} - -bool MockExpectedCallsList::hasUnmatchingExpectationsBecauseOfMissingParameters() const -{ - for (MockExpectedCallsListNode* p = head_; p; p = p->next_) - if (! p->expectedCall_->areParametersMatchingActualCall()) - return true; - return false; -} - diff --git a/src/CppUTestExt/MockFailure.cpp b/src/CppUTestExt/MockFailure.cpp deleted file mode 100644 index 1c0a40f4f..000000000 --- a/src/CppUTestExt/MockFailure.cpp +++ /dev/null @@ -1,242 +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/TestHarness.h" -#include "CppUTestExt/MockFailure.h" -#include "CppUTestExt/MockExpectedCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "CppUTestExt/MockNamedValue.h" - -class MockFailureReporterTestTerminator : public TestTerminator -{ -public: - MockFailureReporterTestTerminator(bool crashOnFailure) : crashOnFailure_(crashOnFailure) - { - } - - virtual void exitCurrentTest() const CPPUTEST_OVERRIDE - { - if (crashOnFailure_) - UT_CRASH(); - - UtestShell::getCurrentTestTerminator().exitCurrentTest(); - } // LCOV_EXCL_LINE - - virtual ~MockFailureReporterTestTerminator() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } -private: - bool crashOnFailure_; - -}; - -void MockFailureReporter::failTest(const MockFailure& failure) -{ - if (!getTestToFail()->hasFailed()) - getTestToFail()->failWith(failure, MockFailureReporterTestTerminator(crashOnFailure_)); -} // LCOV_EXCL_LINE - -UtestShell* MockFailureReporter::getTestToFail() -{ - return UtestShell::getCurrent(); -} - -MockFailure::MockFailure(UtestShell* test) : TestFailure(test, "Test failed with MockFailure without an error! Something went seriously wrong.") -{ -} - -void MockFailure::addExpectationsAndCallHistory(const MockExpectedCallsList& expectations) -{ - message_ += "\tEXPECTED calls that WERE NOT fulfilled:\n"; - message_ += expectations.unfulfilledCallsToString("\t\t"); - message_ += "\n\tEXPECTED calls that WERE fulfilled:\n"; - message_ += expectations.fulfilledCallsToString("\t\t"); -} - -void MockFailure::addExpectationsAndCallHistoryRelatedTo(const SimpleString& name, const MockExpectedCallsList& expectations) -{ - MockExpectedCallsList expectationsForFunction; - expectationsForFunction.addExpectationsRelatedTo(name, expectations); - - message_ += "\tEXPECTED calls that WERE NOT fulfilled related to function: "; - message_ += name; - message_ += "\n"; - - message_ += expectationsForFunction.unfulfilledCallsToString("\t\t"); - - message_ += "\n\tEXPECTED calls that WERE fulfilled related to function: "; - message_ += name; - message_ += "\n"; - - message_ += expectationsForFunction.fulfilledCallsToString("\t\t"); -} - -MockExpectedCallsDidntHappenFailure::MockExpectedCallsDidntHappenFailure(UtestShell* test, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - message_ = "Mock Failure: Expected call WAS NOT fulfilled.\n"; - addExpectationsAndCallHistory(expectations); -} - -MockUnexpectedCallHappenedFailure::MockUnexpectedCallHappenedFailure(UtestShell* test, const SimpleString& name, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - unsigned int amountOfActualCalls = expectations.amountOfActualCallsFulfilledFor(name); - if (amountOfActualCalls > 0) { - SimpleString ordinalNumber = StringFromOrdinalNumber(amountOfActualCalls + 1); - message_ = StringFromFormat("Mock Failure: Unexpected additional (%s) call to function: ", ordinalNumber.asCharString()); - } else { - message_ = "Mock Failure: Unexpected call to function: "; - } - message_ += name; - message_ += "\n"; - addExpectationsAndCallHistory(expectations); -} - -MockCallOrderFailure::MockCallOrderFailure(UtestShell* test, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - MockExpectedCallsList expectationsForOutOfOrder; - expectationsForOutOfOrder.addExpectations(expectations); - expectationsForOutOfOrder.onlyKeepOutOfOrderExpectations(); - - message_ = "Mock Failure: Out of order calls"; - message_ += "\n"; - addExpectationsAndCallHistory(expectationsForOutOfOrder); -} - -MockUnexpectedInputParameterFailure::MockUnexpectedInputParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - MockExpectedCallsList expectationsForFunctionWithParameterName; - expectationsForFunctionWithParameterName.addExpectationsRelatedTo(functionName, expectations); - expectationsForFunctionWithParameterName.onlyKeepExpectationsWithInputParameterName(parameter.getName()); - - if (expectationsForFunctionWithParameterName.isEmpty()) { - message_ = "Mock Failure: Unexpected parameter name to function \""; - message_ += functionName; - message_ += "\": "; - message_ += parameter.getName(); - } - else { - message_ = "Mock Failure: Unexpected parameter value to parameter \""; - message_ += parameter.getName(); - message_ += "\" to function \""; - message_ += functionName; - message_ += "\": <"; - message_ += StringFrom(parameter); - message_ += ">"; - } - - message_ += "\n"; - addExpectationsAndCallHistoryRelatedTo(functionName, expectations); - - message_ += "\n\tACTUAL unexpected parameter passed to function: "; - message_ += functionName; - message_ += "\n"; - - message_ += "\t\t"; - message_ += parameter.getType(); - message_ += " "; - message_ += parameter.getName(); - message_ += ": <"; - message_ += StringFrom(parameter); - message_ += ">"; -} - -MockUnexpectedOutputParameterFailure::MockUnexpectedOutputParameterFailure(UtestShell* test, const SimpleString& functionName, const MockNamedValue& parameter, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - MockExpectedCallsList expectationsForFunctionWithParameterName; - expectationsForFunctionWithParameterName.addExpectationsRelatedTo(functionName, expectations); - expectationsForFunctionWithParameterName.onlyKeepExpectationsWithOutputParameterName(parameter.getName()); - - if (expectationsForFunctionWithParameterName.isEmpty()) { - message_ = "Mock Failure: Unexpected output parameter name to function \""; - message_ += functionName; - message_ += "\": "; - message_ += parameter.getName(); - } - else { - message_ = "Mock Failure: Unexpected parameter type \""; - message_ += parameter.getType(); - message_ += "\" to output parameter \""; - message_ += parameter.getName(); - message_ += "\" to function \""; - message_ += functionName; - message_ += "\""; - } - - message_ += "\n"; - addExpectationsAndCallHistoryRelatedTo(functionName, expectations); - - message_ += "\n\tACTUAL unexpected output parameter passed to function: "; - message_ += functionName; - message_ += "\n"; - - message_ += "\t\t"; - message_ += parameter.getType(); - message_ += " "; - message_ += parameter.getName(); -} - -MockExpectedParameterDidntHappenFailure::MockExpectedParameterDidntHappenFailure(UtestShell* test, const SimpleString& functionName, - const MockExpectedCallsList& allExpectations, - const MockExpectedCallsList& matchingExpectations) : MockFailure(test) -{ - message_ = "Mock Failure: Expected parameter for function \""; - message_ += functionName; - message_ += "\" did not happen.\n"; - - message_ += "\tEXPECTED calls with MISSING parameters related to function: "; - message_ += functionName; - message_ += "\n"; - message_ += matchingExpectations.callsWithMissingParametersToString("\t\t", "\tMISSING parameters: "); - message_ += "\n"; - - addExpectationsAndCallHistoryRelatedTo(functionName, allExpectations); -} - -MockNoWayToCompareCustomTypeFailure::MockNoWayToCompareCustomTypeFailure(UtestShell* test, const SimpleString& typeName) : MockFailure(test) -{ - message_ = StringFromFormat("MockFailure: No way to compare type <%s>. Please install a MockNamedValueComparator.", typeName.asCharString()); -} - -MockNoWayToCopyCustomTypeFailure::MockNoWayToCopyCustomTypeFailure(UtestShell* test, const SimpleString& typeName) : MockFailure(test) -{ - message_ = StringFromFormat("MockFailure: No way to copy type <%s>. Please install a MockNamedValueCopier.", typeName.asCharString()); -} - -MockUnexpectedObjectFailure::MockUnexpectedObjectFailure(UtestShell* test, const SimpleString& functionName, const void* actual, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - message_ = StringFromFormat ("MockFailure: Function called on an unexpected object: %s\n" - "\tActual object for call has address: <%p>\n", functionName.asCharString(),actual); - addExpectationsAndCallHistoryRelatedTo(functionName, expectations); -} - -MockExpectedObjectDidntHappenFailure::MockExpectedObjectDidntHappenFailure(UtestShell* test, const SimpleString& functionName, const MockExpectedCallsList& expectations) : MockFailure(test) -{ - message_ = StringFromFormat("Mock Failure: Expected call on object for function \"%s\" but it did not happen.\n", functionName.asCharString()); - addExpectationsAndCallHistoryRelatedTo(functionName, expectations); -} - - diff --git a/src/CppUTestExt/MockNamedValue.cpp b/src/CppUTestExt/MockNamedValue.cpp deleted file mode 100644 index 2d4f1d1a0..000000000 --- a/src/CppUTestExt/MockNamedValue.cpp +++ /dev/null @@ -1,662 +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/TestHarness.h" -#include "CppUTestExt/MockNamedValue.h" -#include "CppUTest/PlatformSpecificFunctions.h" - - -MockNamedValueComparatorsAndCopiersRepository* MockNamedValue::defaultRepository_ = NULLPTR; -const double MockNamedValue::defaultDoubleTolerance = 0.005; - -void MockNamedValue::setDefaultComparatorsAndCopiersRepository(MockNamedValueComparatorsAndCopiersRepository* repository) -{ - defaultRepository_ = repository; -} - -MockNamedValueComparatorsAndCopiersRepository* MockNamedValue::getDefaultComparatorsAndCopiersRepository() -{ - return defaultRepository_; -} - -MockNamedValue::MockNamedValue(const SimpleString& name) : name_(name), type_("int"), size_(0), comparator_(NULLPTR), copier_(NULLPTR) -{ - value_.intValue_ = 0; -} - -MockNamedValue::~MockNamedValue() -{ -} - -void MockNamedValue::setValue(bool value) -{ - type_ = "bool"; - value_.boolValue_ = value; -} - -void MockNamedValue::setValue(unsigned int value) -{ - type_ = "unsigned int"; - value_.unsignedIntValue_ = value; -} - -void MockNamedValue::setValue(int value) -{ - type_ = "int"; - value_.intValue_ = value; -} - -void MockNamedValue::setValue(long int value) -{ - type_ = "long int"; - value_.longIntValue_ = value; -} - -void MockNamedValue::setValue(unsigned long int value) -{ - type_ = "unsigned long int"; - value_.unsignedLongIntValue_ = value; -} - -#if CPPUTEST_USE_LONG_LONG - -void MockNamedValue::setValue(cpputest_longlong value) -{ - type_ = "long long int"; - value_.longLongIntValue_ = value; -} - -void MockNamedValue::setValue(cpputest_ulonglong value) -{ - type_ = "unsigned long long int"; - value_.unsignedLongLongIntValue_ = value; -} - -#else - -void MockNamedValue::setValue(cpputest_longlong) -{ - FAIL("Long Long type is not supported"); -} - -void MockNamedValue::setValue(cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); -} - -#endif - -void MockNamedValue::setValue(double value) -{ - setValue(value, defaultDoubleTolerance); -} - -void MockNamedValue::setValue(double value, double tolerance) -{ - type_ = "double"; - value_.doubleValue_.value = value; - value_.doubleValue_.tolerance = tolerance; -} - -void MockNamedValue::setValue(void* value) -{ - type_ = "void*"; - value_.pointerValue_ = value; -} - -void MockNamedValue::setValue(const void* value) -{ - type_ = "const void*"; - value_.constPointerValue_ = value; -} - -void MockNamedValue::setValue(void (*value)()) -{ - type_ = "void (*)()"; - value_.functionPointerValue_ = value; -} - -void MockNamedValue::setValue(const char* value) -{ - type_ = "const char*"; - value_.stringValue_ = value; -} - -void MockNamedValue::setMemoryBuffer(const unsigned char* value, size_t size) -{ - type_ = "const unsigned char*"; - value_.memoryBufferValue_ = value; - size_ = size; -} - -void MockNamedValue::setConstObjectPointer(const SimpleString& type, const void* objectPtr) -{ - type_ = type; - value_.constObjectPointerValue_ = objectPtr; - if (defaultRepository_) - { - comparator_ = defaultRepository_->getComparatorForType(type); - copier_ = defaultRepository_->getCopierForType(type); - } -} - -void MockNamedValue::setObjectPointer(const SimpleString& type, void* objectPtr) -{ - type_ = type; - value_.objectPointerValue_ = objectPtr; - if (defaultRepository_) - { - comparator_ = defaultRepository_->getComparatorForType(type); - copier_ = defaultRepository_->getCopierForType(type); - } -} - -void MockNamedValue::setSize(size_t size) -{ - size_ = size; -} - -void MockNamedValue::setName(const char* name) -{ - name_ = name; -} - -SimpleString MockNamedValue::getName() const -{ - return name_; -} - -SimpleString MockNamedValue::getType() const -{ - return type_; -} - -bool MockNamedValue::getBoolValue() const -{ - STRCMP_EQUAL("bool", type_.asCharString()); - return value_.boolValue_; -} - -unsigned int MockNamedValue::getUnsignedIntValue() const -{ - if(type_ == "int" && value_.intValue_ >= 0) - return (unsigned int)value_.intValue_; - else - { - STRCMP_EQUAL("unsigned int", type_.asCharString()); - return value_.unsignedIntValue_; - } -} - -int MockNamedValue::getIntValue() const -{ - STRCMP_EQUAL("int", type_.asCharString()); - return value_.intValue_; -} - -long int MockNamedValue::getLongIntValue() const -{ - if(type_ == "int") - return value_.intValue_; - else if(type_ == "unsigned int") - return (long int)value_.unsignedIntValue_; - else - { - STRCMP_EQUAL("long int", type_.asCharString()); - return value_.longIntValue_; - } -} - -unsigned long int MockNamedValue::getUnsignedLongIntValue() const -{ - if(type_ == "unsigned int") - return value_.unsignedIntValue_; - else if(type_ == "int" && value_.intValue_ >= 0) - return (unsigned long int)value_.intValue_; - else if(type_ == "long int" && value_.longIntValue_ >= 0) - return (unsigned long int)value_.longIntValue_; - else - { - STRCMP_EQUAL("unsigned long int", type_.asCharString()); - return value_.unsignedLongIntValue_; - } -} - -#if CPPUTEST_USE_LONG_LONG - -cpputest_longlong MockNamedValue::getLongLongIntValue() const -{ - if(type_ == "int") - return value_.intValue_; - else if(type_ == "unsigned int") - return (long long int)value_.unsignedIntValue_; - else if(type_ == "long int") - return value_.longIntValue_; - else if(type_ == "unsigned long int") - return (long long int)value_.unsignedLongIntValue_; - else - { - STRCMP_EQUAL("long long int", type_.asCharString()); - return value_.longLongIntValue_; - } -} - -cpputest_ulonglong MockNamedValue::getUnsignedLongLongIntValue() const -{ - if(type_ == "unsigned int") - return value_.unsignedIntValue_; - else if(type_ == "int" && value_.intValue_ >= 0) - return (unsigned long long int)value_.intValue_; - else if(type_ == "long int" && value_.longIntValue_ >= 0) - return (unsigned long long int)value_.longIntValue_; - else if(type_ == "unsigned long int") - return value_.unsignedLongIntValue_; - else if(type_ == "long long int" && value_.longLongIntValue_ >= 0) - return (unsigned long long int)value_.longLongIntValue_; - else - { - STRCMP_EQUAL("unsigned long long int", type_.asCharString()); - return value_.unsignedLongLongIntValue_; - } -} - -#else - -cpputest_longlong MockNamedValue::getLongLongIntValue() const -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_ulonglong MockNamedValue::getUnsignedLongLongIntValue() const -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -#endif - -double MockNamedValue::getDoubleValue() const -{ - STRCMP_EQUAL("double", type_.asCharString()); - return value_.doubleValue_.value; -} - -double MockNamedValue::getDoubleTolerance() const -{ - STRCMP_EQUAL("double", type_.asCharString()); - return value_.doubleValue_.tolerance; -} - -const char* MockNamedValue::getStringValue() const -{ - STRCMP_EQUAL("const char*", type_.asCharString()); - return value_.stringValue_; -} - -void* MockNamedValue::getPointerValue() const -{ - STRCMP_EQUAL("void*", type_.asCharString()); - return value_.pointerValue_; -} - -const void* MockNamedValue::getConstPointerValue() const -{ - STRCMP_EQUAL("const void*", type_.asCharString()); - return value_.pointerValue_; -} - -void (*MockNamedValue::getFunctionPointerValue() const)() -{ - STRCMP_EQUAL("void (*)()", type_.asCharString()); - return value_.functionPointerValue_; -} - -const unsigned char* MockNamedValue::getMemoryBuffer() const -{ - STRCMP_EQUAL("const unsigned char*", type_.asCharString()); - return value_.memoryBufferValue_; -} - -const void* MockNamedValue::getConstObjectPointer() const -{ - return value_.constObjectPointerValue_; -} - -void* MockNamedValue::getObjectPointer() const -{ - return value_.objectPointerValue_; -} - -size_t MockNamedValue::getSize() const -{ - return size_; -} - -MockNamedValueComparator* MockNamedValue::getComparator() const -{ - return comparator_; -} - -MockNamedValueCopier* MockNamedValue::getCopier() const -{ - return copier_; -} - -bool MockNamedValue::equals(const MockNamedValue& p) const -{ - if((type_ == "long int") && (p.type_ == "int")) - return value_.longIntValue_ == p.value_.intValue_; - else if((type_ == "int") && (p.type_ == "long int")) - return value_.intValue_ == p.value_.longIntValue_; - else if((type_ == "unsigned int") && (p.type_ == "int")) - return (p.value_.intValue_ >= 0) && (value_.unsignedIntValue_ == (unsigned int)p.value_.intValue_); - else if((type_ == "int") && (p.type_ == "unsigned int")) - return (value_.intValue_ >= 0) && ((unsigned int)value_.intValue_ == p.value_.unsignedIntValue_); - else if((type_ == "unsigned long int") && (p.type_ == "int")) - return (p.value_.intValue_ >= 0) && (value_.unsignedLongIntValue_ == (unsigned long)p.value_.intValue_); - else if((type_ == "int") && (p.type_ == "unsigned long int")) - return (value_.intValue_ >= 0) && ((unsigned long)value_.intValue_ == p.value_.unsignedLongIntValue_); - else if((type_ == "unsigned int") && (p.type_ == "long int")) - return (p.value_.longIntValue_ >= 0) && (value_.unsignedIntValue_ == (unsigned long)p.value_.longIntValue_); - else if((type_ == "long int") && (p.type_ == "unsigned int")) - return (value_.longIntValue_ >= 0) && ((unsigned long)value_.longIntValue_ == p.value_.unsignedIntValue_); - else if((type_ == "unsigned int") && (p.type_ == "unsigned long int")) - return value_.unsignedIntValue_ == p.value_.unsignedLongIntValue_; - else if((type_ == "unsigned long int") && (p.type_ == "unsigned int")) - return value_.unsignedLongIntValue_ == p.value_.unsignedIntValue_; - else if((type_ == "long int") && (p.type_ == "unsigned long int")) - 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_); -#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")) - return value_.intValue_ == p.value_.longLongIntValue_; - else if ((type_ == "long long int") && (p.type_ == "long int")) - return value_.longLongIntValue_ == p.value_.longIntValue_; - else if ((type_ == "long int") && (p.type_ == "long long int")) - return value_.longIntValue_ == p.value_.longLongIntValue_; - else if ((type_ == "long long int") && (p.type_ == "unsigned int")) - return (value_.longLongIntValue_ >= 0) && ((unsigned long long)value_.longLongIntValue_ == p.value_.unsignedIntValue_); - else if ((type_ == "unsigned int") && (p.type_ == "long long int")) - return (p.value_.longLongIntValue_ >= 0) && (value_.unsignedIntValue_ == (unsigned long long)p.value_.longLongIntValue_); - else if ((type_ == "long long int") && (p.type_ == "unsigned long int")) - return (value_.longLongIntValue_ >= 0) && ((unsigned long long)value_.longLongIntValue_ == p.value_.unsignedLongIntValue_); - else if ((type_ == "unsigned long int") && (p.type_ == "long long int")) - return (p.value_.longLongIntValue_ >= 0) && (value_.unsignedLongIntValue_ == (unsigned long long)p.value_.longLongIntValue_); - else if ((type_ == "long long int") && (p.type_ == "unsigned long long int")) - return (value_.longLongIntValue_ >= 0) && ((unsigned long long)value_.longLongIntValue_ == p.value_.unsignedLongLongIntValue_); - else if ((type_ == "unsigned long long int") && (p.type_ == "long long int")) - return (p.value_.longLongIntValue_ >= 0) && (value_.unsignedLongLongIntValue_ == (unsigned long long)p.value_.longLongIntValue_); - else if ((type_ == "unsigned long long int") && (p.type_ == "int")) - return (p.value_.intValue_ >= 0) && (value_.unsignedLongLongIntValue_ == (unsigned long long)p.value_.intValue_); - else if ((type_ == "int") && (p.type_ == "unsigned long long int")) - return (value_.intValue_ >= 0) && ((unsigned long long)value_.intValue_ == p.value_.unsignedLongLongIntValue_); - else if ((type_ == "unsigned long long int") && (p.type_ == "unsigned int")) - return value_.unsignedLongLongIntValue_ == p.value_.unsignedIntValue_; - else if ((type_ == "unsigned int") && (p.type_ == "unsigned long long int")) - return value_.unsignedIntValue_ == p.value_.unsignedLongLongIntValue_; - else if ((type_ == "unsigned long long int") && (p.type_ == "long int")) - return (p.value_.longIntValue_ >= 0) && (value_.unsignedLongLongIntValue_ == (unsigned long long)p.value_.longIntValue_); - else if ((type_ == "long int") && (p.type_ == "unsigned long long int")) - return (value_.longIntValue_ >= 0) && ((unsigned long long)value_.longIntValue_ == p.value_.unsignedLongLongIntValue_); - else if ((type_ == "unsigned long long int") && (p.type_ == "unsigned long int")) - return value_.unsignedLongLongIntValue_ == p.value_.unsignedLongIntValue_; - else if ((type_ == "unsigned long int") && (p.type_ == "unsigned long long int")) - return value_.unsignedLongIntValue_ == p.value_.unsignedLongLongIntValue_; -#endif - - if (type_ != p.type_) return false; - - if (type_ == "bool") - return value_.boolValue_ == p.value_.boolValue_; - else if (type_ == "int") - return value_.intValue_ == p.value_.intValue_; - else if (type_ == "unsigned int") - return value_.unsignedIntValue_ == p.value_.unsignedIntValue_; - else if (type_ == "long int") - return value_.longIntValue_ == p.value_.longIntValue_; - else if (type_ == "unsigned long int") - return value_.unsignedLongIntValue_ == p.value_.unsignedLongIntValue_; -#if CPPUTEST_USE_LONG_LONG - else if (type_ == "long long int") - return value_.longLongIntValue_ == p.value_.longLongIntValue_; - else if (type_ == "unsigned long long int") - return value_.unsignedLongLongIntValue_ == p.value_.unsignedLongLongIntValue_; -#endif - else if (type_ == "const char*") - return SimpleString(value_.stringValue_) == SimpleString(p.value_.stringValue_); - else if (type_ == "void*") - return value_.pointerValue_ == p.value_.pointerValue_; - else if (type_ == "const void*") - return value_.constPointerValue_ == p.value_.constPointerValue_; - else if (type_ == "void (*)()") - return value_.functionPointerValue_ == p.value_.functionPointerValue_; - else if (type_ == "double") - return (doubles_equal(value_.doubleValue_.value, p.value_.doubleValue_.value, value_.doubleValue_.tolerance)); - else if (type_ == "const unsigned char*") - { - if (size_ != p.size_) { - return false; - } - return SimpleString::MemCmp(value_.memoryBufferValue_, p.value_.memoryBufferValue_, size_) == 0; - } - - if (comparator_) - return comparator_->isEqual(value_.constObjectPointerValue_, p.value_.constObjectPointerValue_); - - return false; -} - -bool MockNamedValue::compatibleForCopying(const MockNamedValue& p) const -{ - if (type_ == p.type_) return true; - - if ((type_ == "const void*") && (p.type_ == "void*")) - return true; - - return false; -} - -SimpleString MockNamedValue::toString() const -{ - if (type_ == "bool") - return StringFrom(value_.boolValue_); - else if (type_ == "int") - return StringFrom(value_.intValue_) + " " + BracketsFormattedHexStringFrom(value_.intValue_); - else if (type_ == "unsigned int") - return StringFrom(value_.unsignedIntValue_) + " " + BracketsFormattedHexStringFrom(value_.unsignedIntValue_); - else if (type_ == "long int") - return StringFrom(value_.longIntValue_) + " " + BracketsFormattedHexStringFrom(value_.longIntValue_); - else if (type_ == "unsigned long int") - return StringFrom(value_.unsignedLongIntValue_) + " " + BracketsFormattedHexStringFrom(value_.unsignedLongIntValue_); -#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") - return StringFrom(value_.unsignedLongLongIntValue_) + " " + BracketsFormattedHexStringFrom(value_.unsignedLongLongIntValue_); -#endif - else if (type_ == "const char*") - return value_.stringValue_; - else if (type_ == "void*") - return StringFrom(value_.pointerValue_); - else if (type_ == "void (*)()") - return StringFrom(value_.functionPointerValue_); - else if (type_ == "const void*") - return StringFrom(value_.constPointerValue_); - else if (type_ == "double") - return StringFrom(value_.doubleValue_.value); - else if (type_ == "const unsigned char*") - return StringFromBinaryWithSizeOrNull(value_.memoryBufferValue_, size_); - - if (comparator_) - return comparator_->valueToString(value_.constObjectPointerValue_); - - return StringFromFormat("No comparator found for type: \"%s\"", type_.asCharString()); - -} - -void MockNamedValueListNode::setNext(MockNamedValueListNode* node) -{ - next_ = node; -} - -MockNamedValueListNode* MockNamedValueListNode::next() -{ - return next_; -} - -MockNamedValue* MockNamedValueListNode::item() -{ - return data_; -} - -void MockNamedValueListNode::destroy() -{ - delete data_; -} - -MockNamedValueListNode::MockNamedValueListNode(MockNamedValue* newValue) - : data_(newValue), next_(NULLPTR) -{ -} - -SimpleString MockNamedValueListNode::getName() const -{ - return data_->getName(); -} - -SimpleString MockNamedValueListNode::getType() const -{ - return data_->getType(); -} - -MockNamedValueList::MockNamedValueList() : head_(NULLPTR) -{ -} - -void MockNamedValueList::clear() -{ - while (head_) { - MockNamedValueListNode* n = head_->next(); - head_->destroy(); - delete head_; - head_ = n; - } -} - -void MockNamedValueList::add(MockNamedValue* newValue) -{ - MockNamedValueListNode* newNode = new MockNamedValueListNode(newValue); - if (head_ == NULLPTR) - head_ = newNode; - else { - MockNamedValueListNode* lastNode = head_; - while (lastNode->next()) lastNode = lastNode->next(); - lastNode->setNext(newNode); - } -} - -MockNamedValue* MockNamedValueList::getValueByName(const SimpleString& name) -{ - for (MockNamedValueListNode * p = head_; p; p = p->next()) - if (p->getName() == name) - return p->item(); - return NULLPTR; -} - -MockNamedValueListNode* MockNamedValueList::begin() -{ - return head_; -} - -struct MockNamedValueComparatorsAndCopiersRepositoryNode -{ - MockNamedValueComparatorsAndCopiersRepositoryNode(const SimpleString& name, MockNamedValueComparator* comparator, MockNamedValueComparatorsAndCopiersRepositoryNode* next) - : name_(name), comparator_(comparator), copier_(NULLPTR), next_(next) {} - MockNamedValueComparatorsAndCopiersRepositoryNode(const SimpleString& name, MockNamedValueCopier* copier, MockNamedValueComparatorsAndCopiersRepositoryNode* next) - : name_(name), comparator_(NULLPTR), copier_(copier), next_(next) {} - MockNamedValueComparatorsAndCopiersRepositoryNode(const SimpleString& name, MockNamedValueComparator* comparator, MockNamedValueCopier* copier, MockNamedValueComparatorsAndCopiersRepositoryNode* next) - : name_(name), comparator_(comparator), copier_(copier), next_(next) {} - SimpleString name_; - MockNamedValueComparator* comparator_; - MockNamedValueCopier* copier_; - MockNamedValueComparatorsAndCopiersRepositoryNode* next_; -}; - -MockNamedValueComparatorsAndCopiersRepository::MockNamedValueComparatorsAndCopiersRepository() : head_(NULLPTR) -{ - -} - -MockNamedValueComparatorsAndCopiersRepository::~MockNamedValueComparatorsAndCopiersRepository() -{ - clear(); -} - -void MockNamedValueComparatorsAndCopiersRepository::clear() -{ - while (head_) { - MockNamedValueComparatorsAndCopiersRepositoryNode* next = head_->next_; - delete head_; - head_ = next; - } -} - -void MockNamedValueComparatorsAndCopiersRepository::installComparator(const SimpleString& name, MockNamedValueComparator& comparator) -{ - head_ = new MockNamedValueComparatorsAndCopiersRepositoryNode(name, &comparator, head_); -} - -void MockNamedValueComparatorsAndCopiersRepository::installCopier(const SimpleString& name, MockNamedValueCopier& copier) -{ - head_ = new MockNamedValueComparatorsAndCopiersRepositoryNode(name, &copier, head_); -} - -MockNamedValueComparator* MockNamedValueComparatorsAndCopiersRepository::getComparatorForType(const SimpleString& name) -{ - for (MockNamedValueComparatorsAndCopiersRepositoryNode* p = head_; p; p = p->next_) - if (p->name_ == name && p->comparator_) return p->comparator_; - return NULLPTR; -} - -MockNamedValueCopier* MockNamedValueComparatorsAndCopiersRepository::getCopierForType(const SimpleString& name) -{ - for (MockNamedValueComparatorsAndCopiersRepositoryNode* p = head_; p; p = p->next_) - if (p->name_ == name && p->copier_) return p->copier_; - return NULLPTR; -} - -void MockNamedValueComparatorsAndCopiersRepository::installComparatorsAndCopiers(const MockNamedValueComparatorsAndCopiersRepository& repository) -{ - for (MockNamedValueComparatorsAndCopiersRepositoryNode* p = repository.head_; p; p = p->next_) - head_ = new MockNamedValueComparatorsAndCopiersRepositoryNode(p->name_, p->comparator_, p->copier_, head_); -} diff --git a/src/CppUTestExt/MockSupport.cpp b/src/CppUTestExt/MockSupport.cpp deleted file mode 100644 index eced71afb..000000000 --- a/src/CppUTestExt/MockSupport.cpp +++ /dev/null @@ -1,682 +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/TestHarness.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockActualCall.h" -#include "CppUTestExt/MockExpectedCall.h" -#include "CppUTestExt/MockFailure.h" - -#define MOCK_SUPPORT_SCOPE_PREFIX "!!!$$$MockingSupportScope$$$!!!" - -static MockSupport global_mock; - -MockSupport& mock(const SimpleString& mockName, MockFailureReporter* failureReporterForThisCall) -{ - MockSupport& mock_support = (mockName != "") ? *global_mock.getMockSupportScope(mockName) : global_mock; - mock_support.setActiveReporter(failureReporterForThisCall); - mock_support.setDefaultComparatorsAndCopiersRepository(); - return mock_support; -} - -MockSupport::MockSupport(const SimpleString& mockName) - : - actualCallOrder_(0), - expectedCallOrder_(0), - strictOrdering_(false), - activeReporter_(NULLPTR), - standardReporter_(&defaultReporter_), - ignoreOtherCalls_(false), - enabled_(true), - lastActualFunctionCall_(NULLPTR), - mockName_(mockName), - tracing_(false) -{ -} - -MockSupport::~MockSupport() -{ -} - -void MockSupport::crashOnFailure(bool shouldCrash) -{ - activeReporter_->crashOnFailure(shouldCrash); -} - -void MockSupport::setMockFailureStandardReporter(MockFailureReporter* reporter) -{ - standardReporter_ = (reporter != NULLPTR) ? reporter : &defaultReporter_; - - if (lastActualFunctionCall_) - lastActualFunctionCall_->setMockFailureReporter(standardReporter_); - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->setMockFailureStandardReporter(standardReporter_); -} - -void MockSupport::setActiveReporter(MockFailureReporter* reporter) -{ - activeReporter_ = (reporter) ? reporter : standardReporter_; -} - -void MockSupport::setDefaultComparatorsAndCopiersRepository() -{ - MockNamedValue::setDefaultComparatorsAndCopiersRepository(&comparatorsAndCopiersRepository_); -} - -void MockSupport::installComparator(const SimpleString& typeName, MockNamedValueComparator& comparator) -{ - comparatorsAndCopiersRepository_.installComparator(typeName, comparator); - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->installComparator(typeName, comparator); -} - -void MockSupport::installCopier(const SimpleString& typeName, MockNamedValueCopier& copier) -{ - comparatorsAndCopiersRepository_.installCopier(typeName, copier); - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->installCopier(typeName, copier); -} - -void MockSupport::installComparatorsAndCopiers(const MockNamedValueComparatorsAndCopiersRepository& repository) -{ - comparatorsAndCopiersRepository_.installComparatorsAndCopiers(repository); - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->installComparatorsAndCopiers(repository); -} - -void MockSupport::removeAllComparatorsAndCopiers() -{ - comparatorsAndCopiersRepository_.clear(); - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->removeAllComparatorsAndCopiers(); -} - -void MockSupport::clear() -{ - delete lastActualFunctionCall_; - lastActualFunctionCall_ = NULLPTR; - - tracing_ = false; - MockActualCallTrace::clearInstance(); - - expectations_.deleteAllExpectationsAndClearList(); - ignoreOtherCalls_ = false; - enabled_ = true; - actualCallOrder_ = 0; - expectedCallOrder_ = 0; - strictOrdering_ = false; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) { - MockSupport* support = getMockSupport(p); - if (support) { - support->clear(); - delete support; - } - } - data_.clear(); -} - -void MockSupport::strictOrder() -{ - strictOrdering_ = true; -} - -SimpleString MockSupport::appendScopeToName(const SimpleString& functionName) -{ - if (mockName_.isEmpty()) return functionName; - return mockName_ + "::" + functionName; -} - -MockExpectedCall& MockSupport::expectOneCall(const SimpleString& functionName) -{ - return expectNCalls(1, functionName); -} - -void MockSupport::expectNoCall(const SimpleString& functionName) -{ - expectNCalls(0, functionName); -} - -MockExpectedCall& MockSupport::expectNCalls(unsigned int amount, const SimpleString& functionName) -{ - if (!enabled_) return MockIgnoredExpectedCall::instance(); - - countCheck(); - - MockCheckedExpectedCall* call = new MockCheckedExpectedCall(amount); - call->withName(appendScopeToName(functionName)); - if (strictOrdering_) { - call->withCallOrder(expectedCallOrder_ + 1, expectedCallOrder_ + amount); - expectedCallOrder_ += amount; - } - expectations_.addExpectedCall(call); - return *call; -} - -MockCheckedActualCall* MockSupport::createActualCall() -{ - lastActualFunctionCall_ = new MockCheckedActualCall(++actualCallOrder_, activeReporter_, expectations_); - return lastActualFunctionCall_; -} - -bool MockSupport::callIsIgnored(const SimpleString& functionName) -{ - return ignoreOtherCalls_ && !expectations_.hasExpectationWithName(functionName); -} - -MockActualCall& MockSupport::actualCall(const SimpleString& functionName) -{ - const SimpleString scopeFunctionName = appendScopeToName(functionName); - - if (lastActualFunctionCall_) { - lastActualFunctionCall_->checkExpectations(); - delete lastActualFunctionCall_; - lastActualFunctionCall_ = NULLPTR; - } - - if (!enabled_) return MockIgnoredActualCall::instance(); - if (tracing_) return MockActualCallTrace::instance().withName(scopeFunctionName); - - - if (callIsIgnored(scopeFunctionName)) { - return MockIgnoredActualCall::instance(); - } - - MockCheckedActualCall* call = createActualCall(); - call->withName(scopeFunctionName); - return *call; -} - -void MockSupport::ignoreOtherCalls() -{ - ignoreOtherCalls_ = true; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->ignoreOtherCalls(); -} - -void MockSupport::disable() -{ - enabled_ = false; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->disable(); -} - -void MockSupport::enable() -{ - enabled_ = true; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->enable(); -} - -void MockSupport::tracing(bool enabled) -{ - tracing_ = enabled; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) getMockSupport(p)->tracing(enabled); -} - -const char* MockSupport::getTraceOutput() -{ - return MockActualCallTrace::instance().getTraceOutput(); -} - -bool MockSupport::expectedCallsLeft() -{ - checkExpectationsOfLastActualCall(); - int callsLeft = expectations_.hasUnfulfilledExpectations(); - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p)) callsLeft += getMockSupport(p)->expectedCallsLeft(); - - return callsLeft != 0; -} - -bool MockSupport::wasLastActualCallFulfilled() -{ - if (lastActualFunctionCall_ && !lastActualFunctionCall_->isFulfilled()) - return false; - - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p) && !getMockSupport(p)->wasLastActualCallFulfilled()) - return false; - - return true; -} - -void MockSupport::failTestWithExpectedCallsNotFulfilled() -{ - MockExpectedCallsList expectationsList; - expectationsList.addExpectations(expectations_); - - for(MockNamedValueListNode *p = data_.begin();p;p = p->next()) - if(getMockSupport(p)) - expectationsList.addExpectations(getMockSupport(p)->expectations_); - - MockExpectedCallsDidntHappenFailure failure(activeReporter_->getTestToFail(), expectationsList); - failTest(failure); -} - -void MockSupport::failTestWithOutOfOrderCalls() -{ - MockExpectedCallsList expectationsList; - expectationsList.addExpectations(expectations_); - - for(MockNamedValueListNode *p = data_.begin();p;p = p->next()) - if(getMockSupport(p)) - expectationsList.addExpectations(getMockSupport(p)->expectations_); - - MockCallOrderFailure failure(activeReporter_->getTestToFail(), expectationsList); - failTest(failure); -} - -void MockSupport::failTest(MockFailure& failure) -{ - clear(); - activeReporter_->failTest(failure); -} - -void MockSupport::countCheck() -{ - UtestShell::getCurrent()->countCheck(); -} - -void MockSupport::checkExpectationsOfLastActualCall() -{ - if(lastActualFunctionCall_) - lastActualFunctionCall_->checkExpectations(); - - for(MockNamedValueListNode *p = data_.begin();p;p = p->next()) - if(getMockSupport(p) && getMockSupport(p)->lastActualFunctionCall_) - getMockSupport(p)->lastActualFunctionCall_->checkExpectations(); -} - -bool MockSupport::hasCallsOutOfOrder() -{ - if (expectations_.hasCallsOutOfOrder()) - { - return true; - } - for (MockNamedValueListNode* p = data_.begin(); p; p = p->next()) - if (getMockSupport(p) && getMockSupport(p)->hasCallsOutOfOrder()) - { - return true; - } - return false; -} - -void MockSupport::checkExpectations() -{ - checkExpectationsOfLastActualCall(); - - if (wasLastActualCallFulfilled() && expectedCallsLeft()) - failTestWithExpectedCallsNotFulfilled(); - - if (hasCallsOutOfOrder()) - failTestWithOutOfOrderCalls(); -} - - -bool MockSupport::hasData(const SimpleString& name) -{ - return data_.getValueByName(name) != NULLPTR; -} - -MockNamedValue* MockSupport::retrieveDataFromStore(const SimpleString& name) -{ - MockNamedValue* newData = data_.getValueByName(name); - if (newData == NULLPTR) { - newData = new MockNamedValue(name); - data_.add(newData); - } - return newData; -} - -void MockSupport::setData(const SimpleString& name, bool value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, unsigned int value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, int value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, long int value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, unsigned long int value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, const char* value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, double value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, void* value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, const void* value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setData(const SimpleString& name, void (*value)()) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setValue(value); -} - -void MockSupport::setDataObject(const SimpleString& name, const SimpleString& type, void* value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setObjectPointer(type, value); -} - -void MockSupport::setDataConstObject(const SimpleString& name, const SimpleString& type, const void* value) -{ - MockNamedValue* newData = retrieveDataFromStore(name); - newData->setConstObjectPointer(type, value); -} - -MockNamedValue MockSupport::getData(const SimpleString& name) -{ - MockNamedValue* value = data_.getValueByName(name); - if (value == NULLPTR) - return MockNamedValue(""); - return *value; -} - -MockSupport* MockSupport::clone(const SimpleString& mockName) -{ - MockSupport* newMock = new MockSupport(mockName); - newMock->setMockFailureStandardReporter(standardReporter_); - if (ignoreOtherCalls_) newMock->ignoreOtherCalls(); - - if (!enabled_) newMock->disable(); - - if (strictOrdering_) newMock->strictOrder(); - - newMock->tracing(tracing_); - newMock->installComparatorsAndCopiers(comparatorsAndCopiersRepository_); - return newMock; -} - -MockSupport* MockSupport::getMockSupportScope(const SimpleString& name) -{ - SimpleString mockingSupportName = MOCK_SUPPORT_SCOPE_PREFIX; - mockingSupportName += name; - - if (hasData(mockingSupportName)) { - STRCMP_EQUAL("MockSupport", getData(mockingSupportName).getType().asCharString()); - return (MockSupport*) getData(mockingSupportName).getObjectPointer(); - } - - MockSupport *newMock = clone(name); - - setDataObject(mockingSupportName, "MockSupport", newMock); - return newMock; -} - -MockSupport* MockSupport::getMockSupport(MockNamedValueListNode* node) -{ - if (node->getType() == "MockSupport" && node->getName().contains(MOCK_SUPPORT_SCOPE_PREFIX)) - return (MockSupport*) node->item()->getObjectPointer(); - return NULLPTR; -} - -MockNamedValue MockSupport::returnValue() -{ - if (lastActualFunctionCall_) return lastActualFunctionCall_->returnValue(); - return MockNamedValue(""); -} - -bool MockSupport::boolReturnValue() -{ - return returnValue().getBoolValue(); -} - -unsigned int MockSupport::unsignedIntReturnValue() -{ - return returnValue().getUnsignedIntValue(); -} - -int MockSupport::intReturnValue() -{ - return returnValue().getIntValue(); -} - -const char * MockSupport::returnStringValueOrDefault(const char * defaultValue) -{ - if (hasReturnValue()) { - return stringReturnValue(); - } - return defaultValue; -} - -double MockSupport::returnDoubleValueOrDefault(double defaultValue) -{ - if (hasReturnValue()) { - return doubleReturnValue(); - } - return defaultValue; -} - -long int MockSupport::returnLongIntValueOrDefault(long int defaultValue) -{ - if (hasReturnValue()) { - return longIntReturnValue(); - } - return defaultValue; -} - -bool MockSupport::returnBoolValueOrDefault(bool defaultValue) -{ - if (hasReturnValue()) { - return boolReturnValue(); - } - return defaultValue; -} - -int MockSupport::returnIntValueOrDefault(int defaultValue) -{ - if (hasReturnValue()) { - return intReturnValue(); - } - return defaultValue; -} - -unsigned int MockSupport::returnUnsignedIntValueOrDefault(unsigned int defaultValue) -{ - if (hasReturnValue()) { - return unsignedIntReturnValue(); - } - return defaultValue; -} - -unsigned long int MockSupport::returnUnsignedLongIntValueOrDefault(unsigned long int defaultValue) -{ - if (hasReturnValue()) { - return unsignedLongIntReturnValue(); - } - return defaultValue; -} - -long int MockSupport::longIntReturnValue() -{ - return returnValue().getLongIntValue(); -} - -unsigned long int MockSupport::unsignedLongIntReturnValue() -{ - return returnValue().getUnsignedLongIntValue(); -} - -#if CPPUTEST_USE_LONG_LONG - -cpputest_longlong MockSupport::longLongIntReturnValue() -{ - return returnValue().getLongLongIntValue(); -} - -cpputest_ulonglong MockSupport::unsignedLongLongIntReturnValue() -{ - return returnValue().getUnsignedLongLongIntValue(); -} - -cpputest_longlong MockSupport::returnLongLongIntValueOrDefault(cpputest_longlong defaultValue) -{ - if (hasReturnValue()) { - return longLongIntReturnValue(); - } - return defaultValue; -} - -cpputest_ulonglong MockSupport::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong defaultValue) -{ - if (hasReturnValue()) { - return unsignedLongLongIntReturnValue(); - } - return defaultValue; -} - -#else - -cpputest_longlong MockSupport::longLongIntReturnValue() -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_ulonglong MockSupport::unsignedLongLongIntReturnValue() -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -cpputest_longlong MockSupport::returnLongLongIntValueOrDefault(cpputest_longlong defaultValue) -{ - FAIL("Long Long type is not supported"); - return defaultValue; -} - -cpputest_ulonglong MockSupport::returnUnsignedLongLongIntValueOrDefault(cpputest_ulonglong defaultValue) -{ - FAIL("Unsigned Long Long type is not supported"); - return defaultValue; -} - -#endif - -const char* MockSupport::stringReturnValue() -{ - return returnValue().getStringValue(); -} - -double MockSupport::doubleReturnValue() -{ - return returnValue().getDoubleValue(); -} - -void * MockSupport::returnPointerValueOrDefault(void * defaultValue) -{ - if (hasReturnValue()) { - return pointerReturnValue(); - } - return defaultValue; -} - -const void* MockSupport::returnConstPointerValueOrDefault(const void * defaultValue) -{ - if (hasReturnValue()) { - return constPointerReturnValue(); - } - return defaultValue; -} - -void (*MockSupport::returnFunctionPointerValueOrDefault(void (*defaultValue)()))() -{ - if (hasReturnValue()) { - return functionPointerReturnValue(); - } - return defaultValue; -} - -void* MockSupport::pointerReturnValue() -{ - return returnValue().getPointerValue(); -} - -const void* MockSupport::constPointerReturnValue() -{ - return returnValue().getConstPointerValue(); -} - -void (*MockSupport::functionPointerReturnValue())() -{ - return returnValue().getFunctionPointerValue(); -} - -bool MockSupport::hasReturnValue() -{ - if (lastActualFunctionCall_) return lastActualFunctionCall_->hasReturnValue(); - return false; -} diff --git a/src/CppUTestExt/MockSupportPlugin.cpp b/src/CppUTestExt/MockSupportPlugin.cpp deleted file mode 100644 index e484c466c..000000000 --- a/src/CppUTestExt/MockSupportPlugin.cpp +++ /dev/null @@ -1,92 +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/TestHarness.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockSupportPlugin.h" - -class MockSupportPluginReporter : public MockFailureReporter -{ - UtestShell& test_; - TestResult& result_; -public: - MockSupportPluginReporter(UtestShell& test, TestResult& result) - : test_(test), result_(result) - { - } - - virtual void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE - { - result_.addFailure(failure); - } - - virtual UtestShell* getTestToFail() CPPUTEST_OVERRIDE - { - return &test_; - } -}; - -MockSupportPlugin::MockSupportPlugin(const SimpleString& name) - : TestPlugin(name) -{ -} - -MockSupportPlugin::~MockSupportPlugin() -{ - clear(); -} - -void MockSupportPlugin::clear() -{ - repository_.clear(); -} - -void MockSupportPlugin::preTestAction(UtestShell&, TestResult&) -{ - mock().installComparatorsAndCopiers(repository_); -} - -void MockSupportPlugin::postTestAction(UtestShell& test, TestResult& result) -{ - MockSupportPluginReporter reporter(test, result); - mock().setMockFailureStandardReporter(&reporter); - if (!test.hasFailed()) - mock().checkExpectations(); - mock().clear(); - mock().setMockFailureStandardReporter(NULLPTR); - mock().removeAllComparatorsAndCopiers(); -} - -void MockSupportPlugin::installComparator(const SimpleString& name, MockNamedValueComparator& comparator) -{ - repository_.installComparator(name, comparator); -} - -void MockSupportPlugin::installCopier(const SimpleString& name, MockNamedValueCopier& copier) -{ - repository_.installCopier(name, copier); -} diff --git a/src/CppUTestExt/MockSupport_c.cpp b/src/CppUTestExt/MockSupport_c.cpp deleted file mode 100644 index 640f4b93d..000000000 --- a/src/CppUTestExt/MockSupport_c.cpp +++ /dev/null @@ -1,1125 +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/CppUTestConfig.h" -#include "CppUTest/Utest.h" -#include "CppUTest/UtestMacros.h" -#include "CppUTest/PlatformSpecificFunctions_c.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockSupport_c.h" - -typedef void (*cpputest_cpp_function_pointer)(); /* Cl2000 requires cast to C++ function */ - -class MockFailureReporterTestTerminatorForInCOnlyCode : public TestTerminator -{ -public: - MockFailureReporterTestTerminatorForInCOnlyCode(bool crashOnFailure) : crashOnFailure_(crashOnFailure) - { - } - - virtual void exitCurrentTest() const CPPUTEST_OVERRIDE - { - if (crashOnFailure_) - UT_CRASH(); - - UtestShell::getCurrentTestTerminatorWithoutExceptions().exitCurrentTest(); - } // LCOV_EXCL_LINE - // LCOV_EXCL_START - virtual ~MockFailureReporterTestTerminatorForInCOnlyCode() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - // LCOV_EXCL_STOP -private: - bool crashOnFailure_; - -}; - -class MockFailureReporterForInCOnlyCode : public MockFailureReporter -{ -public: - void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE - { - if (!getTestToFail()->hasFailed()) - getTestToFail()->failWith(failure, MockFailureReporterTestTerminatorForInCOnlyCode(crashOnFailure_)); - } // LCOV_EXCL_LINE - -}; - -static MockSupport* currentMockSupport = NULLPTR; -static MockExpectedCall* expectedCall = NULLPTR; -static MockActualCall* actualCall = NULLPTR; -static MockFailureReporterForInCOnlyCode failureReporterForC; - -class MockCFunctionComparatorNode : public MockNamedValueComparator -{ -public: - MockCFunctionComparatorNode(MockCFunctionComparatorNode* next, MockTypeEqualFunction_c equal, MockTypeValueToStringFunction_c toString) - : next_(next), equal_(equal), toString_(toString) {} - virtual ~MockCFunctionComparatorNode() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE - { - return equal_(object1, object2) != 0; - } - virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE - { - return SimpleString(toString_(object)); - } - - MockCFunctionComparatorNode* next_; - MockTypeEqualFunction_c equal_; - MockTypeValueToStringFunction_c toString_; -}; - -static MockCFunctionComparatorNode* comparatorList_ = NULLPTR; - -class MockCFunctionCopierNode : public MockNamedValueCopier -{ -public: - MockCFunctionCopierNode(MockCFunctionCopierNode* next, MockTypeCopyFunction_c copier) - : next_(next), copier_(copier) {} - virtual ~MockCFunctionCopierNode() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - virtual void copy(void* dst, const void* src) CPPUTEST_OVERRIDE - { - copier_(dst, src); - } - - MockCFunctionCopierNode* next_; - MockTypeCopyFunction_c copier_; -}; - -static MockCFunctionCopierNode* copierList_ = NULLPTR; - -extern "C" { - -void strictOrder_c(); -MockExpectedCall_c* expectOneCall_c(const char* name); -void expectNoCall_c(const char* name); -MockExpectedCall_c* expectNCalls_c(const unsigned int number, const char* name); -MockActualCall_c* actualCall_c(const char* name); -void disable_c(); -void enable_c(); -void ignoreOtherCalls_c(); -void setBoolData_c(const char* name, int value); -void setIntData_c(const char* name, int value); -void setUnsignedIntData_c(const char* name, unsigned int value); -void setLongIntData_c(const char* name, long int value); -void setUnsignedLongIntData_c(const char* name, unsigned long int value); -void setDoubleData_c(const char* name, double value); -void setStringData_c(const char* name, const char* value); -void setPointerData_c(const char* name, void* value); -void setConstPointerData_c(const char* name, const void* value); -void setFunctionPointerData_c(const char* name, void (*value)()); -void setDataObject_c(const char* name, const char* type, void* value); -void setDataConstObject_c(const char* name, const char* type, const void* value); -MockValue_c getData_c(const char* name); -int hasReturnValue_c(); - -void checkExpectations_c(); -int expectedCallsLeft_c(); -void clear_c(); -void crashOnFailure_c(unsigned shouldCrash); - -MockExpectedCall_c* withBoolParameters_c(const char* name, int value); -MockExpectedCall_c* withIntParameters_c(const char* name, int value); -MockExpectedCall_c* withUnsignedIntParameters_c(const char* name, unsigned int value); -MockExpectedCall_c* withLongIntParameters_c(const char* name, long int value); -MockExpectedCall_c* withUnsignedLongIntParameters_c(const char* name, unsigned long int value); -MockExpectedCall_c* withLongLongIntParameters_c(const char* name, cpputest_longlong value); -MockExpectedCall_c* withUnsignedLongLongIntParameters_c(const char* name, cpputest_ulonglong value); -MockExpectedCall_c* withDoubleParameters_c(const char* name, double value); -MockExpectedCall_c* withDoubleParametersAndTolerance_c(const char* name, double value, double tolerance); -MockExpectedCall_c* withStringParameters_c(const char* name, const char* value); -MockExpectedCall_c* withPointerParameters_c(const char* name, void* value); -MockExpectedCall_c* withConstPointerParameters_c(const char* name, const void* value); -MockExpectedCall_c* withFunctionPointerParameters_c(const char* name, void (*value)()); -MockExpectedCall_c* withMemoryBufferParameters_c(const char* name, const unsigned char* value, size_t size); -MockExpectedCall_c* withParameterOfType_c(const char* type, const char* name, const void* value); -MockExpectedCall_c* withOutputParameterReturning_c(const char* name, const void* value, size_t size); -MockExpectedCall_c* withOutputParameterOfTypeReturning_c(const char* type, const char* name, const void* value); -MockExpectedCall_c* withUnmodifiedOutputParameter_c(const char* name); -MockExpectedCall_c* ignoreOtherParameters_c(); -MockExpectedCall_c* andReturnBoolValue_c(int value); -MockExpectedCall_c* andReturnIntValue_c(int value); -MockExpectedCall_c* andReturnUnsignedIntValue_c(unsigned int value); -MockExpectedCall_c* andReturnLongIntValue_c(long int value); -MockExpectedCall_c* andReturnUnsignedLongIntValue_c(unsigned long int value); -MockExpectedCall_c* andReturnLongLongIntValue_c(cpputest_longlong value); -MockExpectedCall_c* andReturnUnsignedLongLongIntValue_c(cpputest_ulonglong value); -MockExpectedCall_c* andReturnDoubleValue_c(double value); -MockExpectedCall_c* andReturnStringValue_c(const char* value); -MockExpectedCall_c* andReturnPointerValue_c(void* value); -MockExpectedCall_c* andReturnConstPointerValue_c(const void* value); -MockExpectedCall_c* andReturnFunctionPointerValue_c(void (*value)()); - -MockActualCall_c* withActualBoolParameters_c(const char* name, int value); -MockActualCall_c* withActualIntParameters_c(const char* name, int value); -MockActualCall_c* withActualUnsignedIntParameters_c(const char* name, unsigned int value); -MockActualCall_c* withActualLongIntParameters_c(const char* name, long int value); -MockActualCall_c* withActualUnsignedLongIntParameters_c(const char* name, unsigned long int value); -MockActualCall_c* withActualLongLongIntParameters_c(const char* name, cpputest_longlong value); -MockActualCall_c* withActualUnsignedLongLongIntParameters_c(const char* name, cpputest_ulonglong value); -MockActualCall_c* withActualDoubleParameters_c(const char* name, double value); -MockActualCall_c* withActualStringParameters_c(const char* name, const char* value); -MockActualCall_c* withActualPointerParameters_c(const char* name, void* value); -MockActualCall_c* withActualConstPointerParameters_c(const char* name, const void* value); -MockActualCall_c* withActualFunctionPointerParameters_c(const char* name, void (*value)()); -MockActualCall_c* withActualMemoryBufferParameters_c(const char* name, const unsigned char* value, size_t size); -MockActualCall_c* withActualParameterOfType_c(const char* type, const char* name, const void* value); -MockActualCall_c* withActualOutputParameter_c(const char* name, void* value); -MockActualCall_c* withActualOutputParameterOfType_c(const char* type, const char* name, void* value); -MockValue_c returnValue_c(); -int boolReturnValue_c(); -int returnBoolValueOrDefault_c(int defaultValue); -int intReturnValue_c(); -int returnIntValueOrDefault_c(int defaultValue); -unsigned int unsignedIntReturnValue_c(); -unsigned int returnUnsignedIntValueOrDefault_c(unsigned int defaultValue); -long int longIntReturnValue_c(); -long int returnLongIntValueOrDefault_c(long int defaultValue); -unsigned long int unsignedLongIntReturnValue_c(); -unsigned long int returnUnsignedLongIntValueOrDefault_c(unsigned long int defaultValue); -cpputest_longlong longLongIntReturnValue_c(); -cpputest_longlong returnLongLongIntValueOrDefault_c(cpputest_longlong defaultValue); -cpputest_ulonglong unsignedLongLongIntReturnValue_c(); -cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault_c(cpputest_ulonglong defaultValue); -const char* stringReturnValue_c(); -const char* returnStringValueOrDefault_c(const char * defaultValue); -double doubleReturnValue_c(); -double returnDoubleValueOrDefault_c(double defaultValue); -void* pointerReturnValue_c(); -void* returnPointerValueOrDefault_c(void * defaultValue); -const void* constPointerReturnValue_c(); -const void* returnConstPointerValueOrDefault_c(const void * defaultValue); -void (*functionPointerReturnValue_c())(); -void (*returnFunctionPointerValueOrDefault_c(void(*defaultValue)()))(); - -static void installComparator_c (const char* typeName, MockTypeEqualFunction_c isEqual, MockTypeValueToStringFunction_c valueToString) -{ - comparatorList_ = new MockCFunctionComparatorNode(comparatorList_, isEqual, valueToString); - currentMockSupport->installComparator(typeName, *comparatorList_); -} - -static void installCopier_c (const char* typeName, MockTypeCopyFunction_c copier) -{ - copierList_ = new MockCFunctionCopierNode(copierList_, copier); - currentMockSupport->installCopier(typeName, *copierList_); -} - -static void removeAllComparatorsAndCopiers_c() -{ - while (comparatorList_) { - MockCFunctionComparatorNode *next = comparatorList_->next_; - delete comparatorList_; - comparatorList_ = next; - } - while (copierList_) { - MockCFunctionCopierNode *next = copierList_->next_; - delete copierList_; - copierList_ = next; - } - currentMockSupport->removeAllComparatorsAndCopiers(); -} - -static MockExpectedCall_c gExpectedCall = { - withBoolParameters_c, - withIntParameters_c, - withUnsignedIntParameters_c, - withLongIntParameters_c, - withUnsignedLongIntParameters_c, - withLongLongIntParameters_c, - withUnsignedLongLongIntParameters_c, - withDoubleParameters_c, - withDoubleParametersAndTolerance_c, - withStringParameters_c, - withPointerParameters_c, - withConstPointerParameters_c, - withFunctionPointerParameters_c, - withMemoryBufferParameters_c, - withParameterOfType_c, - withOutputParameterReturning_c, - withOutputParameterOfTypeReturning_c, - withUnmodifiedOutputParameter_c, - ignoreOtherParameters_c, - andReturnBoolValue_c, - andReturnUnsignedIntValue_c, - andReturnIntValue_c, - andReturnLongIntValue_c, - andReturnUnsignedLongIntValue_c, - andReturnLongLongIntValue_c, - andReturnUnsignedLongLongIntValue_c, - andReturnDoubleValue_c, - andReturnStringValue_c, - andReturnPointerValue_c, - andReturnConstPointerValue_c, - andReturnFunctionPointerValue_c, -}; - -static MockActualCall_c gActualCall = { - withActualBoolParameters_c, - withActualIntParameters_c, - withActualUnsignedIntParameters_c, - withActualLongIntParameters_c, - withActualUnsignedLongIntParameters_c, - withActualLongLongIntParameters_c, - withActualUnsignedLongLongIntParameters_c, - withActualDoubleParameters_c, - withActualStringParameters_c, - withActualPointerParameters_c, - withActualConstPointerParameters_c, - withActualFunctionPointerParameters_c, - withActualMemoryBufferParameters_c, - withActualParameterOfType_c, - withActualOutputParameter_c, - withActualOutputParameterOfType_c, - hasReturnValue_c, - returnValue_c, - boolReturnValue_c, - returnBoolValueOrDefault_c, - intReturnValue_c, - returnIntValueOrDefault_c, - unsignedIntReturnValue_c, - returnUnsignedIntValueOrDefault_c, - longIntReturnValue_c, - returnLongIntValueOrDefault_c, - unsignedLongIntReturnValue_c, - returnUnsignedLongIntValueOrDefault_c, - longLongIntReturnValue_c, - returnLongLongIntValueOrDefault_c, - unsignedLongLongIntReturnValue_c, - returnUnsignedLongLongIntValueOrDefault_c, - stringReturnValue_c, - returnStringValueOrDefault_c, - doubleReturnValue_c, - returnDoubleValueOrDefault_c, - pointerReturnValue_c, - returnPointerValueOrDefault_c, - constPointerReturnValue_c, - returnConstPointerValueOrDefault_c, - functionPointerReturnValue_c, - returnFunctionPointerValueOrDefault_c -}; - -static MockSupport_c gMockSupport = { - strictOrder_c, - expectOneCall_c, - expectNoCall_c, - expectNCalls_c, - actualCall_c, - hasReturnValue_c, - returnValue_c, - boolReturnValue_c, - returnBoolValueOrDefault_c, - intReturnValue_c, - returnIntValueOrDefault_c, - unsignedIntReturnValue_c, - returnUnsignedIntValueOrDefault_c, - longIntReturnValue_c, - returnLongIntValueOrDefault_c, - unsignedLongIntReturnValue_c, - returnUnsignedLongIntValueOrDefault_c, - longLongIntReturnValue_c, - returnLongLongIntValueOrDefault_c, - unsignedLongLongIntReturnValue_c, - returnUnsignedLongLongIntValueOrDefault_c, - stringReturnValue_c, - returnStringValueOrDefault_c, - doubleReturnValue_c, - returnDoubleValueOrDefault_c, - pointerReturnValue_c, - returnPointerValueOrDefault_c, - constPointerReturnValue_c, - returnConstPointerValueOrDefault_c, - functionPointerReturnValue_c, - returnFunctionPointerValueOrDefault_c, - setBoolData_c, - setIntData_c, - setUnsignedIntData_c, - setLongIntData_c, - setUnsignedLongIntData_c, - setStringData_c, - setDoubleData_c, - setPointerData_c, - setConstPointerData_c, - setFunctionPointerData_c, - setDataObject_c, - setDataConstObject_c, - getData_c, - disable_c, - enable_c, - ignoreOtherCalls_c, - checkExpectations_c, - expectedCallsLeft_c, - clear_c, - crashOnFailure_c, - installComparator_c, - installCopier_c, - removeAllComparatorsAndCopiers_c -}; - -MockExpectedCall_c* withBoolParameters_c(const char* name, int value) -{ - expectedCall = &expectedCall->withParameter(name, (value != 0)); - return &gExpectedCall; -} - -MockExpectedCall_c* withIntParameters_c(const char* name, int value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withUnsignedIntParameters_c(const char* name, unsigned int value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withLongIntParameters_c(const char* name, long int value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withUnsignedLongIntParameters_c(const char* name, unsigned long int value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -#if CPPUTEST_USE_LONG_LONG - -MockExpectedCall_c* withLongLongIntParameters_c(const char* name, cpputest_longlong value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withUnsignedLongLongIntParameters_c(const char* name, cpputest_ulonglong value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -#else - -MockExpectedCall_c* withLongLongIntParameters_c(const char*, cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return &gExpectedCall; -} - -MockExpectedCall_c* withUnsignedLongLongIntParameters_c(const char*, cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return &gExpectedCall; -} - -#endif - -MockExpectedCall_c* withDoubleParameters_c(const char* name, double value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withDoubleParametersAndTolerance_c(const char* name, double value, double tolerance) -{ - expectedCall = &expectedCall->withParameter(name, value, tolerance); - return &gExpectedCall; -} - -MockExpectedCall_c* withStringParameters_c(const char* name, const char* value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withPointerParameters_c(const char* name, void* value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withConstPointerParameters_c(const char* name, const void* value) -{ - expectedCall = &expectedCall->withParameter(name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withFunctionPointerParameters_c(const char* name, void (*value)()) -{ - expectedCall = &expectedCall->withParameter(name, (cpputest_cpp_function_pointer)value); - return &gExpectedCall; -} - -MockExpectedCall_c* withMemoryBufferParameters_c(const char* name, const unsigned char* value, size_t size) -{ - expectedCall = &expectedCall->withParameter(name, value, size); - return &gExpectedCall; -} - -MockExpectedCall_c* withParameterOfType_c(const char* type, const char* name, const void* value) -{ - expectedCall = &expectedCall->withParameterOfType(type, name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withOutputParameterReturning_c(const char* name, const void* value, size_t size) -{ - expectedCall = &expectedCall->withOutputParameterReturning(name, value, size); - return &gExpectedCall; -} - -MockExpectedCall_c* withOutputParameterOfTypeReturning_c(const char* type, const char* name, const void* value) -{ - expectedCall = &expectedCall->withOutputParameterOfTypeReturning(type, name, value); - return &gExpectedCall; -} - -MockExpectedCall_c* withUnmodifiedOutputParameter_c(const char* name) -{ - expectedCall = &expectedCall->withUnmodifiedOutputParameter(name); - return &gExpectedCall; -} - -MockExpectedCall_c* ignoreOtherParameters_c() -{ - expectedCall = &expectedCall->ignoreOtherParameters(); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnBoolValue_c(int value) -{ - expectedCall = &expectedCall->andReturnValue(value != 0); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnUnsignedIntValue_c(unsigned int value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnIntValue_c(int value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnLongIntValue_c(long int value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnUnsignedLongIntValue_c(unsigned long int value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -#if CPPUTEST_USE_LONG_LONG - -MockExpectedCall_c* andReturnLongLongIntValue_c(cpputest_longlong value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnUnsignedLongLongIntValue_c(cpputest_ulonglong value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -#else - -MockExpectedCall_c* andReturnLongLongIntValue_c(cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnUnsignedLongLongIntValue_c(cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return &gExpectedCall; -} - -#endif - -MockExpectedCall_c* andReturnDoubleValue_c(double value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnStringValue_c(const char* value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnPointerValue_c(void* value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnConstPointerValue_c(const void* value) -{ - expectedCall = &expectedCall->andReturnValue(value); - return &gExpectedCall; -} - -MockExpectedCall_c* andReturnFunctionPointerValue_c(void (*value)()) -{ - expectedCall = &expectedCall->andReturnValue((cpputest_cpp_function_pointer)value); - return &gExpectedCall; -} - -static MockValue_c getMockValueCFromNamedValue(const MockNamedValue& namedValue) -{ - MockValue_c returnValue; - if (SimpleString::StrCmp(namedValue.getType().asCharString(), "bool") == 0) { - returnValue.type = MOCKVALUETYPE_BOOL; - returnValue.value.boolValue = namedValue.getBoolValue() ? 1 : 0; - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "int") == 0) { - returnValue.type = MOCKVALUETYPE_INTEGER; - returnValue.value.intValue = namedValue.getIntValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "unsigned int") == 0) { - returnValue.type = MOCKVALUETYPE_UNSIGNED_INTEGER; - returnValue.value.unsignedIntValue = namedValue.getUnsignedIntValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "long int") == 0) { - returnValue.type = MOCKVALUETYPE_LONG_INTEGER; - returnValue.value.longIntValue = namedValue.getLongIntValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "unsigned long int") == 0) { - returnValue.type = MOCKVALUETYPE_UNSIGNED_LONG_INTEGER; - returnValue.value.unsignedLongIntValue = namedValue.getUnsignedLongIntValue(); - } -#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(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "unsigned long long int") == 0) { - returnValue.type = MOCKVALUETYPE_UNSIGNED_LONG_LONG_INTEGER; - returnValue.value.unsignedLongLongIntValue = namedValue.getUnsignedLongLongIntValue(); - } -#endif - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "double") == 0) { - returnValue.type = MOCKVALUETYPE_DOUBLE; - returnValue.value.doubleValue = namedValue.getDoubleValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "const char*") == 0) { - returnValue.type = MOCKVALUETYPE_STRING; - returnValue.value.stringValue = namedValue.getStringValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "void*") == 0) { - returnValue.type = MOCKVALUETYPE_POINTER; - returnValue.value.pointerValue = namedValue.getPointerValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "const void*") == 0) { - returnValue.type = MOCKVALUETYPE_CONST_POINTER; - returnValue.value.constPointerValue = namedValue.getConstPointerValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "void (*)()") == 0) { - returnValue.type = MOCKVALUETYPE_FUNCTIONPOINTER; - returnValue.value.functionPointerValue = (void (*)()) namedValue.getFunctionPointerValue(); - } - else if (SimpleString::StrCmp(namedValue.getType().asCharString(), "const unsigned char*") == 0) { - returnValue.type = MOCKVALUETYPE_MEMORYBUFFER; - returnValue.value.memoryBufferValue = namedValue.getMemoryBuffer(); - } - else { - returnValue.type = MOCKVALUETYPE_OBJECT; - returnValue.value.objectValue = namedValue.getObjectPointer(); - } - return returnValue; -} - -void strictOrder_c() -{ - currentMockSupport->strictOrder(); -} - -MockExpectedCall_c* expectOneCall_c(const char* name) -{ - expectedCall = ¤tMockSupport->expectOneCall(name); - return &gExpectedCall; -} - -void expectNoCall_c(const char* name) -{ - currentMockSupport->expectNoCall(name); -} - -MockExpectedCall_c* expectNCalls_c(const unsigned int number, const char* name) -{ - expectedCall = ¤tMockSupport->expectNCalls(number, name); - return &gExpectedCall; -} - -MockActualCall_c* actualCall_c(const char* name) -{ - actualCall = ¤tMockSupport->actualCall(name); - return &gActualCall; -} - -MockActualCall_c* withActualBoolParameters_c(const char* name, int value) -{ - actualCall = &actualCall->withParameter(name, (value != 0)); - return &gActualCall; -} - -MockActualCall_c* withActualIntParameters_c(const char* name, int value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualUnsignedIntParameters_c(const char* name, unsigned int value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualLongIntParameters_c(const char* name, long int value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualUnsignedLongIntParameters_c(const char* name, unsigned long int value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -#if CPPUTEST_USE_LONG_LONG - -MockActualCall_c* withActualLongLongIntParameters_c(const char* name, cpputest_longlong value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualUnsignedLongLongIntParameters_c(const char* name, cpputest_ulonglong value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -#else - -MockActualCall_c* withActualLongLongIntParameters_c(const char*, cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - return &gActualCall; -} - -MockActualCall_c* withActualUnsignedLongLongIntParameters_c(const char*, cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - return &gActualCall; -} - -#endif - -MockActualCall_c* withActualDoubleParameters_c(const char* name, double value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualStringParameters_c(const char* name, const char* value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualPointerParameters_c(const char* name, void* value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualConstPointerParameters_c(const char* name, const void* value) -{ - actualCall = &actualCall->withParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualFunctionPointerParameters_c(const char* name, void (*value)()) -{ - actualCall = &actualCall->withParameter(name, (cpputest_cpp_function_pointer) value); - return &gActualCall; -} - -MockActualCall_c* withActualMemoryBufferParameters_c(const char* name, const unsigned char* value, size_t size) -{ - actualCall = &actualCall->withParameter(name, value, size); - return &gActualCall; -} - -MockActualCall_c* withActualParameterOfType_c(const char* type, const char* name, const void* value) -{ - actualCall = &actualCall->withParameterOfType(type, name, value); - return &gActualCall; -} - -MockActualCall_c* withActualOutputParameter_c(const char* name, void* value) -{ - actualCall = &actualCall->withOutputParameter(name, value); - return &gActualCall; -} - -MockActualCall_c* withActualOutputParameterOfType_c(const char* type, const char* name, void* value) -{ - actualCall = &actualCall->withOutputParameterOfType(type, name, value); - return &gActualCall; -} - -MockValue_c returnValue_c() -{ - return getMockValueCFromNamedValue(actualCall->returnValue()); -} - -int boolReturnValue_c() -{ - return actualCall->returnBoolValue() ? 1 : 0; -} - -int returnBoolValueOrDefault_c(int defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return boolReturnValue_c(); -} - -int intReturnValue_c() -{ - return actualCall->returnIntValue(); -} - -int returnIntValueOrDefault_c(int defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return intReturnValue_c(); -} - -unsigned int unsignedIntReturnValue_c() -{ - return actualCall->returnUnsignedIntValue(); -} - -unsigned int returnUnsignedIntValueOrDefault_c(unsigned int defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return unsignedIntReturnValue_c(); -} - -long int longIntReturnValue_c() -{ - return actualCall->returnLongIntValue(); -} - -long int returnLongIntValueOrDefault_c(long int defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return longIntReturnValue_c(); -} - -unsigned long int unsignedLongIntReturnValue_c() -{ - return actualCall->returnUnsignedLongIntValue(); -} - -unsigned long int returnUnsignedLongIntValueOrDefault_c(unsigned long int defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return unsignedLongIntReturnValue_c(); -} - -#if CPPUTEST_USE_LONG_LONG - -cpputest_longlong longLongIntReturnValue_c() -{ - return actualCall->returnLongLongIntValue(); -} - -cpputest_longlong returnLongLongIntValueOrDefault_c(cpputest_longlong defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return longLongIntReturnValue_c(); -} - -cpputest_ulonglong unsignedLongLongIntReturnValue_c() -{ - return actualCall->returnUnsignedLongLongIntValue(); -} - -cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault_c(cpputest_ulonglong defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return unsignedLongLongIntReturnValue_c(); -} - -#else - -cpputest_longlong longLongIntReturnValue_c() -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_longlong returnLongLongIntValueOrDefault_c(cpputest_longlong) -{ - FAIL("Long Long type is not supported"); - cpputest_longlong ret = {}; - return ret; -} - -cpputest_ulonglong unsignedLongLongIntReturnValue_c() -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -cpputest_ulonglong returnUnsignedLongLongIntValueOrDefault_c(cpputest_ulonglong) -{ - FAIL("Unsigned Long Long type is not supported"); - cpputest_ulonglong ret = {}; - return ret; -} - -#endif - -const char* stringReturnValue_c() -{ - return actualCall->returnStringValue(); -} - -const char* returnStringValueOrDefault_c(const char * defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return stringReturnValue_c(); -} - -double doubleReturnValue_c() -{ - return actualCall->returnDoubleValue(); -} - -double returnDoubleValueOrDefault_c(double defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return doubleReturnValue_c(); -} - -void* pointerReturnValue_c() -{ - return actualCall->returnPointerValue(); -} - -void* returnPointerValueOrDefault_c(void * defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return pointerReturnValue_c(); -} - -const void* constPointerReturnValue_c() -{ - return actualCall->returnConstPointerValue(); -} - -const void* returnConstPointerValueOrDefault_c(const void * defaultValue) -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return constPointerReturnValue_c(); -} - -void (*functionPointerReturnValue_c())() -{ - return (void (*)()) actualCall->returnFunctionPointerValue(); -} - -void (*returnFunctionPointerValueOrDefault_c(void (*defaultValue)()))() -{ - if (!hasReturnValue_c()) { - return defaultValue; - } - return functionPointerReturnValue_c(); -} - -void disable_c() -{ - currentMockSupport->disable(); -} - -void enable_c() -{ - currentMockSupport->enable(); -} - -void ignoreOtherCalls_c() -{ - currentMockSupport->ignoreOtherCalls(); -} - -void setBoolData_c(const char* name, int value) -{ - currentMockSupport->setData(name, (value != 0)); -} - -void setIntData_c(const char* name, int value) -{ - currentMockSupport->setData(name, value); -} - -void setUnsignedIntData_c(const char* name, unsigned int value) -{ - currentMockSupport->setData(name, value); -} - -void setLongIntData_c(const char* name, long int value) -{ - currentMockSupport->setData(name, value); -} - -void setUnsignedLongIntData_c(const char* name, unsigned long int value) -{ - currentMockSupport->setData(name, value); -} - -void setDoubleData_c(const char* name, double value) -{ - currentMockSupport->setData(name, value); -} - -void setStringData_c(const char* name, const char* value) -{ - currentMockSupport->setData(name, value); -} - -void setPointerData_c(const char* name, void* value) -{ - currentMockSupport->setData(name, value); -} - -void setConstPointerData_c(const char* name, const void* value) -{ - currentMockSupport->setData(name, value); -} - -void setFunctionPointerData_c(const char* name, void (*value)()) -{ - currentMockSupport->setData(name, (cpputest_cpp_function_pointer) value); -} - -void setDataObject_c(const char* name, const char* type, void* value) -{ - currentMockSupport->setDataObject(name, type, value); -} - -void setDataConstObject_c(const char* name, const char* type, const void* value) -{ - currentMockSupport->setDataConstObject(name, type, value); -} - -MockValue_c getData_c(const char* name) -{ - return getMockValueCFromNamedValue(currentMockSupport->getData(name)); -} - -int hasReturnValue_c() -{ - return currentMockSupport->hasReturnValue(); -} - -void checkExpectations_c() -{ - currentMockSupport->checkExpectations(); -} - -int expectedCallsLeft_c() -{ - return currentMockSupport->expectedCallsLeft(); -} - -void clear_c() -{ - currentMockSupport->clear(); -} - -void crashOnFailure_c(unsigned shouldCrash) -{ - currentMockSupport->crashOnFailure(0 != shouldCrash); -} - -MockSupport_c* mock_c() -{ - currentMockSupport = &mock("", &failureReporterForC); - return &gMockSupport; -} - -MockSupport_c* mock_scope_c(const char* scope) -{ - currentMockSupport = &mock(scope, &failureReporterForC); - return &gMockSupport; -} - -} diff --git a/src/CppUTestExt/OrderedTest.cpp b/src/CppUTestExt/OrderedTest.cpp deleted file mode 100644 index 50d0b3440..000000000 --- a/src/CppUTestExt/OrderedTest.cpp +++ /dev/null @@ -1,137 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTestExt/OrderedTest.h" - -OrderedTestShell* OrderedTestShell::_orderedTestsHead = NULLPTR; - -OrderedTestShell::OrderedTestShell() : - _nextOrderedTest(NULLPTR), _level(0) -{ -} - -OrderedTestShell::~OrderedTestShell() -{ -} - -int OrderedTestShell::getLevel() -{ - return _level; -} - -void OrderedTestShell::setLevel(int level) -{ - _level = level; -} - -void OrderedTestShell::setOrderedTestHead(OrderedTestShell* test) -{ - _orderedTestsHead = test; -} - -OrderedTestShell* OrderedTestShell::getOrderedTestHead() -{ - return _orderedTestsHead; -} - -bool OrderedTestShell::firstOrderedTest() -{ - return (getOrderedTestHead() == NULLPTR); -} - -OrderedTestShell* OrderedTestShell::addOrderedTest(OrderedTestShell* test) -{ - UtestShell::addTest(test); - _nextOrderedTest = test; - return this; -} - -void OrderedTestShell::addOrderedTestToHead(OrderedTestShell* test) -{ - TestRegistry *reg = TestRegistry::getCurrentRegistry(); - UtestShell* head = getOrderedTestHead(); - - if (NULLPTR == reg->getFirstTest() || head == reg->getFirstTest()) { - reg->addTest(test); - } - else { - reg->getTestWithNext(head)->addTest(test); - test->addTest(head); - } - - test->_nextOrderedTest = getOrderedTestHead(); - setOrderedTestHead(test); -} - -OrderedTestShell* OrderedTestShell::getNextOrderedTest() -{ - return _nextOrderedTest; -} - -OrderedTestInstaller::OrderedTestInstaller(OrderedTestShell& test, - const char* groupName, const char* testName, const char* fileName, - size_t lineNumber, int level) -{ - test.setTestName(testName); - test.setGroupName(groupName); - test.setFileName(fileName); - test.setLineNumber(lineNumber); - test.setLevel(level); - - if (OrderedTestShell::firstOrderedTest()) OrderedTestShell::addOrderedTestToHead(&test); - else addOrderedTestInOrder(&test); -} - -void OrderedTestInstaller::addOrderedTestInOrder(OrderedTestShell* test) -{ - if (test->getLevel() < OrderedTestShell::getOrderedTestHead()->getLevel()) - OrderedTestShell::addOrderedTestToHead(test); - else addOrderedTestInOrderNotAtHeadPosition(test); -} - -void OrderedTestInstaller::addOrderedTestInOrderNotAtHeadPosition( - OrderedTestShell* test) -{ - OrderedTestShell* current = OrderedTestShell::getOrderedTestHead(); - while (current->getNextOrderedTest()) { - - if (current->getNextOrderedTest()->getLevel() > test->getLevel()) { - test->addOrderedTest(current->getNextOrderedTest()); - current->addOrderedTest(test); - return; - } - current = current->getNextOrderedTest(); - } - test->addOrderedTest(current->getNextOrderedTest()); - current->addOrderedTest(test); -} - -OrderedTestInstaller::~OrderedTestInstaller() -{ -} diff --git a/src/Platforms/Borland/UtestPlatform.cpp b/src/Platforms/Borland/UtestPlatform.cpp deleted file mode 100644 index 3a09a3e68..000000000 --- a/src/Platforms/Borland/UtestPlatform.cpp +++ /dev/null @@ -1,332 +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 -#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 deleted file mode 100644 index 558245c5d..000000000 --- a/src/Platforms/C2000/UtestPlatform.cpp +++ /dev/null @@ -1,250 +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. - */ - -/* Un-comment to use buffer instead of std out */ -// #define USE_BUFFER_OUTPUT 1 -#include - -#include "CppUTest/TestHarness.h" -#undef malloc -#undef free -#undef calloc -#undef realloc -#undef strdup -#undef strndup -#define far // eliminate "meaningless type qualifier" warning -extern "C" { -#include -#include -#include -#include -#include -#include -#include -} -#undef far -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -#if USE_BUFFER_OUTPUT - // Buffer for crude output routine - #define BUFFER_SIZE 4096 - static char buffer [BUFFER_SIZE]; /* "never used" warning is OK */ - static int idx = 0; -#endif - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static void C2000RunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result) -{ - result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b")); -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell*, TestPlugin*, TestResult*) = - C2000RunTestInASeperateProcess; - -extern "C" { - -static int C2000SetJmp(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 C2000LongJmp() -{ - jmp_buf_index--; - longjmp(test_exit_jmp_buf[jmp_buf_index], 1); -} - -static void C2000RestoreJumpBuffer() -{ - jmp_buf_index--; -} - -int (*PlatformSpecificSetJmp)(void (*function) (void*), void*) = C2000SetJmp; -void (*PlatformSpecificLongJmp)(void) = C2000LongJmp; -void (*PlatformSpecificRestoreJumpBuffer)(void) = C2000RestoreJumpBuffer; - -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 - * This has two consequences: - * (1) We need to sum up the part in order to get an "elapsed since" time value, - * rather than just using tm_sec. - * (2) There is a possibility of overflow, since we stop at the hour - * (3) Resolution is 1 s, even though we return ms. - */ - time_t t = time((time_t*)0); - struct tm * ptm = gmtime(&t); - 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; -} - -static const char* TimeStringImplementation() -{ - time_t tm = time(NULL); - return ctime(&tm); -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = C2000TimeInMillis; -const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation; - -extern int vsnprintf(char*, size_t, const char*, va_list); // not std::vsnprintf() - -extern int (*PlatformSpecificVSNprintf)(char *, size_t, const char*, va_list) = vsnprintf; - -PlatformSpecificFile C2000FOpen(const char* filename, const char* flag) -{ - return fopen(filename, flag); -} - -static void C2000FPuts(const char* str, PlatformSpecificFile 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) -{ - 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 void CL2000Flush() -{ - fflush(stdout); -} - -extern void (*PlatformSpecificFlush)(void) = CL2000Flush; - -static void* C2000Malloc(size_t size) -{ - return (void*)malloc((unsigned long)size); -} - -static void* C2000Realloc (void* memory, size_t size) -{ - return (void*)realloc(memory, (unsigned long)size); -} - -static void C2000Free(void* memory) -{ - free(memory); -} - -static void* C2000MemCpy(void* s1, const void* s2, size_t size) -{ - return (void*)memcpy(s1, s2, size); -} - -static void* C2000Memset(void* mem, int c, size_t size) -{ - register unsigned long i = size; - register long p = (long) mem; - while (i--) *__farptr_to_word(p++) = c; - return mem; -} - -void* (*PlatformSpecificMalloc)(size_t size) = C2000Malloc; -void* (*PlatformSpecificRealloc)(void* memory, size_t size) = C2000Realloc; -void (*PlatformSpecificFree)(void* memory) = C2000Free; -void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size) = C2000MemCpy; -void* (*PlatformSpecificMemset)(void* mem, int c, size_t size) = C2000Memset; - -/* -double PlatformSpecificFabs(double d) -{ - return fabs(d); -} -*/ -double (*PlatformSpecificFabs)(double) = fabs; - -static int IsNanImplementation(double d) -{ - return 0; -} - -static int IsInfImplementation(double d) -{ - return 0; -} - -int (*PlatformSpecificIsNan)(double d) = IsNanImplementation; -int (*PlatformSpecificIsInf)(double d) = IsInfImplementation; - -static PlatformSpecificMutex DummyMutexCreate(void) -{ - return 0; -} - -static void DummyMutexLock(PlatformSpecificMutex mtx) -{ -} - -static void DummyMutexUnlock(PlatformSpecificMutex mtx) -{ -} - -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; - -} diff --git a/src/Platforms/Dos/UtestPlatform.cpp b/src/Platforms/Dos/UtestPlatform.cpp deleted file mode 100644 index c17cd1a4a..000000000 --- a/src/Platforms/Dos/UtestPlatform.cpp +++ /dev/null @@ -1,244 +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. - */ - -/* Un-comment to use buffer instead of std out */ -// #define USE_BUFFER_OUTPUT 1 -#include - -#include "CppUTest/TestHarness.h" -#undef malloc -#undef free -#undef calloc -#undef realloc -#undef strdup -#undef strndup - -#define far // eliminate "meaningless type qualifier" warning -#include -#include -#include -#include -#include -#include -#include -#undef far - -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static void DummyRunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result) -{ - result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b")); -} - -static int DummyPlatformSpecificFork(void) -{ - return 0; -} - -static int DummyPlatformSpecificWaitPid(int, int*, int) -{ - return 0; -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell*, TestPlugin*, TestResult*) = DummyRunTestInASeperateProcess; -int (*PlatformSpecificFork)() = DummyPlatformSpecificFork; -int (*PlatformSpecificWaitPid)(int, int*, int) = DummyPlatformSpecificWaitPid; - -extern "C" { - -static int DosSetJmp(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 DosLongJmp() -{ - jmp_buf_index--; - longjmp(test_exit_jmp_buf[jmp_buf_index], 1); -} - -static void DosRestoreJumpBuffer() -{ - jmp_buf_index--; -} - -int (*PlatformSpecificSetJmp)(void (*function) (void*), void*) = DosSetJmp; -void (*PlatformSpecificLongJmp)(void) = DosLongJmp; -void (*PlatformSpecificRestoreJumpBuffer)(void) = DosRestoreJumpBuffer; - -static unsigned long DosTimeInMillis() -{ - return (unsigned long)(clock() * 1000 / CLOCKS_PER_SEC); -} - -static const char* DosTimeString() -{ - time_t tm = time(NULL); - return ctime(&tm); -} - -static int DosVSNprintf(char* str, size_t size, const char* format, va_list args) { - return vsnprintf(str, size, format, args); -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = DosTimeInMillis; -const char* (*GetPlatformSpecificTimeString)() = DosTimeString; -int (*PlatformSpecificVSNprintf)(char *, size_t, const char*, va_list) = DosVSNprintf; - -PlatformSpecificFile DosFOpen(const char* filename, const char* flag) -{ - return fopen(filename, flag); -} - -static void DosFPuts(const char* str, PlatformSpecificFile file) -{ - fputs(str, (FILE*)file); -} - -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 void DosFlush() -{ - fflush(stdout); -} - -extern void (*PlatformSpecificFlush)(void) = DosFlush; - -static void* DosMalloc(size_t size) -{ - return malloc(size); -} - -static void* DosRealloc (void* memory, size_t size) -{ - return realloc(memory, size); -} - -static void DosFree(void* memory) -{ - free(memory); -} - -static void* DosMemCpy(void* s1, const void* s2, size_t size) -{ - return memcpy(s1, s2, size); -} - -static void* DosMemset(void* mem, int c, size_t size) -{ - return memset(mem, c, size); -} - -void* (*PlatformSpecificMalloc)(size_t size) = DosMalloc; -void* (*PlatformSpecificRealloc)(void* memory, size_t size) = DosRealloc; -void (*PlatformSpecificFree)(void* memory) = DosFree; -void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size) = DosMemCpy; -void* (*PlatformSpecificMemset)(void* mem, int c, size_t size) = DosMemset; - -static void DosSrand(unsigned int seed) -{ - srand(seed); -} - -static int DosRand() -{ - return rand(); -} - -static double DosFabs(double d) -{ - return fabs(d); -} - -static int DosIsNan(double d) -{ - return isnan(d); -} - -static int DosIsInf(double d) -{ - return isinf(d); -} - -void (*PlatformSpecificSrand)(unsigned int) = DosSrand; -int (*PlatformSpecificRand)(void) = DosRand; -double (*PlatformSpecificFabs)(double) = DosFabs; -int (*PlatformSpecificIsNan)(double d) = DosIsNan; -int (*PlatformSpecificIsInf)(double d) = DosIsInf; - -static PlatformSpecificMutex DummyMutexCreate(void) -{ - return 0; -} - -static void DummyMutexLock(PlatformSpecificMutex mtx) -{ -} - -static void DummyMutexUnlock(PlatformSpecificMutex mtx) -{ -} - -static void DummyMutexDestroy(PlatformSpecificMutex mtx) -{ -} - -PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate; -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 deleted file mode 100644 index c86b47839..000000000 --- a/src/Platforms/Gcc/UtestPlatform.cpp +++ /dev/null @@ -1,358 +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 -#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 - -#ifdef CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK -#include -#endif - -#include "CppUTest/PlatformSpecificFunctions.h" - -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. -#if !defined(CPPUTEST_HAVE_FORK) || !defined(CPPUTEST_HAVE_WAITPID) || !defined(CPPUTEST_HAVE_KILL) - -static void GccPlatformSpecificRunTestInASeperateProcess(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 GccPlatformSpecificRunTestInASeperateProcess(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) = - GccPlatformSpecificRunTestInASeperateProcess; -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; -} - -/* - * 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 :( - */ -#ifdef __clang__ - #if !((__clang_major__ == 3) && (__clang_minor__ == 0)) - CPPUTEST_NORETURN - #endif -#endif -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]; -#ifdef STDC_WANT_SECURE_LIB - static struct tm lastlocaltime; - localtime_s(&lastlocaltime, &theTime); - struct tm *tmp = &lastlocaltime; -#else - struct tm *tmp = localtime(&theTime); -#endif - strftime(dateTime, 80, "%Y-%m-%dT%H:%M:%S", tmp); - return dateTime; -} - -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 */ -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wformat-nonliteral" -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wused-but-marked-unused" -#endif -int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list) = vsnprintf; - -static PlatformSpecificFile PlatformSpecificFOpenImplementation(const char* filename, const char* flag) -{ -#ifdef STDC_WANT_SECURE_LIB - FILE* file; - fopen_s(&file, filename, flag); - return file; -#else - return fopen(filename, flag); -#endif -} - -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; - -/* GCC 4.9.x introduces -Wfloat-conversion, which causes a warning / error - * in GCC's own (macro) implementation of isnan() and isinf(). - */ -#if defined(__GNUC__) && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)) -#pragma GCC diagnostic ignored "-Wfloat-conversion" -#endif - -static int IsNanImplementation(double d) -{ - return isnan(d); -} - -static int IsInfImplementation(double d) -{ - return isinf(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/GccNoStdC/UtestPlatform.cpp b/src/Platforms/GccNoStdC/UtestPlatform.cpp deleted file mode 100644 index 3b3c996b3..000000000 --- a/src/Platforms/GccNoStdC/UtestPlatform.cpp +++ /dev/null @@ -1,83 +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/TestHarness.h" -#undef malloc -#undef free -#undef calloc -#undef realloc -#undef strdup -#undef strndup - -#include "CppUTest/PlatformSpecificFunctions.h" - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell*, TestPlugin*, TestResult*) = NULLPTR; -int (*PlatformSpecificFork)() = NULLPTR; -int (*PlatformSpecificWaitPid)(int, int*, int) = NULLPTR; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -void (*PlatformSpecificLongJmp)() = NULLPTR; -int (*PlatformSpecificSetJmp)(void (*)(void*), void*) = NULLPTR; -void (*PlatformSpecificRestoreJumpBuffer)() = 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; - -void (*PlatformSpecificFlush)(void) = NULLPTR; - -int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list) = NULLPTR; - -/* Dynamic Memory operations */ -void* (*PlatformSpecificMalloc)(size_t) = NULLPTR; -void* (*PlatformSpecificRealloc)(void*, size_t) = NULLPTR; -void (*PlatformSpecificFree)(void*) = NULLPTR; -void* (*PlatformSpecificMemCpy)(void*, const void*, size_t) = NULLPTR; -void* (*PlatformSpecificMemset)(void*, int, size_t) = NULLPTR; - -double (*PlatformSpecificFabs)(double) = NULLPTR; -int (*PlatformSpecificIsNan)(double) = NULLPTR; -int (*PlatformSpecificIsInf)(double) = NULLPTR; -int (*PlatformSpecificAtExit)(void(*func)(void)) = NULLPTR; - -PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = NULLPTR; -void (*PlatformSpecificMutexLock)(PlatformSpecificMutex mtx) = NULLPTR; -void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex mtx) = NULLPTR; -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 deleted file mode 100644 index 771ca5804..000000000 --- a/src/Platforms/Iar/UtestPlatform.cpp +++ /dev/null @@ -1,206 +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 -#include -#include -#include -#include -#include -#include -#include -#include "CppUTest/TestHarness.h" -#undef malloc -#undef calloc -#undef realloc -#undef free -#undef strdup -#undef strndup -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static void DummyPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result) -{ - result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b")); -} - -static int DummyPlatformSpecificFork(void) -{ - return 0; -} - -static int DummyPlatformSpecificWaitPid(int, int*, int) -{ - return 0; -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) = - DummyPlatformSpecificRunTestInASeperateProcess; -int (*PlatformSpecificFork)(void) = DummyPlatformSpecificFork; -int (*PlatformSpecificWaitPid)(int, int*, int) = DummyPlatformSpecificWaitPid; - -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() -{ - clock_t t = clock(); - - t = t * 10; - - return (unsigned long)t; -} - -///////////// Time in String - -static const char* TimeStringImplementation() -{ - time_t tm = time(NULL); - char* pTimeStr = ctime(&tm); - char* newlineChar = strchr(pTimeStr, '\n'); // Find the terminating newline character. - if(newlineChar != NULL) *newlineChar = '\0'; //If newline is found replace it with the string terminator. - return (pTimeStr); -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation; -const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation; - -int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list args) = vsnprintf; - -static PlatformSpecificFile PlatformSpecificFOpenImplementation(const char* filename, const char* flag) -{ - static int fileNo = 0; - (void)filename; - (void)flag; - fileNo++; - return (void*)fileNo; -} - -static void PlatformSpecificFPutsImplementation(const char* str, PlatformSpecificFile file) -{ - (void)str; - (void)file; - printf("FILE%d:%s",(int)file, str); -} - -static void PlatformSpecificFCloseImplementation(PlatformSpecificFile file) -{ - (void)file; -} - -static void PlatformSpecificFlushImplementation() -{ -} - -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 isinf(d); -} - -double (*PlatformSpecificFabs)(double) = fabs; -int (*PlatformSpecificIsNan)(double) = IsNanImplementation; -int (*PlatformSpecificIsInf)(double) = IsInfImplementation; -int (*PlatformSpecificAtExit)(void(*func)(void)) = atexit; /// this was undefined before - -static PlatformSpecificMutex DummyMutexCreate(void) -{ - return 0; -} - -static void DummyMutexLock(PlatformSpecificMutex) -{ -} - -static void DummyMutexUnlock(PlatformSpecificMutex) -{ -} - -static void DummyMutexDestroy(PlatformSpecificMutex) -{ -} - -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 deleted file mode 100644 index 9d2582eaa..000000000 --- a/src/Platforms/Keil/UtestPlatform.cpp +++ /dev/null @@ -1,221 +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 -#include "CppUTest/TestHarness.h" -#undef malloc -#undef free -#undef calloc -#undef realloc -#undef strdup -#undef strndup - -#define far // eliminate "meaningless type qualifier" warning -#include -#include -#include -#include -#include -#include -#include - -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static void DummyRunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result) -{ - result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b")); -} - -static int DummyPlatformSpecificFork(void) -{ - return 0; -} - -static int DummyPlatformSpecificWaitPid(int, int*, int) -{ - return 0; -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell*, TestPlugin*, TestResult*) = DummyRunTestInASeperateProcess; -int (*PlatformSpecificFork)() = DummyPlatformSpecificFork; -int (*PlatformSpecificWaitPid)(int, int*, int) = DummyPlatformSpecificWaitPid; - -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 (*function)(void*), void*) = PlatformSpecificSetJmpImplementation; - void (*PlatformSpecificRestoreJumpBuffer)() = PlatformSpecificRestoreJumpBufferImplementation; - - - - ///////////// Time in millis - /* - * In Keil MDK-ARM, clock() default implementation used semihosting. - * Resolutions is user adjustable (1 ms for now) - */ - static unsigned long TimeInMillisImplementation() - { - clock_t t = clock(); - - t = t * 10; - - return (unsigned long)t; - } - - unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation; - - static const char* TimeStringImplementation() - { - time_t tm = 0;//time(NULL); // todo - return ctime(&tm); - } - - const char* (*GetPlatformSpecificTimeString)() = TimeStringImplementation; - - int PlatformSpecificAtoI(const char* str) - { - return atoi(str); - } - - /* The ARMCC compiler will compile this function with C++ linkage, unless - * we specifically tell it to use C linkage again, in the function definiton. - */ - extern int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list args) = vsnprintf; - - static PlatformSpecificFile PlatformSpecificFOpenImplementation(const char* filename, const char* flag) - { - return 0; - } - - static void PlatformSpecificFPutsImplementation(const char* str, PlatformSpecificFile file) - { - printf("%s", str); - } - - static void PlatformSpecificFCloseImplementation(PlatformSpecificFile file) - { - } - - static void PlatformSpecificFlushImplementation() - { - } - - 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) = malloc; - void* (*PlatformSpecificRealloc) (void*, size_t) = realloc; - void (*PlatformSpecificFree)(void*) = free; - void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size) = memcpy; - void* (*PlatformSpecificMemset)(void*, int, size_t) = memset; - - static int IsNanImplementation(double d) - { -# ifdef __MICROLIB - return 0; -# else - return isnan(d); -# endif - } - - static int IsInfImplementation(double d) - { -# ifdef __MICROLIB - return 0; -# else - return isinf(d); -# endif - } - - int DummyAtExit(void(*)(void)) - { - return 0; - } - - double (*PlatformSpecificFabs)(double) = abs; - int (*PlatformSpecificIsNan)(double) = IsNanImplementation; - int (*PlatformSpecificIsInf)(double) = IsInfImplementation; - int (*PlatformSpecificAtExit)(void(*func)(void)) = DummyAtExit; - - static PlatformSpecificMutex DummyMutexCreate(void) - { - return 0; - } - - static void DummyMutexLock(PlatformSpecificMutex mtx) - { - } - - static void DummyMutexUnlock(PlatformSpecificMutex mtx) - { - } - - static void DummyMutexDestroy(PlatformSpecificMutex mtx) - { - } - - 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/Symbian/README_Symbian.txt b/src/Platforms/Symbian/README_Symbian.txt deleted file mode 100644 index 1f9dc6c36..000000000 --- a/src/Platforms/Symbian/README_Symbian.txt +++ /dev/null @@ -1,36 +0,0 @@ -CppUTest on Symbian - -Compliling - -To compile CppUTest you need to have Symbian Posix libraries installed. On S60 it's -recommended to use S60 Open C. On other platforms one can use Symbian PIPS. Compiling is -in standard way, by issuing from command line commands bldmake bldfiles && abld build in -build-directory. You can also import the project's bld.inf file into Carbide in normal way. - - -Writing tests - -CppUTest exports the needed header files into \epoc32\include\CppUTest -directory. Add the directory -to the include-path of the test project. One needs to include TestHarness.h file into test source -file. The test project must link against cpputest.lib using STATICLIBRARY statement in MMP-file. -CppUTest depends also on standard C-library so the tests must be linked against libc as well. - -The entry point file of the tests is normally the following: -#include - -#include - -// This is a GCCE toolchain workaround needed when compiling with GCCE -// and using main() entry point -#ifdef __GCCE__ -#include -#endif - -int main(int argc, char** argv) - { - CommandLineTestRunner::RunAllTests(argc, argv); - } - -The test must be statically linked against libcrt0.lib if standard main (not E32Main) is used as above. - -For the further example, please consult alltests.mmp in build directory. diff --git a/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp b/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp deleted file mode 100644 index dbea37a3c..000000000 --- a/src/Platforms/Symbian/SymbianMemoryLeakWarning.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde and Timo Puronen - * 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 "MemoryLeakWarning.h" - -#include - -MemoryLeakWarning* MemoryLeakWarning::_latest = NULL; - -// naming convention due to CppUTest generic class name -class MemoryLeakWarningData : public CBase { -public: - TInt iInitialAllocCells; - TInt iExpectedLeaks; - TInt iInitialThreadHandleCount; - TInt iInitialProcessHandleCount; -}; - -MemoryLeakWarning::MemoryLeakWarning() -{ - _latest = this; - CreateData(); -} - -MemoryLeakWarning::~MemoryLeakWarning() -{ - DestroyData(); -} - -void MemoryLeakWarning::Enable() -{ -} - -const char* MemoryLeakWarning::FinalReport(int toBeDeletedLeaks) -{ - TInt cellDifference(User::CountAllocCells() - _impl->iInitialAllocCells); - if( cellDifference != toBeDeletedLeaks ) { - return "Heap imbalance after test\n"; - } - - TInt processHandles; - TInt threadHandles; - RThread().HandleCount(processHandles, threadHandles); - - if(_impl->iInitialProcessHandleCount != processHandles || - _impl->iInitialThreadHandleCount != threadHandles) { - return "Handle count imbalance after test\n"; - } - - return ""; -} - -void MemoryLeakWarning::CheckPointUsage() -{ - _impl->iInitialAllocCells = User::CountAllocCells(); - RThread().HandleCount(_impl->iInitialProcessHandleCount, _impl->iInitialThreadHandleCount); -} - -bool MemoryLeakWarning::UsageIsNotBalanced() -{ - TInt allocatedCells(User::CountAllocCells()); - if(_impl->iExpectedLeaks != 0) { - TInt difference(Abs(_impl->iInitialAllocCells - allocatedCells)); - return difference != _impl->iExpectedLeaks; - } - return allocatedCells != _impl->iInitialAllocCells; -} - -const char* MemoryLeakWarning::Message() -{ - return ""; -} - -void MemoryLeakWarning::ExpectLeaks(int n) -{ - _impl->iExpectedLeaks = n; -} - -// this method leaves (no naming convention followed due to CppUTest framework -void MemoryLeakWarning::CreateData() -{ - _impl = new(ELeave) MemoryLeakWarningData(); -} - -void MemoryLeakWarning::DestroyData() -{ - delete _impl; - _impl = NULL; -} - -MemoryLeakWarning* MemoryLeakWarning::GetLatest() -{ - return _latest; -} - -void MemoryLeakWarning::SetLatest(MemoryLeakWarning* latest) -{ - _latest = latest; -} diff --git a/src/Platforms/Symbian/UtestPlatform.cpp b/src/Platforms/Symbian/UtestPlatform.cpp deleted file mode 100644 index 2829a6f7d..000000000 --- a/src/Platforms/Symbian/UtestPlatform.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2007, Michael Feathers, James Grenning, Bas Vodde and Timo Puronen - * 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/TestHarness.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -int PlatformSpecificSetJmp(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; -} - -void PlatformSpecificLongJmp() -{ - jmp_buf_index--; - longjmp(test_exit_jmp_buf[jmp_buf_index], 1); -} - -void PlatformSpecificRestoreJumpBuffer() -{ - jmp_buf_index--; -} - -void PlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin* plugin, TestResult* result) -{ - printf("-p doesn't work on this platform as it is not implemented. Running inside the process\b"); - shell->runOneTest(plugin, *result); -} - -static unsigned long TimeInMillisImplementation() { - struct timeval tv; - struct timezone tz; - ::gettimeofday(&tv, &tz); - return ((unsigned long)tv.tv_sec * 1000) + ((unsigned long)tv.tv_usec / 1000); -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static SimpleString TimeStringImplementation() { - time_t tm = time(NULL); - return ctime(&tm); -} - -SimpleString GetPlatformSpecificTimeString() = TimeStringImplementation; - -int PlatformSpecificVSNprintf(char* str, size_t size, const char* format, va_list args) { - return vsnprintf(str, size, format, args); -} - -void PlatformSpecificFlush() { - fflush(stdout); -} - -double PlatformSpecificFabs(double d) { - return fabs(d); -} - -void* PlatformSpecificMalloc(size_t size) { - return malloc(size); -} - -void* PlatformSpecificRealloc (void* memory, size_t size) { - return realloc(memory, size); -} - -void PlatformSpecificFree(void* memory) { - free(memory); -} - -void* PlatformSpecificMemCpy(void* s1, const void* s2, size_t size) { - return memcpy(s1, s2, size); -} - -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); -} - -void PlatformSpecificFPuts(const char* str, PlatformSpecificFile file) { - fputs(str, (FILE*)file); -} - -void PlatformSpecificFClose(PlatformSpecificFile file) { - fclose((FILE*)file); -} - -extern "C" { - -static int IsNanImplementation(double d) -{ - return isnan(d); -} - -static int IsInfImplementation(double d) -{ - return isinf(d); -} - -int (*PlatformSpecificIsNan)(double) = IsNanImplementation; -int (*PlatformSpecificIsInf)(double) = IsInfImplementation; - -} - -static PlatformSpecificMutex DummyMutexCreate(void) -{ - FAIL("PlatformSpecificMutexCreate is not implemented"); - return 0; -} - -static void DummyMutexLock(PlatformSpecificMutex mtx) -{ - FAIL("PlatformSpecificMutexLock is not implemented"); -} - -static void DummyMutexUnlock(PlatformSpecificMutex mtx) -{ - FAIL("PlatformSpecificMutexUnlock is not implemented"); -} - -static void DummyMutexDestroy(PlatformSpecificMutex mtx) -{ - FAIL("PlatformSpecificMutexDestroy is not implemented"); -} - -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 deleted file mode 100644 index 992c6b863..000000000 --- a/src/Platforms/VisualCpp/UtestPlatform.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include -#include "CppUTest/TestHarness.h" -#undef malloc -#undef free -#undef calloc -#undef realloc -#undef strdup -#undef strndup - -#include -#include -#include -#include -#include -#include -#include -#include "CppUTest/PlatformSpecificFunctions.h" - -#include -#include - -#include - -#ifdef STDC_WANT_SECURE_LIB - #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 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]; -static int jmp_buf_index = 0; - -static int VisualCppSetJmp(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; -} - -CPPUTEST_NORETURN static void VisualCppLongJmp() -{ - jmp_buf_index--; - longjmp(test_exit_jmp_buf[jmp_buf_index], 1); -} - -static void VisualCppRestoreJumpBuffer() -{ - jmp_buf_index--; -} - -int (*PlatformSpecificSetJmp)(void (*function) (void*), void* data) = VisualCppSetJmp; -void (*PlatformSpecificLongJmp)(void) = VisualCppLongJmp; -void (*PlatformSpecificRestoreJumpBuffer)(void) = VisualCppRestoreJumpBuffer; - -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")); -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) = - VisualCppRunTestInASeperateProcess; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::visualStudio; -} - -///////////// Time in millis - -static unsigned long VisualCppTimeInMillis() -{ - static LARGE_INTEGER s_frequency; - static const BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency); - if (s_use_qpc) - { - LARGE_INTEGER now; - QueryPerformanceCounter(&now); - return (unsigned long)((now.QuadPart * 1000) / s_frequency.QuadPart); - } - else - { - #ifdef TIMERR_NOERROR - return (unsigned long)timeGetTime(); - #else - #if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || (_WIN32_WINNT < _WIN32_WINNT_VISTA) - return (unsigned long)GetTickCount(); - #else - return (unsigned long)GetTickCount64(); - #endif - #endif - } -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = VisualCppTimeInMillis; - -///////////// Time in String - -static const char* VisualCppTimeString() -{ - time_t the_time = time(NULLPTR); - struct tm the_local_time; - static char dateTime[80]; - MAYBE_SECURE_LOCALTIME(&the_local_time, &the_time); - strftime(dateTime, 80, "%Y-%m-%dT%H:%M:%S", &the_local_time); - return dateTime; -} - -const char* (*GetPlatformSpecificTimeString)() = VisualCppTimeString; - -////// taken from gcc - -static int VisualCppVSNprintf(char *str, size_t size, const char* format, va_list args) -{ - char* buf = NULLPTR; - size_t sizeGuess = size; - - int result = MAYBE_SECURE_VSNPRINTF( str, size, _TRUNCATE, format, args); - str[size-1] = 0; - while (result == -1) - { - if (buf) - free(buf); - sizeGuess += 10; - buf = (char*)malloc(sizeGuess); - result = MAYBE_SECURE_VSNPRINTF( buf, sizeGuess, _TRUNCATE, format, args); - } - - if (buf) - free(buf); - return result; - -} - -int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list va_args_list) = VisualCppVSNprintf; - -static PlatformSpecificFile VisualCppFOpen(const char* filename, const char* flag) -{ - FILE* file; - MAYBE_SECURE_FOPEN(&file, filename, flag); - return file; -} - -static void VisualCppFPuts(const char* str, PlatformSpecificFile file) -{ - fputs(str, (FILE*)file); -} - -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; - -static void VisualCppFlush() -{ - fflush(stdout); -} - -void (*PlatformSpecificFlush)(void) = VisualCppFlush; - -static void* VisualCppMalloc(size_t size) -{ - return malloc(size); -} - -static void* VisualCppReAlloc(void* memory, size_t size) -{ - return realloc(memory, size); -} - -static void VisualCppFree(void* memory) -{ - free(memory); -} - -void (*PlatformSpecificSrand)(unsigned int) = srand; -int (*PlatformSpecificRand)(void) = rand; -void* (*PlatformSpecificMalloc)(size_t size) = VisualCppMalloc; -void* (*PlatformSpecificRealloc)(void* memory, size_t size) = VisualCppReAlloc; -void (*PlatformSpecificFree)(void* memory) = VisualCppFree; -void* (*PlatformSpecificMemCpy)(void* s1, const void* s2, size_t size) = memcpy; -void* (*PlatformSpecificMemset)(void* mem, int c, size_t size) = memset; - -static int IsInfImplementation(double d) -{ - return !_finite(d); -} - -double (*PlatformSpecificFabs)(double d) = fabs; -extern "C" int (*PlatformSpecificIsNan)(double) = _isnan; -extern "C" int (*PlatformSpecificIsInf)(double) = IsInfImplementation; -int (*PlatformSpecificAtExit)(void(*func)(void)) = atexit; - -static PlatformSpecificMutex VisualCppMutexCreate(void) -{ - CRITICAL_SECTION *critical_section = new CRITICAL_SECTION; - InitializeCriticalSection(critical_section); - return (PlatformSpecificMutex)critical_section; -} - -static void VisualCppMutexLock(PlatformSpecificMutex mutex) -{ - EnterCriticalSection((CRITICAL_SECTION*)mutex); -} - -static void VisualCppMutexUnlock(PlatformSpecificMutex mutex) -{ - LeaveCriticalSection((CRITICAL_SECTION*)mutex); -} - -static void VisualCppMutexDestroy(PlatformSpecificMutex mutex) -{ - CRITICAL_SECTION *critical_section = (CRITICAL_SECTION*)mutex; - DeleteCriticalSection(critical_section); - delete critical_section; -} - -PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = VisualCppMutexCreate; -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 deleted file mode 100644 index 8c686c25a..000000000 --- a/src/Platforms/armcc/UtestPlatform.cpp +++ /dev/null @@ -1,208 +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 -#include -#include -#include -#include -#include -#include -#include -#include "CppUTest/TestHarness.h" -#undef malloc -#undef calloc -#undef realloc -#undef free -#undef strdup -#undef strndup - -#define far // eliminate "meaningless type qualifier" warning - -#include "CppUTest/PlatformSpecificFunctions.h" - -static jmp_buf test_exit_jmp_buf[10]; -static int jmp_buf_index = 0; - -TestOutput::WorkingEnvironment PlatformSpecificGetWorkingEnvironment() -{ - return TestOutput::eclipse; -} - -static void DummyPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result) -{ - result->addFailure(TestFailure(shell, "-p doesn't work on this platform, as it is lacking fork.\b")); -} - -static int DummyPlatformSpecificFork(void) -{ - return 0; -} - -static int DummyPlatformSpecificWaitPid(int, int*, int) -{ - return 0; -} - -void (*PlatformSpecificRunTestInASeperateProcess)(UtestShell* shell, TestPlugin* plugin, TestResult* result) = - DummyPlatformSpecificRunTestInASeperateProcess; -int (*PlatformSpecificFork)(void) = DummyPlatformSpecificFork; -int (*PlatformSpecificWaitPid)(int, int*, int) = DummyPlatformSpecificWaitPid; - -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 -/* -* In Keil MDK-ARM, clock() default implementation used semihosting. -* Resolutions is user adjustable (1 ms for now) -*/ -static unsigned long TimeInMillisImplementation() -{ - clock_t t = clock(); - return (unsigned long)t; -} - -///////////// Time in String - -static const char* DummyTimeStringImplementation() -{ - time_t tm = 0; - return ctime(&tm); -} - -unsigned long (*GetPlatformSpecificTimeInMillis)() = TimeInMillisImplementation; -const char* (*GetPlatformSpecificTimeString)() = DummyTimeStringImplementation; - -int (*PlatformSpecificVSNprintf)(char *str, size_t size, const char* format, va_list args) = vsnprintf; - -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; - -void (*PlatformSpecificSrand)(unsigned int) = srand; -int (*PlatformSpecificRand)(void) = rand; - -static int IsNanImplementation(double d) -{ - return isnan(d); -} - -static int IsInfImplementation(double d) -{ - return isinf(d); -} - -static int AtExitImplementation(void(*func)(void)) -{ - return atexit(func); -} - -double (*PlatformSpecificFabs)(double) = fabs; -int (*PlatformSpecificIsNan)(double) = IsNanImplementation; -int (*PlatformSpecificIsInf)(double) = IsInfImplementation; -int (*PlatformSpecificAtExit)(void(*func)(void)) = AtExitImplementation; - -static PlatformSpecificMutex DummyMutexCreate(void) -{ - return 0; -} - -static void DummyMutexLock(PlatformSpecificMutex) -{ -} - -static void DummyMutexUnlock(PlatformSpecificMutex) -{ -} - -static void DummyMutexDestroy(PlatformSpecificMutex) -{ -} - -PlatformSpecificMutex (*PlatformSpecificMutexCreate)(void) = DummyMutexCreate; -void (*PlatformSpecificMutexLock)(PlatformSpecificMutex) = DummyMutexLock; -void (*PlatformSpecificMutexUnlock)(PlatformSpecificMutex) = DummyMutexUnlock; -void (*PlatformSpecificMutexDestroy)(PlatformSpecificMutex) = DummyMutexDestroy; -void (*PlatformSpecificAbort)(void) = abort; - -} diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 000000000..d1df6a210 --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,68 @@ +.highlight .c { color: #999988; font-style: italic } /* Comment */ +.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ +.highlight .k { font-weight: bold } /* Keyword */ +.highlight .o { font-weight: bold } /* Operator */ +.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */ +.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */ +.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */ +.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */ +.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ +.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gr { color: #aa0000 } /* Generic.Error */ +.highlight .gh { color: #999999 } /* Generic.Heading */ +.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ +.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */ +.highlight .go { color: #888888 } /* Generic.Output */ +.highlight .gp { color: #555555 } /* Generic.Prompt */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */ +.highlight .gt { color: #aa0000 } /* Generic.Traceback */ +.highlight .kc { font-weight: bold } /* Keyword.Constant */ +.highlight .kd { font-weight: bold } /* Keyword.Declaration */ +.highlight .kn { font-weight: bold } /* Keyword.Namespace */ +.highlight .kp { font-weight: bold } /* Keyword.Pseudo */ +.highlight .kr { font-weight: bold } /* Keyword.Reserved */ +.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */ +.highlight .m { color: #009999 } /* Literal.Number */ +.highlight .s { color: #d14 } /* Literal.String */ +.highlight .na { color: #008080 } /* Name.Attribute */ +.highlight .nb { color: #0086B3 } /* Name.Builtin */ +.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */ +.highlight .no { color: #008080 } /* Name.Constant */ +.highlight .ni { color: #800080 } /* Name.Entity */ +.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */ +.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */ +.highlight .nn { color: #555555 } /* Name.Namespace */ +.highlight .nt { color: #CBDFFF } /* Name.Tag */ +.highlight .nv { color: #008080 } /* Name.Variable */ +.highlight .ow { font-weight: bold } /* Operator.Word */ +.highlight .w { color: #bbbbbb } /* Text.Whitespace */ +.highlight .mf { color: #009999 } /* Literal.Number.Float */ +.highlight .mh { color: #009999 } /* Literal.Number.Hex */ +.highlight .mi { color: #009999 } /* Literal.Number.Integer */ +.highlight .mo { color: #009999 } /* Literal.Number.Oct */ +.highlight .sb { color: #d14 } /* Literal.String.Backtick */ +.highlight .sc { color: #d14 } /* Literal.String.Char */ +.highlight .sd { color: #d14 } /* Literal.String.Doc */ +.highlight .s2 { color: #d14 } /* Literal.String.Double */ +.highlight .se { color: #d14 } /* Literal.String.Escape */ +.highlight .sh { color: #d14 } /* Literal.String.Heredoc */ +.highlight .si { color: #d14 } /* Literal.String.Interpol */ +.highlight .sx { color: #d14 } /* Literal.String.Other */ +.highlight .sr { color: #009926 } /* Literal.String.Regex */ +.highlight .s1 { color: #d14 } /* Literal.String.Single */ +.highlight .ss { color: #990073 } /* Literal.String.Symbol */ +.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #008080 } /* Name.Variable.Class */ +.highlight .vg { color: #008080 } /* Name.Variable.Global */ +.highlight .vi { color: #008080 } /* Name.Variable.Instance */ +.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */ + +.type-csharp .highlight .k { color: #0000FF } +.type-csharp .highlight .kt { color: #0000FF } +.type-csharp .highlight .nf { color: #000000; font-weight: normal } +.type-csharp .highlight .nc { color: #2B91AF } +.type-csharp .highlight .nn { color: #000000 } +.type-csharp .highlight .s { color: #A31515 } +.type-csharp .highlight .sc { color: #A31515 } diff --git a/stylesheets/stylesheet.css b/stylesheets/stylesheet.css new file mode 100644 index 000000000..a54a6397e --- /dev/null +++ b/stylesheets/stylesheet.css @@ -0,0 +1,247 @@ +body { + margin: 0; + padding: 0; + background: #151515 url("../images/bkg.png") 0 0; + color: #eaeaea; + font: 16px; + line-height: 1.5; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; +} + +/* General & 'Reset' Stuff */ + +.container { + width: 90%; + max-width: 600px; + margin: 0 auto; +} + +section { + display: block; + margin: 0 0 20px 0; +} + +h1, h2, h3, h4, h5, h6 { + margin: 0 0 20px; +} + +li { + line-height: 1.4 ; +} + +/* Header,
+ header - container + h1 - project name + h2 - project description +*/ + +header { + background: rgba(0, 0, 0, 0.1); + width: 100%; + border-bottom: 1px dashed #b5e853; + padding: 20px 0; + margin: 0 0 40px 0; +} + +header h1 { + font-size: 30px; + line-height: 1.5; + margin: 0 0 0 -40px; + font-weight: bold; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + color: #b5e853; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), + 0 0 5px rgba(181, 232, 83, 0.1), + 0 0 10px rgba(181, 232, 83, 0.1); + letter-spacing: -1px; + -webkit-font-smoothing: antialiased; +} + +header h1:before { + content: "./ "; + font-size: 24px; +} + +header h2 { + font-size: 18px; + font-weight: 300; + color: #666; +} + +#downloads .btn { + display: inline-block; + text-align: center; + margin: 0; +} + +/* Main Content +*/ + +#main_content { + width: 100%; + -webkit-font-smoothing: antialiased; +} +section img { + max-width: 100% +} + +h1, h2, h3, h4, h5, h6 { + font-weight: normal; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + color: #b5e853; + letter-spacing: -0.03em; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1), + 0 0 5px rgba(181, 232, 83, 0.1), + 0 0 10px rgba(181, 232, 83, 0.1); +} + +#main_content h1 { + font-size: 30px; +} + +#main_content h2 { + font-size: 24px; +} + +#main_content h3 { + font-size: 18px; +} + +#main_content h4 { + font-size: 14px; +} + +#main_content h5 { + font-size: 12px; + text-transform: uppercase; + margin: 0 0 5px 0; +} + +#main_content h6 { + font-size: 12px; + text-transform: uppercase; + color: #999; + margin: 0 0 5px 0; +} + +dt { + font-style: italic; + font-weight: bold; +} + +ul li { + list-style: none; +} + +ul li:before { + content: ">>"; + font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; + font-size: 13px; + color: #b5e853; + margin-left: -37px; + margin-right: 21px; + line-height: 16px; +} + +blockquote { + color: #aaa; + padding-left: 10px; + border-left: 1px dotted #666; +} + +pre { + background: rgba(0, 0, 0, 0.9); + border: 1px solid rgba(255, 255, 255, 0.15); + padding: 10px; + font-size: 14px; + color: #b5e853; + border-radius: 2px; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + text-wrap: normal; + overflow: auto; + overflow-y: hidden; +} + +table { + width: 100%; + margin: 0 0 20px 0; +} + +th { + text-align: left; + border-bottom: 1px dashed #b5e853; + padding: 5px 10px; +} + +td { + padding: 5px 10px; +} + +hr { + height: 0; + border: 0; + border-bottom: 1px dashed #b5e853; + color: #b5e853; +} + +/* Buttons +*/ + +.btn { + display: inline-block; + background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.3), rgba(35, 35, 35, 0.3) 50%, rgba(10, 10, 10, 0.3) 50%, rgba(0, 0, 0, 0.3)); + padding: 8px 18px; + border-radius: 50px; + border: 2px solid rgba(0, 0, 0, 0.7); + border-bottom: 2px solid rgba(0, 0, 0, 0.7); + border-top: 2px solid rgba(0, 0, 0, 1); + color: rgba(255, 255, 255, 0.8); + font-family: Helvetica, Arial, sans-serif; + font-weight: bold; + font-size: 13px; + text-decoration: none; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.75); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); +} + +.btn:hover { + background: -webkit-linear-gradient(top, rgba(40, 40, 40, 0.6), rgba(35, 35, 35, 0.6) 50%, rgba(10, 10, 10, 0.8) 50%, rgba(0, 0, 0, 0.8)); +} + +.btn .icon { + display: inline-block; + width: 16px; + height: 16px; + margin: 1px 8px 0 0; + float: left; +} + +.btn-github .icon { + opacity: 0.6; + background: url("../images/blacktocat.png") 0 0 no-repeat; +} + +/* Links + a, a:hover, a:visited +*/ + +a { + color: #63c0f5; + text-shadow: 0 0 5px rgba(104, 182, 255, 0.5); +} + +/* Clearfix */ + +.cf:before, .cf:after { + content:""; + display:table; +} + +.cf:after { + clear:both; +} + +.cf { + zoom:1; +} \ No newline at end of file diff --git a/tests/AllTests.vcproj b/tests/AllTests.vcproj deleted file mode 100644 index 7e32f154e..000000000 --- a/tests/AllTests.vcproj +++ /dev/null @@ -1,1459 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/AllTests.vcxproj b/tests/AllTests.vcxproj deleted file mode 100644 index 1892b6c1b..000000000 --- a/tests/AllTests.vcxproj +++ /dev/null @@ -1,322 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {913088F6-37C0-4195-80E9-548C7C5303CB} - - - - Application - false - MultiByte - - - Application - false - MultiByte - - - Application - false - MultiByte - - - Application - false - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\cpputest_build\x86\ - ..\cpputest_build\x64\ - ..\cpputest_build\Release\x86\$(ProjectName)\ - ..\cpputest_build\Release\x64\$(ProjectName)\ - false - false - ..\cpputest_build\x86\ - ..\cpputest_build\x64\ - ..\cpputest_build\Debug\x86\$(ProjectName)\ - ..\cpputest_build\Debug\x64\$(ProjectName)\ - true - true - - - - .\Release/AllTests.tlb - - - - - MaxSpeed - OnlyExplicitInline - WIN32;NDEBUG;_CONSOLE;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - Level3 - true - ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories) - OldStyle - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Console - false - - - MachineX86 - - - true - .\Release/AllTests.bsc - - - "$(TargetPath)" - - - - - .\Release/AllTests.tlb - - - - - MaxSpeed - OnlyExplicitInline - WIN32;NDEBUG;_CONSOLE;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - true - MultiThreadedDLL - true - Level3 - true - ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories) - OldStyle - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Console - false - - - - - true - .\Release/AllTests.bsc - - - "$(TargetPath)" - - - - - .\Debug/AllTests.tlb - - - - - Disabled - ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_DEBUG;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - true - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - - - true - true - Console - false - - - MachineX86 - - - true - - - "$(TargetPath)" - - - - - .\Debug/AllTests.tlb - - - - - Disabled - ..\include;..\include\CppUTestExt\CppUTestGTest;..\include\CppUTestExt\CppUTestGMock;..\include\Platforms\VisualCpp;%(AdditionalIncludeDirectories) - _CONSOLE;WIN32;_DEBUG;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - true - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - - - true - true - Console - false - - - - - true - - - "$(TargetPath)" - - - - - {f468f539-27bd-468e-be64-dde641400b51} - false - false - false - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 5d090ace3..000000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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 deleted file mode 100644 index e9e6a2b75..000000000 --- a/tests/CppUTest/AllTests.cpp +++ /dev/null @@ -1,59 +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/TestMemoryAllocator.h" -#include "CppUTest/SimpleStringInternalCache.h" - -#define SHOW_MEMORY_REPORT 0 - -int main(int ac, char **av) -{ - int returnValue = 0; - GlobalSimpleStringCache stringCache; - - { - /* These checks are here to make sure assertions outside test runs don't crash */ - CHECK(true); - LONGS_EQUAL(1, 1); - -#if SHOW_MEMORY_REPORT - GlobalMemoryAccountant accountant; - accountant.start(); -#endif - - returnValue = CommandLineTestRunner::RunAllTests(ac, av); /* cover alternate method */ - -#if SHOW_MEMORY_REPORT - accountant.stop(); - printf("%s", accountant.report().asCharString()); -#endif - } - - return returnValue; -} - diff --git a/tests/CppUTest/AllTests.h b/tests/CppUTest/AllTests.h deleted file mode 100644 index 32ef2c770..000000000 --- a/tests/CppUTest/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/tests/CppUTest/AllocLetTestFree.c b/tests/CppUTest/AllocLetTestFree.c deleted file mode 100644 index 82358074f..000000000 --- a/tests/CppUTest/AllocLetTestFree.c +++ /dev/null @@ -1,28 +0,0 @@ - -#include "CppUTest/StandardCLibrary.h" - -#if CPPUTEST_USE_STD_C_LIB - -#include "AllocLetTestFree.h" - -typedef struct AllocLetTestFreeStruct -{ - int placeHolderForHiddenStructElements; -} AllocLetTestFreeStruct; - -AllocLetTestFree AllocLetTestFree_Create(void) -{ - size_t count = 1; - AllocLetTestFree self = (AllocLetTestFree)calloc(count, sizeof(AllocLetTestFreeStruct)); - return self; -} - -void AllocLetTestFree_Destroy(AllocLetTestFree self) -{ - AllocLetTestFree no_use = self; - self = NULL; - self = no_use; - (void)self; - -} -#endif diff --git a/tests/CppUTest/AllocLetTestFree.h b/tests/CppUTest/AllocLetTestFree.h deleted file mode 100644 index d8b124a72..000000000 --- a/tests/CppUTest/AllocLetTestFree.h +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef D_AllocLetTestFree_H -#define D_AllocLetTestFree_H - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct AllocLetTestFreeStruct * AllocLetTestFree; - -AllocLetTestFree AllocLetTestFree_Create(void); -void AllocLetTestFree_Destroy(AllocLetTestFree); - -#ifdef __cplusplus -} -#endif - -#endif /* D_FakeAllocLetTestFree_H */ diff --git a/tests/CppUTest/AllocLetTestFreeTest.cpp b/tests/CppUTest/AllocLetTestFreeTest.cpp deleted file mode 100644 index 5c05464b7..000000000 --- a/tests/CppUTest/AllocLetTestFreeTest.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -#include "CppUTest/StandardCLibrary.h" - -extern "C" -{ -#include "AllocLetTestFree.h" -} - -#include "CppUTest/TestHarness.h" - -#if CPPUTEST_USE_STD_C_LIB -/* - * This test makes sure that memory leak malloc macros are forced into .cpp and .c files - */ -TEST_GROUP(AllocLetTestFree) -{ - AllocLetTestFree allocLetTestFree; - - void setup() CPPUTEST_OVERRIDE - { - allocLetTestFree = AllocLetTestFree_Create(); - } - - void teardown() CPPUTEST_OVERRIDE - { - AllocLetTestFree_Destroy(allocLetTestFree); - } -}; - -TEST(AllocLetTestFree, Create) -{ - free(allocLetTestFree); -} - -#endif diff --git a/tests/CppUTest/AllocationInCFile.c b/tests/CppUTest/AllocationInCFile.c deleted file mode 100644 index 03165a958..000000000 --- a/tests/CppUTest/AllocationInCFile.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "AllocationInCFile.h" -#include "CppUTest/MemoryLeakDetectorMallocMacros.h" -#include "CppUTest/StandardCLibrary.h" - -/* This file is for simulating overloads of malloc */ - -char* mallocAllocation(void) -{ - return (char*) malloc(10UL); -} - -char* strdupAllocation(void) -{ -#ifdef CPPUTEST_USE_STRDUP_MACROS - return strdup("0123456789"); -#else - return NULL; -#endif -} - - -char* strndupAllocation(void) -{ -#ifdef CPPUTEST_USE_STRDUP_MACROS - return strndup("0123456789", 10); -#else - return NULL; -#endif -} - -void freeAllocation(void* memory) -{ - free(memory); -} - -#undef free - -void freeAllocationWithoutMacro(void* memory) -{ - free(memory); -} - diff --git a/tests/CppUTest/AllocationInCFile.h b/tests/CppUTest/AllocationInCFile.h deleted file mode 100644 index c2131b949..000000000 --- a/tests/CppUTest/AllocationInCFile.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ALLOCATIONINCFILE_H -#define ALLOCATIONINCFILE_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern char* mallocAllocation(void); -extern char* strdupAllocation(void); -extern char* strndupAllocation(void); -extern void freeAllocation(void* memory); -extern void freeAllocationWithoutMacro(void* memory); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tests/CppUTest/AllocationInCppFile.cpp b/tests/CppUTest/AllocationInCppFile.cpp deleted file mode 100644 index b1a662b1c..000000000 --- a/tests/CppUTest/AllocationInCppFile.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* This file is for emulating allocations in a C++ file. - * It is used simulating the use of the memory leak detector on production code in C++ - */ -#undef new -#include "CppUTest/MemoryLeakDetectorNewMacros.h" -#include "AllocationInCppFile.h" - -char* newAllocation() -{ - return new char; -} - -char* newArrayAllocation() -{ - return new char[100]; -} - -#undef new - -char* newAllocationWithoutMacro() -{ - return new char; -} - -char* newArrayAllocationWithoutMacro() -{ - return new char[100]; -} - -#if CPPUTEST_HAVE_EXCEPTIONS - -ClassThatThrowsAnExceptionInTheConstructor::ClassThatThrowsAnExceptionInTheConstructor() -{ - throw 1; -} - -#endif diff --git a/tests/CppUTest/AllocationInCppFile.h b/tests/CppUTest/AllocationInCppFile.h deleted file mode 100644 index 1d59789df..000000000 --- a/tests/CppUTest/AllocationInCppFile.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ALLOCATIONINCPPFILE_H -#define ALLOCATIONINCPPFILE_H - -char* newAllocation(); -char* newArrayAllocation(); - -char* newAllocationWithoutMacro(); -char* newArrayAllocationWithoutMacro(); - -#if CPPUTEST_HAVE_EXCEPTIONS - -class ClassThatThrowsAnExceptionInTheConstructor -{ -public: - CPPUTEST_NORETURN ClassThatThrowsAnExceptionInTheConstructor(); -}; - -#endif - -#endif diff --git a/tests/CppUTest/CMakeLists.txt b/tests/CppUTest/CMakeLists.txt deleted file mode 100644 index 0471ce762..000000000 --- a/tests/CppUTest/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -add_library(CppUTestTests_main OBJECT - AllTests.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 - CompatabilityTests.cpp - CommandLineArgumentsTest.cpp - CommandLineTestRunnerTest.cpp - JUnitOutputTest.cpp -) - -add_cpputest_test(2 - DummyMemoryLeakDetector.cpp - MemoryLeakWarningTest.cpp - PluginTest.cpp - PreprocessorTest.cpp - SetPluginTest.cpp - SimpleMutexTest.cpp - TeamCityOutputTest.cpp - TestFailureNaNTest.cpp - TestFailureTest.cpp - TestResultTest.cpp -) - -add_cpputest_test(3 - MemoryLeakDetectorTest.cpp - SimpleStringTest.cpp - SimpleStringCacheTest.cpp -) - -add_cpputest_test(4 - TestOutputTest.cpp - TestRegistryTest.cpp -) - -add_cpputest_test(5 - AllocationInCFile.c - AllocationInCppFile.cpp - MemoryOperatorOverloadTest.cpp - TeamCityOutputTest.cpp -) - -add_cpputest_test(6 - TestFilterTest.cpp - TestHarness_cTest.cpp - TestHarness_cTestCFile.c - TestInstallerTest.cpp -) - -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 deleted file mode 100644 index dbde888b7..000000000 --- a/tests/CppUTest/CheatSheetTest.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -static void (*real_one) (); -static void stub(){} - -/* in CheatSheetTest.cpp */ -#include "CppUTest/TestHarness.h" - -/* Declare TestGroup with name CheatSheet */ -TEST_GROUP(CheatSheet) -{ -/* declare a setup method for the test group. Optional. */ - 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() CPPUTEST_OVERRIDE - { - } -}; /* Do not forget semicolumn */ - -/* Declare one test within the test group */ -TEST(CheatSheet, TestName) -{ - /* Check two longs are equal */ - LONGS_EQUAL(1, 1); - - /* Check a condition */ - CHECK(true == true); - - /* Check a string */ - STRCMP_EQUAL("HelloWorld", "HelloWorld"); -} diff --git a/tests/CppUTest/CommandLineArgumentsTest.cpp b/tests/CppUTest/CommandLineArgumentsTest.cpp deleted file mode 100644 index 2a4e29b7f..000000000 --- a/tests/CppUTest/CommandLineArgumentsTest.cpp +++ /dev/null @@ -1,638 +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/TestHarness.h" -#include "CppUTest/CommandLineArguments.h" -#include "CppUTest/TestRegistry.h" - -class OptionsPlugin: public TestPlugin -{ -public: - OptionsPlugin(const SimpleString& name) : - TestPlugin(name) - { - } - ~OptionsPlugin() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - bool parseArguments(int /*ac*/, const char *const * /*av*/, int /*index*/) CPPUTEST_OVERRIDE - { - return true; - } -}; - -TEST_GROUP(CommandLineArguments) -{ - CommandLineArguments* args; - OptionsPlugin* plugin; - - void setup() CPPUTEST_OVERRIDE - { - plugin = new OptionsPlugin("options"); - args = NULLPTR; - } - void teardown() CPPUTEST_OVERRIDE - { - delete args; - delete plugin; - } - - bool newArgumentParser(int argc, const char *const *argv) - { - args = new CommandLineArguments(argc, argv); - return args->parse(plugin); - } -}; - -TEST(CommandLineArguments, Create) -{ -} - -TEST(CommandLineArguments, verboseSetMultipleParameters) -{ - const char* argv[] = { "tests.exe", "-v" }; - CHECK(newArgumentParser(2, argv)); - CHECK(args->isVerbose()); -} - -TEST(CommandLineArguments, veryVerbose) -{ - const char* argv[] = { "tests.exe", "-vv" }; - CHECK(newArgumentParser(2, argv)); - CHECK(args->isVeryVerbose()); -} - -TEST(CommandLineArguments, setColor) -{ - const char* argv[] = { "tests.exe", "-c" }; - CHECK(newArgumentParser(2, argv)); - CHECK(args->isColor()); -} - -TEST(CommandLineArguments, repeatSet) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-r3" }; - CHECK(newArgumentParser(argc, argv)); - LONGS_EQUAL(3, args->getRepeatCount()); -} - -TEST(CommandLineArguments, repeatSetDifferentParameter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-r", "4" }; - CHECK(newArgumentParser(argc, argv)); - LONGS_EQUAL(4, args->getRepeatCount()); -} - -TEST(CommandLineArguments, repeatSetDefaultsToTwoAndShuffleDisabled) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-r" }; - CHECK(newArgumentParser(argc, argv)); - LONGS_EQUAL(2, args->getRepeatCount()); -} - -TEST(CommandLineArguments, reverseEnabled) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-b" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_TRUE(args->isReversing()); -} - -TEST(CommandLineArguments, shuffleDisabledByDefault) -{ - int argc = 1; - const char* argv[] = { "tests.exe" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_FALSE(args->isShuffling()); -} - -TEST(CommandLineArguments, shuffleEnabled) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-s" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_TRUE(args->isShuffling()); -} - -TEST(CommandLineArguments, shuffleWithSeedZeroIsOk) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-s0" }; - CHECK_FALSE(newArgumentParser(argc, argv)); - CHECK_EQUAL(0, args->getShuffleSeed()); -} - -TEST(CommandLineArguments, shuffleEnabledSpecificSeedCase1) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-s999"}; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(999, args->getShuffleSeed()); -} - -TEST(CommandLineArguments, shuffleEnabledSpecificSeedCase2) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-s 888"}; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(888, args->getShuffleSeed()); -} - -TEST(CommandLineArguments, shuffleEnabledSpecificSeedCase3) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-s", "777"}; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(777, args->getShuffleSeed()); -} - -TEST(CommandLineArguments, shuffleBeforeDoesNotDisturbOtherSwitch) -{ - int argc = 4; - const char* argv[] = { "tests.exe", "-s", "-sg", "group" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.strictMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); - CHECK_TRUE(args->isShuffling()); -} - -TEST(CommandLineArguments, runningTestsInSeperateProcesses) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-p" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->runTestsInSeperateProcess()); -} - -TEST(CommandLineArguments, setGroupFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-g", "group" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(TestFilter("group"), *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setCompleteGroupDotNameFilterInvalidArgument) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-t", "groupname" }; - CHECK_FALSE(newArgumentParser(argc, argv)); -} - -TEST(CommandLineArguments, setCompleteGroupDotNameFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-t", "group.name" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(TestFilter("group"), *args->getGroupFilters()); - 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) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-ggroup" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(TestFilter("group"), *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setStrictGroupFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-sg", "group" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.strictMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setStrictGroupFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-sggroup" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.strictMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setExcludeGroupFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-xg", "group" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.invertMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setExcludeGroupFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-xggroup" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.invertMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setExcludeStrictGroupFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-xsg", "group" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.invertMatching(); - groupFilter.strictMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setExcludeStrictGroupFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-xsggroup" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter groupFilter("group"); - groupFilter.invertMatching(); - groupFilter.strictMatching(); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setNameFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-n", "name" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(TestFilter("name"), *args->getNameFilters()); -} - -TEST(CommandLineArguments, setNameFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-nname" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(TestFilter("name"), *args->getNameFilters()); -} - -TEST(CommandLineArguments, setStrictNameFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-sn", "name" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setStrictNameFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-snname" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setExcludeNameFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-xn", "name" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.invertMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setExcludeNameFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-xnname" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.invertMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setExcludeStrictNameFilter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-xsn", "name" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.invertMatching(); - nameFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setExcludeStrictNameFilterSameParameter) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-xsnname" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("name"); - nameFilter.invertMatching(); - nameFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); -} - -TEST(CommandLineArguments, setTestToRunUsingVerboseOutput) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "TEST(testgroup, testname) - stuff" }; - CHECK(newArgumentParser(argc, argv)); - - TestFilter nameFilter("testname"); - TestFilter groupFilter("testgroup"); - nameFilter.strictMatching(); - groupFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setTestToRunUsingVerboseOutputOfIgnoreTest) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "IGNORE_TEST(testgroup, testname) - stuff" }; - CHECK(newArgumentParser(argc, argv)); - - TestFilter nameFilter("testname"); - TestFilter groupFilter("testgroup"); - nameFilter.strictMatching(); - groupFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()); -} - -TEST(CommandLineArguments, setNormalOutput) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-onormal" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isEclipseOutput()); -} - -TEST(CommandLineArguments, setEclipseOutput) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-oeclipse" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isEclipseOutput()); -} - -TEST(CommandLineArguments, setNormalOutputDifferentParameter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-o", "normal" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isEclipseOutput()); -} - -TEST(CommandLineArguments, setJUnitOutputDifferentParameter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-o", "junit" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isJUnitOutput()); -} - -TEST(CommandLineArguments, setTeamCityOutputDifferentParameter) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-o", "teamcity" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isTeamCityOutput()); -} - -TEST(CommandLineArguments, setOutputToGarbage) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-o", "garbage" }; - CHECK(!newArgumentParser(argc, argv)); -} - -TEST(CommandLineArguments, setPrintGroups) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-lg" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isListingTestGroupNames()); -} - -TEST(CommandLineArguments, setPrintGroupsAndNames) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-ln" }; - CHECK(newArgumentParser(argc, argv)); - CHECK(args->isListingTestGroupAndCaseNames()); -} - -TEST(CommandLineArguments, weirdParamatersReturnsFalse) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-SomethingWeird" }; - CHECK(!newArgumentParser(argc, argv)); -} - -TEST(CommandLineArguments, printUsage) -{ - 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()); -} - -TEST(CommandLineArguments, helpPrintsTheHelp) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-h" }; - CHECK(!newArgumentParser(argc, argv)); - CHECK(args->needHelp()); -} - - -TEST(CommandLineArguments, pluginKnowsOption) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-pPluginOption" }; - TestRegistry::getCurrentRegistry()->installPlugin(plugin); - CHECK(newArgumentParser(argc, argv)); - TestRegistry::getCurrentRegistry()->removePluginByName("options"); -} - - -TEST(CommandLineArguments, checkDefaultArguments) -{ - int argc = 1; - const char* argv[] = { "tests.exe" }; - 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(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) -{ - int argc = 3; - const char* argv[] = { "tests.exe", "-k", "package" }; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(SimpleString("package"), args->getPackageName()); -} - -TEST(CommandLineArguments, lotsOfGroupsAndTests) -{ - int argc = 10; - const char* argv[] = { "tests.exe", "-sggroup1", "-xntest1", "-sggroup2", "-sntest2", "-sntest3", "-sggroup3", "-sntest4", "-sggroup4", "-sntest5" }; - CHECK(newArgumentParser(argc, argv)); - TestFilter nameFilter("test1"); - nameFilter.invertMatching(); - TestFilter groupFilter("group1"); - groupFilter.strictMatching(); - CHECK_EQUAL(nameFilter, *args->getNameFilters()->getNext()->getNext()->getNext()->getNext()); - CHECK_EQUAL(groupFilter, *args->getGroupFilters()->getNext()->getNext()->getNext()); -} - -TEST(CommandLineArguments, lastParameterFieldMissing) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-k"}; - CHECK(newArgumentParser(argc, argv)); - CHECK_EQUAL(SimpleString(""), args->getPackageName()); -} - -TEST(CommandLineArguments, setOptRun) -{ - int argc = 2; - const char* argv[] = { "tests.exe", "-ri"}; - CHECK(newArgumentParser(argc, argv)); - 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 deleted file mode 100644 index e0beed18e..000000000 --- a/tests/CppUTest/CommandLineTestRunnerTest.cpp +++ /dev/null @@ -1,459 +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/TestHarness.h" -#include "CppUTest/CommandLineTestRunner.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/TestPlugin.h" -#include "CppUTest/JUnitTestOutput.h" -#include "CppUTest/PlatformSpecificFunctions.h" - - -class DummyPluginWhichCountsThePlugins : public TestPlugin -{ -public: - - bool returnValue; - int amountOfPlugins; - - DummyPluginWhichCountsThePlugins(const SimpleString& name, TestRegistry* registry) : - TestPlugin(name), returnValue(true), amountOfPlugins(0), registry_(registry) - { - } - - virtual bool parseArguments(int, const char *const *, int) CPPUTEST_OVERRIDE - { - /* Remove ourselves from the count */ - amountOfPlugins = registry_->countPlugins() - 1; - return returnValue; - } -private: - TestRegistry* registry_; -}; - -class CommandLineTestRunnerWithStringBufferOutput : public CommandLineTestRunner -{ -public: - StringBufferTestOutput* fakeJUnitOutputWhichIsReallyABuffer_; - StringBufferTestOutput* fakeConsoleOutputWhichIsReallyABuffer; - StringBufferTestOutput* fakeTCOutputWhichIsReallyABuffer; - - CommandLineTestRunnerWithStringBufferOutput(int argc, const char *const *argv, TestRegistry* registry) - : CommandLineTestRunner(argc, argv, registry), fakeJUnitOutputWhichIsReallyABuffer_(NULLPTR), - fakeConsoleOutputWhichIsReallyABuffer(NULLPTR), fakeTCOutputWhichIsReallyABuffer(NULLPTR) - {} - - TestOutput* createConsoleOutput() CPPUTEST_OVERRIDE - { - fakeConsoleOutputWhichIsReallyABuffer = new StringBufferTestOutput; - return fakeConsoleOutputWhichIsReallyABuffer; - } - - TestOutput* createJUnitOutput(const SimpleString&) CPPUTEST_OVERRIDE - { - fakeJUnitOutputWhichIsReallyABuffer_ = new StringBufferTestOutput; - return fakeJUnitOutputWhichIsReallyABuffer_; - } - - TestOutput* createTeamCityOutput() CPPUTEST_OVERRIDE - { - fakeTCOutputWhichIsReallyABuffer = new StringBufferTestOutput; - return fakeTCOutputWhichIsReallyABuffer; - } -}; - -TEST_GROUP(CommandLineTestRunner) -{ - TestRegistry registry; - UtestShell *test1; - UtestShell *test2; - DummyPluginWhichCountsThePlugins* pluginCountingPlugin; - - 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() CPPUTEST_OVERRIDE - { - delete pluginCountingPlugin; - delete test2; - delete test1; - } - - SimpleString runAndGetOutput(const int argc, const char* argv[]) - { - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(argc, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - return commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput(); - } -}; - -TEST(CommandLineTestRunner, OnePluginGetsInstalledDuringTheRunningTheTests) -{ - const char* argv[] = { "tests.exe", "-psomething"}; - - registry.installPlugin(pluginCountingPlugin); - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - registry.removePluginByName("PluginCountingPlugin"); - - LONGS_EQUAL(0, registry.countPlugins()); - LONGS_EQUAL(1, pluginCountingPlugin->amountOfPlugins); -} - -TEST(CommandLineTestRunner, NoPluginsAreInstalledAtTheEndOfARunWhenTheArgumentsAreInvalid) -{ - const char* argv[] = { "tests.exe", "-fdskjnfkds"}; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - LONGS_EQUAL(0, registry.countPlugins()); - -} - -TEST(CommandLineTestRunner, ReturnsOneWhenTheArgumentsAreInvalid) -{ - const char* argv[] = { "tests.exe", "-some-invalid=parameter" }; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - int returned = commandLineTestRunner.runAllTestsMain(); - - LONGS_EQUAL(1, returned); -} - -TEST(CommandLineTestRunner, ReturnsOnePrintsHelpOnHelp) -{ - const char* argv[] = { "tests.exe", "-h" }; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - int returned = commandLineTestRunner.runAllTestsMain(); - - LONGS_EQUAL(1, returned); - STRCMP_CONTAINS("Thanks for using CppUTest.", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString()); -} - - -TEST(CommandLineTestRunner, ReturnsZeroWhenNoErrors) -{ - const char* argv[] = { "tests.exe" }; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(1, argv, ®istry); - int returned = commandLineTestRunner.runAllTestsMain(); - - LONGS_EQUAL(0, returned); -} - -TEST(CommandLineTestRunner, ReturnsOneWhenNoTestsMatchProvidedFilter) -{ - const char* argv[] = { "tests.exe", "-g", "NoSuchGroup"}; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(3, argv, ®istry); - int returned = commandLineTestRunner.runAllTestsMain(); - - LONGS_EQUAL(1, returned); -} - -TEST(CommandLineTestRunner, TeamcityOutputEnabled) -{ - const char* argv[] = {"tests.exe", "-oteamcity"}; - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - CHECK(commandLineTestRunner.fakeTCOutputWhichIsReallyABuffer != NULLPTR); -} - -TEST(CommandLineTestRunner, JunitOutputEnabled) -{ - const char* argv[] = { "tests.exe", "-ojunit"}; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - CHECK(commandLineTestRunner.fakeJUnitOutputWhichIsReallyABuffer_ != NULLPTR); -} - -TEST(CommandLineTestRunner, JunitOutputAndVerboseEnabled) -{ - const char* argv[] = { "tests.exe", "-ojunit", "-v"}; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(3, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - STRCMP_CONTAINS("TEST(group1, test1)", commandLineTestRunner.fakeJUnitOutputWhichIsReallyABuffer_->getOutput().asCharString()); - STRCMP_CONTAINS("TEST(group1, test1)", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString()); -} - -TEST(CommandLineTestRunner, veryVerboseSetOnOutput) -{ - const char* argv[] = { "tests.exe", "-vv"}; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - STRCMP_CONTAINS("TEST(group1, test1)", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString()); - STRCMP_CONTAINS("destroyTest", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString()); -} - -TEST(CommandLineTestRunner, defaultTestsAreRunInOrderTheyAreInRepository) -{ - const char* argv[] = { "tests.exe", "-v"}; - - registry.addTest(test2); - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - SimpleStringCollection stringCollection; - commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().split("\n", stringCollection); - STRCMP_CONTAINS("test2", stringCollection[0].asCharString()); - STRCMP_CONTAINS("test1", stringCollection[1].asCharString()); -} - -TEST(CommandLineTestRunner, testsCanBeRunInReverseOrder) -{ - const char* argv[] = { "tests.exe", "-v", "-b"}; - - registry.addTest(test2); - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(3, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - SimpleStringCollection stringCollection; - commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().split("\n", stringCollection); - STRCMP_CONTAINS("test1", stringCollection[0].asCharString()); - STRCMP_CONTAINS("test2", stringCollection[1].asCharString()); -} - -TEST(CommandLineTestRunner, listTestGroupNamesShouldWorkProperly) -{ - const char* argv[] = { "tests.exe", "-lg" }; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - STRCMP_CONTAINS("group", commandLineTestRunner.fakeConsoleOutputWhichIsReallyABuffer->getOutput().asCharString()); -} - -TEST(CommandLineTestRunner, listTestGroupAndCaseNamesShouldWorkProperly) -{ - const char* argv[] = { "tests.exe", "-ln" }; - - CommandLineTestRunnerWithStringBufferOutput commandLineTestRunner(2, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - 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_() - UtestShell *anotherTest = new UtestShell("group", "test2", "file", 1); - registry.addTest(anotherTest); - - const char* argv[] = { "tests.exe", "-s"}; - SimpleString text = runAndGetOutput(2, argv); - STRCMP_CONTAINS("shuffling enabled with seed:", text.asCharString()); - - delete anotherTest; -} - -TEST(CommandLineTestRunner, specificShuffleSeedIsPrintedVerbose) -{ - const char* argv[] = { "tests.exe", "-s2", "-v"}; - SimpleString text = runAndGetOutput(3, argv); - STRCMP_CONTAINS("shuffling enabled with seed: 2", text.asCharString()); -} - -extern "C" { - typedef PlatformSpecificFile (*FOpenFunc)(const char*, const char*); - typedef void (*FPutsFunc)(const char*, PlatformSpecificFile); - typedef void (*FCloseFunc)(PlatformSpecificFile); -} - -struct FakeOutput -{ - FakeOutput() : SaveFOpen(PlatformSpecificFOpen), SaveFPuts(PlatformSpecificFPuts), - SaveFClose(PlatformSpecificFClose) - { - installFakes(); - currentFake = this; - } - - ~FakeOutput() - { - currentFake = NULLPTR; - restoreOriginals(); - } - - void installFakes() - { - PlatformSpecificFOpen = (FOpenFunc)fopen_fake; - PlatformSpecificFPuts = (FPutsFunc)fputs_fake; - PlatformSpecificFClose = (FCloseFunc)fclose_fake; - } - - void restoreOriginals() - { - PlatformSpecificFOpen = SaveFOpen; - PlatformSpecificFPuts = SaveFPuts; - PlatformSpecificFClose = SaveFClose; - } - - static PlatformSpecificFile fopen_fake(const char*, const char*) - { - return (PlatformSpecificFile) NULLPTR; - } - - static void fputs_fake(const char* str, PlatformSpecificFile f) - { - if (f == PlatformSpecificStdOut) { - currentFake->console += str; - } - else { - currentFake->file += str; - } - } - - static void fclose_fake(PlatformSpecificFile) - { - } - - SimpleString file; - SimpleString console; - - static FakeOutput* currentFake; -private: - FOpenFunc SaveFOpen; - FPutsFunc SaveFPuts; - FCloseFunc SaveFClose; -}; - -FakeOutput* FakeOutput::currentFake = NULLPTR; - -TEST(CommandLineTestRunner, realJunitOutputShouldBeCreatedAndWorkProperly) -{ - const char* argv[] = { "tests.exe", "-ojunit", "-v", "-kpackage", }; - - FakeOutput fakeOutput; /* UT_PTR_SET() is not reentrant */ - - CommandLineTestRunner commandLineTestRunner(4, argv, ®istry); - commandLineTestRunner.runAllTestsMain(); - - fakeOutput.restoreOriginals(); - - STRCMP_CONTAINS(" - -TEST_GROUP(StandardCppLibrary) -{ -}; - -#if defined(__cplusplus) && __cplusplus >= 201402L - -TEST(StandardCppLibrary, UniquePtrConversationToBool) -{ - auto const aNull = std::unique_ptr(NULLPTR); - CHECK_FALSE(aNull); - - auto const notNull = std::make_unique(1); - CHECK_TRUE(notNull); -} - -#endif - -#endif - diff --git a/tests/CppUTest/DummyMemoryLeakDetector.cpp b/tests/CppUTest/DummyMemoryLeakDetector.cpp deleted file mode 100644 index dc28bab68..000000000 --- a/tests/CppUTest/DummyMemoryLeakDetector.cpp +++ /dev/null @@ -1,72 +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/TestHarness.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "DummyMemoryLeakDetector.h" - -DummyMemoryLeakDetector::DummyMemoryLeakDetector(MemoryLeakFailure* reporter) : MemoryLeakDetector(reporter) -{ - memoryLeakDetectorWasDeleted = false; -} - -DummyMemoryLeakDetector::~DummyMemoryLeakDetector() -{ - memoryLeakDetectorWasDeleted = true; -} - -bool DummyMemoryLeakDetector::wasDeleted() -{ - return memoryLeakDetectorWasDeleted; -} - -bool DummyMemoryLeakDetector::memoryLeakDetectorWasDeleted = false; - -DummyMemoryLeakFailure::DummyMemoryLeakFailure() - : MemoryLeakFailure() -{ - memoryLeakFailureWasDelete = false; -} - -DummyMemoryLeakFailure::~DummyMemoryLeakFailure() -{ - memoryLeakFailureWasDelete = true; -} - -bool DummyMemoryLeakFailure::wasDeleted() -{ - return memoryLeakFailureWasDelete; -} - -void DummyMemoryLeakFailure::fail(char*) -{ -} - -bool DummyMemoryLeakFailure::memoryLeakFailureWasDelete = false; - - - diff --git a/tests/CppUTest/DummyMemoryLeakDetector.h b/tests/CppUTest/DummyMemoryLeakDetector.h deleted file mode 100644 index 73824af27..000000000 --- a/tests/CppUTest/DummyMemoryLeakDetector.h +++ /dev/null @@ -1,55 +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. - */ - -#ifndef DUMMYMEMORYLEAKDETECTOR_H -#define DUMMYMEMORYLEAKDETECTOR_H - -class DummyMemoryLeakDetector : public MemoryLeakDetector -{ -public: - DummyMemoryLeakDetector(MemoryLeakFailure* reporter); - virtual ~DummyMemoryLeakDetector() CPPUTEST_DESTRUCTOR_OVERRIDE; - static bool wasDeleted(); - -private: - static bool memoryLeakDetectorWasDeleted; -}; - -class DummyMemoryLeakFailure : public MemoryLeakFailure -{ -public: - DummyMemoryLeakFailure(); - - virtual ~DummyMemoryLeakFailure() CPPUTEST_DESTRUCTOR_OVERRIDE; - static bool wasDeleted(); - 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 deleted file mode 100644 index 32b5654d4..000000000 --- a/tests/CppUTest/JUnitOutputTest.cpp +++ /dev/null @@ -1,769 +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/TestHarness.h" -#include "CppUTest/JUnitTestOutput.h" -#include "CppUTest/TestResult.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/SimpleString.h" - -class FileForJUnitOutputTests -{ - SimpleString name_; - bool isOpen_; - SimpleString buffer_; - FileForJUnitOutputTests* next_; - - SimpleStringCollection linesOfFile_; - -public: - - FileForJUnitOutputTests(const SimpleString& filename, FileForJUnitOutputTests* next) : - name_(filename), isOpen_(true), next_(next) {} - - FileForJUnitOutputTests* nextFile() - { - return next_; - } - - SimpleString name() - { - return name_; - } - - void write(const SimpleString& buffer) - { - buffer_ += buffer; - } - - void close() - { - isOpen_ = false; - } - - const char* line(size_t lineNumber) - { - buffer_.split("\n", linesOfFile_); - return linesOfFile_[lineNumber-1].asCharString(); - - } - - const char* lineFromTheBack(size_t lineNumberFromTheBack) - { - return line(amountOfLines() - (lineNumberFromTheBack - 1)); - } - - size_t amountOfLines() - { - buffer_.split("\n", linesOfFile_); - return linesOfFile_.size(); - } - - SimpleString content() - { - return buffer_; - } -}; - -class FileSystemForJUnitTestOutputTests -{ - FileForJUnitOutputTests* firstFile_; - -public: - FileSystemForJUnitTestOutputTests() : firstFile_(NULLPTR) {} - ~FileSystemForJUnitTestOutputTests() { clear(); } - - void clear(void) - { - while (firstFile_) { - FileForJUnitOutputTests* fileToBeDeleted = firstFile_; - firstFile_ = firstFile_->nextFile(); - delete fileToBeDeleted; - } - } - - FileForJUnitOutputTests* openFile(const SimpleString& filename) - { - firstFile_ = new FileForJUnitOutputTests(filename, firstFile_); - return firstFile_; - } - - int amountOfFiles() { - int totalAmountOfFiles = 0; - for (FileForJUnitOutputTests* current = firstFile_; current != NULLPTR; current = current->nextFile()) - totalAmountOfFiles++; - return totalAmountOfFiles; - } - - bool fileExists(const char* filename) - { - FileForJUnitOutputTests *searchedFile = file(filename); - return (searchedFile != NULLPTR); - } - - FileForJUnitOutputTests* file(const char* filename) - { - for (FileForJUnitOutputTests* current = firstFile_; current != NULLPTR; current = current->nextFile()) - if (current->name() == filename) - return current; - return NULLPTR; - } -}; - -extern "C" { - static unsigned long millisTime = 0; - static const char* theTime = ""; - - static unsigned long MockGetPlatformSpecificTimeInMillis() - { - return millisTime; - } - - static const char* MockGetPlatformSpecificTimeString() - { - return theTime; - } -} - -class JUnitTestOutputTestRunner -{ - TestResult result_; - - const char* currentGroupName_; - UtestShell* currentTest_; - bool firstTestInGroup_; - unsigned int timeTheTestTakes_; - unsigned int numberOfChecksInTest_; - TestFailure* testFailure_; - -public: - - explicit JUnitTestOutputTestRunner(const TestResult& result) : - result_(result), currentGroupName_(NULLPTR), currentTest_(NULLPTR), firstTestInGroup_(true), timeTheTestTakes_(0), numberOfChecksInTest_(0), testFailure_(NULLPTR) - { - millisTime = 0; - theTime = "1978-10-03T00:00:00"; - - UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis); - UT_PTR_SET(GetPlatformSpecificTimeString, MockGetPlatformSpecificTimeString); - } - - JUnitTestOutputTestRunner& start() - { - result_.testsStarted(); - return *this; - } - - JUnitTestOutputTestRunner& end() - { - endOfPreviousTestGroup(); - delete currentTest_; - result_.testsEnded(); - return *this; - } - - JUnitTestOutputTestRunner& endGroupAndClearTest() - { - endOfPreviousTestGroup(); - delete currentTest_; - currentTest_ = NULLPTR; - return *this; - } - - void endOfPreviousTestGroup() - { - runPreviousTest(); - if (currentTest_) { - result_.currentGroupEnded(currentTest_); - firstTestInGroup_ = true; - } - - currentGroupName_ = NULLPTR; - } - - JUnitTestOutputTestRunner& withGroup(const char* groupName) - { - runPreviousTest(); - endOfPreviousTestGroup(); - - currentGroupName_ = groupName; - return *this; - } - - JUnitTestOutputTestRunner& withTest(const char* testName) - { - runPreviousTest(); - delete currentTest_; - - currentTest_ = new UtestShell(currentGroupName_, testName, "file", 1); - return *this; - } - - JUnitTestOutputTestRunner& withIgnoredTest(const char* testName) - { - runPreviousTest(); - delete currentTest_; - - currentTest_ = new IgnoredUtestShell(currentGroupName_, testName, "file", 1); - return *this; - } - - JUnitTestOutputTestRunner& inFile(const char* fileName) - { - if(currentTest_) { - currentTest_->setFileName(fileName); - } - return *this; - } - - JUnitTestOutputTestRunner& onLine(size_t lineNumber) - { - if(currentTest_) { - currentTest_->setLineNumber(lineNumber); - } - return *this; - } - - void runPreviousTest() - { - if (currentTest_ == NULLPTR) return; - - if (firstTestInGroup_) { - result_.currentGroupStarted(currentTest_); - firstTestInGroup_ = false; - } - result_.currentTestStarted(currentTest_); - - millisTime += timeTheTestTakes_; - for(unsigned int i = 0; i < numberOfChecksInTest_; i++) { - result_.countCheck(); - } - numberOfChecksInTest_ = 0; - - if (testFailure_) { - result_.addFailure(*testFailure_); - delete testFailure_; - testFailure_ = NULLPTR; - } - - result_.currentTestEnded(currentTest_); - } - - JUnitTestOutputTestRunner& thatHasChecks(unsigned int numOfChecks) - { - numberOfChecksInTest_ = numOfChecks; - return *this; - } - - JUnitTestOutputTestRunner& thatTakes(unsigned int timeElapsed) - { - timeTheTestTakes_ = timeElapsed; - return *this; - } - - JUnitTestOutputTestRunner& seconds() - { - return *this; - } - - JUnitTestOutputTestRunner& thatFails(const char* message, const char* file, size_t line) - { - testFailure_ = new TestFailure( currentTest_, file, line, message); - return *this; - } - - JUnitTestOutputTestRunner& atTime(const char* newTime) - { - theTime = newTime; - return *this; - } - - JUnitTestOutputTestRunner& thatPrints(const char* output) - { - runPreviousTest(); - result_.print(output); - return *this; - } -}; - -extern "C" { - static FileSystemForJUnitTestOutputTests fileSystem; - static FileForJUnitOutputTests* currentFile = NULLPTR; - - static PlatformSpecificFile mockFOpen(const char* filename, const char*) - { - currentFile = fileSystem.openFile(filename); - return currentFile; - } - - static void (*originalFPuts)(const char* str, PlatformSpecificFile file); - static void mockFPuts(const char* str, PlatformSpecificFile file) - { - if (file == currentFile) { - ((FileForJUnitOutputTests*)file)->write(str); - } - else { - originalFPuts(str, file); - } - } - - static void mockFClose(PlatformSpecificFile file) - { - currentFile = NULLPTR; - ((FileForJUnitOutputTests*)file)->close(); - } -} - -TEST_GROUP(JUnitOutputTest) -{ - JUnitTestOutput *junitOutput; - TestResult *result; - JUnitTestOutputTestRunner *testCaseRunner; - FileForJUnitOutputTests* outputFile; - - void setup() CPPUTEST_OVERRIDE - { - UT_PTR_SET(PlatformSpecificFOpen, mockFOpen); - originalFPuts = PlatformSpecificFPuts; - UT_PTR_SET(PlatformSpecificFPuts, mockFPuts); - UT_PTR_SET(PlatformSpecificFClose, mockFClose); - junitOutput = new JUnitTestOutput(); - result = new TestResult(*junitOutput); - testCaseRunner = new JUnitTestOutputTestRunner(*result); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete testCaseRunner; - delete result; - delete junitOutput; - fileSystem.clear(); - } -}; - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestOnlyWriteToOneFile) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - LONGS_EQUAL(1, fileSystem.amountOfFiles()); - CHECK(fileSystem.fileExists("cpputest_groupname.xml")); -} - -TEST(JUnitOutputTest, withReservedCharactersInPackageOrTestGroupUsesUnderscoresForFileName) -{ - junitOutput->setPackageName("p/a\\c?k%a*g:e|n\"ae."); - testCaseRunner->start() - .withGroup("g/r\\o?u%p*n:a|m\"eere").withTest("testname") - .end(); - - CHECK(fileSystem.fileExists("cpputest_p_a_c_k_a_g_e_n_a_m_e._g_r_o_u_p_n_a_m_e_h_ere.xml")); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestOutputsValidXMLFiles) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("\n", outputFile->line(1)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestOutputsTestSuiteStartAndEndBlocks) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("\n", outputFile->line(2)); - STRCMP_EQUAL("\n", outputFile->lineFromTheBack(1)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestFileShouldContainAnEmptyPropertiesBlock) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("\n", outputFile->line(3)); - STRCMP_EQUAL("\n", outputFile->line(4)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestFileShouldContainAnEmptyStdoutBlock) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("\n", outputFile->lineFromTheBack(3)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestFileShouldContainAnEmptyStderrBlock) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("\n", outputFile->lineFromTheBack(2)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneTestFileShouldContainsATestCaseBlock) -{ - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndTwoTestCasesCreateCorrectTestgroupBlockAndCorrectTestCaseBlock) -{ - testCaseRunner->start() - .withGroup("twoTestsGroup").withTest("firstTestName").withTest("secondTestName") - .end(); - - outputFile = fileSystem.file("cpputest_twoTestsGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(2)); - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); - STRCMP_EQUAL("\n", outputFile->line(7)); - STRCMP_EQUAL("\n", outputFile->line(8)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndTimeHasElapsedAndTimestampChanged) -{ - testCaseRunner->start().atTime("2013-07-04T22:28:00") - .withGroup("timeGroup").withTest("Dummy").thatTakes(10).seconds() - .end(); - - outputFile = fileSystem.file("cpputest_timeGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(2)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndMultipleTestCasesWithElapsedTime) -{ - testCaseRunner->start() - .withGroup("twoTestsGroup") - .withTest("firstTestName").thatTakes(10).seconds() - .withTest("secondTestName").thatTakes(50).seconds() - .end(); - - outputFile = fileSystem.file("cpputest_twoTestsGroup.xml"); - STRCMP_EQUAL("\n", outputFile->line(2)); - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); - STRCMP_EQUAL("\n", outputFile->line(7)); - STRCMP_EQUAL("\n", outputFile->line(8)); -} - -TEST(JUnitOutputTest, withOneTestGroupAndOneFailingTest) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("Test failed", "thisfile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - STRCMP_EQUAL("\n", outputFile->line(2)); - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); - STRCMP_EQUAL("\n", outputFile->line(7)); - STRCMP_EQUAL("\n", outputFile->line(8)); -} - -TEST(JUnitOutputTest, withTwoTestGroupAndOneFailingTest) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FirstTest") - .withTest("FailingTestName").thatFails("Test failed", "thisfile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(2)); - STRCMP_EQUAL("\n", outputFile->line(7)); - STRCMP_EQUAL("\n", outputFile->line(8)); -} - -TEST(JUnitOutputTest, testFailureWithLessThanAndGreaterThanInsideIt) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("Test ", "thisfile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, testFailureWithQuotesInIt) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("Test \"failed\"", "thisfile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, testFailureWithNewlineInIt) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("Test \nfailed", "thisfile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, testFailureWithDifferentFileAndLine) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("Test failed", "importantFile", 999) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, testFailureWithAmpersandsAndLessThan) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("&object1 < &object2", "importantFile", 999) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, testFailureWithAmpersands) -{ - testCaseRunner->start() - .withGroup("testGroupWithFailingTest") - .withTest("FailingTestName").thatFails("&object1 != &object2", "importantFile", 999) - .end(); - - outputFile = fileSystem.file("cpputest_testGroupWithFailingTest.xml"); - - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, aCoupleOfTestFailures) -{ - testCaseRunner->start() - .withGroup("testGroup") - .withTest("passingOne") - .withTest("FailingTest").thatFails("Failure", "file", 99) - .withTest("passingTwo") - .withTest("passingThree") - .withTest("AnotherFailingTest").thatFails("otherFailure", "anotherFile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(8)); - STRCMP_EQUAL("\n", outputFile->line(16)); -} - -TEST(JUnitOutputTest, testFailuresInSeparateGroups) -{ - testCaseRunner->start() - .withGroup("testGroup") - .withTest("passingOne") - .withTest("FailingTest").thatFails("Failure", "file", 99) - .withGroup("AnotherGroup") - .withTest("AnotherFailingTest").thatFails("otherFailure", "anotherFile", 10) - .end(); - - outputFile = fileSystem.file("cpputest_testGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(8)); - - outputFile = fileSystem.file("cpputest_AnotherGroup.xml"); - STRCMP_EQUAL("\n", outputFile->line(8)); -} - -TEST(JUnitOutputTest, twoTestGroupsWriteToTwoDifferentFiles) -{ - testCaseRunner->start() - .withGroup("firstTestGroup") - .withTest("testName") - .withGroup("secondTestGroup") - .withTest("testName") - .end(); - - CHECK(fileSystem.file("cpputest_firstTestGroup.xml") != NULLPTR); - CHECK(fileSystem.file("cpputest_secondTestGroup.xml") != NULLPTR); - -} - -TEST(JUnitOutputTest, testGroupWithWeirdName) -{ - STRCMP_EQUAL("cpputest_group_weird_name.xml", junitOutput->createFileName("group/weird/name").asCharString()); -} - -TEST(JUnitOutputTest, TestCaseBlockWithAPackageName) -{ - junitOutput->setPackageName("packagename"); - testCaseRunner->start() - .withGroup("groupname").withTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_packagename_groupname.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); -} - -TEST(JUnitOutputTest, TestCaseBlockForIgnoredTest) -{ - junitOutput->setPackageName("packagename"); - testCaseRunner->start() - .withGroup("groupname").withIgnoredTest("testname") - .end(); - - outputFile = fileSystem.file("cpputest_packagename_groupname.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(6)); - STRCMP_EQUAL("\n", outputFile->line(7)); -} - -TEST(JUnitOutputTest, TestCaseWithTestLocation) -{ - junitOutput->setPackageName("packagename"); - testCaseRunner->start() - .withGroup("groupname") - .withTest("testname").inFile("MySource.c").onLine(159) - .end(); - - outputFile = fileSystem.file("cpputest_packagename_groupname.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); -} - -TEST(JUnitOutputTest, MultipleTestCaseWithTestLocations) -{ - testCaseRunner->start() - .withGroup("twoTestsGroup") - .withTest("firstTestName").inFile("MyFirstSource.c").onLine(846) - .withTest("secondTestName").inFile("MySecondSource.c").onLine(513) - .end(); - - outputFile = fileSystem.file("cpputest_twoTestsGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(7)); -} - -TEST(JUnitOutputTest, TestCaseBlockWithAssertions) -{ - junitOutput->setPackageName("packagename"); - testCaseRunner->start() - .withGroup("groupname") - .withTest("testname") - .thatHasChecks(24) - .end(); - - outputFile = fileSystem.file("cpputest_packagename_groupname.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); -} - -TEST(JUnitOutputTest, MultipleTestCaseBlocksWithAssertions) -{ - testCaseRunner->start() - .withGroup("twoTestsGroup") - .withTest("firstTestName").thatHasChecks(456) - .withTest("secondTestName").thatHasChecks(567) - .end(); - - outputFile = fileSystem.file("cpputest_twoTestsGroup.xml"); - - STRCMP_EQUAL("\n", outputFile->line(5)); - STRCMP_EQUAL("\n", outputFile->line(7)); -} - -TEST(JUnitOutputTest, MultipleTestCasesInDifferentGroupsWithAssertions) -{ - testCaseRunner->start() - .withGroup("groupOne") - .withTest("testA").thatHasChecks(456) - .endGroupAndClearTest() - .withGroup("groupTwo") - .withTest("testB").thatHasChecks(678) - .end(); - - outputFile = fileSystem.file("cpputest_groupOne.xml"); - STRCMP_EQUAL("\n", outputFile->line(5)); - - outputFile = fileSystem.file("cpputest_groupTwo.xml"); - STRCMP_EQUAL("\n", outputFile->line(5)); -} - -TEST(JUnitOutputTest, UTPRINTOutputInJUnitOutput) -{ - testCaseRunner->start() - .withGroup("groupname") - .withTest("testname").thatPrints("someoutput") - .end(); - - outputFile = fileSystem.file("cpputest_groupname.xml"); - STRCMP_EQUAL("someoutput\n", outputFile->lineFromTheBack(3)); -} - -TEST(JUnitOutputTest, UTPRINTOutputInJUnitOutputWithSpecials) -{ - testCaseRunner->start() - .withGroup("groupname") - .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" Goes \\mainly\\ down the Dr&in \n", outputFile->lineFromTheBack(3)); -} diff --git a/tests/CppUTest/MemoryLeakDetectorTest.cpp b/tests/CppUTest/MemoryLeakDetectorTest.cpp deleted file mode 100644 index 825ed312e..000000000 --- a/tests/CppUTest/MemoryLeakDetectorTest.cpp +++ /dev/null @@ -1,692 +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/TestHarness.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -class MemoryLeakFailureForTest: public MemoryLeakFailure -{ -public: - virtual ~MemoryLeakFailureForTest() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - virtual void fail(char* fail_string) CPPUTEST_OVERRIDE - { - *message = fail_string; - } - - SimpleString *message; -}; - -class NewAllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator -{ -public: - NewAllocatorForMemoryLeakDetectionTest() : - TestMemoryAllocator("Standard New Allocator", "new", "delete"), - alloc_called(0), free_called(0) - { - } - - int alloc_called; - int free_called; - 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) CPPUTEST_OVERRIDE - { - free_called++; - TestMemoryAllocator::free_memory(memory, size, file, line); - } -}; - -class AllocatorForMemoryLeakDetectionTest: public TestMemoryAllocator -{ -public: - AllocatorForMemoryLeakDetectionTest() : - alloc_called(0), free_called(0), allocMemoryLeakNodeCalled(0), freeMemoryLeakNodeCalled(0) - { - } - - int alloc_called; - int free_called; - int allocMemoryLeakNodeCalled; - int freeMemoryLeakNodeCalled; - - 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) CPPUTEST_OVERRIDE - { - free_called++; - TestMemoryAllocator::free_memory(memory, size, file, line); - } - - char* allocMemoryLeakNode(size_t size) CPPUTEST_OVERRIDE - { - allocMemoryLeakNodeCalled++; - return TestMemoryAllocator::alloc_memory(size, __FILE__, __LINE__); - } - - void freeMemoryLeakNode(char* memory) CPPUTEST_OVERRIDE - { - freeMemoryLeakNodeCalled++; - TestMemoryAllocator::free_memory(memory, 0, __FILE__, __LINE__); - } -}; - -TEST_GROUP(MemoryLeakDetectorTest) -{ - MemoryLeakDetector* detector; - MemoryLeakFailureForTest *reporter; - AllocatorForMemoryLeakDetectionTest* testAllocator; - - void setup() CPPUTEST_OVERRIDE - { - reporter = new MemoryLeakFailureForTest; - detector = new MemoryLeakDetector(reporter); - testAllocator = new AllocatorForMemoryLeakDetectionTest; - detector->enable(); - detector->startChecking(); - reporter->message = new SimpleString(); - } - void teardown() CPPUTEST_OVERRIDE - { - delete reporter->message; - delete detector; - delete reporter; - delete testAllocator; - } -}; - -TEST(MemoryLeakDetectorTest, OneLeak) -{ - char* mem = detector->allocMemory(testAllocator, 3); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - STRCMP_CONTAINS("Memory leak(s) found", output.asCharString()); - STRCMP_CONTAINS("size: 3", output.asCharString()); - STRCMP_CONTAINS("alloc", output.asCharString()); - STRCMP_CONTAINS(StringFromFormat("%p", (void*) mem).asCharString(), output.asCharString()); - STRCMP_CONTAINS("Total number of leaks", output.asCharString()); - PlatformSpecificFree(mem); - LONGS_EQUAL(1, testAllocator->alloc_called); - LONGS_EQUAL(0, testAllocator->free_called); -} - -TEST(MemoryLeakDetectorTest, sequenceNumbersOfMemoryLeaks) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 1); - char* mem2 = detector->allocMemory(defaultNewAllocator(), 2); - char* mem3 = detector->allocMemory(defaultNewAllocator(), 3); - SimpleString output = detector->report(mem_leak_period_checking); - - STRCMP_CONTAINS("Alloc num (1)", output.asCharString()); - STRCMP_CONTAINS("Alloc num (2)", output.asCharString()); - STRCMP_CONTAINS("Alloc num (3)", output.asCharString()); - - PlatformSpecificFree(mem); - PlatformSpecificFree(mem2); - PlatformSpecificFree(mem3); -} - -TEST(MemoryLeakDetectorTest, memoryDumpOutput) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 6); - SimpleString::StrNCpy(mem, "test1", 6); - SimpleString output = detector->report(mem_leak_period_checking); - - STRCMP_CONTAINS("Alloc num (1)", output.asCharString()); - STRCMP_CONTAINS("Leak size: 6 Allocated at", output.asCharString()); - STRCMP_CONTAINS("Content:", output.asCharString()); - STRCMP_CONTAINS("0000: 74 65 73 74 31 00 |test1.|", output.asCharString()); - - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, OneHundredLeaks) -{ - const int amount_alloc = 100; - char *mem[amount_alloc]; - for (int i = 0; i < amount_alloc; i++) - mem[i] = detector->allocMemory(defaultMallocAllocator(), 3); - detector->stopChecking(); - - SimpleString output = detector->report(mem_leak_period_checking); - - STRCMP_CONTAINS("Memory leak(s) found", output.asCharString()); - STRCMP_CONTAINS("Total number of leaks", output.asCharString()); - STRCMP_CONTAINS("Memory leak reports about malloc and free", output.asCharString()); - - //don't reuse i for vc6 compatibility - for (int j = 0; j < amount_alloc; j++) - PlatformSpecificFree(mem[j]); -} - -TEST(MemoryLeakDetectorTest, OneLeakOutsideCheckingPeriod) -{ - detector->stopChecking(); - char* mem = detector->allocMemory(defaultNewAllocator(), 4); - SimpleString output = detector->report(mem_leak_period_all); - CHECK(output.contains("Memory leak(s) found")); - CHECK(output.contains("size: 4")); - CHECK(output.contains("new")); - CHECK(output.contains("Total number of leaks")); - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, NoLeaksWhatsoever) -{ - detector->stopChecking(); - STRCMP_CONTAINS("No memory leaks", detector->report(mem_leak_period_checking)); - STRCMP_CONTAINS("No memory leaks", detector->report(mem_leak_period_all)); -} - -TEST(MemoryLeakDetectorTest, TwoLeaksUsingOperatorNew) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 4); - char* mem2 = detector->allocMemory(defaultNewAllocator(), 8); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_checking)); - CHECK(output.contains("size: 8")); - CHECK(output.contains("size: 4")); - PlatformSpecificFree(mem); - PlatformSpecificFree(mem2); -} - -TEST(MemoryLeakDetectorTest, OneAllocButNoLeak) -{ - char* mem = detector->allocMemory(testAllocator, 4); - detector->deallocMemory(testAllocator, mem); - detector->stopChecking(); - STRCMP_CONTAINS("No memory leaks", detector->report(mem_leak_period_checking)); - LONGS_EQUAL(1, testAllocator->alloc_called); - LONGS_EQUAL(1, testAllocator->free_called); -} - -TEST(MemoryLeakDetectorTest, TwoAllocOneFreeOneLeak) -{ - char* mem = detector->allocMemory(testAllocator, 4); - char* mem2 = detector->allocMemory(testAllocator, 12); - detector->deallocMemory(testAllocator, mem); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - CHECK(output.contains("Leak size: 12")); - CHECK(!output.contains("Leak size: 4")); - PlatformSpecificFree(mem2); - LONGS_EQUAL(2, testAllocator->alloc_called); - LONGS_EQUAL(1, testAllocator->free_called); -} - -TEST(MemoryLeakDetectorTest, TwoAllocOneFreeOneLeakReverseOrder) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 4); - char* mem2 = detector->allocMemory(defaultNewAllocator(), 12); - detector->deallocMemory(defaultNewAllocator(), mem2); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - CHECK(!output.contains("size: 12")); - CHECK(output.contains("size: 4")); - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, DeleteNonAlocatedMemory) -{ - char a; - char* pa = &a; - detector->deallocMemory(defaultMallocAllocator(), pa, "FREE.c", 100); - detector->stopChecking(); - CHECK(reporter->message->contains("Deallocating non-allocated memory")); - CHECK(reporter->message->contains(" allocated at file: line: 0 size: 0 type: unknown")); - CHECK(reporter->message->contains(" deallocated at file: FREE.c line: 100 type: free")); -} - -TEST(MemoryLeakDetectorTest, IgnoreMemoryAllocatedOutsideCheckingPeriod) -{ - detector->stopChecking(); - char* mem = detector->allocMemory(defaultNewAllocator(), 4); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->deallocMemory(defaultNewAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, IgnoreMemoryAllocatedOutsideCheckingPeriodComplicatedCase) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 4); - detector->stopChecking(); - - char* mem2 = detector->allocMemory(defaultNewAllocator(), 8); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - detector->clearAllAccounting(mem_leak_period_checking); - PlatformSpecificFree(mem); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - - detector->startChecking(); - char* mem3 = detector->allocMemory(defaultNewAllocator(), 4); - detector->stopChecking(); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_all)); - - detector->clearAllAccounting(mem_leak_period_checking); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - - detector->clearAllAccounting(mem_leak_period_all); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_all)); - PlatformSpecificFree(mem2); - PlatformSpecificFree(mem3); -} - -TEST(MemoryLeakDetectorTest, OneLeakUsingOperatorNewWithFileLine) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 4, "file.cpp", 1234); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - CHECK(output.contains("file.cpp")); - CHECK(output.contains("1234")); - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, OneAllocAndFreeUsingArrayNew) -{ - char* mem = detector->allocMemory(defaultNewArrayAllocator(), 10, "file.cpp", 1234); - char* mem2 = detector->allocMemory(defaultNewArrayAllocator(), 12); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_all)); - SimpleString output = detector->report(mem_leak_period_checking); - CHECK(output.contains("new []")); - detector->deallocMemory(defaultNewArrayAllocator(), mem); - detector->deallocMemory(defaultNewArrayAllocator(), mem2); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->stopChecking(); -} - -TEST(MemoryLeakDetectorTest, OneAllocAndFree) -{ - char* mem = detector->allocMemory(defaultMallocAllocator(), 10, "file.cpp", 1234); - char* mem2 = detector->allocMemory(defaultMallocAllocator(), 12); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_checking)); - SimpleString output = detector->report(mem_leak_period_checking); - CHECK(output.contains("malloc")); - detector->deallocMemory(defaultMallocAllocator(), mem); - detector->deallocMemory(defaultMallocAllocator(), mem2, "file.c", 5678); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->stopChecking(); -} - -TEST(MemoryLeakDetectorTest, OneRealloc) -{ - char* mem1 = detector->allocMemory(testAllocator, 10, "file.cpp", 1234, true); - - char* mem2 = detector->reallocMemory(testAllocator, mem1, 1000, "other.cpp", 5678, true); - - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - SimpleString output = detector->report(mem_leak_period_checking); - CHECK(output.contains("other.cpp")); - - detector->deallocMemory(testAllocator, mem2, true); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->stopChecking(); - LONGS_EQUAL(1, testAllocator->alloc_called); - LONGS_EQUAL(1, testAllocator->free_called); - LONGS_EQUAL(2, testAllocator->allocMemoryLeakNodeCalled); - LONGS_EQUAL(2, testAllocator->freeMemoryLeakNodeCalled); -} - -TEST(MemoryLeakDetectorTest, ReallocNonAllocatedMemory) -{ - char mem1; - char* mem2 = detector->reallocMemory(testAllocator, &mem1, 5, "other.cpp", 13, true); - detector->deallocMemory(testAllocator, mem2, true); - detector->stopChecking(); - CHECK(reporter->message->contains("Deallocating non-allocated memory\n")); - CHECK(reporter->message->contains(" deallocated at file: other.cpp line: 13")); -} - -TEST(MemoryLeakDetectorTest, AllocOneTypeFreeAnotherType) -{ - char* mem = detector->allocMemory(defaultNewArrayAllocator(), 100, "ALLOC.c", 10); - detector->deallocMemory(defaultMallocAllocator(), mem, "FREE.c", 100); - detector->stopChecking(); - CHECK(reporter->message->contains("Allocation/deallocation type mismatch")); - CHECK(reporter->message->contains(" allocated at file: ALLOC.c line: 10 size: 100 type: new []")); - CHECK(reporter->message->contains(" deallocated at file: FREE.c line: 100 type: free")); -} - -TEST(MemoryLeakDetectorTest, AllocOneTypeFreeAnotherTypeWithCheckingDisabled) -{ - detector->disableAllocationTypeChecking(); - char* mem = detector->allocMemory(defaultNewArrayAllocator(), 100, "ALLOC.c", 10); - detector->deallocMemory(defaultNewAllocator(), mem, "FREE.c", 100); - detector->stopChecking(); - STRCMP_EQUAL("", reporter->message->asCharString()); - detector->enableAllocationTypeChecking(); -} - -TEST(MemoryLeakDetectorTest, mallocLeakGivesAdditionalWarning) -{ - char* mem = detector->allocMemory(defaultMallocAllocator(), 100, "ALLOC.c", 10); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - STRCMP_CONTAINS("Memory leak reports about malloc and free can be caused by allocating using the cpputest version of malloc", output.asCharString()); - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, newLeakDoesNotGiveAdditionalWarning) -{ - char* mem = detector->allocMemory(defaultNewAllocator(), 100, "ALLOC.c", 10); - detector->stopChecking(); - SimpleString output = detector->report(mem_leak_period_checking); - CHECK(! output.contains("Memory leak reports about malloc and free")); - PlatformSpecificFree(mem); -} - -TEST(MemoryLeakDetectorTest, MarkCheckingPeriodLeaksAsNonCheckingPeriod) -{ - char* mem = detector->allocMemory(defaultNewArrayAllocator(), 100); - char* mem2 = detector->allocMemory(defaultNewArrayAllocator(), 100); - detector->stopChecking(); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->markCheckingPeriodLeaksAsNonCheckingPeriod(); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - LONGS_EQUAL(2, detector->totalMemoryLeaks(mem_leak_period_all)); - PlatformSpecificFree(mem); - PlatformSpecificFree(mem2); -} - -TEST(MemoryLeakDetectorTest, memoryCorruption) -{ - char* mem = detector->allocMemory(defaultMallocAllocator(), 10, "ALLOC.c", 10); - mem[10] = 'O'; - mem[11] = 'H'; - detector->deallocMemory(defaultMallocAllocator(), mem, "FREE.c", 100); - detector->stopChecking(); - CHECK(reporter->message->contains("Memory corruption")); - CHECK(reporter->message->contains(" allocated at file: ALLOC.c line: 10 size: 10 type: malloc")); - CHECK(reporter->message->contains(" deallocated at file: FREE.c line: 100 type: free")); -} - -TEST(MemoryLeakDetectorTest, safelyDeleteNULL) -{ - detector->deallocMemory(defaultNewAllocator(), NULLPTR); - STRCMP_EQUAL("", reporter->message->asCharString()); -} - -TEST(MemoryLeakDetectorTest, periodDisabled) -{ - detector->disable(); - char* mem = detector->allocMemory(defaultMallocAllocator(), 2); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_disabled)); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_enabled)); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - detector->deallocMemory(defaultMallocAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, periodEnabled) -{ - detector->enable(); - char* mem = detector->allocMemory(defaultMallocAllocator(), 2); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_disabled)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_enabled)); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_checking)); - detector->deallocMemory(defaultMallocAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, periodChecking) -{ - char* mem = detector->allocMemory(defaultMallocAllocator(), 2); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_disabled)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_enabled)); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_checking)); - detector->deallocMemory(defaultMallocAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, defaultAllocationStageIsZero) -{ - LONGS_EQUAL(0, detector->getCurrentAllocationStage()); -} - -TEST(MemoryLeakDetectorTest, canFreeNoAllocations) -{ - detector->deallocAllMemoryInCurrentAllocationStage(); - LONGS_EQUAL(0, detector->getCurrentAllocationStage()); -} - -TEST(MemoryLeakDetectorTest, increaseAllocationStage) -{ - detector->increaseAllocationStage(); - LONGS_EQUAL(1, detector->getCurrentAllocationStage()); -} - -TEST(MemoryLeakDetectorTest, decreaseAllocationStage) -{ - detector->increaseAllocationStage(); - detector->decreaseAllocationStage(); - LONGS_EQUAL(0, detector->getCurrentAllocationStage()); -} - -TEST(MemoryLeakDetectorTest, freeAllMemoryInCurrentAllocationStage) -{ - detector->increaseAllocationStage(); - detector->allocMemory(defaultMallocAllocator(), 2); - detector->allocMemory(defaultMallocAllocator(), 2); - detector->deallocAllMemoryInCurrentAllocationStage(); - LONGS_EQUAL(0, detector->totalMemoryLeaks(mem_leak_period_all)); -} - -TEST(MemoryLeakDetectorTest, freeOnlyTheMemoryInTheAllocationStage) -{ - char* mem = detector->allocMemory(defaultMallocAllocator(), 2); - detector->increaseAllocationStage(); - detector->allocMemory(defaultMallocAllocator(), 2); - detector->deallocAllMemoryInCurrentAllocationStage(); - LONGS_EQUAL(1, detector->totalMemoryLeaks(mem_leak_period_all)); - detector->deallocMemory(defaultMallocAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, allocateWithANullAllocatorCausesNoProblems) -{ - char* mem = detector->allocMemory(NullUnknownAllocator::defaultAllocator(), 2); - detector->deallocMemory(NullUnknownAllocator::defaultAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, invalidateMemory) -{ - unsigned char* mem = (unsigned char*)detector->allocMemory(defaultMallocAllocator(), 2); - - detector->invalidateMemory((char*)mem); - CHECK(mem[0] == 0xCD); - CHECK(mem[1] == 0xCD); - detector->deallocMemory(defaultMallocAllocator(), mem); -} - -TEST(MemoryLeakDetectorTest, invalidateMemoryNULLShouldWork) -{ - detector->invalidateMemory(NULLPTR); -} - -TEST_GROUP(MemoryLeakDetectorListTest) -{ -}; - -TEST(MemoryLeakDetectorListTest, clearAllAccountingIsWorkingProperly) -{ - MemoryLeakDetectorList listForTesting; - MemoryLeakDetectorNode node1, node2, node3; - node3.period_ = mem_leak_period_disabled; - listForTesting.addNewNode(&node1); - listForTesting.addNewNode(&node2); - listForTesting.addNewNode(&node3); - - listForTesting.clearAllAccounting(mem_leak_period_enabled); - - POINTERS_EQUAL(NULLPTR, listForTesting.getFirstLeak(mem_leak_period_enabled)); - CHECK(&node3 == listForTesting.getFirstLeak(mem_leak_period_disabled)); -} - -TEST_GROUP(SimpleStringBuffer) -{ -}; - -TEST(SimpleStringBuffer, initialStringIsEmpty) -{ - SimpleStringBuffer buffer; - STRCMP_EQUAL("", buffer.toString()); -} - -TEST(SimpleStringBuffer, simpleTest) -{ - SimpleStringBuffer buffer; - buffer.add("Hello"); - buffer.add(" World"); - STRCMP_EQUAL("Hello World", buffer.toString()); -} - -TEST(SimpleStringBuffer, writePastLimit) -{ - SimpleStringBuffer buffer; - for (int i = 0; i < SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN * 2; i++) - buffer.add("h"); - SimpleString str("h", SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN-1); - STRCMP_EQUAL(str.asCharString(), buffer.toString()); -} - -TEST(SimpleStringBuffer, setWriteLimit) -{ - SimpleStringBuffer buffer; - buffer.setWriteLimit(10); - for (int i = 0; i < SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN ; i++) - buffer.add("h"); - SimpleString str("h", 10); - STRCMP_EQUAL(str.asCharString(), buffer.toString()); -} - -TEST(SimpleStringBuffer, setWriteLimitTooHighIsIgnored) -{ - SimpleStringBuffer buffer; - buffer.setWriteLimit(SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN+10); - for (int i = 0; i < SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN+10; i++) - buffer.add("h"); - SimpleString str("h", SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN-1); - STRCMP_EQUAL(str.asCharString(), buffer.toString()); -} - -TEST(SimpleStringBuffer, resetWriteLimit) -{ - SimpleStringBuffer buffer; - buffer.setWriteLimit(10); - for (int i = 0; i < SimpleStringBuffer::SIMPLE_STRING_BUFFER_LEN ; i++) - buffer.add("h"); - buffer.resetWriteLimit(); - buffer.add("%s", SimpleString("h", 10).asCharString()); - - SimpleString str("h", 20); - STRCMP_EQUAL(str.asCharString(), buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpOneLinePlusOnePartial) -{ - SimpleStringBuffer buffer; - buffer.addMemoryDump("deadbeefdeadbeefhopsxx", 22); - STRCMP_EQUAL(" 0000: 64 65 61 64 62 65 65 66 64 65 61 64 62 65 65 66 |deadbeefdeadbeef|\n" - " 0010: 68 6f 70 73 78 78 |hopsxx|\n", - buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpNonPrintable) -{ - SimpleStringBuffer buffer; - // Ensure we test edge cases - NUL, 0x1F, 0x7F, 0xFF - buffer.addMemoryDump("\x15\x7f\xff\x00\x1ftdd", 8); - STRCMP_EQUAL(" 0000: 15 7f ff 00 1f 74 64 64 |.....tdd|\n", - buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpOneLine) -{ - SimpleStringBuffer buffer; - buffer.addMemoryDump("deadbeefdeadbeef", 16); - STRCMP_EQUAL(" 0000: 64 65 61 64 62 65 65 66 64 65 61 64 62 65 65 66 |deadbeefdeadbeef|\n", - buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpOneHalfLine) -{ - SimpleStringBuffer buffer; - buffer.addMemoryDump("deadbeef", 8); - STRCMP_EQUAL(" 0000: 64 65 61 64 62 65 65 66 |deadbeef|\n", - buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpOneByte) -{ - SimpleStringBuffer buffer; - buffer.addMemoryDump("Z", 1); - STRCMP_EQUAL(" 0000: 5a |Z|\n", - buffer.toString()); -} - -TEST(SimpleStringBuffer, addMemoryDumpZeroBytes) -{ - SimpleStringBuffer buffer; - buffer.addMemoryDump("", 0); - STRCMP_EQUAL("", buffer.toString()); -} - -TEST_GROUP(ReallocBugReported) -{ - MemoryLeakFailureForTest reporter; -}; - -TEST(ReallocBugReported, CanSafelyDoAReallocWithANewAllocator) -{ - MemoryLeakDetector detector(&reporter); - char* mem = detector.allocMemory(defaultNewAllocator(), 5, "file", 1); - mem = detector.reallocMemory(defaultNewAllocator(), mem, 19, "file", 1); - detector.deallocMemory(defaultNewAllocator(), mem); -} - -TEST(ReallocBugReported, CanSafelyDoAReallocWithAMallocAllocator) -{ - MemoryLeakDetector detector(&reporter); - char* mem = detector.allocMemory(defaultMallocAllocator(), 5, "file", 1, true); - mem = detector.reallocMemory(defaultMallocAllocator(), mem, 19, "file", 1, true); - detector.deallocMemory(defaultMallocAllocator(), mem, true); -} diff --git a/tests/CppUTest/MemoryLeakWarningTest.cpp b/tests/CppUTest/MemoryLeakWarningTest.cpp deleted file mode 100644 index d4a6ea6fc..000000000 --- a/tests/CppUTest/MemoryLeakWarningTest.cpp +++ /dev/null @@ -1,520 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/MemoryLeakWarningPlugin.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/TestHarness_c.h" -#include "CppUTest/SimpleMutex.h" -#include "DummyMemoryLeakDetector.h" - -TEST_GROUP(MemoryLeakWarningLocalDetectorTest) -{ - DummyMemoryLeakFailure dummy; -}; - -TEST(MemoryLeakWarningLocalDetectorTest, localDetectorReturnsNewGlobalWhenNoneWasSet) -{ - MemoryLeakWarningPlugin memoryLeakWarningPlugin("TestMemoryLeakWarningPlugin", NULLPTR); - CHECK(NULLPTR != memoryLeakWarningPlugin.getMemoryLeakDetector()); -} - -TEST(MemoryLeakWarningLocalDetectorTest, localDetectorIsTheOneSpecifiedInConstructor) -{ - MemoryLeakDetector localDetector(&dummy); - MemoryLeakWarningPlugin memoryLeakWarningPlugin("TestMemoryLeakWarningPlugin", &localDetector); - POINTERS_EQUAL(&localDetector, memoryLeakWarningPlugin.getMemoryLeakDetector()); -} - -TEST(MemoryLeakWarningLocalDetectorTest, localDetectorIsGlobalDetector) -{ - MemoryLeakDetector* globalDetector = MemoryLeakWarningPlugin::getGlobalDetector(); - MemoryLeakWarningPlugin memoryLeakWarningPlugin("TestMemoryLeakWarningPlugin", NULLPTR); - MemoryLeakDetector* localDetector = memoryLeakWarningPlugin.getMemoryLeakDetector(); - POINTERS_EQUAL(globalDetector, localDetector); -} - -static char* leak1; -static long* leak2; - -static MemoryLeakDetector* detector; -static MemoryLeakWarningPlugin* memPlugin; -static TestMemoryAllocator* allocator; - -TEST_GROUP(MemoryLeakWarningTest) -{ - DummyMemoryLeakFailure dummy; - TestTestingFixture* fixture; - - void setup() CPPUTEST_OVERRIDE - { - fixture = new TestTestingFixture(); - detector = new MemoryLeakDetector(&dummy); - allocator = new TestMemoryAllocator; - memPlugin = new MemoryLeakWarningPlugin("TestMemoryLeakWarningPlugin", detector); - fixture->installPlugin(memPlugin); - memPlugin->enable(); - - leak1 = NULLPTR; - leak2 = NULLPTR; - } - - void teardown() CPPUTEST_OVERRIDE - { - detector->deallocMemory(allocator, leak1); - detector->deallocMemory(allocator, leak2); - - delete fixture; - delete memPlugin; - delete detector; - delete allocator; - } -}; - -static void testTwoLeaks_() -{ - leak1 = detector->allocMemory(allocator, 10); - leak2 = (long*) (void*) detector->allocMemory(allocator, 4); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -TEST(MemoryLeakWarningTest, TwoLeaks) -{ - fixture->setTestFunction(testTwoLeaks_); - fixture->runAllTests(); - - LONGS_EQUAL(1, fixture->getFailureCount()); -} - -#else - -TEST(MemoryLeakWarningTest, TwoLeaks) -{ - fixture->setTestFunction(testTwoLeaks_); - fixture->runAllTests(); - - LONGS_EQUAL(0, fixture->getFailureCount()); -} - -#endif - - -static void testLeakWarningWithPluginDisabled_() -{ - memPlugin->expectLeaksInTest(1); - leak1 = (char*) cpputest_malloc_location_with_leak_detection(10, __FILE__, __LINE__); -} - -TEST(MemoryLeakWarningTest, LeakWarningWithPluginDisabled) -{ - fixture->setTestFunction(testLeakWarningWithPluginDisabled_); - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); - - fixture->runAllTests(); - - LONGS_EQUAL(0, fixture->getFailureCount()); - fixture->assertPrintContains("Warning: Expected 1 leak(s), but leak detection was disabled"); - - cpputest_free_location_with_leak_detection(leak1, __FILE__, __LINE__); - leak1 = NULLPTR; - - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); -} - -static void testIgnore2_() -{ - memPlugin->expectLeaksInTest(2); - leak1 = detector->allocMemory(allocator, 10); - leak2 = (long*) (void*) detector->allocMemory(allocator, 4); -} - -TEST(MemoryLeakWarningTest, Ignore2) -{ - fixture->setTestFunction(testIgnore2_); - fixture->runAllTests(); - LONGS_EQUAL(0, fixture->getFailureCount()); -} - -static void failAndLeakMemory_() -{ - leak1 = detector->allocMemory(allocator, 10); - FAIL(""); -} - -TEST(MemoryLeakWarningTest, FailingTestDoesNotReportMemoryLeaks) -{ - fixture->setTestFunction(failAndLeakMemory_); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); -} - -static bool cpputestHasCrashed; - -TEST_GROUP(MemoryLeakWarningGlobalDetectorTest) -{ - MemoryLeakDetector* detector; - MemoryLeakFailure* failureReporter; - - DummyMemoryLeakDetector * dummyDetector; - MemoryLeakFailure* dummyReporter; - - GlobalMemoryAllocatorStash memoryAllocatorStash; - - static void crashMethod() - { - cpputestHasCrashed = true; - } - - void setup() CPPUTEST_OVERRIDE - { - memoryAllocatorStash.save(); - detector = MemoryLeakWarningPlugin::getGlobalDetector(); - failureReporter = MemoryLeakWarningPlugin::getGlobalFailureReporter(); - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); - - dummyReporter = new DummyMemoryLeakFailure; - dummyDetector = new DummyMemoryLeakDetector(dummyReporter); - - UtestShell::setCrashMethod(crashMethod); - cpputestHasCrashed = false; -} - - void teardown() CPPUTEST_OVERRIDE - { - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); - - if (!DummyMemoryLeakDetector::wasDeleted()) delete dummyDetector; - if (!DummyMemoryLeakFailure::wasDeleted()) delete dummyReporter; - MemoryLeakWarningPlugin::setGlobalDetector(detector, failureReporter); - - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - UtestShell::resetCrashMethod(); - - memoryAllocatorStash.restore(); - } -}; - -TEST(MemoryLeakWarningGlobalDetectorTest, turnOffNewOverloadsCausesNoAdditionalLeaks) -{ - size_t storedAmountOfLeaks = detector->totalMemoryLeaks(mem_leak_period_all); - - char* arrayMemory = new char[100]; - char* nonArrayMemory = new char; - char* mallocMemory = (char*) cpputest_malloc_location_with_leak_detection(10, "file", 10); - char* reallocMemory = (char*) cpputest_realloc_location_with_leak_detection(NULLPTR, 10, "file", 10); - - LONGS_EQUAL(storedAmountOfLeaks, detector->totalMemoryLeaks(mem_leak_period_all)); - - cpputest_free_location_with_leak_detection(mallocMemory, "file", 10); - cpputest_free_location_with_leak_detection(reallocMemory, "file", 10); - delete [] arrayMemory; - delete nonArrayMemory; -} - -TEST(MemoryLeakWarningGlobalDetectorTest, destroyGlobalDetector) -{ - MemoryLeakWarningPlugin::setGlobalDetector(dummyDetector, dummyReporter); - - MemoryLeakWarningPlugin::destroyGlobalDetector(); - - CHECK(DummyMemoryLeakDetector::wasDeleted()); - CHECK(DummyMemoryLeakFailure::wasDeleted()); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, MemoryWarningPluginCanBeSetToDestroyTheGlobalDetector) -{ - MemoryLeakWarningPlugin* plugin = new MemoryLeakWarningPlugin("dummy"); - plugin->destroyGlobalDetectorAndTurnOffMemoryLeakDetectionInDestructor(true); - MemoryLeakWarningPlugin::setGlobalDetector(dummyDetector, dummyReporter); - - delete plugin; - - CHECK(DummyMemoryLeakDetector::wasDeleted()); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -TEST(MemoryLeakWarningGlobalDetectorTest, crashOnLeakWithOperatorNew) -{ - MemoryLeakWarningPlugin::setGlobalDetector(dummyDetector, dummyReporter); - - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - crash_on_allocation_number(1); - char* memory = new char[100]; - CHECK(cpputestHasCrashed); - delete [] memory; - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, crashOnLeakWithOperatorNewArray) -{ - MemoryLeakWarningPlugin::setGlobalDetector(dummyDetector, dummyReporter); - - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - crash_on_allocation_number(1); - char* memory = new char; - CHECK(cpputestHasCrashed); - delete memory; - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, crashOnLeakWithOperatorMalloc) -{ - MemoryLeakWarningPlugin::setGlobalDetector(dummyDetector, dummyReporter); - - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - crash_on_allocation_number(1); - char* memory = (char*) cpputest_malloc(10); - CHECK(cpputestHasCrashed); - cpputest_free(memory); - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, gettingTheGlobalDetectorDoesNotRestoreTheMemoryLeakOverloadsWhenTheyWereAlreadyOff) -{ - MemoryLeakWarningPlugin::setGlobalDetector(NULLPTR, NULLPTR); - MemoryLeakDetector* temporaryDetector = MemoryLeakWarningPlugin::getGlobalDetector(); - MemoryLeakFailure* temporaryReporter = MemoryLeakWarningPlugin::getGlobalFailureReporter(); - - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); - - bool areNewDeleteOverloaded = MemoryLeakWarningPlugin::areNewDeleteOverloaded(); - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - - CHECK(!areNewDeleteOverloaded); - - delete temporaryReporter; - delete temporaryDetector; - MemoryLeakWarningPlugin::setGlobalDetector(NULLPTR, NULLPTR); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, checkIfTheMemoryLeakOverloadsAreOn) -{ - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); - CHECK(MemoryLeakWarningPlugin::areNewDeleteOverloaded()); - - MemoryLeakWarningPlugin::turnOffNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, checkIfTheMemoryLeakOverloadsAreOff) -{ - MemoryLeakWarningPlugin::turnOffNewDeleteOverloads(); - bool areNewDeleteOverloaded = MemoryLeakWarningPlugin::areNewDeleteOverloaded(); - - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); - CHECK(!areNewDeleteOverloaded); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, checkIfTheMemoryLeakOverloadsAreOnWithRestore) -{ - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - CHECK(MemoryLeakWarningPlugin::areNewDeleteOverloaded()); - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, checkIfTheMemoryLeakOverloadsAreOffWithSaveDisable) -{ - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); - CHECK(!MemoryLeakWarningPlugin::areNewDeleteOverloaded()); - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningGlobalDetectorTest, threadSafeMemoryLeakDetectorOverloadsAreAlsoOverloaded) -{ - MemoryLeakWarningPlugin::restoreNewDeleteOverloads(); - MemoryLeakWarningPlugin::turnOnThreadSafeNewDeleteOverloads(); - CHECK(MemoryLeakWarningPlugin::areNewDeleteOverloaded()); - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); - MemoryLeakWarningPlugin::saveAndDisableNewDeleteOverloads(); -} - -#endif - -#if CPPUTEST_USE_STD_CPP_LIB - -TEST(MemoryLeakWarningGlobalDetectorTest, turnOffNewOverloadsNoThrowCausesNoAdditionalLeaks) -{ -#undef new - size_t storedAmountOfLeaks = detector->totalMemoryLeaks(mem_leak_period_all); - - char* nonMemoryNoThrow = new (std::nothrow) char; - char* nonArrayMemoryNoThrow = new (std::nothrow) char[10]; - char* nonArrayMemoryThrow = new char[10]; - - LONGS_EQUAL(storedAmountOfLeaks, detector->totalMemoryLeaks(mem_leak_period_all)); - - ::operator delete(nonMemoryNoThrow, std::nothrow); - ::operator delete[](nonArrayMemoryNoThrow, std::nothrow); - ::operator delete[](nonArrayMemoryThrow, std::nothrow); -#ifdef CPPUTEST_USE_NEW_MACROS - #include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -static int mutexLockCount = 0; -static int mutexUnlockCount = 0; - -static void StubMutexLock(PlatformSpecificMutex) -{ - mutexLockCount++; -} - -static void StubMutexUnlock(PlatformSpecificMutex) -{ - mutexUnlockCount++; -} - -TEST_GROUP(MemoryLeakWarningThreadSafe) -{ - void setup() CPPUTEST_OVERRIDE - { - UT_PTR_SET(PlatformSpecificMutexLock, StubMutexLock); - UT_PTR_SET(PlatformSpecificMutexUnlock, StubMutexUnlock); - - mutexLockCount = 0; - mutexUnlockCount = 0; - } - - void teardown() CPPUTEST_OVERRIDE - { - } -}; - -TEST(MemoryLeakWarningThreadSafe, turnOnThreadSafeMallocFreeReallocOverloadsDebug) -{ - size_t storedAmountOfLeaks = MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all); - - MemoryLeakWarningPlugin::turnOnThreadSafeNewDeleteOverloads(); - - int *n = (int*) cpputest_malloc(sizeof(int)); - - LONGS_EQUAL(storedAmountOfLeaks + 1, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(1, mutexLockCount); - CHECK_EQUAL(1, mutexUnlockCount); - - n = (int*) cpputest_realloc(n, sizeof(int)*3); - - LONGS_EQUAL(storedAmountOfLeaks + 1, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(2, mutexLockCount); - CHECK_EQUAL(2, mutexUnlockCount); - - cpputest_free(n); - - LONGS_EQUAL(storedAmountOfLeaks, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(3, mutexLockCount); - CHECK_EQUAL(3, mutexUnlockCount); - - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); -} - -TEST(MemoryLeakWarningThreadSafe, turnOnThreadSafeNewDeleteOverloadsDebug) -{ - size_t storedAmountOfLeaks = MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all); - - MemoryLeakWarningPlugin::turnOnThreadSafeNewDeleteOverloads(); - - int *n = new int; - char *str = new char[20]; - - LONGS_EQUAL(storedAmountOfLeaks + 2, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(2, mutexLockCount); - CHECK_EQUAL(2, mutexUnlockCount); - - delete [] str; - delete n; - - LONGS_EQUAL(storedAmountOfLeaks, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(4, mutexLockCount); - CHECK_EQUAL(4, mutexUnlockCount); - - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); -} - -#ifdef __clang__ - -IGNORE_TEST(MemoryLeakWarningThreadSafe, turnOnThreadSafeNewDeleteOverloads) -{ - /* Clang misbehaves with -O2 - it will not overload operator new or - * operator new[] no matter what. Therefore, this test is must be ignored. - */ -} - -#else - -TEST(MemoryLeakWarningThreadSafe, turnOnThreadSafeNewDeleteOverloads) -{ -#undef new - - size_t storedAmountOfLeaks = MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all); - MemoryLeakWarningPlugin::turnOnThreadSafeNewDeleteOverloads(); - - int *n = new int; - int *n_nothrow = new (std::nothrow) int; - char *str = new char[20]; - char *str_nothrow = new (std::nothrow) char[20]; - - LONGS_EQUAL(storedAmountOfLeaks + 4, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(4, mutexLockCount); - CHECK_EQUAL(4, mutexUnlockCount); - - delete [] str_nothrow; - delete [] str; - delete n; - delete n_nothrow; - - LONGS_EQUAL(storedAmountOfLeaks, MemoryLeakWarningPlugin::getGlobalDetector()->totalMemoryLeaks(mem_leak_period_all)); - CHECK_EQUAL(8, mutexLockCount); - CHECK_EQUAL(8, mutexUnlockCount); - - MemoryLeakWarningPlugin::turnOnDefaultNotThreadSafeNewDeleteOverloads(); -#ifdef CPPUTEST_USE_NEW_MACROS - #include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif -} - -#endif - -#endif - -#endif diff --git a/tests/CppUTest/MemoryOperatorOverloadTest.cpp b/tests/CppUTest/MemoryOperatorOverloadTest.cpp deleted file mode 100644 index df4b212d5..000000000 --- a/tests/CppUTest/MemoryOperatorOverloadTest.cpp +++ /dev/null @@ -1,443 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestTestingFixture.h" -#include "AllocationInCppFile.h" - -#include "CppUTest/TestHarness_c.h" -#include "AllocationInCFile.h" - - -TEST_GROUP(BasicBehavior) -{ -}; - -TEST(BasicBehavior, CanDeleteNullPointers) -{ - delete (char*) NULLPTR; - delete [] (char*) NULLPTR; -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -#if __cplusplus >= 201402L -TEST(BasicBehavior, DeleteWithSizeParameterWorks) -{ - char* charMemory = new char; - char* charArrayMemory = new char[10]; - ::operator delete(charMemory, sizeof(char)); - ::operator delete[](charArrayMemory, sizeof(char)* 10); -} -#endif - -#endif - -#ifdef CPPUTEST_USE_MALLOC_MACROS - -/* This include is added because *sometimes* the cstdlib does an #undef. This should have been prevented */ -#if CPPUTEST_USE_STD_CPP_LIB -#include -#endif - -TEST(BasicBehavior, bothMallocAndFreeAreOverloaded) -{ - void* memory = cpputest_malloc_location(sizeof(char), "file", 10); - free(memory); - - memory = malloc(sizeof(unsigned char)); - cpputest_free_location(memory, "file", 10); -} - -#endif - -TEST_GROUP(MemoryLeakOverridesToBeUsedInProductionCode) -{ - MemoryLeakDetector* memLeakDetector; - void setup() CPPUTEST_OVERRIDE - { - memLeakDetector = MemoryLeakWarningPlugin::getGlobalDetector(); - } - -}; - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -#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) -{ - 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(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteArrayOverloadsWithIntLineWorks) -{ - 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)); -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, newDeleteArrayOverloadsWithSizeTLineWorks) -{ - 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 - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, MallocOverrideIsUsed) -{ - size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking); - void* memory = malloc(10); - LONGS_EQUAL(memLeaks+1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - free (memory); -} - -#ifdef CPPUTEST_USE_STRDUP_MACROS - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, StrdupOverrideIsUsed) -{ - size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking); - char* memory = strdup("0123456789"); - LONGS_EQUAL(memLeaks+1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - free (memory); -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, StrndupOverrideIsUsed) -{ - size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking); - char* memory = strndup("0123456789", 10); - LONGS_EQUAL(memLeaks+1, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - free (memory); -} -#endif - -#endif - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, UseNativeMallocByTemporarlySwitchingOffMalloc) -{ - size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking); -#ifdef CPPUTEST_USE_MALLOC_MACROS - #undef malloc - #undef free -#endif - -#if CPPUTEST_USE_STD_C_LIB - void* memory = malloc(10); - LONGS_EQUAL(memLeaks, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - free (memory); -#else - void* memory = PlatformSpecificMalloc(10); - LONGS_EQUAL(memLeaks, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - PlatformSpecificFree (memory); -#endif - -#ifdef CPPUTEST_USE_MALLOC_MACROS -#include "CppUTest/MemoryLeakDetectorMallocMacros.h" -#endif -} - -/* TEST... allowing for a new overload in a class */ -class NewDummyClass -{ -public: - static bool overloaded_new_called; - -#ifdef CPPUTEST_USE_NEW_MACROS - #undef new -#endif - void* operator new (size_t size) -#ifdef CPPUTEST_USE_NEW_MACROS - #include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif - { - overloaded_new_called = true; - return malloc(size); - } - void dummyFunction() - { - char* memory = new char; - delete memory; - } -}; -bool NewDummyClass::overloaded_new_called = false; - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, NoSideEffectsFromTurningOffNewMacros) -{ - /* - * Interesting effect of wrapping the operator new around the macro is - * that the actual new that is called is a different one than expected. - * - * The overloaded operator new doesn't actually ever get called. - * - * This might come as a surprise, so it is important to realize! - */ - NewDummyClass dummy; - dummy.dummyFunction(); - // CHECK(dummy.overloaded_new_called); -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, UseNativeNewByTemporarlySwitchingOffNew) -{ -#ifdef CPPUTEST_USE_NEW_MACROS - #undef new - #undef delete -#endif - char* memory = new char[10]; - delete [] memory; -#ifdef CPPUTEST_USE_NEW_MACROS - #include "CppUTest/MemoryLeakDetectorNewMacros.h" -#endif -} - - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, OperatorNewMacroOverloadViaIncludeFileWorks) -{ - char* leak = newAllocation(); - STRCMP_NOCASE_CONTAINS("AllocationInCppFile.cpp", memLeakDetector->report(mem_leak_period_checking)); - delete leak; -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, OperatorNewArrayMacroOverloadViaIncludeFileWorks) -{ - char* leak = newArrayAllocation(); - STRCMP_NOCASE_CONTAINS("AllocationInCppFile.cpp", memLeakDetector->report(mem_leak_period_checking)); - delete[] leak; -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, MallocOverrideWorks) -{ - char* leak = mallocAllocation(); - STRCMP_NOCASE_CONTAINS("AllocationInCFile.c", memLeakDetector->report(mem_leak_period_checking)); - freeAllocation(leak); -} - -#ifdef CPPUTEST_USE_STRDUP_MACROS -TEST(MemoryLeakOverridesToBeUsedInProductionCode, StrdupOverrideWorks) -{ - char* leak = strdupAllocation(); - STRCMP_NOCASE_CONTAINS("AllocationInCFile.c", memLeakDetector->report(mem_leak_period_checking)); - freeAllocation(leak); -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, StrndupOverrideWorks) -{ - char* leak = strndupAllocation(); - STRCMP_NOCASE_CONTAINS("AllocationInCFile.c", memLeakDetector->report(mem_leak_period_checking)); - freeAllocation(leak); -} -#endif - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, MallocWithButFreeWithoutLeakDetectionDoesntCrash) -{ - char* leak = mallocAllocation(); - freeAllocationWithoutMacro(leak); - LONGS_EQUAL(2, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); - memLeakDetector->removeMemoryLeakInformationWithoutCheckingOrDeallocatingTheMemoryButDeallocatingTheAccountInformation(getCurrentMallocAllocator(), leak, true); -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, OperatorNewOverloadingWithoutMacroWorks) -{ - char* leak = newAllocationWithoutMacro(); - STRCMP_CONTAINS("unknown", memLeakDetector->report(mem_leak_period_checking)); - delete leak; -} - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, OperatorNewArrayOverloadingWithoutMacroWorks) -{ - char* leak = newArrayAllocationWithoutMacro(); - STRCMP_CONTAINS("unknown", memLeakDetector->report(mem_leak_period_checking)); - delete[] leak; -} - -#else - -TEST(MemoryLeakOverridesToBeUsedInProductionCode, MemoryOverridesAreDisabled) -{ - char* leak = newAllocation(); - STRCMP_EQUAL("No memory leaks were detected.", memLeakDetector->report(mem_leak_period_checking)); - delete leak; -} - -#endif - -TEST_GROUP(OutOfMemoryTestsForOperatorNew) -{ - TestMemoryAllocator* no_memory_allocator; - GlobalMemoryAllocatorStash memoryAllocatorStash; - void setup() CPPUTEST_OVERRIDE - { - memoryAllocatorStash.save(); - no_memory_allocator = new NullUnknownAllocator; - setCurrentNewAllocator(no_memory_allocator); - setCurrentNewArrayAllocator(no_memory_allocator); - } - - void teardown() CPPUTEST_OVERRIDE - { - memoryAllocatorStash.restore(); - delete no_memory_allocator; - } -}; - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -#if CPPUTEST_HAVE_EXCEPTIONS - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorThrowsAnExceptionWhenUsingStdCppNew) -{ - CHECK_THROWS(CPPUTEST_BAD_ALLOC, new char); -} - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorThrowsAnExceptionWhenUsingStdCppNew) -{ - CHECK_THROWS(CPPUTEST_BAD_ALLOC, new char[10]); -} - -TEST_GROUP(TestForExceptionsInConstructor) -{ -}; - -TEST(TestForExceptionsInConstructor,ConstructorThrowsAnException) -{ - CHECK_THROWS(int, new ClassThatThrowsAnExceptionInTheConstructor); -} - -TEST(TestForExceptionsInConstructor,ConstructorThrowsAnExceptionAllocatedAsArray) -{ - CHECK_THROWS(int, new ClassThatThrowsAnExceptionInTheConstructor[10]); -} - -#else - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorReturnsNull) -{ - POINTERS_EQUAL(NULLPTR, new char); -} - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorReturnsNull) -{ - POINTERS_EQUAL(NULLPTR, new char[10]); -} - -#endif - -#undef new - -#if CPPUTEST_HAVE_EXCEPTIONS - - -/* - * CLang 4.2 and memory allocation. - * - * Clang 4.2 has done some optimizations to their memory management that actually causes slightly different behavior than what the C++ Standard defines. - * Usually this is not a problem... but in this case, it is a problem. - * - * More information about the optimization can be found at: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3433.html - * We've done a bug-report to clang to fix some of this non-standard behavior, which is open at: http://llvm.org/bugs/show_bug.cgi?id=15541 - * - * I very much hope that nobody would actually ever hit this bug/optimization as it is hard to figure out what is going on. - * - * The original test simply did "new char". Because the memory wasn't assigned to anything and is local in context, the optimization *doesn't* call - * the operator new overload. Because it doesn't call the operator new (optimizing away a call to operator new), therefore the method wouldn't throw an exception - * and therefore this test failed. - * - * The first attempt to fix this is to create a local variable and assigned the memory to that. Also this doesn't work as it still detects the allocation is - * local and optimizes away the memory call. - * - * Now, we assign the memory on some static global which fools the optimizer to believe that it isn't local and it stops optimizing the operator new call. - * - * We (Bas Vodde and Terry Yin) suspect that in a real product, you wouldn't be able to detect the optimization and it's breaking of Standard C++. Therefore, - * for now, we keep this hack in the test to fool the optimizer and hope nobody will ever notice this 'optimizer behavior' in a real product. - * - * Update 2020: The gcc compiler implemented the same optimization, but it seems to be slightly smarter and discovered that we assign to a static variable. - * Thus it still optimized away the call to operator new. Did another bug report, but it is unlikely to get fixed. You can find it at: - * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94671 - * - * Changed the variable to be external so it would definitively be a mistake to optimize the call. - * - */ - -extern char* some_memory; -char* some_memory; - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorThrowsAnExceptionWhenUsingStdCppNewWithoutOverride) -{ - CHECK_THROWS(CPPUTEST_BAD_ALLOC, some_memory = new char); -} - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorThrowsAnExceptionWhenUsingStdCppNewWithoutOverride) -{ - 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); -} - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorReturnsNullWithoutOverride) -{ - POINTERS_EQUAL(NULLPTR, new (std::nothrow) char[10]); -} -#endif - -#else - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewOperatorReturnsNullWithoutOverride) -{ - POINTERS_EQUAL(NULLPTR, new char); -} - -TEST(OutOfMemoryTestsForOperatorNew, FailingNewArrayOperatorReturnsNullWithoutOverride) -{ - POINTERS_EQUAL(NULLPTR, new char[10]); -} - -#endif - -#endif diff --git a/tests/CppUTest/PluginTest.cpp b/tests/CppUTest/PluginTest.cpp deleted file mode 100644 index c9b74fd07..000000000 --- a/tests/CppUTest/PluginTest.cpp +++ /dev/null @@ -1,198 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" - -#define GENERIC_PLUGIN "GenericPlugin" -#define GENERIC_PLUGIN2 "GenericPlugin2" -#define GENERIC_PLUGIN3 "GenericPlugin3" - -static int sequenceNumber; - -class DummyPlugin: public TestPlugin -{ -public: - DummyPlugin(const SimpleString& name) : - TestPlugin(name), preAction(0), preActionSequence(0), postAction(0), postActionSequence(0) - { - } - - virtual void preTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE - { - preAction++; - preActionSequence = sequenceNumber++; - } - - virtual void postTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE - { - postAction++; - postActionSequence = sequenceNumber++; - } - - int preAction; - int preActionSequence; - int postAction; - int postActionSequence; -}; - -class DummyPluginWhichAcceptsParameters: public DummyPlugin -{ -public: - DummyPluginWhichAcceptsParameters(const SimpleString& name) : - DummyPlugin(name) - { - } - - virtual bool parseArguments(int ac, const char *const *av, int index) CPPUTEST_OVERRIDE - { - SimpleString argument (av[index]); - if (argument == "-paccept") - return true; - return TestPlugin::parseArguments(ac, av, index); - } - -}; - -TEST_GROUP(PluginTest) -{ - DummyPlugin* firstPlugin; - DummyPluginWhichAcceptsParameters* secondPlugin; - DummyPlugin* thirdPlugin; - TestTestingFixture *genFixture; - TestRegistry* registry; - - void setup() CPPUTEST_OVERRIDE - { - firstPlugin = new DummyPlugin(GENERIC_PLUGIN); - secondPlugin = new DummyPluginWhichAcceptsParameters(GENERIC_PLUGIN2); - thirdPlugin = new DummyPlugin(GENERIC_PLUGIN3); - genFixture = new TestTestingFixture; - registry = genFixture->getRegistry(); - registry->installPlugin(firstPlugin); - sequenceNumber = 1; - } - - void teardown() CPPUTEST_OVERRIDE - { - delete firstPlugin; - delete secondPlugin; - delete thirdPlugin; - delete genFixture; - } -}; - -#define GENERIC_PLUGIN "GenericPlugin" - -TEST(PluginTest, PluginHasName) -{ - STRCMP_EQUAL(GENERIC_PLUGIN, firstPlugin->getName().asCharString()); -} - -TEST(PluginTest, InstallPlugin) -{ - CHECK_EQUAL(firstPlugin, registry->getFirstPlugin()); - CHECK_EQUAL(firstPlugin, registry->getPluginByName(GENERIC_PLUGIN)); - LONGS_EQUAL(1, registry->countPlugins()); -} - -TEST(PluginTest, InstallMultiplePlugins) -{ - registry->installPlugin(thirdPlugin); - CHECK_EQUAL(firstPlugin, registry->getPluginByName(GENERIC_PLUGIN)); - CHECK_EQUAL(thirdPlugin, registry->getPluginByName(GENERIC_PLUGIN3)); - POINTERS_EQUAL(NULLPTR, registry->getPluginByName("I do not exist")); -} - -TEST(PluginTest, ActionsAllRun) -{ - genFixture->runAllTests(); - genFixture->runAllTests(); - CHECK_EQUAL(2, firstPlugin->preAction); - CHECK_EQUAL(2, firstPlugin->postAction); -} - -TEST(PluginTest, Sequence) -{ - registry->installPlugin(thirdPlugin); - genFixture->runAllTests(); - CHECK_EQUAL(1, thirdPlugin->preActionSequence); - CHECK_EQUAL(2, firstPlugin->preActionSequence); - CHECK_EQUAL(3, firstPlugin->postActionSequence); - CHECK_EQUAL(4, thirdPlugin->postActionSequence); - LONGS_EQUAL(2, registry->countPlugins()); -} - -TEST(PluginTest, RemovePluginByName) -{ - registry->installPlugin(secondPlugin); - registry->installPlugin(thirdPlugin); - LONGS_EQUAL(3, registry->countPlugins()); - registry->removePluginByName(GENERIC_PLUGIN2); - LONGS_EQUAL(2, registry->countPlugins()); -} - -struct DefaultPlugin : public TestPlugin -{ - DefaultPlugin() : TestPlugin("default") {} -}; - -TEST(PluginTest, DefaultPostTestActionDoesntDoAnything) -{ - DefaultPlugin defaultPlugin; - registry->installPlugin(&defaultPlugin); - genFixture->runAllTests(); -} - -TEST(PluginTest, DisablesPluginsDontRun) -{ - registry->installPlugin(thirdPlugin); - thirdPlugin->disable(); - genFixture->runAllTests(); - CHECK(!thirdPlugin->isEnabled()); - thirdPlugin->enable(); - genFixture->runAllTests(); - CHECK_EQUAL(2, firstPlugin->preAction); - CHECK_EQUAL(1, thirdPlugin->preAction); - CHECK(thirdPlugin->isEnabled()); -} - -TEST(PluginTest, ParseArgumentsForUnknownArgumentsFails) -{ - registry->installPlugin(secondPlugin); - const char *cmd_line[] = {"nonsense", "andmorenonsense"}; - CHECK(registry->getFirstPlugin()->parseAllArguments(2, const_cast(cmd_line), 0) == false); /* cover non-const wrapper, too */ -} - -TEST(PluginTest, ParseArgumentsContinuesAndSucceedsWhenAPluginCanParse) -{ - registry->installPlugin(secondPlugin); - const char *cmd_line[] = {"-paccept", "andmorenonsense"}; - CHECK(registry->getFirstPlugin()->parseAllArguments(2, const_cast(cmd_line), 0)); /* cover non-const wrapper, too */ -} diff --git a/tests/CppUTest/PreprocessorTest.cpp b/tests/CppUTest/PreprocessorTest.cpp deleted file mode 100644 index d41c8055a..000000000 --- a/tests/CppUTest/PreprocessorTest.cpp +++ /dev/null @@ -1,33 +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/TestHarness.h" - -TEST_GROUP(PreprocessorTest) -{ -}; - diff --git a/tests/CppUTest/SetPluginTest.cpp b/tests/CppUTest/SetPluginTest.cpp deleted file mode 100644 index d55b91dfb..000000000 --- a/tests/CppUTest/SetPluginTest.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestPlugin.h" - -static void orig_func1() -{ -} - -static void stub_func1() -{ -} - -static void orig_func2() -{ -} - -static void stub_func2() -{ -} - -static void (*fp1)(); -static void (*fp2)(); - -TEST_GROUP(SetPointerPluginTest) -{ - SetPointerPlugin* plugin_; - TestRegistry* myRegistry_; - StringBufferTestOutput* output_; - TestResult* result_; - - void setup() CPPUTEST_OVERRIDE - { - myRegistry_ = new TestRegistry(); - plugin_ = new SetPointerPlugin("TestSetPlugin"); - myRegistry_->setCurrentRegistry(myRegistry_); - myRegistry_->installPlugin(plugin_); - output_ = new StringBufferTestOutput(); - result_ = new TestResult(*output_); - } - - void teardown() CPPUTEST_OVERRIDE - { - myRegistry_->setCurrentRegistry(NULLPTR); - delete myRegistry_; - delete plugin_; - delete output_; - delete result_; - } -}; - -class FunctionPointerUtest : public Utest -{ -public: - void setup() CPPUTEST_OVERRIDE - { - UT_PTR_SET(fp1, stub_func1); - UT_PTR_SET(fp2, stub_func2); - UT_PTR_SET(fp2, stub_func2); - } - void testBody() CPPUTEST_OVERRIDE - { - CHECK(fp1 == stub_func1); - CHECK(fp2 == stub_func2); - } -}; - -class FunctionPointerUtestShell: public UtestShell -{ -public: - virtual Utest* createTest() CPPUTEST_OVERRIDE - { - return new FunctionPointerUtest(); - } -}; - -TEST(SetPointerPluginTest, installTwoFunctionPointer) -{ - FunctionPointerUtestShell *tst = new FunctionPointerUtestShell(); - - fp1 = orig_func1; - fp2 = orig_func2; - myRegistry_->addTest(tst); - myRegistry_->runAllTests(*result_); - CHECK(fp1 == orig_func1); - CHECK(fp2 == orig_func2); - LONGS_EQUAL(0, result_->getFailureCount()); - LONGS_EQUAL(2, result_->getCheckCount()); - delete tst; -} - -class MaxFunctionPointerUtest : public Utest -{ -public: - int numOfFpSets; - MaxFunctionPointerUtest(int num) : - numOfFpSets(num) - { - } - - void setup() CPPUTEST_OVERRIDE - { - for (int i = 0; i < numOfFpSets; ++i) - { - UT_PTR_SET(fp1, stub_func1); - } - } -}; - -class MaxFunctionPointerUtestShell: public UtestShell -{ -public: - int numOfFpSets; - MaxFunctionPointerUtestShell(int num) : - numOfFpSets(num) - { - } - - virtual Utest* createTest() CPPUTEST_OVERRIDE - { - return new MaxFunctionPointerUtest(numOfFpSets); - } -}; - -TEST(SetPointerPluginTest, installTooMuchFunctionPointer) -{ - MaxFunctionPointerUtestShell *tst = new MaxFunctionPointerUtestShell(SetPointerPlugin::MAX_SET + 1); - myRegistry_->addTest(tst); - - myRegistry_->runAllTests(*result_); - - LONGS_EQUAL(1, result_->getFailureCount()); - delete tst; -} - -static double orig_double = 3.0; -static double* orig_double_ptr = &orig_double; -static double stub_double = 4.0; - -class SetDoublePointerUtest : public Utest -{ -public: - void setup() CPPUTEST_OVERRIDE - { - UT_PTR_SET(orig_double_ptr, &stub_double); - } - void testBody() CPPUTEST_OVERRIDE - { - CHECK(orig_double_ptr == &stub_double); - } -}; - -class SetDoublePointerUtestShell: public UtestShell -{ -public: - Utest * createTest() CPPUTEST_OVERRIDE - { - return new SetDoublePointerUtest(); - } -}; - -TEST(SetPointerPluginTest, doublePointer) -{ - SetDoublePointerUtestShell *doubletst = new SetDoublePointerUtestShell(); - myRegistry_->addTest(doubletst); - myRegistry_->runAllTests(*result_); - - CHECK(orig_double_ptr == &orig_double); - LONGS_EQUAL(1, result_->getCheckCount()); - delete doubletst; -} diff --git a/tests/CppUTest/SimpleMutexTest.cpp b/tests/CppUTest/SimpleMutexTest.cpp deleted file mode 100644 index 19eeae935..000000000 --- a/tests/CppUTest/SimpleMutexTest.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2014, Michael Feathers, James Grenning, Bas Vodde and Chen YewMing - * 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/TestHarness.h" -#include "CppUTest/SimpleMutex.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -static int mutexCreateCount = 0; -static int mutexLockCount = 0; -static int mutexUnlockCount = 0; -static int mutexDestroyCount = 0; - -static PlatformSpecificMutex StubMutexCreate(void) -{ - mutexCreateCount++; - return NULLPTR; -} - -static void StubMutexLock(PlatformSpecificMutex) -{ - mutexLockCount++; -} - -static void StubMutexUnlock(PlatformSpecificMutex) -{ - mutexUnlockCount++; -} - -static void StubMutexDestroy(PlatformSpecificMutex) -{ - mutexDestroyCount++; -} - - - -TEST_GROUP(SimpleMutexTest) -{ - void setup() CPPUTEST_OVERRIDE - { - UT_PTR_SET(PlatformSpecificMutexCreate, StubMutexCreate); - UT_PTR_SET(PlatformSpecificMutexLock, StubMutexLock); - UT_PTR_SET(PlatformSpecificMutexUnlock, StubMutexUnlock); - UT_PTR_SET(PlatformSpecificMutexDestroy, StubMutexDestroy); - - mutexCreateCount = 0; - mutexDestroyCount = 0; - mutexLockCount = 0; - mutexUnlockCount = 0; - } - - void teardown() CPPUTEST_OVERRIDE - { - } -}; - -TEST(SimpleMutexTest, CreateAndDestroy) -{ - { - SimpleMutex mtx; - } - - CHECK_EQUAL(1, mutexCreateCount); - CHECK_EQUAL(1, mutexDestroyCount); - CHECK_EQUAL(0, mutexLockCount); - CHECK_EQUAL(0, mutexUnlockCount); -} - -TEST(SimpleMutexTest, LockUnlockTest) -{ - { - SimpleMutex mtx; - mtx.Lock(); - mtx.Unlock(); - } - - CHECK_EQUAL(1, mutexCreateCount); - CHECK_EQUAL(1, mutexLockCount); - CHECK_EQUAL(1, mutexUnlockCount); - CHECK_EQUAL(1, mutexDestroyCount); -} diff --git a/tests/CppUTest/SimpleStringCacheTest.cpp b/tests/CppUTest/SimpleStringCacheTest.cpp deleted file mode 100644 index 3fd98ab4f..000000000 --- a/tests/CppUTest/SimpleStringCacheTest.cpp +++ /dev/null @@ -1,389 +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/TestHarness.h" -#include "CppUTest/SimpleStringInternalCache.h" -#include "CppUTest/TestTestingFixture.h" - -class TestFunctionWithCache : public ExecFunction -{ -public: - void (*testFunction)(SimpleStringInternalCache*, size_t); - SimpleStringInternalCache* parameter; - size_t allocationSize; - - void exec() CPPUTEST_OVERRIDE - { - testFunction(parameter, allocationSize); - } -}; - -TEST_GROUP(SimpleStringInternalCache) -{ - SimpleStringInternalCache cache; - MemoryAccountant accountant; - MemoryLeakAllocator* defaultAllocator; - AccountingTestMemoryAllocator* allocator; - - TestFunctionWithCache testFunction; - TestTestingFixture fixture; - - void setup() CPPUTEST_OVERRIDE - { - fixture.setTestFunction(&testFunction); - testFunction.parameter = &cache; - - defaultAllocator = new MemoryLeakAllocator(defaultMallocAllocator()); - allocator = new AccountingTestMemoryAllocator(accountant, defaultAllocator); - cache.setAllocator(defaultAllocator); - } - - void teardown() CPPUTEST_OVERRIDE - { - cache.clearAllIncludingCurrentlyUsedMemory(); - accountant.clear(); - delete allocator; - delete defaultAllocator; - } - - void createCacheForSize(size_t size, size_t amount) - { - for (size_t i = 0; i < amount; i++) { - char* memory = cache.alloc(size); - cache.dealloc(memory, size); - } - } -}; - -TEST(SimpleStringInternalCache, cacheHitWithOneEntry) -{ - createCacheForSize(10, 1); - cache.setAllocator(allocator); - - char* mem = cache.alloc(10); - mem[0] = 'B'; - mem[3] = 'A'; - mem[9] = 'S'; - - cache.setAllocator(allocator->originalAllocator()); - - LONGS_EQUAL(0, accountant.totalAllocationsOfSize(10)); - CHECK(!cache.hasFreeBlocksOfSize(10)); - - cache.setAllocator(allocator); -} - -TEST(SimpleStringInternalCache, cacheHitWithTwoEntries) -{ - createCacheForSize(10, 2); - cache.setAllocator(allocator); - - cache.alloc(10); - cache.alloc(10); - - cache.setAllocator(allocator->originalAllocator()); - - LONGS_EQUAL(0, accountant.totalAllocationsOfSize(10)); - CHECK(!cache.hasFreeBlocksOfSize(10)); - - cache.setAllocator(allocator); -} - -TEST(SimpleStringInternalCache, allocatingMoreThanCacheAvailable) -{ - createCacheForSize(10, 1); - cache.setAllocator(allocator); - - cache.alloc(10); - cache.alloc(10); - - cache.setAllocator(allocator->originalAllocator()); - - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(32)); - CHECK(!cache.hasFreeBlocksOfSize(10)); - - cache.setAllocator(allocator); -} - - -TEST(SimpleStringInternalCache, allocationWillReuseTheAllocatedBlocks) -{ - cache.setAllocator(allocator); - - char* mem = cache.alloc(10); - cache.dealloc(mem, 10); - mem = cache.alloc(10); - cache.dealloc(mem, 10); - - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(32)); -} - - -TEST(SimpleStringInternalCache, multipleDifferentSizeAllocationsAndDeallocations) -{ - cache.setAllocator(allocator); - - char* mem10 = cache.alloc(10); - char* mem11 = cache.alloc(11); - - char* mem100 = cache.alloc(100); - cache.dealloc(mem100, 100); - - char* mem101 = cache.alloc(101); - char* mem102 = cache.alloc(102); - char* mem103 = cache.alloc(103); - cache.dealloc(mem101, 102); - cache.dealloc(mem102, 103); - cache.dealloc(mem103, 104); - - cache.alloc(105); - cache.alloc(106); - cache.alloc(107); - - cache.dealloc(mem10, 10); - cache.dealloc(mem11, 11); - - LONGS_EQUAL(2, accountant.totalAllocationsOfSize(32)); - LONGS_EQUAL(3, accountant.totalAllocationsOfSize(128)); -} - -TEST(SimpleStringInternalCache, deallocOfCachedMemoryWillNotDealloc) -{ - cache.setAllocator(allocator); - - char* mem = cache.alloc(10); - cache.dealloc(mem, 10); - - LONGS_EQUAL(0, accountant.totalDeallocationsOfSize(32)); -} - -TEST(SimpleStringInternalCache, clearCacheWillRemoveAllCachedMemoryButNotAllUsedMemory) -{ - cache.setAllocator(allocator); - - char* mem = cache.alloc(10); - cache.dealloc(mem, 10); - - cache.alloc(60); - - cache.clearCache(); - - LONGS_EQUAL(1, accountant.totalDeallocationsOfSize(32)); - LONGS_EQUAL(0, accountant.totalDeallocationsOfSize(64)); -} - -TEST(SimpleStringInternalCache, clearAllIncludingCurrentlyUsedMemory) -{ - cache.setAllocator(allocator); - - cache.alloc(60); - - cache.clearAllIncludingCurrentlyUsedMemory(); - - LONGS_EQUAL(1, accountant.totalDeallocationsOfSize(64)); -} - - - -TEST(SimpleStringInternalCache, allocatingLargerStringThanCached) -{ - cache.setAllocator(allocator); - - char* mem = cache.alloc(1234); - cache.dealloc(mem, 1234); - - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(1234)); - LONGS_EQUAL(1, accountant.totalDeallocationsOfSize(1234)); -} - -TEST(SimpleStringInternalCache, allocatingMultipleLargerStringThanCached) -{ - cache.setAllocator(allocator); - - char* mem = cache.alloc(1234); - char* mem2 = cache.alloc(1234); - char* mem3 = cache.alloc(1234); - - cache.dealloc(mem2, 1234); - cache.dealloc(mem, 1234); - cache.dealloc(mem3, 1234); - - LONGS_EQUAL(3, accountant.totalAllocationsOfSize(1234)); - LONGS_EQUAL(3, accountant.totalDeallocationsOfSize(1234)); -} - - -TEST(SimpleStringInternalCache, clearAllIncludingCurrentlyUsedMemoryAlsoReleasesLargeNonCachesMemory) -{ - cache.setAllocator(allocator); - - cache.alloc(1234); - cache.alloc(1234); - cache.alloc(1234); - - cache.clearAllIncludingCurrentlyUsedMemory(); - - LONGS_EQUAL(3, accountant.totalAllocationsOfSize(1234)); - LONGS_EQUAL(3, accountant.totalDeallocationsOfSize(1234)); -} - -static void deallocatingStringMemoryThatWasntAllocatedWithCache_(SimpleStringInternalCache* cache, size_t allocationSize) -{ - char* mem = defaultMallocAllocator()->alloc_memory(allocationSize, __FILE__, __LINE__); - mem[0] = 'B'; - mem[1] = 'a'; - mem[2] = 's'; - mem[3] = '\0'; - cache->dealloc(mem, allocationSize); - defaultMallocAllocator()->free_memory(mem, allocationSize, __FILE__, __LINE__); -} - -TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarning) -{ - testFunction.testFunction = deallocatingStringMemoryThatWasntAllocatedWithCache_; - testFunction.allocationSize = 123; - - cache.setAllocator(allocator); - fixture.runAllTests(); - - fixture.assertPrintContains("\nWARNING: Attempting to deallocate a String buffer that was allocated while not caching. Ignoring it!\n" - "This is likely due statics and will cause problems.\n" - "Only warning once to avoid recursive warnings.\n" - "String we are deallocating: \"Bas\"\n"); - -} - -static void deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_(SimpleStringInternalCache* cache, size_t allocationSize) -{ - char* mem = defaultMallocAllocator()->alloc_memory(allocationSize, __FILE__, __LINE__); - mem[0] = '\0'; - cache->dealloc(mem, allocationSize); - cache->dealloc(mem, allocationSize); - defaultMallocAllocator()->free_memory(mem, allocationSize, __FILE__, __LINE__); -} - -TEST(SimpleStringInternalCache, deallocatingMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarningButOnlyOnce) -{ - testFunction.testFunction = deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_; - testFunction.allocationSize = 123; - - cache.setAllocator(allocator); - fixture.runAllTests(); - - LONGS_EQUAL(1, fixture.getOutput().count("WARNING")); -} - -TEST(SimpleStringInternalCache, deallocatingLargeMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarning) -{ - testFunction.testFunction = deallocatingStringMemoryThatWasntAllocatedWithCache_; - testFunction.allocationSize = 12345; - - cache.setAllocator(allocator); - fixture.runAllTests(); - - fixture.assertPrintContains("\nWARNING: Attempting to deallocate a String buffer that was allocated while not caching. Ignoring it!\n" - "This is likely due statics and will cause problems.\n" - "Only warning once to avoid recursive warnings.\n" - "String we are deallocating: \"Bas\"\n"); - -} - -TEST(SimpleStringInternalCache, deallocatingLargeMemoryThatWasntAllocatedWhileCacheWasInPlaceProducesWarningButOnlyOnce) -{ - testFunction.testFunction = deallocatingStringMemoryTwiceThatWasntAllocatedWithCache_; - testFunction.allocationSize = 12345; - - cache.setAllocator(allocator); - fixture.runAllTests(); - - LONGS_EQUAL(1, fixture.getOutput().count("WARNING")); -} - -TEST_GROUP(SimpleStringCacheAllocator) -{ - SimpleStringCacheAllocator* allocator; - SimpleStringInternalCache cache; - MemoryAccountant accountant; - AccountingTestMemoryAllocator* accountingAllocator; - - void setup() CPPUTEST_OVERRIDE - { - accountingAllocator = new AccountingTestMemoryAllocator(accountant, defaultMallocAllocator()); - allocator = new SimpleStringCacheAllocator(cache, accountingAllocator); - } - - void teardown() CPPUTEST_OVERRIDE - { - cache.clearCache(); - delete allocator; - delete accountingAllocator; - } -}; - -TEST(SimpleStringCacheAllocator, allocationIsCached) -{ - char* mem = allocator->alloc_memory(10, __FILE__, __LINE__); - allocator->free_memory(mem, 10, __FILE__, __LINE__); - - size_t totalAllocations = accountant.totalAllocations(); - size_t totalDeallocations = accountant.totalDeallocations(); - - mem = allocator->alloc_memory(10, __FILE__, __LINE__); - allocator->free_memory(mem, 10, __FILE__, __LINE__); - - LONGS_EQUAL(totalAllocations, accountant.totalAllocations()); - LONGS_EQUAL(totalDeallocations, accountant.totalDeallocations()); -} - -TEST(SimpleStringCacheAllocator, originalAllocator) -{ - POINTERS_EQUAL(defaultMallocAllocator(), allocator->actualAllocator()); - STRCMP_EQUAL(defaultMallocAllocator()->alloc_name(), allocator->alloc_name()); - STRCMP_EQUAL(defaultMallocAllocator()->free_name(), allocator->free_name()); -} - -TEST(SimpleStringCacheAllocator, name) -{ - STRCMP_EQUAL("SimpleStringCacheAllocator", allocator->name()); -} - - - -TEST_GROUP(GlobalSimpleStringCache) -{ -}; - -TEST(GlobalSimpleStringCache, installsAndRemovedCache) -{ - TestMemoryAllocator* originalStringAllocator = SimpleString::getStringAllocator(); - { - GlobalSimpleStringCache cache; - STRCMP_EQUAL("SimpleStringCacheAllocator", SimpleString::getStringAllocator()->name()); - POINTERS_EQUAL(cache.getAllocator(), SimpleString::getStringAllocator()); - } - POINTERS_EQUAL(originalStringAllocator, SimpleString::getStringAllocator()); -} diff --git a/tests/CppUTest/SimpleStringTest.cpp b/tests/CppUTest/SimpleStringTest.cpp deleted file mode 100644 index 7a4e7629e..000000000 --- a/tests/CppUTest/SimpleStringTest.cpp +++ /dev/null @@ -1,1277 +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/TestHarness.h" -#include "CppUTest/SimpleString.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/MemoryLeakDetector.h" -#include "CppUTest/TestTestingFixture.h" - -class JustUseNewStringAllocator : public TestMemoryAllocator -{ -public: - virtual ~JustUseNewStringAllocator() CPPUTEST_DESTRUCTOR_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) CPPUTEST_OVERRIDE - { - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(getCurrentNewArrayAllocator(), str, file, line); - } -}; - -class GlobalSimpleStringMemoryAccountantExecFunction - : public ExecFunction -{ -public: - void (*testFunction_)(GlobalSimpleStringMemoryAccountant*); - GlobalSimpleStringMemoryAccountant* parameter_; - - virtual void exec() CPPUTEST_OVERRIDE - { - testFunction_(parameter_); - } -}; - -TEST_GROUP(GlobalSimpleStringMemoryAccountant) -{ - GlobalSimpleStringAllocatorStash stash; - GlobalSimpleStringMemoryAccountantExecFunction testFunction; - TestTestingFixture fixture; - GlobalSimpleStringMemoryAccountant accountant; - - void setup() CPPUTEST_OVERRIDE - { - stash.save(); - testFunction.parameter_ = &accountant; - fixture.setTestFunction(&testFunction); - } - - void teardown() CPPUTEST_OVERRIDE - { - stash.restore(); - } -}; - -TEST(GlobalSimpleStringMemoryAccountant, start) -{ - accountant.start(); - POINTERS_EQUAL(accountant.getAllocator(), SimpleString::getStringAllocator()); -} - -TEST(GlobalSimpleStringMemoryAccountant, startTwiceDoesNothing) -{ - accountant.start(); - TestMemoryAllocator* memoryAccountantAllocator = SimpleString::getStringAllocator(); - accountant.start(); - - POINTERS_EQUAL(memoryAccountantAllocator, SimpleString::getStringAllocator()); - - accountant.stop(); -} - -TEST(GlobalSimpleStringMemoryAccountant, stop) -{ - TestMemoryAllocator* originalAllocator = SimpleString::getStringAllocator(); - accountant.start(); - accountant.stop(); - POINTERS_EQUAL(originalAllocator, SimpleString::getStringAllocator()); -} - -static void stopAccountant_(GlobalSimpleStringMemoryAccountant* accountant) -{ - accountant->stop(); -} - -TEST(GlobalSimpleStringMemoryAccountant, stopWithoutStartWillFail) -{ - testFunction.testFunction_ = stopAccountant_; - fixture.runAllTests(); - fixture.assertPrintContains("Global SimpleString allocator stopped without starting"); -} - -static void changeAllocatorBetweenStartAndStop_(GlobalSimpleStringMemoryAccountant* accountant) -{ - TestMemoryAllocator* originalAllocator = SimpleString::getStringAllocator(); - accountant->start(); - SimpleString::setStringAllocator(originalAllocator); - accountant->stop(); -} - -TEST(GlobalSimpleStringMemoryAccountant, stopFailsWhenAllocatorWasChangedInBetween) -{ - testFunction.testFunction_ = changeAllocatorBetweenStartAndStop_; - fixture.runAllTests(); - fixture.assertPrintContains("GlobalStrimpleStringMemoryAccountant: allocator has changed between start and stop!"); -} - -TEST(GlobalSimpleStringMemoryAccountant, report) -{ - SimpleString str; - accountant.start(); - str += "More"; - accountant.stop(); - STRCMP_CONTAINS(" 1 0 1", accountant.report().asCharString()); -} - -TEST(GlobalSimpleStringMemoryAccountant, reportUseCaches) -{ - size_t caches[] = {32}; - accountant.useCacheSizes(caches, 1); - SimpleString str; - accountant.start(); - str += "More"; - accountant.stop(); - STRCMP_CONTAINS("32 1 1 1", accountant.report().asCharString()); -} - - -TEST_GROUP(SimpleString) -{ - JustUseNewStringAllocator justNewForSimpleStringTestAllocator; - GlobalSimpleStringAllocatorStash stash; - void setup() CPPUTEST_OVERRIDE - { - stash.save(); - SimpleString::setStringAllocator(&justNewForSimpleStringTestAllocator); - } - void teardown() CPPUTEST_OVERRIDE - { - stash.restore(); - } -}; - -TEST(SimpleString, defaultAllocatorIsNewArrayAllocator) -{ - SimpleString::setStringAllocator(NULLPTR); - POINTERS_EQUAL(defaultNewArrayAllocator(), SimpleString::getStringAllocator()); -} - -class MyOwnStringAllocator : public TestMemoryAllocator -{ -public: - MyOwnStringAllocator() : memoryWasAllocated(false) {} - virtual ~MyOwnStringAllocator() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - bool memoryWasAllocated; - char* alloc_memory(size_t size, const char* file, size_t line) CPPUTEST_OVERRIDE - { - memoryWasAllocated = true; - return TestMemoryAllocator::alloc_memory(size, file, line); - } -}; - -TEST(SimpleString, allocatorForSimpleStringCanBeReplaced) -{ - MyOwnStringAllocator myOwnAllocator; - SimpleString::setStringAllocator(&myOwnAllocator); - SimpleString simpleString; - CHECK(myOwnAllocator.memoryWasAllocated); - SimpleString::setStringAllocator(NULLPTR); -} - -TEST(SimpleString, CreateSequence) -{ - SimpleString expected("hellohello"); - SimpleString actual("hello", 2); - - CHECK_EQUAL(expected, actual); -} - -TEST(SimpleString, CreateSequenceOfZero) -{ - SimpleString expected(""); - SimpleString actual("hello", 0); - - CHECK_EQUAL(expected, actual); -} - -TEST(SimpleString, Copy) -{ - SimpleString s1("hello"); - SimpleString s2(s1); - - CHECK_EQUAL(s1, s2); -} - -TEST(SimpleString, Assignment) -{ - SimpleString s1("hello"); - SimpleString s2("goodbye"); - - s2 = s1; - - CHECK_EQUAL(s1, s2); -} - -TEST(SimpleString, Equality) -{ - SimpleString s1("hello"); - SimpleString s2("hello"); - - CHECK(s1 == s2); -} - -TEST(SimpleString, InEquality) -{ - SimpleString s1("hello"); - SimpleString s2("goodbye"); - - CHECK(s1 != s2); -} - -TEST(SimpleString, CompareNoCaseWithoutCase) -{ - SimpleString s1("hello"); - SimpleString s2("hello"); - - CHECK(s1.equalsNoCase(s2)); -} - -TEST(SimpleString, CompareNoCaseWithCase) -{ - SimpleString s1("hello"); - SimpleString s2("HELLO"); - - CHECK(s1.equalsNoCase(s2)); -} - -TEST(SimpleString, CompareNoCaseWithCaseNotEqual) -{ - SimpleString s1("hello"); - SimpleString s2("WORLD"); - - CHECK(!s1.equalsNoCase(s2)); -} - - -TEST(SimpleString, asCharString) -{ - SimpleString s1("hello"); - - STRCMP_EQUAL("hello", s1.asCharString()); -} - -TEST(SimpleString, Size) -{ - SimpleString s1("hello!"); - - LONGS_EQUAL(6, s1.size()); -} - -TEST(SimpleString, lowerCase) -{ - SimpleString s1("AbCdEfG1234"); - SimpleString s2(s1.lowerCase()); - STRCMP_EQUAL("abcdefg1234", s2.asCharString()); - 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!"); - SimpleString s2("goodbye!"); - SimpleString s3("hello!goodbye!"); - SimpleString s4; - s4 = s1 + s2; - - CHECK_EQUAL(s3, s4); -} - -TEST(SimpleString, Concatenation) -{ - SimpleString s1("hello!"); - SimpleString s2("goodbye!"); - SimpleString s3("hello!goodbye!"); - SimpleString s4; - s4 += s1; - s4 += s2; - - CHECK_EQUAL(s3, s4); - - SimpleString s5("hello!goodbye!hello!goodbye!"); - s4 += s4; - - CHECK_EQUAL(s5, s4); -} - -TEST(SimpleString, Contains) -{ - SimpleString s("hello!"); - SimpleString empty(""); - SimpleString beginning("hello"); - SimpleString end("lo!"); - SimpleString mid("l"); - SimpleString notPartOfString("xxxx"); - - CHECK(s.contains(empty)); - CHECK(s.contains(beginning)); - CHECK(s.contains(end)); - CHECK(s.contains(mid)); - CHECK(!s.contains(notPartOfString)); - - CHECK(empty.contains(empty)); - CHECK(!empty.contains(s)); -} - -TEST(SimpleString, startsWith) -{ - SimpleString hi("Hi you!"); - SimpleString part("Hi"); - SimpleString diff("Hrrm Hi you! ffdsfd"); - CHECK(hi.startsWith(part)); - CHECK(!part.startsWith(hi)); - CHECK(!diff.startsWith(hi)); -} - -TEST(SimpleString, split) -{ - SimpleString hi("hello\nworld\nhow\ndo\nyou\ndo\n\n"); - - SimpleStringCollection collection; - hi.split("\n", collection); - - LONGS_EQUAL(7, collection.size()); - STRCMP_EQUAL("hello\n", collection[0].asCharString()); - STRCMP_EQUAL("world\n", collection[1].asCharString()); - STRCMP_EQUAL("how\n", collection[2].asCharString()); - STRCMP_EQUAL("do\n", collection[3].asCharString()); - STRCMP_EQUAL("you\n", collection[4].asCharString()); - STRCMP_EQUAL("do\n", collection[5].asCharString()); - STRCMP_EQUAL("\n", collection[6].asCharString()); -} - -TEST(SimpleString, splitNoTokenOnTheEnd) -{ - SimpleString string("Bah Yah oops"); - SimpleStringCollection collection; - - string.split(" ", collection); - LONGS_EQUAL(3, collection.size()); - STRCMP_EQUAL("Bah ", collection[0].asCharString()); - STRCMP_EQUAL("Yah ", collection[1].asCharString()); - STRCMP_EQUAL("oops", collection[2].asCharString()); -} - -TEST(SimpleString, count) -{ - SimpleString str("ha ha ha ha"); - LONGS_EQUAL(4, str.count("ha")); -} - -TEST(SimpleString, countTogether) -{ - SimpleString str("hahahaha"); - LONGS_EQUAL(4, str.count("ha")); -} - -TEST(SimpleString, countEmptyString) -{ - SimpleString str("hahahaha"); - LONGS_EQUAL(8, str.count("")); -} - -TEST(SimpleString, countEmptyStringInEmptyString) -{ - SimpleString str; - LONGS_EQUAL(0, str.count("")); -} - -TEST(SimpleString, endsWith) -{ - SimpleString str("Hello World"); - CHECK(str.endsWith("World")); - CHECK(!str.endsWith("Worl")); - CHECK(!str.endsWith("Hello")); - SimpleString str2("ah"); - CHECK(str2.endsWith("ah")); - CHECK(!str2.endsWith("baah")); - SimpleString str3(""); - CHECK(!str3.endsWith("baah")); - - SimpleString str4("ha ha ha ha"); - CHECK(str4.endsWith("ha")); -} - -TEST(SimpleString, replaceCharWithChar) -{ - SimpleString str("abcabcabca"); - str.replace('a', 'b'); - STRCMP_EQUAL("bbcbbcbbcb", str.asCharString()); -} - -TEST(SimpleString, replaceEmptyStringWithEmptyString) -{ - SimpleString str; - str.replace("", ""); - STRCMP_EQUAL("", str.asCharString()); -} - -TEST(SimpleString, replaceWholeString) -{ - SimpleString str("boo"); - str.replace("boo", ""); - STRCMP_EQUAL("", str.asCharString()); -} - -TEST(SimpleString, replaceStringWithString) -{ - SimpleString str("boo baa boo baa boo"); - str.replace("boo", "boohoo"); - STRCMP_EQUAL("boohoo baa boohoo baa boohoo", str.asCharString()); -} - -TEST(SimpleString, subStringFromEmptyString) -{ - SimpleString str(""); - STRCMP_EQUAL("", str.subString(0, 1).asCharString()); -} - -TEST(SimpleString, subStringFromSmallString) -{ - SimpleString str("H"); - STRCMP_EQUAL("H", str.subString(0, 1).asCharString()); -} - -TEST(SimpleString, subStringFromPos0) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("Hello", str.subString(0, 5).asCharString()); -} - -TEST(SimpleString, subStringFromPos1) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("ello ", str.subString(1, 5).asCharString()); -} - -TEST(SimpleString, subStringFromPos5WithAmountLargerThanString) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("World", str.subString(6, 10).asCharString()); -} - -TEST(SimpleString, subStringFromPos6ToEndOfString) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("World", str.subString(6).asCharString()); -} - -TEST(SimpleString, subStringBeginPosOutOfBounds) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("", str.subString(13, 5).asCharString()); -} - -TEST(SimpleString, subStringFromTillNormal) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("Hello", str.subStringFromTill('H', ' ').asCharString()); -} - -TEST(SimpleString, subStringFromTillOutOfBounds) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("World", str.subStringFromTill('W', '!').asCharString()); -} - -TEST(SimpleString, subStringFromTillStartDoesntExist) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("", str.subStringFromTill('!', ' ').asCharString()); -} - -TEST(SimpleString, subStringFromTillWhenTheEndAppearsBeforeTheStart) -{ - SimpleString str("Hello World"); - STRCMP_EQUAL("World", str.subStringFromTill('W', 'H').asCharString()); -} - -TEST(SimpleString, findNormal) -{ - SimpleString str("Hello World"); - LONGS_EQUAL(0, str.find('H')); - LONGS_EQUAL(1, str.find('e')); - LONGS_EQUAL(SimpleString::npos, str.find('!')); -} - -TEST(SimpleString, at) -{ - SimpleString str("Hello World"); - BYTES_EQUAL('H', str.at(0)); -} - -TEST(SimpleString, copyInBufferNormal) -{ - SimpleString str("Hello World"); - size_t bufferSize = str.size()+1; - char* buffer = (char*) PlatformSpecificMalloc(bufferSize); - str.copyToBuffer(buffer, bufferSize); - STRCMP_EQUAL(str.asCharString(), buffer); - PlatformSpecificFree(buffer); -} - -TEST(SimpleString, copyInBufferWithEmptyBuffer) -{ - SimpleString str("Hello World"); - char* buffer= NULLPTR; - str.copyToBuffer(buffer, 0); - POINTERS_EQUAL(NULLPTR, buffer); -} - -TEST(SimpleString, copyInBufferWithBiggerBufferThanNeeded) -{ - SimpleString str("Hello"); - size_t bufferSize = 20; - char* buffer= (char*) PlatformSpecificMalloc(bufferSize); - str.copyToBuffer(buffer, bufferSize); - STRCMP_EQUAL(str.asCharString(), buffer); - PlatformSpecificFree(buffer); -} - -TEST(SimpleString, copyInBufferWithSmallerBufferThanNeeded) -{ - SimpleString str("Hello"); - size_t bufferSize = str.size(); - char* buffer= (char*) PlatformSpecificMalloc(bufferSize); - str.copyToBuffer(buffer, bufferSize); - STRNCMP_EQUAL(str.asCharString(), buffer, (bufferSize-1)); - LONGS_EQUAL(0, buffer[bufferSize-1]); - PlatformSpecificFree(buffer); -} - -TEST(SimpleString, ContainsNull) -{ - SimpleString s(NULLPTR); - STRCMP_EQUAL("", s.asCharString()); -} - -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)); - SimpleString s2(StringFrom(false)); - CHECK(s1 == "true"); - CHECK(s2 == "false"); -} - -TEST(SimpleString, Pointers) -{ - SimpleString s(StringFrom((void *)0x1234)); - STRCMP_EQUAL("0x1234", s.asCharString()); -} - -TEST(SimpleString, FunctionPointers) -{ - SimpleString s(StringFrom((void (*)())0x1234)); - STRCMP_EQUAL("0x1234", s.asCharString()); -} - -TEST(SimpleString, Characters) -{ - SimpleString s(StringFrom('a')); - STRCMP_EQUAL("a", s.asCharString()); -} - -TEST(SimpleString, NegativeSignedBytes) -{ - STRCMP_EQUAL("-15", StringFrom((signed char)-15).asCharString()); -} - -TEST(SimpleString, PositiveSignedBytes) -{ - STRCMP_EQUAL("4", StringFrom(4).asCharString()); -} - -TEST(SimpleString, LongInts) -{ - SimpleString s(StringFrom((long)1)); - CHECK(s == "1"); -} - -TEST(SimpleString, UnsignedLongInts) -{ - SimpleString s(StringFrom((unsigned long)1)); - SimpleString s2(StringFrom((unsigned long)1)); - CHECK(s == s2); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(SimpleString, LongLongInts) -{ - SimpleString s(StringFrom((long long)1)); - CHECK(s == "1"); -} - -TEST(SimpleString, UnsignedLongLongInts) -{ - SimpleString s(StringFrom((unsigned long long)1)); - SimpleString s2(StringFrom((unsigned long long)1)); - CHECK(s == s2); -} - -#endif /* CPPUTEST_USE_LONG_LONG */ - -TEST(SimpleString, Doubles) -{ - SimpleString s(StringFrom(1.2)); - STRCMP_EQUAL("1.2", s.asCharString()); -} - -extern "C" { - static int alwaysTrue(double) { return true; } -} - -TEST(SimpleString, NaN) -{ - UT_PTR_SET(PlatformSpecificIsNan, alwaysTrue); - SimpleString s(StringFrom(0.0)); - STRCMP_EQUAL("Nan - Not a number", s.asCharString()); -} - -TEST(SimpleString, Inf) -{ - UT_PTR_SET(PlatformSpecificIsInf, alwaysTrue); - SimpleString s(StringFrom(0.0)); - STRCMP_EQUAL("Inf - Infinity", s.asCharString()); -} - -TEST(SimpleString, SmallDoubles) -{ - SimpleString s(StringFrom(1.2e-10)); - STRCMP_CONTAINS("1.2e", s.asCharString()); -} - -TEST(SimpleString, Sizes) -{ - size_t size = 10; - STRCMP_EQUAL("10", StringFrom((int) size).asCharString()); -} - -#if __cplusplus > 199711L && !defined __arm__ && CPPUTEST_USE_STD_CPP_LIB - -TEST(SimpleString, nullptr_type) -{ - SimpleString s(StringFrom(NULLPTR)); - STRCMP_EQUAL("(null)", s.asCharString()); -} - -#endif - -TEST(SimpleString, HexStrings) -{ - STRCMP_EQUAL("f3", HexStringFrom((signed char)-13).asCharString()); - - SimpleString h1 = HexStringFrom(0xffffL); - STRCMP_EQUAL("ffff", h1.asCharString()); - -#if CPPUTEST_USE_LONG_LONG - SimpleString h15 = HexStringFrom(0xffffLL); - STRCMP_EQUAL("ffff", h15.asCharString()); -#endif - - SimpleString h2 = HexStringFrom((void *)0xfffeL); - STRCMP_EQUAL("fffe", h2.asCharString()); - - SimpleString h3 = HexStringFrom((void (*)())0xfffdL); - STRCMP_EQUAL("fffd", h3.asCharString()); -} - -TEST(SimpleString, StringFromFormat) -{ - SimpleString h1 = StringFromFormat("%s %s! %d", "Hello", "World", 2009); - STRCMP_EQUAL("Hello World! 2009", h1.asCharString()); -} - -TEST(SimpleString, StringFromFormatpointer) -{ - //this is not a great test. but %p is odd on mingw and even more odd on Solaris. - SimpleString h1 = StringFromFormat("%p", (void*) 1); - if (h1.size() == 3) - STRCMP_EQUAL("0x1", h1.asCharString()); - else if (h1.size() == 8) - STRCMP_EQUAL("00000001", h1.asCharString()); - else if (h1.size() == 9) - STRCMP_EQUAL("0000:0001", h1.asCharString()); - else if (h1.size() == 16) - STRCMP_EQUAL("0000000000000001", h1.asCharString()); - else if (h1.size() == 1) - STRCMP_EQUAL("1", h1.asCharString()); - else - FAIL("Off %p behavior"); -} - -TEST(SimpleString, StringFromFormatLarge) -{ - const char* s = "ThisIsAPrettyLargeStringAndIfWeAddThisManyTimesToABufferItWillbeFull"; - SimpleString h1 = StringFromFormat("%s%s%s%s%s%s%s%s%s%s", s, s, s, s, s, s, s, s, s, s); - LONGS_EQUAL(10, h1.count(s)); -} - -TEST(SimpleString, StringFromConstSimpleString) -{ - STRCMP_EQUAL("bla", StringFrom(SimpleString("bla")).asCharString()); -} - -static int WrappedUpVSNPrintf(char* buf, size_t n, const char* format, ...) -{ - va_list arguments; - va_start(arguments, format); - - int result = PlatformSpecificVSNprintf(buf, n, format, arguments); - va_end(arguments); - return result; -} - -TEST(SimpleString, PlatformSpecificSprintf_fits) -{ - char buf[10]; - - int count = WrappedUpVSNPrintf(buf, sizeof(buf), "%s", "12345"); - STRCMP_EQUAL("12345", buf); - LONGS_EQUAL(5, count); -} - -TEST(SimpleString, PlatformSpecificSprintf_doesNotFit) -{ - char buf[10]; - - int count = WrappedUpVSNPrintf(buf, sizeof(buf), "%s", "12345678901"); - STRCMP_EQUAL("123456789", buf); - LONGS_EQUAL(11, count); -} - -TEST(SimpleString, PadStringsToSameLengthString1Larger) -{ - SimpleString str1("1"); - SimpleString str2("222"); - - SimpleString::padStringsToSameLength(str1, str2, '4'); - STRCMP_EQUAL("441", str1.asCharString()); - STRCMP_EQUAL("222", str2.asCharString()); -} - -TEST(SimpleString, PadStringsToSameLengthString2Larger) -{ - SimpleString str1(" "); - SimpleString str2(""); - - SimpleString::padStringsToSameLength(str1, str2, ' '); - STRCMP_EQUAL(" ", str1.asCharString()); - STRCMP_EQUAL(" ", str2.asCharString()); -} - -TEST(SimpleString, PadStringsToSameLengthWithSameLengthStrings) -{ - SimpleString str1("123"); - SimpleString str2("123"); - - SimpleString::padStringsToSameLength(str1, str2, ' '); - STRCMP_EQUAL("123", str1.asCharString()); - STRCMP_EQUAL("123", str2.asCharString()); -} - -TEST(SimpleString, NullParameters2) -{ - SimpleString* arr = new SimpleString[100]; - delete[] arr; -} - -TEST(SimpleString, CollectionMultipleAllocateNoLeaksMemory) -{ - SimpleStringCollection col; - col.allocate(5); - col.allocate(5); - // CHECK no memory leak -} - -TEST(SimpleString, CollectionReadOutOfBoundsReturnsEmptyString) -{ - SimpleStringCollection col; - col.allocate(3); - STRCMP_EQUAL("", col[3].asCharString()); -} - -TEST(SimpleString, CollectionWritingToEmptyString) -{ - SimpleStringCollection col; - col.allocate(3); - col[3] = SimpleString("HAH"); - STRCMP_EQUAL("", col[3].asCharString()); -} - -#ifdef CPPUTEST_64BIT - -TEST(SimpleString, 64BitAddressPrintsCorrectly) -{ - char* p = (char*) 0x0012345678901234; - SimpleString expected("0x12345678901234"); - SimpleString actual = StringFrom((void*)p); - STRCMP_EQUAL(expected.asCharString(), actual.asCharString()); -} - -#ifndef CPPUTEST_64BIT_32BIT_LONGS - -TEST(SimpleString, BracketsFormattedHexStringFromForLongOnDifferentPlatform) -{ - long value = -1; - - STRCMP_EQUAL("(0xffffffffffffffff)", BracketsFormattedHexStringFrom(value).asCharString()); -} - -#else - -TEST(SimpleString, BracketsFormattedHexStringFromForLongOnDifferentPlatform) -{ - long value = -1; - - STRCMP_EQUAL("(0xffffffff)", BracketsFormattedHexStringFrom(value).asCharString()); -} - -#endif -#else -/* - * This test case cannot pass on 32 bit systems. - */ -IGNORE_TEST(SimpleString, 64BitAddressPrintsCorrectly) -{ -} - -TEST(SimpleString, BracketsFormattedHexStringFromForLongOnDifferentPlatform) -{ - long value = -1; - - STRCMP_EQUAL("(0xffffffff)", BracketsFormattedHexStringFrom(value).asCharString()); -} -#endif - -TEST(SimpleString, BuildStringFromUnsignedLongInteger) -{ - unsigned long int i = 0xffffffff; - - SimpleString result = StringFrom(i); - const char* expected_string = "4294967295"; - CHECK_EQUAL(expected_string, result); -} - -TEST(SimpleString, BuildStringFromUnsignedInteger) -{ - unsigned int i = 0xff; - - SimpleString result = StringFrom(i); - const char* expected_string = "255"; - CHECK_EQUAL(expected_string, result); -} - -#if CPPUTEST_USE_STD_CPP_LIB - -TEST(SimpleString, fromStdString) -{ - std::string s("hello"); - SimpleString s1(StringFrom(s)); - - STRCMP_EQUAL("hello", s1.asCharString()); -} - -TEST(SimpleString, CHECK_EQUAL_unsigned_long) -{ - unsigned long i = 0xffffffffUL; - CHECK_EQUAL(i, i); -} - -TEST(SimpleString, unsigned_long) -{ - unsigned long i = 0xffffffffUL; - - SimpleString result = StringFrom(i); - const char* expected_string = "4294967295"; - CHECK_EQUAL(expected_string, result); -} - -#endif - -TEST(SimpleString, StrCmp) -{ - char empty[] = ""; - char blabla[] = "blabla"; - char bla[] = "bla"; - CHECK(SimpleString::StrCmp(empty, empty) == 0); - CHECK(SimpleString::StrCmp(bla, blabla) == -(int)'b'); - CHECK(SimpleString::StrCmp(blabla, bla) == 'b'); - CHECK(SimpleString::StrCmp(bla, empty) == 'b'); - CHECK(SimpleString::StrCmp(empty, bla) == -(int)'b'); - CHECK(SimpleString::StrCmp(bla, bla) == 0); -} - -TEST(SimpleString, StrNCpy_no_zero_termination) -{ - char str[] = "XXXXXXXXXX"; - STRCMP_EQUAL("womanXXXXX", SimpleString::StrNCpy(str, "woman", 5)); -} - -TEST(SimpleString, StrNCpy_zero_termination) -{ - char str[] = "XXXXXXXXXX"; - STRCMP_EQUAL("woman", SimpleString::StrNCpy(str, "woman", 6)); -} - -TEST(SimpleString, StrNCpy_null_proof) -{ - POINTERS_EQUAL(NULLPTR, SimpleString::StrNCpy(NULLPTR, "woman", 6)); -} - -TEST(SimpleString, StrNCpy_stops_at_end_of_string) -{ - char str[] = "XXXXXXXXXX"; - STRCMP_EQUAL("woman", SimpleString::StrNCpy(str, "woman", 8)); -} - -TEST(SimpleString, StrNCpy_nothing_to_do) -{ - char str[] = "XXXXXXXXXX"; - STRCMP_EQUAL("XXXXXXXXXX", SimpleString::StrNCpy(str, "woman", 0)); -} - -TEST(SimpleString, StrNCpy_write_into_the_middle) -{ - char str[] = "womanXXXXX"; - SimpleString::StrNCpy(str+3, "e", 1); - STRCMP_EQUAL("womenXXXXX", str); -} - -TEST(SimpleString, StrNCmp_equal) -{ - int result = SimpleString::StrNCmp("teststring", "tests", 5); - LONGS_EQUAL(0, result); -} - -TEST(SimpleString, StrNCmp_should_always_return_0_when_n_is_0) -{ - int result = SimpleString::StrNCmp("a", "b", 0); - LONGS_EQUAL(0, result); -} - -TEST(SimpleString, StrNCmp_s1_smaller) -{ - int result = SimpleString::StrNCmp("testing", "tests", 7); - LONGS_EQUAL('i' - 's', result); -} - -TEST(SimpleString, StrNCmp_s1_larger) -{ - int result = SimpleString::StrNCmp("teststring", "tester", 7); - LONGS_EQUAL('s' - 'e', result); -} - -TEST(SimpleString, StrNCmp_n_too_large) -{ - int result = SimpleString::StrNCmp("teststring", "teststring", 20); - LONGS_EQUAL(0, result); -} - -TEST(SimpleString, StrNCmp_s1_empty) -{ - int result = SimpleString::StrNCmp("", "foo", 2); - LONGS_EQUAL(0 - 'f', result); -} - -TEST(SimpleString, StrNCmp_s2_empty) -{ - int result = SimpleString::StrNCmp("foo", "", 2); - LONGS_EQUAL('f', result); -} - -TEST(SimpleString, StrNCmp_s1_and_s2_empty) -{ - int result = SimpleString::StrNCmp("", "", 2); - LONGS_EQUAL(0, result); -} - -TEST(SimpleString, StrStr) -{ - char foo[] = "foo"; - char empty[] = ""; - char foobarfoo[] = "foobarfoo"; - char barf[] = "barf"; - CHECK(SimpleString::StrStr(foo, empty) == foo); - CHECK(SimpleString::StrStr(empty, foo) == NULLPTR); - CHECK(SimpleString::StrStr(foobarfoo, barf) == foobarfoo+3); - CHECK(SimpleString::StrStr(barf, foobarfoo) == NULLPTR); - CHECK(SimpleString::StrStr(foo, foo) == foo); -} - -TEST(SimpleString, AtoI) -{ - char max_short_str[] = "32767"; - char min_short_str[] = "-32768"; - - CHECK(12345 == SimpleString::AtoI("012345")); - CHECK(6789 == SimpleString::AtoI("6789")); - CHECK(12345 == SimpleString::AtoI("12345/")); - CHECK(12345 == SimpleString::AtoI("12345:")); - CHECK(-12345 == SimpleString::AtoI("-12345")); - CHECK(123 == SimpleString::AtoI("\t \r\n123")); - CHECK(123 == SimpleString::AtoI("123-foo")); - CHECK(0 == SimpleString::AtoI("-foo")); - CHECK(-32768 == SimpleString::AtoI(min_short_str)); - CHECK(32767 == SimpleString::AtoI(max_short_str)); -} - -TEST(SimpleString, AtoU) -{ - char max_short_str[] = "65535"; - CHECK(12345 == SimpleString::AtoU("012345")); - CHECK(6789 == SimpleString::AtoU("6789")); - CHECK(12345 == SimpleString::AtoU("12345/")); - CHECK(12345 == SimpleString::AtoU("12345:")); - CHECK(123 == SimpleString::AtoU("\t \r\n123")); - CHECK(123 == SimpleString::AtoU("123-foo")); - CHECK(65535 == SimpleString::AtoU(max_short_str)); - CHECK(0 == SimpleString::AtoU("foo")); - CHECK(0 == SimpleString::AtoU("-foo")); - CHECK(0 == SimpleString::AtoU("+1")); - CHECK(0 == SimpleString::AtoU("-1")); - CHECK(0 == SimpleString::AtoU("0")); -} - -TEST(SimpleString, Binary) -{ - const unsigned char value[] = { 0x00, 0x01, 0x2A, 0xFF }; - const char expectedString[] = "00 01 2A FF"; - - STRCMP_EQUAL(expectedString, StringFromBinary(value, sizeof(value)).asCharString()); - STRCMP_EQUAL(expectedString, StringFromBinaryOrNull(value, sizeof(value)).asCharString()); - STRCMP_EQUAL("", StringFromBinary(value, 0).asCharString()); - STRCMP_EQUAL("(null)", StringFromBinaryOrNull(NULLPTR, 0).asCharString()); -} - -TEST(SimpleString, BinaryWithSize) -{ - const unsigned char value[] = { 0x12, 0xFE, 0xA1 }; - const char expectedString[] = "Size = 3 | HexContents = 12 FE A1"; - - STRCMP_EQUAL(expectedString, StringFromBinaryWithSize(value, sizeof(value)).asCharString()); - STRCMP_EQUAL(expectedString, StringFromBinaryWithSizeOrNull(value, sizeof(value)).asCharString()); - STRCMP_EQUAL("Size = 0 | HexContents = ", StringFromBinaryWithSize(value, 0).asCharString()); - STRCMP_EQUAL("(null)", StringFromBinaryWithSizeOrNull(NULLPTR, 0).asCharString()); -} - -TEST(SimpleString, BinaryWithSizeLargerThan128) -{ - unsigned char value[129]; - value[127] = 0x00; - value[128] = 0xff; - - STRCMP_CONTAINS("00 ...", StringFromBinaryWithSize(value, sizeof(value)).asCharString()); -} - -TEST(SimpleString, MemCmp) -{ - unsigned char smaller[] = { 0x00, 0x01, 0x2A, 0xFF }; - unsigned char greater[] = { 0x00, 0x01, 0xFF, 0xFF }; - - LONGS_EQUAL(0, SimpleString::MemCmp(smaller, smaller, sizeof(smaller))); - CHECK(SimpleString::MemCmp(smaller, greater, sizeof(smaller)) < 0); - CHECK(SimpleString::MemCmp(greater, smaller, sizeof(smaller)) > 0); - LONGS_EQUAL(0, SimpleString::MemCmp(NULLPTR, NULLPTR, 0)); -} - -TEST(SimpleString, MemCmpFirstLastNotMatching) -{ - unsigned char base[] = { 0x00, 0x01, 0x2A, 0xFF }; - unsigned char firstNotMatching[] = { 0x01, 0x01, 0x2A, 0xFF }; - unsigned char lastNotMatching[] = { 0x00, 0x01, 0x2A, 0x00 }; - CHECK(0 != SimpleString::MemCmp(base, firstNotMatching, sizeof(base))); - CHECK(0 != SimpleString::MemCmp(base, lastNotMatching, sizeof(base))); -} - -#if (CPPUTEST_CHAR_BIT == 16) -TEST(SimpleString, MaskedBitsChar) -{ - STRCMP_EQUAL("xxxxxxxx xxxxxxxx", StringFromMaskedBits(0x00, 0x00, 1).asCharString()); - STRCMP_EQUAL("xxxxxxxx 00000000", StringFromMaskedBits(0x00, 0xFF, 1).asCharString()); - STRCMP_EQUAL("xxxxxxxx 11111111", StringFromMaskedBits(0xFF, 0xFF, 1).asCharString()); - STRCMP_EQUAL("xxxxxxxx 1xxxxxxx", StringFromMaskedBits(0x80, 0x80, 1).asCharString()); - STRCMP_EQUAL("xxxxxxxx xxxxxxx1", StringFromMaskedBits(0x01, 0x01, 1).asCharString()); - STRCMP_EQUAL("xxxxxxxx 11xx11xx", StringFromMaskedBits(0xFF, 0xCC, 1).asCharString()); -} -#elif (CPPUTEST_CHAR_BIT == 8) -TEST(SimpleString, MaskedBitsChar) -{ - STRCMP_EQUAL("xxxxxxxx", StringFromMaskedBits(0x00, 0x00, 1).asCharString()); - STRCMP_EQUAL("00000000", StringFromMaskedBits(0x00, 0xFF, 1).asCharString()); - STRCMP_EQUAL("11111111", StringFromMaskedBits(0xFF, 0xFF, 1).asCharString()); - STRCMP_EQUAL("1xxxxxxx", StringFromMaskedBits(0x80, 0x80, 1).asCharString()); - STRCMP_EQUAL("xxxxxxx1", StringFromMaskedBits(0x01, 0x01, 1).asCharString()); - STRCMP_EQUAL("11xx11xx", StringFromMaskedBits(0xFF, 0xCC, 1).asCharString()); -} -#endif - -TEST(SimpleString, MaskedBits16Bit) -{ - STRCMP_EQUAL("xxxxxxxx xxxxxxxx", StringFromMaskedBits(0x0000, 0x0000, 2*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("00000000 00000000", StringFromMaskedBits(0x0000, 0xFFFF, 2*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("11111111 11111111", StringFromMaskedBits(0xFFFF, 0xFFFF, 2*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("1xxxxxxx xxxxxxxx", StringFromMaskedBits(0x8000, 0x8000, 2*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("xxxxxxxx xxxxxxx1", StringFromMaskedBits(0x0001, 0x0001, 2*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("11xx11xx 11xx11xx", StringFromMaskedBits(0xFFFF, 0xCCCC, 2*8/CPPUTEST_CHAR_BIT).asCharString()); -} - -TEST(SimpleString, MaskedBits32Bit) -{ - STRCMP_EQUAL("xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx", StringFromMaskedBits(0x00000000, 0x00000000, 4*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("00000000 00000000 00000000 00000000", StringFromMaskedBits(0x00000000, 0xFFFFFFFF, 4*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("11111111 11111111 11111111 11111111", StringFromMaskedBits(0xFFFFFFFF, 0xFFFFFFFF, 4*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx", StringFromMaskedBits(0x80000000, 0x80000000, 4*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx1", StringFromMaskedBits(0x00000001, 0x00000001, 4*8/CPPUTEST_CHAR_BIT).asCharString()); - STRCMP_EQUAL("11xx11xx 11xx11xx 11xx11xx 11xx11xx", StringFromMaskedBits(0xFFFFFFFF, 0xCCCCCCCC, 4*8/CPPUTEST_CHAR_BIT).asCharString()); -} - -TEST(SimpleString, StringFromOrdinalNumberOnes) -{ - STRCMP_EQUAL("2nd", StringFromOrdinalNumber(2).asCharString()); - STRCMP_EQUAL("3rd", StringFromOrdinalNumber(3).asCharString()); - STRCMP_EQUAL("4th", StringFromOrdinalNumber(4).asCharString()); - STRCMP_EQUAL("5th", StringFromOrdinalNumber(5).asCharString()); - STRCMP_EQUAL("6th", StringFromOrdinalNumber(6).asCharString()); - STRCMP_EQUAL("7th", StringFromOrdinalNumber(7).asCharString()); -} - -TEST(SimpleString, StringFromOrdinalNumberTens) -{ - STRCMP_EQUAL("10th", StringFromOrdinalNumber(10).asCharString()); - STRCMP_EQUAL("11th", StringFromOrdinalNumber(11).asCharString()); - STRCMP_EQUAL("12th", StringFromOrdinalNumber(12).asCharString()); - STRCMP_EQUAL("13th", StringFromOrdinalNumber(13).asCharString()); - STRCMP_EQUAL("14th", StringFromOrdinalNumber(14).asCharString()); - STRCMP_EQUAL("18th", StringFromOrdinalNumber(18).asCharString()); -} - -TEST(SimpleString, StringFromOrdinalNumberOthers) -{ - STRCMP_EQUAL("21st", StringFromOrdinalNumber(21).asCharString()); - STRCMP_EQUAL("22nd", StringFromOrdinalNumber(22).asCharString()); - STRCMP_EQUAL("23rd", StringFromOrdinalNumber(23).asCharString()); - STRCMP_EQUAL("24th", StringFromOrdinalNumber(24).asCharString()); - STRCMP_EQUAL("32nd", StringFromOrdinalNumber(32).asCharString()); - STRCMP_EQUAL("100th", StringFromOrdinalNumber(100).asCharString()); - STRCMP_EQUAL("101st", StringFromOrdinalNumber(101).asCharString()); -} - -TEST(SimpleString, BracketsFormattedHexStringFromForSignedChar) -{ - signed char value = 'c'; - - STRCMP_EQUAL("(0x63)", BracketsFormattedHexStringFrom(value).asCharString()); -} - - -TEST(SimpleString, BracketsFormattedHexStringFromForUnsignedInt) -{ - unsigned int value = 1; - - STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString()); -} - -TEST(SimpleString, BracketsFormattedHexStringFromForUnsignedLong) -{ - unsigned long value = 1; - - STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString()); -} - -#ifdef CPPUTEST_16BIT_INTS -TEST(SimpleString, BracketsFormattedHexStringFromForInt) -{ - int value = -1; - - STRCMP_EQUAL("(0xffff)", BracketsFormattedHexStringFrom(value).asCharString()); -} -#else -TEST(SimpleString, BracketsFormattedHexStringFromForInt) -{ - int value = -1; - STRCMP_EQUAL("(0xffffffff)", BracketsFormattedHexStringFrom(value).asCharString()); -} -#endif - -TEST(SimpleString, BracketsFormattedHexStringFromForLong) -{ - long value = 1; - - STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString()); -} -#if CPPUTEST_USE_LONG_LONG - -TEST(SimpleString, BracketsFormattedHexStringFromForLongLong) -{ - cpputest_longlong value = 1; - - STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString()); -} -TEST(SimpleString, BracketsFormattedHexStringFromForULongLong) -{ - cpputest_ulonglong value = 1; - - STRCMP_EQUAL("(0x1)", BracketsFormattedHexStringFrom(value).asCharString()); -} -#else -TEST(SimpleString, BracketsFormattedHexStringFromForLongLong) -{ - cpputest_longlong value; - - STRCMP_EQUAL("", BracketsFormattedHexStringFrom(value).asCharString()); -} -TEST(SimpleString, BracketsFormattedHexStringFromForULongLong) -{ - cpputest_ulonglong value; - - STRCMP_EQUAL("", BracketsFormattedHexStringFrom(value).asCharString()); -} - -#endif diff --git a/tests/CppUTest/TeamCityOutputTest.cpp b/tests/CppUTest/TeamCityOutputTest.cpp deleted file mode 100644 index 36ee135f5..000000000 --- a/tests/CppUTest/TeamCityOutputTest.cpp +++ /dev/null @@ -1,226 +0,0 @@ -#include "CppUTest/TestHarness.h" -#include "CppUTest/TeamCityTestOutput.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -class TeamCityOutputToBuffer : public TeamCityTestOutput -{ -public: - explicit TeamCityOutputToBuffer() - { - } - - virtual ~TeamCityOutputToBuffer() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - void printBuffer(const char* s) CPPUTEST_OVERRIDE - { - output += s; - } - - void flush() CPPUTEST_OVERRIDE - { - output = ""; - } - - const SimpleString& getOutput() - { - return output; - } - -private: - SimpleString output; -}; - -static unsigned long millisTime; - -extern "C" { - - static unsigned long MockGetPlatformSpecificTimeInMillis() - { - return millisTime; - } - -} - -TEST_GROUP(TeamCityOutputTest) -{ - TeamCityTestOutput* tcout; - TeamCityOutputToBuffer* mock; - UtestShell* tst; - TestFailure *f, *f2, *f3; - TestResult* result; - - void setup() CPPUTEST_OVERRIDE - { - mock = new TeamCityOutputToBuffer(); - tcout = mock; - tst = new UtestShell("group", "test", "file", 10); - f = new TestFailure(tst, "failfile", 20, "failure message"); - f2 = new TestFailure(tst, "file", 20, "message"); - f3 = new TestFailure(tst, "file", 30, "apos' pipe| [brackets]\r\nCRLF"); - result = new TestResult(*mock); - result->setTotalExecutionTime(10); - millisTime = 0; - UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis); - } - void teardown() CPPUTEST_OVERRIDE - { - delete tcout; - delete tst; - delete f; - delete f2; - delete f3; - delete result; - } -}; - -TEST(TeamCityOutputTest, PrintGroupStarted) -{ - result->currentGroupStarted(tst); - STRCMP_EQUAL("##teamcity[testSuiteStarted name='group']\n", mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintGroupStartedAndEnded) -{ - const char* expected = "##teamcity[testSuiteStarted name='group']\n" - "##teamcity[testSuiteFinished name='group']\n"; - result->currentGroupStarted(tst); - result->currentGroupEnded(tst); - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintGroupEndedButNotStarted) -{ - result->currentGroupEnded(tst); - STRCMP_EQUAL("", mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintTestStarted) -{ - tcout->printCurrentTestStarted(*tst); - STRCMP_EQUAL("##teamcity[testStarted name='test']\n", mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintTestStartedAndEnded) -{ - result->currentTestStarted(tst); - millisTime = 42; - result->currentTestEnded(tst); - STRCMP_EQUAL("##teamcity[testStarted name='test']\n##teamcity[testFinished name='test' duration='42']\n", - mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintTestEndedButNotStarted) -{ - result->currentTestEnded(tst); - STRCMP_EQUAL("", mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintTestIgnored) -{ - const char* expected = - "##teamcity[testStarted name='test']\n" - "##teamcity[testIgnored name='test']\n" - "##teamcity[testFinished name='test' duration='41']\n"; - - IgnoredUtestShell* itst = new IgnoredUtestShell("group", "test", "file", 10); - result->currentTestStarted(itst); - millisTime = 41; - result->currentTestEnded(itst); - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); - delete itst; -} - -TEST(TeamCityOutputTest, PrintWithFailureInSameFile) -{ - tcout->printFailure(*f2); - const char* expected = - "##teamcity[testFailed name='test' message='file:20' " - "details='message']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintWithEscapedCharacters) -{ - tcout->printFailure(*f3); - const char* expected = - "##teamcity[testFailed name='test' message='file:30' " - "details='apos|' pipe|| |[brackets|]" - "|r|nCRLF']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, PrintFailureWithFailInDifferentFile) -{ - tcout->printFailure(*f); - const char* expected = - "##teamcity[testFailed name='test' message='TEST failed (file:10): failfile:20' " - "details='failure message']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestGroupEscaped_Start) -{ - tst->setGroupName("'[]\n\r"); - result->currentGroupStarted(tst); - const char* expected = - "##teamcity[testSuiteStarted name='|'|[|]|n|r']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestGroupEscaped_End) -{ - tst->setGroupName("'[]\n\r"); - result->currentGroupStarted(tst); - result->currentGroupEnded(tst); - const char* expected = - "##teamcity[testSuiteStarted name='|'|[|]|n|r']\n" - "##teamcity[testSuiteFinished name='|'|[|]|n|r']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestNameEscaped_Start) -{ - tst->setTestName("'[]\n\r"); - result->currentTestStarted(tst); - const char* expected = - "##teamcity[testStarted name='|'|[|]|n|r']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestNameEscaped_End) -{ - tst->setTestName("'[]\n\r"); - result->currentTestStarted(tst); - result->currentTestEnded(tst); - const char* expected = - "##teamcity[testStarted name='|'|[|]|n|r']\n" - "##teamcity[testFinished name='|'|[|]|n|r' duration='0']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestNameEscaped_Ignore) -{ - IgnoredUtestShell itst("group", "'[]\n\r", "file", 10); - result->currentTestStarted(&itst); - const char* expected = - "##teamcity[testStarted name='|'|[|]|n|r']\n" - "##teamcity[testIgnored name='|'|[|]|n|r']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TeamCityOutputTest, TestNameEscaped_Fail) -{ - tst->setTestName("'[]\n\r"); - TestFailure fail(tst, "failfile", 20, "failure message"); - tcout->printFailure(fail); - const char* expected = - "##teamcity[testFailed name='|'|[|]|n|r' message='TEST failed (file:10): failfile:20' " - "details='failure message']\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -/* Todo: - * -Detect when running in TeamCity and switch output to -o teamcity automatically - */ diff --git a/tests/CppUTest/TestFailureNaNTest.cpp b/tests/CppUTest/TestFailureNaNTest.cpp deleted file mode 100644 index 2f7e2a62f..000000000 --- a/tests/CppUTest/TestFailureNaNTest.cpp +++ /dev/null @@ -1,105 +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/TestHarness.h" -#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"; -} - -TEST_GROUP(TestFailureNanAndInf) -{ - UtestShell* test; - - void setup() CPPUTEST_OVERRIDE - { - test = new UtestShell("groupname", "testname", failFileName, failLineNumber-1); - } - void teardown() CPPUTEST_OVERRIDE - { - delete test; - } -}; -#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, (b).getMessage().asCharString(), "", __FILE__, __LINE__) - -TEST(TestFailureNanAndInf, DoublesEqualExpectedIsNaN) -{ - 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); -} - -TEST(TestFailureNanAndInf, DoublesEqualActualIsNaN) -{ - 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); -} - -TEST(TestFailureNanAndInf, DoublesEqualThresholdIsNaN) -{ - 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); -} - -TEST(TestFailureNanAndInf, DoublesEqualExpectedIsInf) -{ - 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, (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, (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 deleted file mode 100644 index 6a7cb1516..000000000 --- a/tests/CppUTest/TestFailureTest.cpp +++ /dev/null @@ -1,451 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" - -namespace -{ -const int failLineNumber = 2; -const char* failFileName = "fail.cpp"; -} - -TEST_GROUP(TestFailure) -{ - UtestShell* test; - - void setup() CPPUTEST_OVERRIDE - { - test = new UtestShell("groupname", "testname", failFileName, failLineNumber-1); - } - void teardown() CPPUTEST_OVERRIDE - { - delete test; - } -}; -#define FAILURE_EQUAL(a, b) STRCMP_EQUAL_LOCATION(a, (b).getMessage().asCharString(), "", __FILE__, __LINE__) - -TEST(TestFailure, CreateFailure) -{ - TestFailure f1(test, failFileName, failLineNumber, "the failure message"); - TestFailure f2(test, "the failure message"); - TestFailure f3(test, failFileName, failLineNumber); -} - -TEST(TestFailure, GetTestFileAndLineFromFailure) -{ - TestFailure f1(test, failFileName, failLineNumber, "the failure message"); - STRCMP_EQUAL(failFileName, f1.getTestFileName().asCharString()); - LONGS_EQUAL(1, f1.getTestLineNumber()); -} - -TEST(TestFailure, EqualsFailureWithText) -{ - EqualsFailure f(test, failFileName, failLineNumber, "expected", "actual", "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected \n\tbut was ", f); -} - -TEST(TestFailure, EqualsFailure) -{ - EqualsFailure f(test, failFileName, failLineNumber, "expected", "actual", ""); - FAILURE_EQUAL("expected \n\tbut was ", f); -} - -TEST(TestFailure, EqualsFailureWithNullAsActual) -{ - EqualsFailure f(test, failFileName, failLineNumber, "expected", NULLPTR, ""); - FAILURE_EQUAL("expected \n\tbut was <(null)>", f); -} - -TEST(TestFailure, EqualsFailureWithNullAsExpected) -{ - EqualsFailure f(test, failFileName, failLineNumber, NULLPTR, "actual", ""); - FAILURE_EQUAL("expected <(null)>\n\tbut was ", f); -} - -TEST(TestFailure, CheckEqualFailureWithText) -{ - CheckEqualFailure f(test, failFileName, failLineNumber, "expected", "actual", "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected \n" - "\tbut was \n" - "\tdifference starts at position 0 at: < actual >\n" - "\t ^", f); -} - -TEST(TestFailure, CheckEqualFailure) -{ - CheckEqualFailure f(test, failFileName, failLineNumber, "expected", "actual", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 0 at: < actual >\n" - "\t ^", f); -} - -TEST(TestFailure, CheckFailure) -{ - CheckFailure f(test, failFileName, failLineNumber, "CHECK", "chk"); - FAILURE_EQUAL("CHECK(chk) failed", f); -} - -TEST(TestFailure, CheckFailureWithText) -{ - CheckFailure f(test, failFileName, failLineNumber, "CHECK", "chk", "text"); - FAILURE_EQUAL("Message: text\n" - "\tCHECK(chk) failed", f); -} - -TEST(TestFailure, FailFailure) -{ - FailFailure f(test, failFileName, failLineNumber, "chk"); - FAILURE_EQUAL("chk", f); -} - -TEST(TestFailure, LongsEqualFailureWithText) -{ - LongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected <1 (0x1)>\n\tbut was <2 (0x2)>", f); -} - -TEST(TestFailure, LongsEqualFailure) -{ - LongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, ""); - FAILURE_EQUAL("expected <1 (0x1)>\n\tbut was <2 (0x2)>", f); -} - -TEST(TestFailure, LongLongsEqualFailure) -{ -#if CPPUTEST_USE_LONG_LONG - LongLongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, ""); - FAILURE_EQUAL("expected <1 (0x1)>\n\tbut was <2 (0x2)>", f); -#else - cpputest_longlong dummy_longlong; - LongLongsEqualFailure f(test, failFileName, failLineNumber, dummy_longlong, dummy_longlong, ""); - FAILURE_EQUAL("expected < >\n\tbut was < >", f); -#endif -} - -TEST(TestFailure, UnsignedLongLongsEqualFailure) -{ -#if CPPUTEST_USE_LONG_LONG - UnsignedLongLongsEqualFailure f(test, failFileName, failLineNumber, 1, 2, ""); - FAILURE_EQUAL("expected <1 (0x1)>\n\tbut was <2 (0x2)>", f); -#else - cpputest_ulonglong dummy_ulonglong; - UnsignedLongLongsEqualFailure f(test, failFileName, failLineNumber, dummy_ulonglong, dummy_ulonglong, ""); - FAILURE_EQUAL("expected < >\n\tbut was < >", f); -#endif -} - -TEST(TestFailure, SignedBytesEqualFailure) -{ - SignedBytesEqualFailure f(test, failFileName, failLineNumber, (signed char)-1, (signed char)2, ""); - FAILURE_EQUAL("expected <-1 (0xff)>\n\tbut was < 2 (0x2)>", f); -} - -TEST(TestFailure, StringsEqualFailureWithText) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "abc", "abd", "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected \n" - "\tbut was \n" - "\tdifference starts at position 2 at: < abd >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailure) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "abc", "abd", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 2 at: < abd >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureAtTheEnd) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "abc", "ab", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 2 at: < ab >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureNewVariantAtTheEnd) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "EndOfALongerString", "EndOfALongerStrinG", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 17 at: \n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureWithNewLinesAndTabs) -{ - StringEqualFailure f(test, failFileName, failLineNumber, - "StringWith\t\nDifferentString", - "StringWith\t\ndifferentString", ""); - - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 12 at: \n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureInTheMiddle) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "aa", "ab", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 1 at: < ab >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureAtTheBeginning) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "aaa", "bbb", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 0 at: < bbb >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualFailureWithNullAsActual) -{ - StringEqualFailure f(test, failFileName, failLineNumber, "abc", NULLPTR, ""); - FAILURE_EQUAL("expected \n" - "\tbut was <(null)>", f); -} - -TEST(TestFailure, StringsEqualFailureWithNullAsExpected) -{ - StringEqualFailure f(test, failFileName, failLineNumber, NULLPTR, "abd", ""); - FAILURE_EQUAL("expected <(null)>\n" - "\tbut was ", f); -} - -TEST(TestFailure, StringsEqualNoCaseFailureWithText) -{ - StringEqualNoCaseFailure f(test, failFileName, failLineNumber, "ABC", "abd", "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected \n" - "\tbut was \n" - "\tdifference starts at position 2 at: < abd >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualNoCaseFailure) -{ - StringEqualNoCaseFailure f(test, failFileName, failLineNumber, "ABC", "abd", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 2 at: < abd >\n" - "\t ^", f); -} - -TEST(TestFailure, StringsEqualNoCaseFailureWithActualAsNull) -{ - StringEqualNoCaseFailure f(test, failFileName, failLineNumber, "ABC", NULLPTR, ""); - FAILURE_EQUAL("expected \n" - "\tbut was <(null)>", f); -} - -TEST(TestFailure, StringsEqualNoCaseFailureWithExpectedAsNull) -{ - StringEqualNoCaseFailure f(test, failFileName, failLineNumber, NULLPTR, "abd", ""); - FAILURE_EQUAL("expected <(null)>\n" - "\tbut was ", f); -} - -TEST(TestFailure, StringsEqualNoCaseFailure2) -{ - StringEqualNoCaseFailure f(test, failFileName, failLineNumber, "ac", "AB", ""); - FAILURE_EQUAL("expected \n" - "\tbut was \n" - "\tdifference starts at position 1 at: < AB >\n" - "\t ^", f); -} - -TEST(TestFailure, DoublesEqualNormalWithText) -{ - DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, 2.0, 3.0, "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected <1>\n" - "\tbut was <2> threshold used was <3>", f); -} - -TEST(TestFailure, DoublesEqualNormal) -{ - DoublesEqualFailure f(test, failFileName, failLineNumber, 1.0, 2.0, 3.0, ""); - FAILURE_EQUAL("expected <1>\n" - "\tbut was <2> threshold used was <3>", f); -} - -TEST(TestFailure, BinaryEqualWithText) -{ - const unsigned char expectedData[] = { 0x00 }; - const unsigned char actualData[] = { 0x01 }; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected <00>\n" - "\tbut was <01>\n" - "\tdifference starts at position 0 at: < 01 >\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualOneByte) -{ - const unsigned char expectedData[] = { 0x00 }; - const unsigned char actualData[] = { 0x01 }; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00>\n" - "\tbut was <01>\n" - "\tdifference starts at position 0 at: < 01 >\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualTwoBytes) -{ - const unsigned char expectedData[] = {0x00, 0x01}; - const unsigned char actualData[] = {0x00, 0x02}; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00 01>\n" - "\tbut was <00 02>\n" - "\tdifference starts at position 1 at: < 00 02 >\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualThreeBytes) -{ - const unsigned char expectedData[] = {0x00, 0x01, 0x00}; - const unsigned char actualData[] = {0x00, 0x02, 0x00}; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00 01 00>\n" - "\tbut was <00 02 00>\n" - "\tdifference starts at position 1 at: < 00 02 00 >\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualFullWidth) -{ - const unsigned char expectedData[] = {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00}; - const unsigned char actualData[] = {0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00}; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00 00 00 01 00 00 00>\n" - "\tbut was <00 00 00 02 00 00 00>\n" - "\tdifference starts at position 3 at: <00 00 00 02 00 00 00>\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualLast) -{ - const unsigned char expectedData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - const unsigned char actualData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, actualData, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00 00 00 00 00 00 00>\n" - "\tbut was <00 00 00 00 00 00 01>\n" - "\tdifference starts at position 6 at: <00 00 00 01 >\n" - "\t ^", f); -} - -TEST(TestFailure, BinaryEqualActualNull) -{ - const unsigned char expectedData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - BinaryEqualFailure f(test, failFileName, failLineNumber, expectedData, NULLPTR, sizeof(expectedData), ""); - FAILURE_EQUAL("expected <00 00 00 00 00 00 00>\n\tbut was <(null)>", f); -} - -TEST(TestFailure, BinaryEqualExpectedNull) -{ - const unsigned char actualData[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; - BinaryEqualFailure f(test, failFileName, failLineNumber, NULLPTR, actualData, sizeof(actualData), ""); - FAILURE_EQUAL("expected <(null)>\n\tbut was <00 00 00 00 00 00 01>", f); -} - -TEST(TestFailure, BitsEqualWithText) -{ - BitsEqualFailure f(test, failFileName, failLineNumber, 0x0001, 0x0003, 0x00FF, 2*8/CPPUTEST_CHAR_BIT, "text"); - FAILURE_EQUAL("Message: text\n" - "\texpected \n\tbut was ", f); -} - -#if (CPPUTEST_CHAR_BIT == 16) -TEST(TestFailure, BitsEqualChar) -{ - BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), ""); - FAILURE_EQUAL("expected \n\tbut was ", f); -} -#elif (CPPUTEST_CHAR_BIT == 8) -TEST(TestFailure, BitsEqualChar) -{ - BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), ""); - FAILURE_EQUAL("expected <00000001>\n\tbut was <00000011>", f); -} -#endif - -TEST(TestFailure, BitsEqual16Bit) -{ - BitsEqualFailure f(test, failFileName, failLineNumber, 0x0001, 0x0003, 0xFFFF, 2*8/CPPUTEST_CHAR_BIT, ""); - FAILURE_EQUAL("expected <00000000 00000001>\n\tbut was <00000000 00000011>", f); -} - -TEST(TestFailure, BitsEqual32Bit) -{ - BitsEqualFailure f(test, failFileName, failLineNumber, 0x00000001, 0x00000003, 0xFFFFFFFF, 4*8/CPPUTEST_CHAR_BIT, ""); - FAILURE_EQUAL("expected <00000000 00000000 00000000 00000001>\n\tbut was <00000000 00000000 00000000 00000011>", f); -} - -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 deleted file mode 100644 index 231a01a0a..000000000 --- a/tests/CppUTest/TestFilterTest.cpp +++ /dev/null @@ -1,166 +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/TestHarness.h" -#include "CppUTest/TestFilter.h" - -TEST_GROUP(TestFilter) -{ -}; - -TEST(TestFilter, emptyFilterMatchesEverything) -{ - TestFilter filter; - CHECK(filter.match("random_name")); - CHECK(filter.match("")); - CHECK(filter.match("*&%#^&%$(*&^@#(&*@#^(&*$^@#")); -} - -TEST(TestFilter, defaultAbsoluteMismatches) -{ - TestFilter filter("filtername"); - CHECK(!filter.match("notevenclose")); - CHECK(!filter.match("filterrname")); - CHECK(!filter.match("")); -} - -TEST(TestFilter, strictMatching) -{ - TestFilter filter("filter"); - filter.strictMatching(); - CHECK(filter.match("filter")); - CHECK(!filter.match("filterr")); - CHECK(!filter.match(" filter")); -} - -TEST(TestFilter, invertMatching) -{ - TestFilter filter("filter"); - filter.invertMatching(); - CHECK(!filter.match("filter")); - CHECK(!filter.match("filterr")); - CHECK(filter.match("notevenclose")); - CHECK(filter.match("")); -} - -TEST(TestFilter, invertStrictMatching) -{ - TestFilter filter("filter"); - filter.invertMatching(); - filter.strictMatching(); - CHECK(!filter.match("filter")); - CHECK(filter.match("filterr")); - CHECK(filter.match(" filter")); -} - -TEST(TestFilter, equality) -{ - TestFilter filter1("filter"); - TestFilter filter2("filter"); - TestFilter filter3("filter3"); - CHECK(filter1 == filter2); - CHECK(! (filter1 == filter3)); -} - -TEST(TestFilter, equalityWithStrictness) -{ - TestFilter filter1("filter"); - TestFilter filter2("filter"); - filter2.strictMatching(); - CHECK(! (filter1 == filter2)); -} - -TEST(TestFilter, equalityWithInvertion) -{ - TestFilter filter1("filter"); - TestFilter filter2("filter"); - filter2.invertMatching(); - CHECK(! (filter1 == filter2)); -} - -TEST(TestFilter, notEqual) -{ - TestFilter filter1("filter"); - TestFilter filter2("filter"); - TestFilter filter3("filter3"); - CHECK(filter1 != filter3); - CHECK(! (filter1 != filter2)); -} - -TEST(TestFilter, stringFrom) -{ - TestFilter filter("filter"); - STRCMP_EQUAL("TestFilter: \"filter\"", StringFrom(filter).asCharString()); -} - -TEST(TestFilter, stringFromWithStrictMatching) -{ - TestFilter filter("filter"); - filter.strictMatching(); - STRCMP_EQUAL("TestFilter: \"filter\" with strict matching", StringFrom(filter).asCharString()); -} - -TEST(TestFilter, stringFromWithInvertMatching) -{ - TestFilter filter("filter"); - filter.invertMatching(); - STRCMP_EQUAL("TestFilter: \"filter\" with invert matching", StringFrom(filter).asCharString()); -} - -TEST(TestFilter, stringFromWithStrictInvertMatching) -{ - TestFilter filter("filter"); - filter.strictMatching(); - filter.invertMatching(); - STRCMP_EQUAL("TestFilter: \"filter\" with strict, invert matching", StringFrom(filter).asCharString()); -} - -TEST(TestFilter, listOfFilters) -{ - TestFilter *listOfFilters = NULLPTR; - TestFilter first("foo"); - TestFilter secnd("bar"); - listOfFilters = first.add(listOfFilters); - listOfFilters = secnd.add(listOfFilters); - TestFilter *current = listOfFilters; - STRCMP_EQUAL("TestFilter: \"bar\"", StringFrom(*current).asCharString()); - current = current->getNext(); - STRCMP_EQUAL("TestFilter: \"foo\"", StringFrom(*current).asCharString()); - POINTERS_EQUAL(NULLPTR, current->getNext()); -} - -TEST(TestFilter, constructors) -{ - TestFilter filter1; - TestFilter filter2(SimpleString("a")); - TestFilter filter3("a"); - CHECK(filter1.getNext() == NULLPTR); - CHECK(filter2.getNext() == NULLPTR); - CHECK(filter3.getNext() == NULLPTR); - CHECK(filter2.match("ab")); - CHECK(filter3.match("ab")); -} diff --git a/tests/CppUTest/TestHarness_cTest.cpp b/tests/CppUTest/TestHarness_cTest.cpp deleted file mode 100644 index fadc66f1d..000000000 --- a/tests/CppUTest/TestHarness_cTest.cpp +++ /dev/null @@ -1,884 +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/TestHarness_c.h" - -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/PlatformSpecificFunctions.h" - - -extern "C" int setup_teardown_was_called_in_test_group_in_C; -extern "C" int test_was_called_in_test_group_in_C; -int setup_teardown_was_called_in_test_group_in_C = 0; -int test_was_called_in_test_group_in_C = 0; - -TEST_GROUP_C_WRAPPER(TestGroupInC) -{ - TEST_GROUP_C_SETUP_WRAPPER(TestGroupInC) - TEST_GROUP_C_TEARDOWN_WRAPPER(TestGroupInC) -}; - -TEST_C_WRAPPER(TestGroupInC, checkThatTheTestHasRun) -IGNORE_TEST_C_WRAPPER(TestGroupInC, ignoreMacroForCFile) - -/* - * This test is a bit strange. They use the fact that you can do -r2 for repeating the same run. - * When you do so, the same statics will be shared and therefore we can test whether the setup/teardown is run - * correctly. - */ - -TEST(TestGroupInC, setupHasBeenCalled) -{ - test_was_called_in_test_group_in_C++; - /* Increased in setup, decreased in teardown. So at this point it must be 1 also on a multiple run */ - LONGS_EQUAL(1, setup_teardown_was_called_in_test_group_in_C); -} - -static bool hasDestructorOfTheDestructorCheckedBeenCalled; - -class HasTheDestructorBeenCalledChecker -{ -public: - HasTheDestructorBeenCalledChecker(){} - ~HasTheDestructorBeenCalledChecker() { hasDestructorOfTheDestructorCheckedBeenCalled = true; } -}; - -TEST_GROUP(TestHarness_c) -{ - TestTestingFixture* fixture; - TEST_SETUP() - { - hasDestructorOfTheDestructorCheckedBeenCalled = false; - fixture = new TestTestingFixture(); - } - TEST_TEARDOWN() - { - delete fixture; - } -}; - -static void failBoolMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_BOOL(1, 0); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkBool) -{ - CHECK_EQUAL_C_BOOL(1, 1); - CHECK_EQUAL_C_BOOL(1, 2); - fixture->setTestFunction(failBoolMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected \n\tbut was "); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failBoolTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_BOOL_TEXT(1, 0, "BoolTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkBoolText) -{ - CHECK_EQUAL_C_BOOL_TEXT(1, 1, "Text"); - CHECK_EQUAL_C_BOOL_TEXT(1, 2, "Text"); - fixture->setTestFunction(failBoolTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected \n\tbut was "); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: BoolTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_INT(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkInt) -{ - CHECK_EQUAL_C_INT(2, 2); - fixture->setTestFunction(failIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_INT_TEXT(1, 2, "IntTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkIntText) -{ - CHECK_EQUAL_C_INT_TEXT(2, 2, "Text"); - fixture->setTestFunction(failIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: IntTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_UINT(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedInt) -{ - CHECK_EQUAL_C_UINT(2, 2); - fixture->setTestFunction(failUnsignedIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_UINT_TEXT(1, 2, "UnsignedIntTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedIntText) -{ - CHECK_EQUAL_C_UINT_TEXT(2, 2, "Text"); - fixture->setTestFunction(failUnsignedIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: UnsignedIntTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failLongIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_LONG(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongInt) -{ - CHECK_EQUAL_C_LONG(2, 2); - fixture->setTestFunction(failLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failLongIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_LONG_TEXT(1, 2, "LongIntTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongIntText) -{ - CHECK_EQUAL_C_LONG_TEXT(2, 2, "Text"); - fixture->setTestFunction(failLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: LongIntTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedLongIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_ULONG(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongInt) -{ - CHECK_EQUAL_C_ULONG(2, 2); - fixture->setTestFunction(failUnsignedLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedLongIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_ULONG_TEXT(1, 2, "UnsignedLongIntTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongIntText) -{ - CHECK_EQUAL_C_ULONG_TEXT(2, 2, "Text"); - fixture->setTestFunction(failUnsignedLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: UnsignedLongIntTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -#if CPPUTEST_USE_LONG_LONG - -static void failLongLongIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_LONGLONG(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongLongInt) -{ - CHECK_EQUAL_C_LONGLONG(2, 2); - fixture->setTestFunction(failLongLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failLongLongIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_LONGLONG_TEXT(1, 2, "LongLongTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongLongIntText) -{ - CHECK_EQUAL_C_LONGLONG_TEXT(2, 2, "Text"); - fixture->setTestFunction(failLongLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: LongLongTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedLongLongIntMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_ULONGLONG(1, 2); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongLongInt) -{ - CHECK_EQUAL_C_ULONGLONG(2, 2); - fixture->setTestFunction(failUnsignedLongLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedLongLongIntTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_ULONGLONG_TEXT(1, 2, "UnsignedLongLongTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongLongIntText) -{ - CHECK_EQUAL_C_ULONGLONG_TEXT(2, 2, "Text"); - fixture->setTestFunction(failUnsignedLongLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1 (0x1)>\n\tbut was <2 (0x2)>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: UnsignedLongLongTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -#else - -static void failLongLongIntMethod_() -{ - cpputest_longlong dummy_longlong; - CHECK_EQUAL_C_LONGLONG(dummy_longlong, dummy_longlong); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongLongInt) -{ - fixture->setTestFunction(failLongLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("is not supported"); - fixture->assertPrintContains("arness_c"); -} - -static void failLongLongIntTextMethod_() -{ - cpputest_longlong dummy_longlong; - CHECK_EQUAL_C_LONGLONG_TEXT(dummy_longlong, dummy_longlong, "Text"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkLongLongIntText) -{ - fixture->setTestFunction(failLongLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("is not supported"); - fixture->assertPrintContains("arness_c"); -} - -static void failUnsignedLongLongIntMethod_() -{ - cpputest_ulonglong dummy_ulonglong; - CHECK_EQUAL_C_ULONGLONG(dummy_ulonglong, dummy_ulonglong); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongLongInt) -{ - fixture->setTestFunction(failUnsignedLongLongIntMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("is not supported"); - fixture->assertPrintContains("arness_c"); -} - -static void failUnsignedLongLongIntTextMethod_() -{ - cpputest_ulonglong dummy_ulonglong; - CHECK_EQUAL_C_ULONGLONG_TEXT(dummy_ulonglong, dummy_ulonglong, "Text"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkUnsignedLongLongIntText) -{ - fixture->setTestFunction(failUnsignedLongLongIntTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("is not supported"); - fixture->assertPrintContains("arness_c"); -} - -#endif - -static void failRealMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_REAL(1.0, 2.0, 0.5); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkReal) -{ - CHECK_EQUAL_C_REAL(1.0, 1.1, 0.5); - fixture->setTestFunction(failRealMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1>\n\tbut was <2>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failRealTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_REAL_TEXT(1.0, 2.0, 0.5, "RealTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkRealText) -{ - CHECK_EQUAL_C_REAL_TEXT(1.0, 1.1, 0.5, "Text"); - fixture->setTestFunction(failRealTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <1>\n\tbut was <2>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: RealTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failCharMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_CHAR('a', 'c'); -} - -TEST(TestHarness_c, checkChar) -{ - CHECK_EQUAL_C_CHAR('a', 'a'); - fixture->setTestFunction(failCharMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected \n\tbut was "); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failCharTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_CHAR_TEXT('a', 'c', "CharTestText"); -} - -TEST(TestHarness_c, checkCharText) -{ - CHECK_EQUAL_C_CHAR_TEXT('a', 'a', "Text"); - fixture->setTestFunction(failCharTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected \n\tbut was "); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: CharTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedByteMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_UBYTE(254, 253); -} - -TEST(TestHarness_c, checkUnsignedByte) -{ - CHECK_EQUAL_C_UBYTE(254, 254); - fixture->setTestFunction(failUnsignedByteMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <254>\n\tbut was <253>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failUnsignedByteTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_UBYTE_TEXT(254, 253, "UnsignedByteTestText"); -} - -TEST(TestHarness_c, checkUnsignedByteText) -{ - CHECK_EQUAL_C_UBYTE_TEXT(254, 254, "Text"); - fixture->setTestFunction(failUnsignedByteTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <254>\n\tbut was <253>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: UnsignedByteTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failSignedByteMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_SBYTE(-3, -5); -} - -TEST(TestHarness_c, checkSignedByte) -{ - CHECK_EQUAL_C_SBYTE(-3, -3); - fixture->setTestFunction(failSignedByteMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <-3>\n\tbut was <-5>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failSignedByteTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_SBYTE_TEXT(-3, -5, "SignedByteTestText"); -} - -TEST(TestHarness_c, checkSignedByteText) -{ - CHECK_EQUAL_C_SBYTE_TEXT(-3, -3, "Text"); - fixture->setTestFunction(failSignedByteTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <-3>\n\tbut was <-5>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: SignedByteTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failStringMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_STRING("Hello", "Hello World"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkString) -{ - CHECK_EQUAL_C_STRING("Hello", "Hello"); - fixture->setTestFunction(failStringMethod_); - fixture->runAllTests(); - - StringEqualFailure failure(UtestShell::getCurrent(), "file", 1, "Hello", "Hello World", ""); - fixture->assertPrintContains(failure.getMessage()); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failStringTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_STRING_TEXT("Hello", "Hello World", "StringTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkStringText) -{ - CHECK_EQUAL_C_STRING_TEXT("Hello", "Hello", "Text"); - fixture->setTestFunction(failStringTextMethod_); - fixture->runAllTests(); - - StringEqualFailure failure(UtestShell::getCurrent(), "file", 1, "Hello", "Hello World", ""); - fixture->assertPrintContains(failure.getMessage()); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: StringTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failPointerMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_POINTER(NULLPTR, (void *)0x1); -} - -TEST(TestHarness_c, checkPointer) -{ - CHECK_EQUAL_C_POINTER(NULLPTR, NULLPTR); - fixture->setTestFunction(failPointerMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <0x0>\n\tbut was <0x1>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failPointerTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_POINTER_TEXT(NULLPTR, (void *)0x1, "PointerTestText"); -} - -TEST(TestHarness_c, checkPointerText) -{ - CHECK_EQUAL_C_POINTER_TEXT(NULLPTR, NULLPTR, "Text"); - fixture->setTestFunction(failPointerTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <0x0>\n\tbut was <0x1>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: PointerTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -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); -} - -TEST(TestHarness_c, checkBits) -{ - CHECK_EQUAL_C_BITS(0xABCD, (unsigned short)0xABCD, 0xFFFF); - fixture->setTestFunction(failBitsMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <00000000 00000001>\n\tbut was <00000000 00000011>"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failBitsTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_EQUAL_C_BITS_TEXT(0x0001, (unsigned short)0x0003, 0xFFFF, "BitsTestText"); -} - -TEST(TestHarness_c, checkBitsText) -{ - CHECK_EQUAL_C_BITS_TEXT(0xABCD, (unsigned short)0xABCD, 0xFFFF, "Text"); - fixture->setTestFunction(failBitsTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("expected <00000000 00000001>\n\tbut was <00000000 00000011>"); - fixture->assertPrintContains("arness_c"); - fixture->assertPrintContains("Message: BitsTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - FAIL_TEXT_C("Booo"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkFailText) -{ - fixture->setTestFunction(failTextMethod_); - fixture->runAllTests(); - fixture->assertPrintContains("Booo"); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void failMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - FAIL_C(); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkFail) -{ - fixture->setTestFunction(failMethod_); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); - fixture->assertPrintContains("arness_c"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -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); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkCheck) -{ - CHECK_C(true); - fixture->setTestFunction(CheckMethod_); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -static void CheckTextMethod_() -{ - HasTheDestructorBeenCalledChecker checker; - CHECK_C_TEXT(false, "CheckTestText"); -} // LCOV_EXCL_LINE - -TEST(TestHarness_c, checkCheckText) -{ - CHECK_C_TEXT(true, "Text"); - fixture->setTestFunction(CheckTextMethod_); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); - fixture->assertPrintContains("Message: CheckTestText"); - CHECK(!hasDestructorOfTheDestructorCheckedBeenCalled); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -TEST(TestHarness_c, cpputest_malloc_out_of_memory) -{ - cpputest_malloc_set_out_of_memory(); - CHECK(NULLPTR == cpputest_malloc(100)); - - cpputest_malloc_set_not_out_of_memory(); - void * mem = cpputest_malloc(100); - CHECK(NULLPTR != mem); - cpputest_free(mem); -} - -TEST(TestHarness_c, cpputest_malloc_out_of_memory_after_n_mallocs) -{ - cpputest_malloc_set_out_of_memory_countdown(3); - void * m1 = cpputest_malloc(10); - void * m2 = cpputest_malloc(11); - void * m3 = cpputest_malloc(12); - CHECK(m1 != NULLPTR); - CHECK(m2 != NULLPTR); - CHECK(m3 == NULLPTR); - cpputest_malloc_set_not_out_of_memory(); - cpputest_free(m1); - cpputest_free(m2); -} - -TEST(TestHarness_c, cpputest_malloc_out_of_memory_after_0_mallocs) -{ - cpputest_malloc_set_out_of_memory_countdown(0); - void * m1 = cpputest_malloc(10); - CHECK(m1 == NULLPTR); - cpputest_malloc_set_not_out_of_memory(); -} - -TEST(TestHarness_c, count_mallocs) -{ - cpputest_malloc_count_reset(); - void * m1 = cpputest_malloc(10); - void * m2 = cpputest_malloc(11); - void * m3 = cpputest_malloc(12); - cpputest_free(m1); - cpputest_free(m2); - cpputest_free(m3); - LONGS_EQUAL(3, cpputest_malloc_get_count()); -} - -#ifdef CPPUTEST_USE_STRDUP_MACROS - -TEST(TestHarness_c, cpputest_strdup) -{ - char * mem = cpputest_strdup("0123456789"); - CHECK(NULLPTR != mem); - STRCMP_EQUAL("0123456789", mem); - cpputest_free(mem); -} - -TEST(TestHarness_c, cpputest_strndup) -{ - char * mem = cpputest_strndup("0123456789", 3); - CHECK(NULLPTR != mem); - STRCMP_EQUAL("012", mem); - cpputest_free(mem); -} - -#endif - -TEST(TestHarness_c, cpputest_calloc) -{ - void * mem = cpputest_calloc(10, 10); - CHECK(NULLPTR != mem); - cpputest_free(mem); -} - -TEST(TestHarness_c, cpputest_realloc_larger) -{ - const char* number_string = "123456789"; - - char* mem1 = (char*) cpputest_malloc(10); - - SimpleString::StrNCpy(mem1, number_string, 10); - - CHECK(mem1 != NULLPTR); - - char* mem2 = (char*) cpputest_realloc(mem1, 1000); - - CHECK(mem2 != NULLPTR); - STRCMP_EQUAL(number_string, mem2); - - cpputest_free(mem2); -} - -#include "CppUTest/MemoryLeakDetector.h" - -TEST(TestHarness_c, macros) -{ -#if CPPUTEST_USE_MALLOC_MACROS - MemoryLeakDetector* memLeakDetector = MemoryLeakWarningPlugin::getGlobalDetector(); - size_t memLeaks = memLeakDetector->totalMemoryLeaks(mem_leak_period_checking); -#endif - void* mem1 = malloc(10); - void* mem2 = calloc(10, 20); - void* mem3 = realloc(mem2, 100); -#if CPPUTEST_USE_MALLOC_MACROS - LONGS_EQUAL(memLeaks + 2, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); -#endif - free(mem1); - free(mem3); -#if CPPUTEST_USE_MALLOC_MACROS - LONGS_EQUAL(memLeaks, memLeakDetector->totalMemoryLeaks(mem_leak_period_checking)); -#endif - -} - -TEST(TestHarness_c, callocInitializedToZero) -{ - char* mem = (char*) calloc(20, sizeof(char)); - for (int i = 0; i < 20; i++) - CHECK(mem[i] == 0); - free(mem); -} - -TEST(TestHarness_c, callocShouldReturnNULLWhenOutOfMemory) -{ - cpputest_malloc_set_out_of_memory_countdown(0); - void * m = cpputest_calloc(1, 1); - CHECK(m == NULLPTR); - cpputest_malloc_set_not_out_of_memory(); -} -#endif diff --git a/tests/CppUTest/TestHarness_cTestCFile.c b/tests/CppUTest/TestHarness_cTestCFile.c deleted file mode 100644 index bfc7d767f..000000000 --- a/tests/CppUTest/TestHarness_cTestCFile.c +++ /dev/null @@ -1,36 +0,0 @@ - -#include "CppUTest/TestHarness_c.h" -#include "CppUTest/PlatformSpecificFunctions_c.h" - -extern void functionWithUnusedParameter(void* PUNUSED(unlessParamater)); - -void functionWithUnusedParameter(void* PUNUSED(unlessParamater)) -{ - -} - -/* Declared in the cpp file */ -extern int setup_teardown_was_called_in_test_group_in_C; -extern int test_was_called_in_test_group_in_C; - -TEST_GROUP_C_SETUP(TestGroupInC) -{ - setup_teardown_was_called_in_test_group_in_C++; -} - -TEST_GROUP_C_TEARDOWN(TestGroupInC) -{ - setup_teardown_was_called_in_test_group_in_C--; - CHECK_C(test_was_called_in_test_group_in_C == 1); - test_was_called_in_test_group_in_C--; -} - -TEST_C(TestGroupInC, checkThatTheTestHasRun) -{ - test_was_called_in_test_group_in_C++; -} - -IGNORE_TEST_C(TestGroupInC, ignoreMacroForCFile) -{ - test_was_called_in_test_group_in_C++; -} diff --git a/tests/CppUTest/TestInstallerTest.cpp b/tests/CppUTest/TestInstallerTest.cpp deleted file mode 100644 index da59f322d..000000000 --- a/tests/CppUTest/TestInstallerTest.cpp +++ /dev/null @@ -1,62 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" - -class TestInstallerTestUtestShell : public UtestShell -{ -}; - - -// this is file scope because the test is installed -// with all other tests, which also happen to be -// created as static instances at file scope - -TEST_GROUP(TestInstaller) -{ - TestInstaller* testInstaller; - TestRegistry* myRegistry; - TestInstallerTestUtestShell shell; - void setup() CPPUTEST_OVERRIDE - { - myRegistry = new TestRegistry(); - myRegistry->setCurrentRegistry(myRegistry); - testInstaller = new TestInstaller(shell, "TestInstaller", "test", __FILE__, __LINE__); - } - void teardown() CPPUTEST_OVERRIDE - { - myRegistry->setCurrentRegistry(NULLPTR); - testInstaller->unDo(); - delete testInstaller; - delete myRegistry; - } -}; - -TEST(TestInstaller, Create) -{ -} diff --git a/tests/CppUTest/TestMemoryAllocatorTest.cpp b/tests/CppUTest/TestMemoryAllocatorTest.cpp deleted file mode 100644 index 1f2e86618..000000000 --- a/tests/CppUTest/TestMemoryAllocatorTest.cpp +++ /dev/null @@ -1,765 +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/TestHarness.h" -#include "CppUTest/TestMemoryAllocator.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/MemoryLeakDetector.h" - -TEST_GROUP(TestMemoryAllocatorTest) -{ - TestMemoryAllocator* allocator; - GlobalMemoryAllocatorStash memoryAllocatorStash; - - void setup() CPPUTEST_OVERRIDE - { - allocator = NULLPTR; - memoryAllocatorStash.save(); - } - - void teardown() CPPUTEST_OVERRIDE - { - memoryAllocatorStash.restore(); - delete allocator; - } -}; - -TEST(TestMemoryAllocatorTest, SetCurrentNewAllocator) -{ - allocator = new TestMemoryAllocator("new allocator for test"); - setCurrentNewAllocator(allocator); - POINTERS_EQUAL(allocator, getCurrentNewAllocator()); -} - -TEST(TestMemoryAllocatorTest, SetCurrentNewAllocatorToDefault) -{ - TestMemoryAllocator* originalAllocator = getCurrentNewAllocator(); - - setCurrentNewAllocatorToDefault(); - POINTERS_EQUAL(defaultNewAllocator(), getCurrentNewAllocator()); - - setCurrentNewAllocator(originalAllocator); -} - -TEST(TestMemoryAllocatorTest, SetCurrentNewArrayAllocator) -{ - allocator = new TestMemoryAllocator("new array allocator for test"); - setCurrentNewArrayAllocator(allocator); - POINTERS_EQUAL(allocator, getCurrentNewArrayAllocator()); - setCurrentNewArrayAllocatorToDefault(); - POINTERS_EQUAL(defaultNewArrayAllocator(), getCurrentNewArrayAllocator()); -} - -TEST(TestMemoryAllocatorTest, SetCurrentMallocAllocator) -{ - allocator = new TestMemoryAllocator("malloc_allocator"); - setCurrentMallocAllocator(allocator); - POINTERS_EQUAL(allocator, getCurrentMallocAllocator()); - setCurrentMallocAllocatorToDefault(); - POINTERS_EQUAL(defaultMallocAllocator(), getCurrentMallocAllocator()); -} - -TEST(TestMemoryAllocatorTest, MemoryAllocation) -{ - allocator = new TestMemoryAllocator(); - allocator->free_memory(allocator->alloc_memory(100, "file", 1), 100, "file", 1); -} - -TEST(TestMemoryAllocatorTest, MallocNames) -{ - STRCMP_EQUAL("Standard Malloc Allocator", defaultMallocAllocator()->name()); - STRCMP_EQUAL("malloc", defaultMallocAllocator()->alloc_name()); - STRCMP_EQUAL("free", defaultMallocAllocator()->free_name()); -} - -TEST(TestMemoryAllocatorTest, NewNames) -{ - STRCMP_EQUAL("Standard New Allocator", defaultNewAllocator()->name()); - STRCMP_EQUAL("new", defaultNewAllocator()->alloc_name()); - STRCMP_EQUAL("delete", defaultNewAllocator()->free_name()); -} - -TEST(TestMemoryAllocatorTest, NewArrayNames) -{ - STRCMP_EQUAL("Standard New [] Allocator", defaultNewArrayAllocator()->name()); - STRCMP_EQUAL("new []", defaultNewArrayAllocator()->alloc_name()); - STRCMP_EQUAL("delete []", defaultNewArrayAllocator()->free_name()); -} - -TEST(TestMemoryAllocatorTest, NullUnknownAllocation) -{ - allocator = new NullUnknownAllocator; - allocator->free_memory(allocator->alloc_memory(100, "file", 1), 100, "file", 1); -} - -TEST(TestMemoryAllocatorTest, NullUnknownNames) -{ - allocator = new NullUnknownAllocator; - STRCMP_EQUAL("Null Allocator", allocator->name()); - STRCMP_EQUAL("unknown", allocator->alloc_name()); - STRCMP_EQUAL("unknown", allocator->free_name()); -} - -#if (! CPPUTEST_SANITIZE_ADDRESS) - -#define MAX_SIZE_FOR_ALLOC ((size_t) -1 > (unsigned short)-1) ? (size_t)(-97) : (size_t)(-1) - -static void failTryingToAllocateTooMuchMemory(void) -{ - TestMemoryAllocator allocator; - allocator.alloc_memory(MAX_SIZE_FOR_ALLOC, "file", 1); -} // LCOV_EXCL_LINE - -TEST(TestMemoryAllocatorTest, TryingToAllocateTooMuchFailsTest) -{ - TestTestingFixture fixture; - fixture.setTestFunction(&failTryingToAllocateTooMuchMemory); - fixture.runAllTests(); - fixture.assertPrintContains("malloc returned null pointer"); -} - -#endif - -TEST_GROUP(MemoryLeakAllocator) -{ - MemoryLeakAllocator* allocator; - - void setup() CPPUTEST_OVERRIDE - { - allocator = new MemoryLeakAllocator(defaultMallocAllocator()); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete allocator; - } -}; - -TEST(MemoryLeakAllocator, allocMemory) -{ - char* memory = allocator->alloc_memory(10, __FILE__, __LINE__); - memory[0] = 'B'; - MemoryLeakWarningPlugin::getGlobalDetector()->deallocMemory(allocator->actualAllocator(), memory); - - /* No leaks or crashes */ -} - -TEST(MemoryLeakAllocator, freeMemory) -{ - char* memory = MemoryLeakWarningPlugin::getGlobalDetector()->allocMemory(allocator->actualAllocator(), 10); - allocator->free_memory(memory, 10, __FILE__, __LINE__); - - /* No leaks or crashes */ -} - -TEST(MemoryLeakAllocator, originalAllocator) -{ - POINTERS_EQUAL(defaultMallocAllocator(), allocator->actualAllocator()); - STRCMP_EQUAL(defaultMallocAllocator()->alloc_name(), allocator->alloc_name()); - STRCMP_EQUAL(defaultMallocAllocator()->free_name(), allocator->free_name()); -} - -TEST(MemoryLeakAllocator, name) -{ - STRCMP_EQUAL("MemoryLeakAllocator", allocator->name()); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION -#if CPPUTEST_USE_MALLOC_MACROS - -class FailableMemoryAllocatorExecFunction : public ExecFunction -{ -public: - FailableMemoryAllocator* allocator_; - void (*testFunction_)(FailableMemoryAllocator*); - - void exec() CPPUTEST_OVERRIDE - { - testFunction_(allocator_); - } - - FailableMemoryAllocatorExecFunction() : allocator_(NULLPTR), testFunction_(NULLPTR) {} - virtual ~FailableMemoryAllocatorExecFunction() CPPUTEST_DESTRUCTOR_OVERRIDE {} -}; - -TEST_GROUP(FailableMemoryAllocator) -{ - FailableMemoryAllocator *failableMallocAllocator; - FailableMemoryAllocatorExecFunction testFunction; - TestTestingFixture fixture; - GlobalMemoryAllocatorStash stash; - - void setup() CPPUTEST_OVERRIDE - { - stash.save(); - testFunction.allocator_ = failableMallocAllocator = new FailableMemoryAllocator("Failable Malloc Allocator", "malloc", "free"); - fixture.setTestFunction(&testFunction); - setCurrentMallocAllocator(failableMallocAllocator); - } - void teardown() CPPUTEST_OVERRIDE - { - failableMallocAllocator->checkAllFailedAllocsWereDone(); - failableMallocAllocator->clearFailedAllocs(); - delete failableMallocAllocator; - stash.restore(); - } -}; - -TEST(FailableMemoryAllocator, MallocWorksNormallyIfNotAskedToFail) -{ - int *memory = (int*)malloc(sizeof(int)); - CHECK(memory != NULLPTR); - free(memory); -} - -TEST(FailableMemoryAllocator, FailFirstMalloc) -{ - failableMallocAllocator->failAllocNumber(1); - POINTERS_EQUAL(NULLPTR, (int*)malloc(sizeof(int))); -} - -TEST(FailableMemoryAllocator, FailSecondAndFourthMalloc) -{ - failableMallocAllocator->failAllocNumber(2); - failableMallocAllocator->failAllocNumber(4); - int *memory1 = (int*)malloc(sizeof(int)); - int *memory2 = (int*)malloc(sizeof(int)); - int *memory3 = (int*)malloc(sizeof(int)); - int *memory4 = (int*)malloc(sizeof(int)); - - CHECK(NULLPTR != memory1); - POINTERS_EQUAL(NULLPTR, memory2); - CHECK(NULLPTR != memory3); - POINTERS_EQUAL(NULLPTR, memory4); - - free(memory1); - free(memory3); -} - -static void failingAllocIsNeverDone_(FailableMemoryAllocator* failableMallocAllocator) -{ - failableMallocAllocator->failAllocNumber(1); - failableMallocAllocator->failAllocNumber(2); - failableMallocAllocator->failAllocNumber(3); - malloc(sizeof(int)); - malloc(sizeof(int)); - failableMallocAllocator->checkAllFailedAllocsWereDone(); -} - -TEST(FailableMemoryAllocator, CheckAllFailingAllocsWereDone) -{ - testFunction.testFunction_ = failingAllocIsNeverDone_; - - fixture.runAllTests(); - - LONGS_EQUAL(1, fixture.getFailureCount()); - fixture.assertPrintContains("Expected allocation number 3 was never done"); - failableMallocAllocator->clearFailedAllocs(); -} - -TEST(FailableMemoryAllocator, FailFirstAllocationAtGivenLine) -{ - failableMallocAllocator->failNthAllocAt(1, __FILE__, __LINE__ + 2); - - POINTERS_EQUAL(NULLPTR, malloc(sizeof(int))); -} - -TEST(FailableMemoryAllocator, FailThirdAllocationAtGivenLine) -{ - int *memory[10] = { NULLPTR }; - int allocation; - failableMallocAllocator->failNthAllocAt(3, __FILE__, __LINE__ + 4); - - for (allocation = 1; allocation <= 10; allocation++) - { - memory[allocation - 1] = (int *)malloc(sizeof(int)); - if (memory[allocation - 1] == NULLPTR) - break; - free(memory[allocation -1]); - } - - LONGS_EQUAL(3, allocation); -} - -static void failingLocationAllocIsNeverDone_(FailableMemoryAllocator* failableMallocAllocator) -{ - failableMallocAllocator->failNthAllocAt(1, "TestMemoryAllocatorTest.cpp", __LINE__); - failableMallocAllocator->checkAllFailedAllocsWereDone(); -} - -TEST(FailableMemoryAllocator, CheckAllFailingLocationAllocsWereDone) -{ - testFunction.testFunction_ = failingLocationAllocIsNeverDone_; - - fixture.runAllTests(); - - LONGS_EQUAL(1, fixture.getFailureCount()); - fixture.assertPrintContains("Expected failing alloc at TestMemoryAllocatorTest.cpp:"); - fixture.assertPrintContains("was never done"); - - failableMallocAllocator->clearFailedAllocs(); -} - -#endif -#endif - -class MemoryAccountantExecFunction - : public ExecFunction -{ -public: - virtual ~MemoryAccountantExecFunction() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - void (*testFunction_)(MemoryAccountant*); - MemoryAccountant* parameter_; - - virtual void exec() CPPUTEST_OVERRIDE - { - testFunction_(parameter_); - } -}; - -TEST_GROUP(TestMemoryAccountant) -{ - MemoryAccountant accountant; - TestTestingFixture fixture; - MemoryAccountantExecFunction testFunction; - - void setup() CPPUTEST_OVERRIDE - { - testFunction.parameter_ = &accountant; - fixture.setTestFunction(&testFunction); - } - - void teardown() CPPUTEST_OVERRIDE - { - accountant.clear(); - } -}; - -TEST(TestMemoryAccountant, totalAllocsIsZero) -{ - LONGS_EQUAL(0, accountant.totalAllocations()); - LONGS_EQUAL(0, accountant.totalDeallocations()); -} - -TEST(TestMemoryAccountant, countAllocationsPerSize) -{ - accountant.alloc(4); - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(4)); - LONGS_EQUAL(0, accountant.totalAllocationsOfSize(10)); - LONGS_EQUAL(1, accountant.totalAllocations()); - LONGS_EQUAL(0, accountant.maximumAllocationAtATimeOfSize(10)); -} - -TEST(TestMemoryAccountant, countAllocationsPerSizeMultipleAllocations) -{ - accountant.alloc(4); - accountant.alloc(4); - accountant.alloc(8); - LONGS_EQUAL(2, accountant.totalAllocationsOfSize(4)); - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(8)); - LONGS_EQUAL(0, accountant.totalAllocationsOfSize(10)); - LONGS_EQUAL(3, accountant.totalAllocations()); -} - -TEST(TestMemoryAccountant, countAllocationsPerSizeMultipleAllocationsOutOfOrder) -{ - accountant.alloc(4); - accountant.alloc(8); - accountant.alloc(4); - accountant.alloc(5); - accountant.alloc(2); - accountant.alloc(4); - accountant.alloc(10); - - LONGS_EQUAL(3, accountant.totalAllocationsOfSize(4)); - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(8)); - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(10)); - LONGS_EQUAL(7, accountant.totalAllocations()); -} - -TEST(TestMemoryAccountant, countDeallocationsPerSizeMultipleAllocations) -{ - accountant.dealloc(8); - accountant.dealloc(4); - accountant.dealloc(8); - LONGS_EQUAL(1, accountant.totalDeallocationsOfSize(4)); - LONGS_EQUAL(2, accountant.totalDeallocationsOfSize(8)); - LONGS_EQUAL(0, accountant.totalDeallocationsOfSize(20)); - LONGS_EQUAL(3, accountant.totalDeallocations()); -} - -TEST(TestMemoryAccountant, countMaximumAllocationsAtATime) -{ - accountant.alloc(4); - accountant.alloc(4); - accountant.dealloc(4); - accountant.dealloc(4); - accountant.alloc(4); - LONGS_EQUAL(2, accountant.maximumAllocationAtATimeOfSize(4)); -} - -TEST(TestMemoryAccountant, reportNoAllocations) -{ - STRCMP_EQUAL("CppUTest Memory Accountant has not noticed any allocations or deallocations. Sorry\n", accountant.report().asCharString()); -} - -TEST(TestMemoryAccountant, reportAllocations) -{ - accountant.dealloc(8); - accountant.dealloc(8); - accountant.dealloc(8); - - accountant.alloc(4); - accountant.dealloc(4); - accountant.alloc(4); - STRCMP_EQUAL("CppUTest Memory Accountant report:\n" - "Allocation size # allocations # deallocations max # allocations at one time\n" - " 4 2 1 1\n" - " 8 0 3 0\n" - " Thank you for your business\n" - , accountant.report().asCharString()); -} - -TEST(TestMemoryAccountant, reportAllocationsWithSizeZero) -{ - accountant.dealloc(0); - - accountant.dealloc(4); - accountant.dealloc(4); - accountant.alloc(4); - - STRCMP_EQUAL("CppUTest Memory Accountant report:\n" - "Allocation size # allocations # deallocations max # allocations at one time\n" - "other 0 1 0\n" - " 4 1 2 1\n" - " Thank you for your business\n" - , accountant.report().asCharString()); -} - - -static void failUseCacheSizesAfterAllocation_(MemoryAccountant* accountant) -{ - size_t cacheSizes[] = {0}; - - accountant->alloc(4); - accountant->useCacheSizes(cacheSizes, 1); -} - -TEST(TestMemoryAccountant, withCacheSizesFailsWhenAlreadyAllocatedMemory) -{ - testFunction.testFunction_ = failUseCacheSizesAfterAllocation_; - - fixture.runAllTests(); - - fixture.assertPrintContains("MemoryAccountant: Cannot set cache sizes as allocations already occured!"); -} - -TEST(TestMemoryAccountant, reportWithCacheSizesEmpty) -{ - size_t cacheSizes[] = {0}; - - accountant.useCacheSizes(cacheSizes, 0); - accountant.alloc(4); - - STRCMP_EQUAL("CppUTest Memory Accountant report (with cache sizes):\n" - "Cache size # allocations # deallocations max # allocations at one time\n" - "other 1 0 1\n" - " Thank you for your business\n" - , accountant.report().asCharString()); -} - - -TEST(TestMemoryAccountant, reportWithCacheSizes) -{ - size_t cacheSizes[] = {4}; - - accountant.useCacheSizes(cacheSizes, 1); - accountant.dealloc(8); - accountant.dealloc(12); - accountant.dealloc(20); - - accountant.alloc(4); - accountant.dealloc(4); - accountant.alloc(4); - STRCMP_EQUAL("CppUTest Memory Accountant report (with cache sizes):\n" - "Cache size # allocations # deallocations max # allocations at one time\n" - " 4 2 1 1\n" - "other 0 3 0\n" - " Thank you for your business\n" - , accountant.report().asCharString()); -} - -TEST(TestMemoryAccountant, reportWithCacheSizesMultipleCaches) -{ - size_t cacheSizes[] = {4, 10, 20}; - - accountant.useCacheSizes(cacheSizes, 3); - accountant.alloc(8); - accountant.alloc(12); - accountant.alloc(20); - - accountant.alloc(4); - accountant.dealloc(4); - accountant.alloc(4); - STRCMP_EQUAL("CppUTest Memory Accountant report (with cache sizes):\n" - "Cache size # allocations # deallocations max # allocations at one time\n" - " 4 2 1 1\n" - " 10 1 0 1\n" - " 20 2 0 2\n" - "other 0 0 0\n" - " Thank you for your business\n" - , accountant.report().asCharString()); -} - - -TEST_GROUP(AccountingTestMemoryAllocator) -{ - MemoryAccountant accountant; - AccountingTestMemoryAllocator *allocator; - - void setup() CPPUTEST_OVERRIDE - { - allocator = new AccountingTestMemoryAllocator(accountant, getCurrentMallocAllocator()); - } - - void teardown() CPPUTEST_OVERRIDE - { - accountant.clear(); - delete allocator; - } -}; - -TEST(AccountingTestMemoryAllocator, canAllocateAndAccountMemory) -{ - char* memory = allocator->alloc_memory(10, __FILE__, __LINE__); - allocator->free_memory(memory, 10, __FILE__, __LINE__); - - LONGS_EQUAL(1, accountant.totalAllocationsOfSize(10)); - LONGS_EQUAL(1, accountant.totalDeallocationsOfSize(10)); -} - -TEST(AccountingTestMemoryAllocator, canAllocateAndAccountMemoryMultipleAllocations) -{ - char* memory1 = allocator->alloc_memory(10, __FILE__, __LINE__); - char* memory2 = allocator->alloc_memory(8, __FILE__, __LINE__); - char* memory3 = allocator->alloc_memory(12, __FILE__, __LINE__); - - allocator->free_memory(memory1, 10, __FILE__, __LINE__); - allocator->free_memory(memory3, 12, __FILE__, __LINE__); - - char* memory4 = allocator->alloc_memory(15, __FILE__, __LINE__); - char* memory5 = allocator->alloc_memory(20, __FILE__, __LINE__); - - allocator->free_memory(memory2, 8, __FILE__, __LINE__); - allocator->free_memory(memory4, 15, __FILE__, __LINE__); - allocator->free_memory(memory5, 20, __FILE__, __LINE__); - - char* memory6 = allocator->alloc_memory(1, __FILE__, __LINE__); - char* memory7 = allocator->alloc_memory(100, __FILE__, __LINE__); - - allocator->free_memory(memory6, 1, __FILE__, __LINE__); - allocator->free_memory(memory7, 100, __FILE__, __LINE__); - - LONGS_EQUAL(7, accountant.totalAllocations()); - LONGS_EQUAL(7, accountant.totalDeallocations()); -} - -TEST(AccountingTestMemoryAllocator, useOriginalAllocatorWhenDeallocatingMemoryNotAllocatedByAllocator) -{ - char* memory = getCurrentMallocAllocator()->alloc_memory(10, __FILE__, __LINE__); - allocator->free_memory(memory, 10, __FILE__, __LINE__); - - LONGS_EQUAL(0, accountant.totalAllocations()); - LONGS_EQUAL(1, accountant.totalDeallocations()); -} - -TEST(AccountingTestMemoryAllocator, allocatorForwardsAllocAndFreeName) -{ - STRCMP_EQUAL("malloc", allocator->alloc_name()); - STRCMP_EQUAL("free", allocator->free_name()); -} - - -class GlobalMemoryAccountantExecFunction - : public ExecFunction -{ -public: - void (*testFunction_)(GlobalMemoryAccountant*); - GlobalMemoryAccountant* parameter_; - - virtual void exec() CPPUTEST_OVERRIDE - { - testFunction_(parameter_); - } -}; - -TEST_GROUP(GlobalMemoryAccountant) -{ - GlobalMemoryAccountant accountant; - TestTestingFixture fixture; - GlobalMemoryAccountantExecFunction testFunction; - GlobalMemoryAllocatorStash stash; - - void setup() CPPUTEST_OVERRIDE - { - testFunction.parameter_ = &accountant; - fixture.setTestFunction(&testFunction); - stash.save(); - } - - void teardown() CPPUTEST_OVERRIDE - { - stash.restore(); - } -}; - -TEST(GlobalMemoryAccountant, start) -{ - accountant.start(); - - POINTERS_EQUAL(accountant.getMallocAllocator(), getCurrentMallocAllocator()); - POINTERS_EQUAL(accountant.getNewAllocator(), getCurrentNewAllocator()); - POINTERS_EQUAL(accountant.getNewArrayAllocator(), getCurrentNewArrayAllocator()); - - accountant.stop(); -} - -TEST(GlobalMemoryAccountant, stop) -{ - TestMemoryAllocator* originalMallocAllocator = getCurrentMallocAllocator(); - TestMemoryAllocator* originalNewAllocator = getCurrentNewAllocator(); - TestMemoryAllocator* originalNewArrayAllocator = getCurrentNewArrayAllocator(); - - accountant.start(); - accountant.stop(); - - POINTERS_EQUAL(originalMallocAllocator, getCurrentMallocAllocator()); - POINTERS_EQUAL(originalNewAllocator, getCurrentNewAllocator()); - POINTERS_EQUAL(originalNewArrayAllocator, getCurrentNewArrayAllocator()); -} - -#if CPPUTEST_USE_MEM_LEAK_DETECTION - -TEST(GlobalMemoryAccountant, report) -{ - accountant.start(); - char* memory = new char[185]; - delete [] memory; - accountant.stop(); - - /* Allocation includes memory leak info */ - STRCMP_CONTAINS("1 1 1", accountant.report().asCharString()); -} - -TEST(GlobalMemoryAccountant, reportWithCacheSizes) -{ - size_t cacheSizes[] = {512}; - accountant.useCacheSizes(cacheSizes, 1); - accountant.start(); - char* memory = new char[185]; - delete [] memory; - accountant.stop(); - - /* Allocation includes memory leak info */ - STRCMP_CONTAINS("512 1 1 1", accountant.report().asCharString()); -} - - -#endif - -static void failStopWithoutStartingWillFail_(GlobalMemoryAccountant* accountant) -{ - accountant->stop(); -} - -TEST(GlobalMemoryAccountant, StopCantBeCalledWithoutStarting) -{ - testFunction.testFunction_ = failStopWithoutStartingWillFail_; - fixture.runAllTests(); - fixture.assertPrintContains("GlobalMemoryAccount: Stop called without starting"); -} - -static void failStartingTwiceWillFail_(GlobalMemoryAccountant* accountant) -{ - accountant->start(); - accountant->start(); -} - -TEST(GlobalMemoryAccountant, startTwiceWillFail) -{ - testFunction.testFunction_ = failStartingTwiceWillFail_; - fixture.runAllTests(); - accountant.stop(); - - fixture.assertPrintContains("Global allocator start called twice!"); -} - -static void failChangeMallocMemoryAllocator_(GlobalMemoryAccountant* accountant) -{ - accountant->start(); - setCurrentMallocAllocator(defaultMallocAllocator()); - accountant->stop(); -} - -TEST(GlobalMemoryAccountant, checkWhetherMallocAllocatorIsNotChanged) -{ - testFunction.testFunction_ = failChangeMallocMemoryAllocator_; - fixture.runAllTests(); - fixture.assertPrintContains("GlobalMemoryAccountant: Malloc memory allocator has been changed while accounting for memory"); -} - -static void failChangeNewMemoryAllocator_(GlobalMemoryAccountant* accountant) -{ - accountant->start(); - setCurrentNewAllocator(defaultNewAllocator()); - accountant->stop(); -} - -TEST(GlobalMemoryAccountant, checkWhetherNewAllocatorIsNotChanged) -{ - testFunction.testFunction_ = failChangeNewMemoryAllocator_; - fixture.runAllTests(); - fixture.assertPrintContains("GlobalMemoryAccountant: New memory allocator has been changed while accounting for memory"); -} - -static void failChangeNewArrayMemoryAllocator_(GlobalMemoryAccountant* accountant) -{ - accountant->start(); - setCurrentNewArrayAllocator(defaultNewArrayAllocator()); - accountant->stop(); -} - -TEST(GlobalMemoryAccountant, checkWhetherNewArrayAllocatorIsNotChanged) -{ - 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 deleted file mode 100644 index bde55df4f..000000000 --- a/tests/CppUTest/TestOutputTest.cpp +++ /dev/null @@ -1,480 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestResult.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -static unsigned long millisTime; - -extern "C" { - - static unsigned long MockGetPlatformSpecificTimeInMillis() - { - return millisTime; - } - -} - -TEST_GROUP(TestOutput) -{ - TestOutput* printer; - StringBufferTestOutput* mock; - UtestShell* tst; - TestFailure *f; - TestFailure *f2; - TestFailure *f3; - TestResult* result; - - void setup() CPPUTEST_OVERRIDE - { - mock = new StringBufferTestOutput(); - printer = mock; - tst = new UtestShell("group", "test", "file", 10); - f = new TestFailure(tst, "failfile", 20, "message"); - f2 = new TestFailure(tst, "file", 20, "message"); - f3 = new TestFailure(tst, "file", 2, "message"); - result = new TestResult(*mock); - result->setTotalExecutionTime(10); - millisTime = 0; - UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis); - TestOutput::setWorkingEnvironment(TestOutput::eclipse); - - } - void teardown() CPPUTEST_OVERRIDE - { - TestOutput::setWorkingEnvironment(TestOutput::detectEnvironment); - delete printer; - delete tst; - delete f; - delete f2; - delete f3; - delete result; - } - - void runOneTest() - { - result->countTest(); - result->countRun(); - } -}; - -TEST(TestOutput, PrintConstCharStar) -{ - printer->print("hello"); - printer->print("hello\n"); - STRCMP_EQUAL("hellohello\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintLong) -{ - long number = 1234; - printer->print(number); - STRCMP_EQUAL("1234", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintSize) -{ - size_t ten = 10; - printer->print(ten); - STRCMP_EQUAL("10", mock->getOutput().asCharString()); -} - - -TEST(TestOutput, PrintDouble) -{ - printer->printDouble(12.34); - STRCMP_EQUAL("12.34", mock->getOutput().asCharString()); -} - -TEST(TestOutput, StreamOperators) -{ - *printer << "n=" << 1234; - STRCMP_EQUAL("n=1234", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestEnded) -{ - printer->printCurrentTestEnded(*result); - STRCMP_EQUAL(".", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestALot) -{ - for (int i = 0; i < 60; ++i) { - printer->printCurrentTestEnded(*result); - } - STRCMP_EQUAL("..................................................\n..........", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestALotAndSimulateRepeatRun) -{ - for (int i = 0; i < 60; ++i) { - runOneTest(); - printer->printCurrentTestEnded(*result); - } - - printer->printTestsEnded(*result); - - for (int i = 0; i < 60; ++i) { - runOneTest(); - printer->printCurrentTestEnded(*result); - } - STRCMP_EQUAL("..................................................\n.........." \ - "\nOK (60 tests, 60 ran, 0 checks, 0 ignored, 0 filtered out, 10 ms)\n\n" \ - "..................................................\n..........", mock->getOutput().asCharString()); -} - -TEST(TestOutput, SetProgressIndicator) -{ - printer->setProgressIndicator("."); - printer->printCurrentTestEnded(*result); - printer->setProgressIndicator("!"); - printer->printCurrentTestEnded(*result); - printer->setProgressIndicator("."); - printer->printCurrentTestEnded(*result); - - STRCMP_EQUAL(".!.", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestVerboseStarted) -{ - mock->verbose(TestOutput::level_verbose); - printer->printCurrentTestStarted(*tst); - STRCMP_EQUAL("TEST(group, test)", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestVerboseEnded) -{ - mock->verbose(TestOutput::level_verbose); - result->currentTestStarted(tst); - millisTime = 5; - result->currentTestEnded(tst); - STRCMP_EQUAL("TEST(group, test) - 5 ms\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, printColorWithSuccess) -{ - mock->color(); - runOneTest(); - printer->printTestsEnded(*result); - STRCMP_EQUAL("\n\033[32;1mOK (1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out, 10 ms)\033[m\n\n", - mock->getOutput().asCharString()); -} - -TEST(TestOutput, printColorWithFailures) -{ - mock->color(); - runOneTest(); - result->addFailure(*f); - printer->flush(); - printer->printTestsEnded(*result); - STRCMP_EQUAL("\n\033[31;1mErrors (1 failures, 1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out, 10 ms)" - "\033[m\n\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestRun) -{ - printer->printTestRun(2, 3); - STRCMP_EQUAL("Test run 2 of 3\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestRunOnlyOne) -{ - printer->printTestRun(1, 1); - STRCMP_EQUAL("", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintWithFailureInSameFile) -{ - printer->printFailure(*f2); - STRCMP_EQUAL("\nfile:20: error: Failure in TEST(group, test)\n\tmessage\n\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintFailureWithFailInDifferentFile) -{ - printer->printFailure(*f); - const char* expected = - "\nfile:10: error: Failure in TEST(group, test)" - "\nfailfile:20: error:\n\tmessage\n\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintFailureWithFailInHelper) -{ - printer->printFailure(*f3); - const char* expected = - "\nfile:10: error: Failure in TEST(group, test)" - "\nfile:2: error:\n\tmessage\n\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintInVisualStudioFormat) -{ - TestOutput::setWorkingEnvironment(TestOutput::visualStudio); - printer->printFailure(*f3); - const char* expected = - "\nfile(10): error: Failure in TEST(group, test)" - "\nfile(2): error:\n\tmessage\n\n"; - STRCMP_EQUAL(expected, mock->getOutput().asCharString()); -} - -TEST(TestOutput, PrintTestStarts) -{ - printer->printTestsStarted(); - STRCMP_EQUAL("", mock->getOutput().asCharString()); -} - -TEST(TestOutput, printTestsEnded) -{ - result->countTest(); - result->countCheck(); - result->countIgnored(); - result->countIgnored(); - result->countRun(); - result->countRun(); - result->countRun(); - printer->printTestsEnded(*result); - STRCMP_EQUAL("\nOK (1 tests, 3 ran, 1 checks, 2 ignored, 0 filtered out, 10 ms)\n\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, printTestsEndedWithFailures) -{ - result->addFailure(*f); - printer->flush(); - printer->printTestsEnded(*result); - STRCMP_EQUAL("\nErrors (1 failures, 0 tests, 0 ran, 0 checks, 0 ignored, 0 filtered out, 10 ms)\n\n", mock->getOutput().asCharString()); -} - -TEST(TestOutput, printTestsEndedWithNoTestsRunOrIgnored) -{ - result->countTest(); - printer->flush(); - printer->printTestsEnded(*result); - STRCMP_EQUAL("\nErrors (ran nothing, 1 tests, 0 ran, 0 checks, 0 ignored, 0 filtered out, 10 ms)\n" - "Note: test run failed because no tests were run or ignored. Assuming something went wrong. " - "This often happens because of linking errors or typos in test filter.\n\n", - mock->getOutput().asCharString()); -} - -class CompositeTestOutputTestStringBufferTestOutput : public StringBufferTestOutput -{ - public: - virtual void printTestsStarted() CPPUTEST_OVERRIDE - { - output += "Test Start\n"; - } - - virtual void printTestsEnded(const TestResult& result) CPPUTEST_OVERRIDE - { - output += StringFromFormat("Test End %d\n", (int) result.getTestCount()); - } - - void printCurrentGroupStarted(const UtestShell& test) CPPUTEST_OVERRIDE - { - output += StringFromFormat("Group %s Start\n", test.getGroup().asCharString()); - } - - void printCurrentGroupEnded(const TestResult& res) CPPUTEST_OVERRIDE - { - output += StringFromFormat("Group End %d\n", (int) res.getTestCount()); - } - - virtual void printCurrentTestStarted(const UtestShell&) CPPUTEST_OVERRIDE - { - output += "s"; - } - - void flush() CPPUTEST_OVERRIDE - { - output += "flush"; - } - - virtual bool isVerbose() - { - return verbose_ == level_verbose || verbose_ == level_veryVerbose; - } - - virtual bool isColor() - { - return color_; - } - - virtual const char* getProgressIndicator() - { - return progressIndication_; - } -}; - -TEST_GROUP(CompositeTestOutput) -{ - CompositeTestOutputTestStringBufferTestOutput* output1; - CompositeTestOutputTestStringBufferTestOutput* output2; - CompositeTestOutput compositeOutput; - TestResult* result; - UtestShell* test; - - void setup() CPPUTEST_OVERRIDE - { - output1 = new CompositeTestOutputTestStringBufferTestOutput; - output2 = new CompositeTestOutputTestStringBufferTestOutput; - compositeOutput.setOutputOne(output1); - compositeOutput.setOutputTwo(output2); - result = new TestResult(compositeOutput); - test = new UtestShell("Group", "Name", "file", 10); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete test; - delete result; - } -}; - -TEST(CompositeTestOutput, TestStartedAndEnded) -{ - compositeOutput.printTestsStarted(); - compositeOutput.printTestsEnded(*result); - STRCMP_EQUAL("Test Start\nTest End 0\n", output1->getOutput().asCharString()); - STRCMP_EQUAL("Test Start\nTest End 0\n", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, CurrentTestStartedAndEnded) -{ - compositeOutput.printCurrentTestStarted(*test); - compositeOutput.printCurrentTestEnded(*result); - STRCMP_EQUAL("s.", output1->getOutput().asCharString()); - STRCMP_EQUAL("s.", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, CurrentGroupStartedAndEnded) -{ - compositeOutput.printCurrentGroupStarted(*test); - compositeOutput.printCurrentGroupEnded(*result); - STRCMP_EQUAL("Group Group Start\nGroup End 0\n", output1->getOutput().asCharString()); - STRCMP_EQUAL("Group Group Start\nGroup End 0\n", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, PrintBuffer) -{ - compositeOutput.printBuffer("Boo"); - STRCMP_EQUAL("Boo", output1->getOutput().asCharString()); - STRCMP_EQUAL("Boo", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, printChar) -{ - compositeOutput.print("Boo"); - STRCMP_EQUAL("Boo", output1->getOutput().asCharString()); - STRCMP_EQUAL("Boo", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, printLong) -{ - long ten = 10; - compositeOutput.print(ten); - STRCMP_EQUAL("10", output1->getOutput().asCharString()); - STRCMP_EQUAL("10", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, PrintSize) -{ - size_t ten = 10; - compositeOutput.print(ten); - STRCMP_EQUAL("10", output1->getOutput().asCharString()); - STRCMP_EQUAL("10", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, printDouble) -{ - compositeOutput.printDouble(1.01); - STRCMP_EQUAL("1.01", output1->getOutput().asCharString()); - STRCMP_EQUAL("1.01", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, verbose) -{ - compositeOutput.verbose(TestOutput::level_verbose); - CHECK(output1->isVerbose()); - CHECK(output2->isVerbose()); -} - -TEST(CompositeTestOutput, color) -{ - compositeOutput.color(); - CHECK(output1->isColor()); - CHECK(output2->isColor()); -} - -TEST(CompositeTestOutput, PrintTestFailure) -{ - TestOutput::WorkingEnvironment previousEnvironment = TestOutput::getWorkingEnvironment(); - TestOutput::setWorkingEnvironment(TestOutput::eclipse); - TestFailure failure(test, "file", 10, "failed"); - compositeOutput.printFailure(failure); - STRCMP_EQUAL("\nfile:10: error: Failure in TEST(Group, Name)\n\tfailed\n\n", output1->getOutput().asCharString()); - STRCMP_EQUAL("\nfile:10: error: Failure in TEST(Group, Name)\n\tfailed\n\n", output2->getOutput().asCharString()); - TestOutput::setWorkingEnvironment(previousEnvironment); -} - -TEST(CompositeTestOutput, PrintTestRun) -{ - compositeOutput.printTestRun(1, 2); - STRCMP_EQUAL("Test run 1 of 2\n", output1->getOutput().asCharString()); - STRCMP_EQUAL("Test run 1 of 2\n", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, setProgressIndicator) -{ - compositeOutput.setProgressIndicator("?"); - STRCMP_EQUAL("?", output1->getProgressIndicator()); - STRCMP_EQUAL("?", output2->getProgressIndicator()); -} - -TEST(CompositeTestOutput, flush) -{ - compositeOutput.flush(); - STRCMP_EQUAL("flush", output1->getOutput().asCharString()); - STRCMP_EQUAL("flush", output2->getOutput().asCharString()); -} - -TEST(CompositeTestOutput, deletePreviousInstanceWhenSettingNew) -{ - compositeOutput.setOutputOne(new CompositeTestOutput); - compositeOutput.setOutputTwo(new CompositeTestOutput); - - // 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 deleted file mode 100644 index 45d3eb309..000000000 --- a/tests/CppUTest/TestRegistryTest.cpp +++ /dev/null @@ -1,450 +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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -namespace -{ -const int testLineNumber = 1; -} - -class MockTest: public UtestShell -{ -public: - MockTest(const char* group = "Group") : - UtestShell(group, "Name", "File", testLineNumber), hasRun_(false) - { - } - virtual void runOneTest(TestPlugin*, TestResult&) CPPUTEST_OVERRIDE - { - hasRun_ = true; - } - - bool hasRun_; -}; - -class MockTestResult: public TestResult -{ -public: - - int countTestsStarted; - int countTestsEnded; - int countCurrentTestStarted; - int countCurrentTestEnded; - int countCurrentGroupStarted; - int countCurrentGroupEnded; - - MockTestResult(TestOutput& p) : - TestResult(p) - { - resetCount(); - } - - virtual ~MockTestResult() CPPUTEST_DESTRUCTOR_OVERRIDE - { - } - - void resetCount() - { - countTestsStarted = 0; - countTestsEnded = 0; - countCurrentTestStarted = 0; - countCurrentTestEnded = 0; - countCurrentGroupStarted = 0; - countCurrentGroupEnded = 0; - } - - virtual void testsStarted() CPPUTEST_OVERRIDE - { - countTestsStarted++; - } - virtual void testsEnded() CPPUTEST_OVERRIDE - { - countTestsEnded++; - } - virtual void currentTestStarted(UtestShell* /*test*/) CPPUTEST_OVERRIDE - { - countCurrentTestStarted++; - } - virtual void currentTestEnded(UtestShell* /*test*/) CPPUTEST_OVERRIDE - { - countCurrentTestEnded++; - } - virtual void currentGroupStarted(UtestShell* /*test*/) CPPUTEST_OVERRIDE - { - countCurrentGroupStarted++; - } - virtual void currentGroupEnded(UtestShell* /*test*/) CPPUTEST_OVERRIDE - { - countCurrentGroupEnded++; - } - -}; - -TEST_GROUP(TestRegistry) -{ - TestRegistry* myRegistry; - StringBufferTestOutput* output; - MockTest* test1; - MockTest* test2; - MockTest* test3; - MockTest* test4; - TestResult *result; - MockTestResult *mockResult; - void setup() CPPUTEST_OVERRIDE - { - output = new StringBufferTestOutput(); - mockResult = new MockTestResult(*output); - result = mockResult; - test1 = new MockTest(); - test2 = new MockTest(); - test3 = new MockTest("group2"); - test4 = new MockTest(); - myRegistry = new TestRegistry(); - myRegistry->setCurrentRegistry(myRegistry); - } - - void teardown() CPPUTEST_OVERRIDE - { - myRegistry->setCurrentRegistry(NULLPTR); - delete myRegistry; - delete test1; - delete test2; - delete test3; - delete test4; - delete result; - delete output; - } - - void addAndRunAllTests() - { - myRegistry->addTest(test1); - myRegistry->addTest(test2); - myRegistry->addTest(test3); - myRegistry->runAllTests(*result); - } -}; - -TEST(TestRegistry, registryMyRegistryAndReset) -{ - CHECK(myRegistry->getCurrentRegistry() == myRegistry); -} - -TEST(TestRegistry, emptyRegistryIsEmpty) -{ - CHECK(myRegistry->countTests() == 0); -} - -TEST(TestRegistry, addOneTestIsNotEmpty) -{ - myRegistry->addTest(test1); - CHECK(myRegistry->countTests() == 1); -} - -TEST(TestRegistry, addOneTwoTests) -{ - myRegistry->addTest(test1); - myRegistry->addTest(test2); - CHECK(myRegistry->countTests() == 2); -} - -TEST(TestRegistry, runTwoTests) -{ - myRegistry->addTest(test1); - myRegistry->addTest(test2); - CHECK(!test1->hasRun_); - CHECK(!test2->hasRun_); - myRegistry->runAllTests(*result); - CHECK(test1->hasRun_); - CHECK(test2->hasRun_); -} - -TEST(TestRegistry, runTwoTestsCheckResultFunctionsCalled) -{ - myRegistry->addTest(test1); - myRegistry->addTest(test2); - myRegistry->runAllTests(*result); - LONGS_EQUAL(1, mockResult->countTestsStarted); - LONGS_EQUAL(1, mockResult->countTestsEnded); - LONGS_EQUAL(1, mockResult->countCurrentGroupStarted); - LONGS_EQUAL(1, mockResult->countCurrentGroupEnded); - LONGS_EQUAL(2, mockResult->countCurrentTestStarted); - LONGS_EQUAL(2, mockResult->countCurrentTestEnded); -} - -TEST(TestRegistry, runThreeTestsandTwoGroupsCheckResultFunctionsCalled) -{ - addAndRunAllTests(); - LONGS_EQUAL(2, mockResult->countCurrentGroupStarted); - LONGS_EQUAL(2, mockResult->countCurrentGroupEnded); - LONGS_EQUAL(3, mockResult->countCurrentTestStarted); - LONGS_EQUAL(3, mockResult->countCurrentTestEnded); -} - -TEST(TestRegistry, unDoTest) -{ - myRegistry->addTest(test1); - CHECK(myRegistry->countTests() == 1); - myRegistry->unDoLastAddTest(); - CHECK(myRegistry->countTests() == 0); -} - -TEST(TestRegistry, unDoButNoTest) -{ - CHECK(myRegistry->countTests() == 0); - myRegistry->unDoLastAddTest(); - CHECK(myRegistry->countTests() == 0); -} - -TEST(TestRegistry, reallyUndoLastTest) -{ - myRegistry->addTest(test1); - myRegistry->addTest(test2); - CHECK(myRegistry->countTests() == 2); - myRegistry->unDoLastAddTest(); - CHECK(myRegistry->countTests() == 1); - myRegistry->runAllTests(*result); - CHECK(test1->hasRun_); - CHECK(!test2->hasRun_); -} - -TEST(TestRegistry, findTestWithNameDoesntExist) -{ - CHECK(myRegistry->findTestWithName("ThisTestDoesntExists") == NULLPTR); -} - -TEST(TestRegistry, findTestWithName) -{ - test1->setTestName("NameOfATestThatDoesExist"); - test2->setTestName("SomeOtherTest"); - myRegistry->addTest(test1); - myRegistry->addTest(test2); - CHECK(myRegistry->findTestWithName("NameOfATestThatDoesExist") != NULLPTR); -} - -TEST(TestRegistry, findTestWithGroupDoesntExist) -{ - CHECK(myRegistry->findTestWithGroup("ThisTestGroupDoesntExists") == NULLPTR); -} - -TEST(TestRegistry, findTestWithGroup) -{ - test1->setGroupName("GroupOfATestThatDoesExist"); - test2->setGroupName("SomeOtherGroup"); - myRegistry->addTest(test1); - myRegistry->addTest(test2); - CHECK(myRegistry->findTestWithGroup("GroupOfATestThatDoesExist") != NULLPTR); -} - -TEST(TestRegistry, nameFilterWorks) -{ - test1->setTestName("testname"); - test2->setTestName("noname"); - TestFilter nameFilter("testname"); - myRegistry->setNameFilters(&nameFilter); - addAndRunAllTests(); - CHECK(test1->hasRun_); - CHECK(!test2->hasRun_); -} - -TEST(TestRegistry, groupFilterWorks) -{ - test1->setGroupName("groupname"); - test2->setGroupName("noname"); - TestFilter groupFilter("groupname"); - myRegistry->setGroupFilters(&groupFilter); - addAndRunAllTests(); - CHECK(test1->hasRun_); - CHECK(!test2->hasRun_); -} - -TEST(TestRegistry, runTestInSeperateProcess) -{ - myRegistry->setRunTestsInSeperateProcess(); - myRegistry->addTest(test1); - myRegistry->runAllTests(*result); - CHECK(test1->isRunInSeperateProcess()); -} - -TEST(TestRegistry, CurrentRepetitionIsCorrectNone) -{ - CHECK(0 == myRegistry->getCurrentRepetition()); - myRegistry->runAllTests(*result); - LONGS_EQUAL(1, myRegistry->getCurrentRepetition()); -} - -TEST(TestRegistry, CurrentRepetitionIsCorrectTwo) -{ - CHECK(0 == myRegistry->getCurrentRepetition()); - myRegistry->runAllTests(*result); - myRegistry->runAllTests(*result); - LONGS_EQUAL(2, myRegistry->getCurrentRepetition()); -} - -class MyTestPluginDummy: public TestPlugin -{ -public: - MyTestPluginDummy(const SimpleString& name) : TestPlugin(name) {} - virtual ~MyTestPluginDummy() CPPUTEST_DESTRUCTOR_OVERRIDE {} - virtual void runAllPreTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE {} - virtual void runAllPostTestAction(UtestShell&, TestResult&) CPPUTEST_OVERRIDE {} -}; - -TEST(TestRegistry, ResetPluginsWorks) -{ - MyTestPluginDummy plugin1("Plugin-1"); - MyTestPluginDummy plugin2("Plugin-2"); - myRegistry->installPlugin(&plugin1); - myRegistry->installPlugin(&plugin2); - LONGS_EQUAL(2, myRegistry->countPlugins()); - myRegistry->resetPlugins(); - LONGS_EQUAL(0, myRegistry->countPlugins()); -} - -TEST(TestRegistry, listTestGroupNames_shouldListBackwardsGroup1AfterGroup11AndGroup2OnlyOnce) -{ - test1->setGroupName("GROUP_1"); - myRegistry->addTest(test1); - test2->setGroupName("GROUP_2"); - myRegistry->addTest(test2); - test3->setGroupName("GROUP_11"); - myRegistry->addTest(test3); - test4->setGroupName("GROUP_2"); - myRegistry->addTest(test4); - - myRegistry->listTestGroupNames(*result); - SimpleString s = output->getOutput(); - STRCMP_EQUAL("GROUP_2 GROUP_11 GROUP_1", s.asCharString()); -} - -TEST(TestRegistry, listTestGroupAndCaseNames_shouldListBackwardsGroupATestaAfterGroupAtestaa) -{ - test1->setGroupName("GROUP_A"); - test1->setTestName("test_a"); - myRegistry->addTest(test1); - test2->setGroupName("GROUP_B"); - test2->setTestName("test_b"); - myRegistry->addTest(test2); - test3->setGroupName("GROUP_A"); - test3->setTestName("test_aa"); - myRegistry->addTest(test3); - - myRegistry->listTestGroupAndCaseNames(*result); - SimpleString s = output->getOutput(); - 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); - myRegistry->shuffleTests(0); - CHECK_TRUE(myRegistry->getFirstTest() == NULLPTR); -} - -TEST(TestRegistry, shuffleSingleTestIsNoOp) -{ - myRegistry->addTest(test1); - myRegistry->shuffleTests(0); - CHECK_TRUE(myRegistry->getFirstTest() == test1); -} - -static int getZero() -{ - return 0; -} - -IGNORE_TEST(TestRegistry, shuffleTestList) -{ - UT_PTR_SET(PlatformSpecificRand, getZero); - myRegistry->addTest(test3); - myRegistry->addTest(test2); - myRegistry->addTest(test1); - - UtestShell* first_before = myRegistry->getFirstTest(); - UtestShell* second_before = first_before->getNext(); - UtestShell* third_before = second_before->getNext(); - - CHECK_TRUE(first_before == test1); - CHECK_TRUE(second_before == test2); - CHECK_TRUE(third_before == test3); - CHECK_TRUE(third_before->getNext() == NULLPTR); - - // shuffle always with element at index 0: [1] 2 [3] --> [3] [2] 1 --> 2 3 1 - myRegistry->shuffleTests(0); - - UtestShell* first_after = myRegistry->getFirstTest(); - UtestShell* second_after = first_after->getNext(); - UtestShell* third_after = second_after->getNext(); - - CHECK_TRUE(first_after == test2); - CHECK_TRUE(second_after == test3); - CHECK_TRUE(third_after == test1); - CHECK_TRUE(third_after->getNext() == NULLPTR); -} - -TEST(TestRegistry, reverseTests) -{ - myRegistry->addTest(test1); - myRegistry->addTest(test2); - - myRegistry->reverseTests(); - - CHECK(test1 == myRegistry->getFirstTest()); -} - -TEST(TestRegistry, reverseZeroTests) -{ - myRegistry->reverseTests(); - - CHECK(NULLPTR == myRegistry->getFirstTest()); -} diff --git a/tests/CppUTest/TestResultTest.cpp b/tests/CppUTest/TestResultTest.cpp deleted file mode 100644 index a2bd497ba..000000000 --- a/tests/CppUTest/TestResultTest.cpp +++ /dev/null @@ -1,99 +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/TestHarness.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/TestOutput.h" - -extern "C" { - - static unsigned long MockGetPlatformSpecificTimeInMillis() - { - return 10; - } - -} - -TEST_GROUP(TestResult) -{ - TestOutput* printer; - StringBufferTestOutput* mock; - - TestResult* res; - - void setup() CPPUTEST_OVERRIDE - { - mock = new StringBufferTestOutput(); - printer = mock; - res = new TestResult(*printer); - UT_PTR_SET(GetPlatformSpecificTimeInMillis, MockGetPlatformSpecificTimeInMillis); - } - void teardown() CPPUTEST_OVERRIDE - { - delete printer; - delete res; - } -}; - -TEST(TestResult, TestEndedWillPrintResultsAndExecutionTime) -{ - res->testsEnded(); - CHECK(mock->getOutput().contains("10 ms")); -} - -TEST(TestResult, ResultIsOkIfTestIsRunWithNoFailures) -{ - res->countTest(); - res->countRun(); - CHECK_FALSE(res->isFailure()); -} - -TEST(TestResult, ResultIsOkIfTestIsIgnored) -{ - res->countTest(); - res->countIgnored(); - CHECK_FALSE(res->isFailure()); -} - -TEST(TestResult, ResultIsNotOkIfFailures) -{ - res->countTest(); - res->countRun(); - res->addFailure(TestFailure(UtestShell::getCurrent(), StringFrom("dummy message"))); - CHECK_TRUE(res->isFailure()); -} - -TEST(TestResult, ResultIsNotOkIfNoTestsAtAll) -{ - CHECK_TRUE(res->isFailure()); -} - -TEST(TestResult, ResultIsNotOkIfNoTestsRunOrIgnored) -{ - res->countTest(); - CHECK_TRUE(res->isFailure()); -} diff --git a/tests/CppUTest/TestUTestMacro.cpp b/tests/CppUTest/TestUTestMacro.cpp deleted file mode 100644 index ecc07a619..000000000 --- a/tests/CppUTest/TestUTestMacro.cpp +++ /dev/null @@ -1,1367 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" - -#define CHECK_TEST_FAILS_PROPER_WITH_TEXT(text) fixture.checkTestFailsWithProperTestLocation(text, __FILE__, __LINE__) - -// Mainly this is for Visual C++, but we'll define it for any system that has the same behavior -// of a 32-bit long on a 64-bit system -#if defined(CPPUTEST_64BIT) && defined(CPPUTEST_64BIT_32BIT_LONGS) -// Forcing the value to be unsigned long long means that there's no sign-extension to perform -#define to_void_pointer(x) ((void *)x##ULL) -#define to_func_pointer(x) ((void (*)())x##ULL) -#else -// Probably not needed, but let's guarantee that the value is an unsigned long -#define to_void_pointer(x) ((void *)x##UL) -#define to_func_pointer(x) ((void (*)())x##UL) -#endif - -TEST_GROUP(UnitTestMacros) -{ - TestTestingFixture fixture; -}; - -static void failingTestMethodWithFAIL_() -{ - FAIL("This test fails"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FAILMakesTheTestFailPrintsTheRightResultAndStopsExecuting) -{ - fixture.runTestWithMethod(failingTestMethodWithFAIL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("This test fails"); -} - -TEST(UnitTestMacros, FAILWillPrintTheFileThatItFailed) -{ - fixture.runTestWithMethod(failingTestMethodWithFAIL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT(__FILE__); -} - -TEST(UnitTestMacros, FAILBehavesAsAProperMacro) -{ - if (false) FAIL(""); - else CHECK(true); - - if (true) CHECK(true); - else FAIL(""); -} - -IGNORE_TEST(UnitTestMacros, FAILworksInAnIgnoredTest) -{ - FAIL("die!"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void UNSIGNED_LONGS_EQUALTestMethod_() -{ - UNSIGNED_LONGS_EQUAL(1, 1); - UNSIGNED_LONGS_EQUAL(1, 0); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestUNSIGNED_LONGS_EQUAL) -{ - fixture.runTestWithMethod(UNSIGNED_LONGS_EQUALTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>"); -} - -TEST(UnitTestMacros, UNSIGNED_LONGS_EQUALBehavesAsProperMacro) -{ - if (false) UNSIGNED_LONGS_EQUAL(1, 0); - else UNSIGNED_LONGS_EQUAL(1, 1); -} - -IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGS_EQUALWorksInAnIgnoredTest) -{ - UNSIGNED_LONGS_EQUAL(1, 0); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -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_); - 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"); -} - -TEST(UnitTestMacros, UNSIGNED_LONGS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) UNSIGNED_LONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); - else UNSIGNED_LONGS_EQUAL_TEXT(1, 1, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGS_EQUAL_TEXTWorksInAnIgnoredTest) -{ - UNSIGNED_LONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -#if CPPUTEST_USE_LONG_LONG - -static void LONGLONGS_EQUALTestMethod_() -{ - LONGLONGS_EQUAL(1, 1); - LONGLONGS_EQUAL(1, 0); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestLONGLONGS_EQUAL) -{ - fixture.runTestWithMethod(LONGLONGS_EQUALTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>"); -} - -TEST(UnitTestMacros, LONGLONGS_EQUALBehavesAsProperMacro) -{ - if (false) LONGLONGS_EQUAL(1, 0); - else LONGLONGS_EQUAL(1, 1); -} - -IGNORE_TEST(UnitTestMacros, LONGLONGS_EQUALWorksInAnIgnoredTest) -{ - LONGLONGS_EQUAL(1, 0); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -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_); - 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"); -} - -TEST(UnitTestMacros, LONGLONGS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); - else LONGLONGS_EQUAL_TEXT(1, 1, "Failed because it failed"); -} - -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_() -{ - UNSIGNED_LONGLONGS_EQUAL(1, 1); - UNSIGNED_LONGLONGS_EQUAL(1, 0); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestUNSIGNED_LONGLONGS_EQUAL) -{ - fixture.runTestWithMethod(UNSIGNED_LONGLONGS_EQUALTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1 (0x1)>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0 (0x0)>"); -} - -TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUALBehavesAsProperMacro) -{ - if (false) UNSIGNED_LONGLONGS_EQUAL(1, 0); - else UNSIGNED_LONGLONGS_EQUAL(1, 1); -} - -IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUALWorksInAnIgnoredTest) -{ - UNSIGNED_LONGLONGS_EQUAL(1, 0); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -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_); - 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"); -} - -TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) UNSIGNED_LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); - else UNSIGNED_LONGLONGS_EQUAL_TEXT(1, 1, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, UNSIGNED_LONGLONGS_EQUAL_TEXTWorksInAnIgnoredTest) -{ - UNSIGNED_LONGLONGS_EQUAL_TEXT(1, 0, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -#endif /* CPPUTEST_USE_LONG_LONG */ - -static void failingTestMethodWithCHECK_() -{ - CHECK(false); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK) -{ - fixture.runTestWithMethod(failingTestMethodWithCHECK_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK(false) failed"); -} - -TEST(UnitTestMacros, CHECKBehavesAsProperMacro) -{ - if (false) CHECK(false); - else CHECK(true); -} - -IGNORE_TEST(UnitTestMacros, CHECKWorksInAnIgnoredTest) -{ - CHECK(false); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_TEXT_() -{ - CHECK_TEXT(false, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_TEXT) -{ - fixture.runTestWithMethod(failingTestMethodWithCHECK_TEXT_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK(false) failed"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed"); -} - -TEST(UnitTestMacros, CHECK_TEXTBehavesAsProperMacro) -{ - if (false) CHECK_TEXT(false, "false"); - else CHECK_TEXT(true, "true"); -} - -IGNORE_TEST(UnitTestMacros, CHECK_TEXTWorksInAnIgnoredTest) -{ - CHECK_TEXT(false, "false"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_TRUE_() -{ - CHECK_TRUE(false); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_TRUE) -{ - fixture.runTestWithMethod(failingTestMethodWithCHECK_TRUE_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_TRUE(false) failed"); -} - -TEST(UnitTestMacros, CHECK_TRUEBehavesAsProperMacro) -{ - if (false) CHECK_TRUE(false); - else CHECK_TRUE(true); -} - -IGNORE_TEST(UnitTestMacros, CHECK_TRUEWorksInAnIgnoredTest) -{ - CHECK_TRUE(false); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_TRUE_TEXT_() -{ - CHECK_TRUE_TEXT(false, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_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"); -} - -TEST(UnitTestMacros, CHECK_TRUE_TEXTBehavesAsProperMacro) -{ - if (false) CHECK_TRUE_TEXT(false, "Failed because it failed"); - else CHECK_TRUE_TEXT(true, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, CHECK_TRUE_TEXTWorksInAnIgnoredTest) -{ - CHECK_TRUE_TEXT(false, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_FALSE_() -{ - CHECK_FALSE(true); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_FALSE) -{ - fixture.runTestWithMethod(failingTestMethodWithCHECK_FALSE_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_FALSE(true) failed"); -} - -TEST(UnitTestMacros, CHECK_FALSEBehavesAsProperMacro) -{ - if (false) CHECK_FALSE(true); - else CHECK_FALSE(false); -} - -IGNORE_TEST(UnitTestMacros, CHECK_FALSEWorksInAnIgnoredTest) -{ - CHECK_FALSE(true); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_FALSE_TEXT_() -{ - CHECK_FALSE_TEXT(true, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_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"); -} - -TEST(UnitTestMacros, CHECK_FALSE_TEXTBehavesAsProperMacro) -{ - if (false) CHECK_FALSE_TEXT(true, "Failed because it failed"); - else CHECK_FALSE_TEXT(false, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, CHECK_FALSE_TEXTWorksInAnIgnoredTest) -{ - CHECK_FALSE_TEXT(true, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_EQUAL_() -{ - CHECK_EQUAL(1, 2); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_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_() -{ - double small = 0.5, big = 0.8; - CHECK_COMPARE(small, >=, big); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_COMPARE) -{ - fixture.runTestWithMethod(failingTestMethodWithCHECK_COMPARE_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("CHECK_COMPARE(0.5 >= 0.8)"); -} - -TEST(UnitTestMacros, CHECK_COMPAREBehavesAsProperMacro) -{ - if (false) CHECK_COMPARE(1, >, 2); - else CHECK_COMPARE(1, <, 2); -} - -IGNORE_TEST(UnitTestMacros, CHECK_COMPAREWorksInAnIgnoredTest) -{ - CHECK_COMPARE(1, >, 2); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_COMPARE_TEXT_() -{ - double small = 0.5, big = 0.8; - CHECK_COMPARE_TEXT(small, >=, big, "small bigger than big"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_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"); -} - -TEST(UnitTestMacros, CHECK_COMPARE_TEXTBehavesAsProperMacro) -{ - if (false) CHECK_COMPARE_TEXT(1, >, 2, "1 bigger than 2"); - else CHECK_COMPARE_TEXT(1, <, 2, "1 smaller than 2"); -} - -IGNORE_TEST(UnitTestMacros, CHECK_COMPARE_TEXTWorksInAnIgnoredTest) -{ - CHECK_COMPARE_TEXT(1, >, 2, "1 smaller than 2"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static int countInCountingMethod; -static int countingMethod_() -{ - return countInCountingMethod++; -} - -TEST(UnitTestMacros, LONGS_EQUAL_macroExpressionSafety) -{ - LONGS_EQUAL(1, 0.4 + 0.7); - LONGS_EQUAL(0.4 + 0.7, 1); - LONGS_EQUAL_TEXT(1, 0.4 + 0.7, "-Wconversion=great"); - LONGS_EQUAL_TEXT(0.4 + 0.7, 1, "-Wconversion=great"); -} - -TEST(UnitTestMacros, UNSIGNED_LONGS_EQUAL_macroExpressionSafety) -{ - UNSIGNED_LONGS_EQUAL(1, 0.4 + 0.7); - UNSIGNED_LONGS_EQUAL(0.4 + 0.7, 1); - UNSIGNED_LONGS_EQUAL_TEXT(1, 0.4 + 0.7, "-Wconversion=great"); - UNSIGNED_LONGS_EQUAL_TEXT(0.4 + 0.7, 1, "-Wconversion=great"); -} - -TEST(UnitTestMacros, passingCheckEqualWillNotBeEvaluatedMultipleTimesWithCHECK_EQUAL) -{ - countInCountingMethod = 0; - CHECK_EQUAL(0, countingMethod_()); - - LONGS_EQUAL(1, countInCountingMethod); -} - -static void failing_CHECK_EQUAL_WithActualBeingEvaluatesMultipleTimesWillGiveAWarning_() -{ - CHECK_EQUAL(12345, countingMethod_()); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, 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_() -{ - CHECK_EQUAL(countingMethod_(), 12345); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, 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.assertPrintContainsNot("WARNING"); -} - -TEST(UnitTestMacros, CHECK_EQUALBehavesAsProperMacro) -{ - if (false) CHECK_EQUAL(1, 2); - else CHECK_EQUAL(1, 1); -} - -IGNORE_TEST(UnitTestMacros, CHECK_EQUALWorksInAnIgnoredTest) -{ - CHECK_EQUAL(1, 2); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithCHECK_EQUAL_TEXT_() -{ - CHECK_EQUAL_TEXT(1, 2, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_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"); -} - -TEST(UnitTestMacros, CHECK_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) CHECK_EQUAL_TEXT(1, 2, "Failed because it failed"); - else CHECK_EQUAL_TEXT(1, 1, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, CHECK_EQUAL_TEXTWorksInAnIgnoredTest) -{ - CHECK_EQUAL_TEXT(1, 2, "Failed because it failed"); // LCOV_EXCL_LINE; -} // LCOV_EXCL_LINE - -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 -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithLONGS_EQUALS) -{ - 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_() -{ -#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"); - 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: ")); -} - -TEST(UnitTestMacros, LONGS_EQUALBehavesAsProperMacro) -{ - if (false) LONGS_EQUAL(1, 2); - else LONGS_EQUAL(10, 10); -} - -IGNORE_TEST(UnitTestMacros, LONGS_EQUALWorksInAnIgnoredTest) -{ - LONGS_EQUAL(11, 22); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithLONGS_EQUAL_TEXT_() -{ - LONGS_EQUAL_TEXT(1, 0xff, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithLONGS_EQUALS_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"); -} - -TEST(UnitTestMacros, LONGS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) LONGS_EQUAL_TEXT(1, 2, "Failed because it failed"); - else LONGS_EQUAL_TEXT(10, 10, "Failed because it failed"); -} - -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_() -{ - BYTES_EQUAL('a', 'b'); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestMacros, FailureWithBYTES_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithBYTES_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <97 (0x61)>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <98 (0x62)>"); -} - -TEST(UnitTestMacros, BYTES_EQUALBehavesAsProperMacro) -{ - if (false) BYTES_EQUAL('a', 'b'); - else BYTES_EQUAL('c', 'c'); -} - -IGNORE_TEST(UnitTestMacros, BYTES_EQUALWorksInAnIgnoredTest) -{ - BYTES_EQUAL('q', 'w'); // LCOV_EXCL_LINE; -} // LCOV_EXCL_LINE - -static void failingTestMethodWithBYTES_EQUAL_TEXT_() -{ - BYTES_EQUAL_TEXT('a', 'b', "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestMacros, FailureWithBYTES_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"); -} - -TEST(UnitTestMacros, BYTES_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) BYTES_EQUAL_TEXT('a', 'b', "Failed because it failed"); - else BYTES_EQUAL_TEXT('c', 'c', "Failed because it failed"); -} - -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_() -{ - SIGNED_BYTES_EQUAL(-1, -2); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestMacros, FailureWithSIGNED_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)>"); -#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 -} - -TEST(UnitTestMacros, CHARS_EQUALBehavesAsProperMacro) -{ - if (false) SIGNED_BYTES_EQUAL(-1, -2); - else SIGNED_BYTES_EQUAL(-3, -3); -} - -IGNORE_TEST(UnitTestMacros, CHARS_EQUALWorksInAnIgnoredTest) -{ - SIGNED_BYTES_EQUAL(-7, 19); // LCOV_EXCL_LINE; -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSIGNED_BYTES_EQUAL_TEXT_() -{ - SIGNED_BYTES_EQUAL_TEXT(-127, -126, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestMacros, FailureWithSIGNED_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"); -} - -TEST(UnitTestMacros, CHARS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) SIGNED_BYTES_EQUAL_TEXT(-1, -2, "Failed because it failed"); - else SIGNED_BYTES_EQUAL_TEXT(-3, -3, "Failed because it failed"); -} - -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_() -{ - POINTERS_EQUAL((void*)0xa5a5, (void*)0xf0f0); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithPOINTERS_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithPOINTERS_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>"); -} - -TEST(UnitTestMacros, POINTERS_EQUALBehavesAsProperMacro) -{ - if (false) POINTERS_EQUAL(NULLPTR, to_void_pointer(0xbeefbeef)); - else POINTERS_EQUAL(to_void_pointer(0xdeadbeef), to_void_pointer(0xdeadbeef)); -} - -IGNORE_TEST(UnitTestMacros, POINTERS_EQUALWorksInAnIgnoredTest) -{ - POINTERS_EQUAL((void*) 0xbeef, (void*) 0xdead); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithPOINTERS_EQUAL_TEXT_() -{ - POINTERS_EQUAL_TEXT((void*)0xa5a5, (void*)0xf0f0, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithPOINTERS_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"); -} - -TEST(UnitTestMacros, POINTERS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) POINTERS_EQUAL_TEXT(NULLPTR, to_void_pointer(0xbeefbeef), "Failed because it failed"); - else POINTERS_EQUAL_TEXT(to_void_pointer(0xdeadbeef), to_void_pointer(0xdeadbeef), "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, POINTERS_EQUAL_TEXTWorksInAnIgnoredTest) -{ - POINTERS_EQUAL_TEXT((void*) 0xbeef, (void*) 0xdead, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - - -static void failingTestMethodWithFUNCTIONPOINTERS_EQUAL_() -{ - FUNCTIONPOINTERS_EQUAL((void (*)())0xa5a5, (void (*)())0xf0f0); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithFUNCTIONPOINTERS_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <0xa5a5>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0xf0f0>"); -} - -TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUALBehavesAsProperMacro) -{ - if (false) FUNCTIONPOINTERS_EQUAL(NULLPTR, to_func_pointer(0xbeefbeef)); - else FUNCTIONPOINTERS_EQUAL(to_func_pointer(0xdeadbeef), to_func_pointer(0xdeadbeef)); -} - -IGNORE_TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUALWorksInAnIgnoredTest) -{ - FUNCTIONPOINTERS_EQUAL((void (*)())0xbeef, (void (*)())0xdead); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithFUNCTIONPOINTERS_EQUAL_TEXT_() -{ - FUNCTIONPOINTERS_EQUAL_TEXT((void (*)())0xa5a5, (void (*)())0xf0f0, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithFUNCTIONPOINTERS_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"); -} - -TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) FUNCTIONPOINTERS_EQUAL_TEXT(NULLPTR, to_func_pointer(0xbeefbeef), "Failed because it failed"); - else FUNCTIONPOINTERS_EQUAL_TEXT(to_func_pointer(0xdeadbeef), to_func_pointer(0xdeadbeef), "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, FUNCTIONPOINTERS_EQUAL_TEXTWorksInAnIgnoredTest) -{ - FUNCTIONPOINTERS_EQUAL_TEXT((void (*)())0xbeef, (void (*)())0xdead, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - - - - -static void failingTestMethodWithDOUBLES_EQUAL_() -{ - DOUBLES_EQUAL(0.12, 44.1, 0.3); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithDOUBLES_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>"); -} - -TEST(UnitTestMacros, DOUBLES_EQUALBehavesAsProperMacro) -{ - if (false) DOUBLES_EQUAL(0.0, 1.1, 0.0005); - else DOUBLES_EQUAL(0.1, 0.2, 0.2); -} - -IGNORE_TEST(UnitTestMacros, DOUBLES_EQUALWorksInAnIgnoredTest) -{ - DOUBLES_EQUAL(100.0, 0.0, 0.2); // LCOV_EXCL_LINE; -} // LCOV_EXCL_LINE - -static void failingTestMethodWithDOUBLES_EQUAL_TEXT_() -{ - DOUBLES_EQUAL_TEXT(0.12, 44.1, 0.3, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithDOUBLES_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>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed"); -} - -TEST(UnitTestMacros, DOUBLES_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) DOUBLES_EQUAL_TEXT(0.0, 1.1, 0.0005, "Failed because it failed"); - else DOUBLES_EQUAL_TEXT(0.1, 0.2, 0.2, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, DOUBLES_EQUAL_TEXTWorksInAnIgnoredTest) -{ - DOUBLES_EQUAL_TEXT(100.0, 0.0, 0.2, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static bool lineOfCodeExecutedAfterCheck = false; - -static void passingTestMethod_() -{ - CHECK(true); - lineOfCodeExecutedAfterCheck = true; -} - -TEST(UnitTestMacros, SuccessPrintsNothing) -{ - fixture.runTestWithMethod(passingTestMethod_); - - LONGS_EQUAL(0, fixture.getFailureCount()); - fixture.assertPrintContains(".\nOK (1 tests"); - CHECK(lineOfCodeExecutedAfterCheck); -} - -static void methodThatOnlyPrints_() -{ - UT_PRINT("Hello World!"); -} - -TEST(UnitTestMacros, PrintPrintsWhateverPrintPrints) -{ - fixture.runTestWithMethod(methodThatOnlyPrints_); - - LONGS_EQUAL(0, fixture.getFailureCount()); - fixture.assertPrintContains("Hello World!"); - fixture.assertPrintContains(__FILE__); -} - -static void methodThatOnlyPrintsUsingSimpleStringFromFormat_() -{ - UT_PRINT(StringFromFormat("Hello %s %d", "World!", 2009)); -} - -TEST(UnitTestMacros, PrintPrintsSimpleStringsForExampleThoseReturnedByFromString) -{ - fixture.runTestWithMethod(methodThatOnlyPrintsUsingSimpleStringFromFormat_); - fixture.assertPrintContains("Hello World! 2009"); -} - -static int functionThatReturnsAValue() -{ - CHECK(0 == 0); - CHECK_TEXT(0 == 0, "Shouldn't fail"); - CHECK_TRUE(0 == 0); - CHECK_TRUE_TEXT(0 == 0, "Shouldn't fail"); - CHECK_FALSE(0 != 0); - CHECK_FALSE_TEXT(0 != 0, "Shouldn't fail"); - LONGS_EQUAL(1,1); - LONGS_EQUAL_TEXT(1, 1, "Shouldn't fail"); - BYTES_EQUAL(0xab,0xab); - 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); - DOUBLES_EQUAL_TEXT(1.0, 1.0, .01, "Shouldn't fail"); - POINTERS_EQUAL(NULLPTR, NULLPTR); - POINTERS_EQUAL_TEXT(NULLPTR, NULLPTR, "Shouldn't fail"); - MEMCMP_EQUAL("THIS", "THIS", 5); - MEMCMP_EQUAL_TEXT("THIS", "THIS", 5, "Shouldn't fail"); - BITS_EQUAL(0x01, (unsigned char )0x01, 0xFF); - BITS_EQUAL(0x0001, (unsigned short )0x0001, 0xFFFF); - BITS_EQUAL(0x00000001, (unsigned long )0x00000001, 0xFFFFFFFF); - BITS_EQUAL_TEXT(0x01, (unsigned char )0x01, 0xFF, "Shouldn't fail"); - return 0; -} - -TEST(UnitTestMacros, allMacrosFromFunctionThatReturnsAValue) -{ - functionThatReturnsAValue(); -} - -TEST(UnitTestMacros, MEMCMP_EQUALBehavesAsAProperMacro) -{ - if (false) MEMCMP_EQUAL("TEST", "test", 5); - else MEMCMP_EQUAL("TEST", "TEST", 5); -} - -IGNORE_TEST(UnitTestMacros, MEMCMP_EQUALWorksInAnIgnoredTest) -{ - MEMCMP_EQUAL("TEST", "test", 5); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void MEMCMP_EQUALFailingTestMethodWithUnequalInput_() -{ - unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 }; - unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 }; - - MEMCMP_EQUAL(expectedData, actualData, sizeof(expectedData)); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, MEMCMP_EQUALFailureWithUnequalInput) -{ - 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_() -{ - unsigned char actualData[] = { 0x00, 0x01, 0x02, 0x03 }; - - MEMCMP_EQUAL(NULLPTR, actualData, sizeof(actualData)); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, MEMCMP_EQUALFailureWithNullExpected) -{ - 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_() -{ - unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 }; - - MEMCMP_EQUAL(expectedData, NULLPTR, sizeof(expectedData)); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, MEMCMP_EQUALFailureWithNullActual) -{ - fixture.runTestWithMethod(MEMCMP_EQUALFailingTestMethodWithNullActual_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <00 01 02 03>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>"); -} - -TEST(UnitTestMacros, MEMCMP_EQUALNullExpectedNullActual) -{ - MEMCMP_EQUAL(NULLPTR, NULLPTR, 0); - MEMCMP_EQUAL(NULLPTR, NULLPTR, 1024); -} - -TEST(UnitTestMacros, MEMCMP_EQUALNullPointerIgnoredInExpectationWhenSize0) -{ - unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 }; - MEMCMP_EQUAL(NULLPTR, actualData, 0); -} - -TEST(UnitTestMacros, MEMCMP_EQUALNullPointerIgnoredInActualWhenSize0) -{ - unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 }; - MEMCMP_EQUAL(expectedData, NULLPTR, 0); -} - -static void failingTestMethodWithMEMCMP_EQUAL_TEXT_() -{ - unsigned char expectedData[] = { 0x00, 0x01, 0x02, 0x03 }; - unsigned char actualData[] = { 0x00, 0x01, 0x03, 0x03 }; - - MEMCMP_EQUAL_TEXT(expectedData, actualData, sizeof(expectedData), "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithMEMCMP_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"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Failed because it failed"); -} - -TEST(UnitTestMacros, MEMCMP_EQUAL_TEXTBehavesAsAProperMacro) -{ - if (false) MEMCMP_EQUAL_TEXT("TEST", "test", 5, "Failed because it failed"); - else MEMCMP_EQUAL_TEXT("TEST", "TEST", 5, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, MEMCMP_EQUAL_TEXTWorksInAnIgnoredTest) -{ - MEMCMP_EQUAL_TEXT("TEST", "test", 5, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, BITS_EQUALBehavesAsAProperMacro) -{ - if (false) BITS_EQUAL(0x00, 0xFF, 0xFF); - else BITS_EQUAL(0x00, 0x00, 0xFF); -} - -IGNORE_TEST(UnitTestMacros, BITS_EQUALWorksInAnIgnoredTest) -{ - BITS_EQUAL(0x00, 0xFF, 0xFF); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void BITS_EQUALFailingTestMethodWithUnequalInput_() -{ - BITS_EQUAL(0x00, 0xFF, 0xFF); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, BITS_EQUALFailureWithUnequalInput) -{ - fixture.runTestWithMethod(BITS_EQUALFailingTestMethodWithUnequalInput_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("00000000>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("11111111>"); -} - -TEST(UnitTestMacros, BITS_EQUALZeroMaskEqual) -{ - BITS_EQUAL(0x00, 0xFF, 0x00); -} - -static void failingTestMethodWithBITS_EQUAL_TEXT_() -{ - BITS_EQUAL_TEXT(0x00, 0xFFFFFFFF, 0xFF, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithBITS_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"); -} - -TEST(UnitTestMacros, BITS_EQUAL_TEXTBehavesAsAProperMacro) -{ - if (false) BITS_EQUAL_TEXT(0x00, 0xFF, 0xFF, "Failed because it failed"); - else BITS_EQUAL_TEXT(0x00, 0x00, 0xFF, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, BITS_EQUAL_TEXTWorksInAnIgnoredTest) -{ - BITS_EQUAL_TEXT(0x00, 0xFF, 0xFF, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -#if defined(__cplusplus) && __cplusplus >= 201103L -enum class ScopedIntEnum { - A, B -}; - -static void ENUMS_EQUAL_INTWithScopedIntEnumTestMethod_() -{ - ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::B); - ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::A); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestENUMS_EQUAL_INTWithScopedIntEnum) -{ - fixture.runTestWithMethod(ENUMS_EQUAL_INTWithScopedIntEnumTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_INTWithScopedIntEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::A); - else ENUMS_EQUAL_INT(ScopedIntEnum::B, ScopedIntEnum::B); -} - -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_() -{ - 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_); - 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"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_INT_TEXTWithScopedIntEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_INT_TEXT(ScopedIntEnum::B, ScopedIntEnum::A, "Failed because it failed"); - else ENUMS_EQUAL_INT_TEXT(ScopedIntEnum::B, ScopedIntEnum::B, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_EQUAL_INT_TEXTWithScopedIntEnumWorksInAnIgnoredTest) -{ - ENUMS_EQUAL_INT_TEXT(ScopedIntEnum::B, ScopedIntEnum::A, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -enum class ScopedLongEnum : long { - A, B -}; - -static void ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod_() -{ - ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::B); - ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::A); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestENUMS_EQUAL_TYPEWithScopedLongEnum) -{ - fixture.runTestWithMethod(ENUMS_EQUAL_TYPEWithScopedLongEnumTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_TYPEWithScopedLongEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::A); - else ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::B); -} - -IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_TYPEWithScopedLongEnumWorksInAnIgnoredTest) -{ - ENUMS_EQUAL_TYPE(long, ScopedLongEnum::B, ScopedLongEnum::A); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -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_); - 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"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_TYPE_TEXTWithScopedLongEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_TYPE_TEXT(long, ScopedLongEnum::B, ScopedLongEnum::A, "Failed because it failed"); - else ENUMS_EQUAL_TYPE_TEXT(long, ScopedLongEnum::B, ScopedLongEnum::B, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_EQUAL_TYPE_TEXTWithScopedLongEnumWorksInAnIgnoredTest) -{ - ENUMS_EQUAL_TYPE_TEXT(long, ScopedLongEnum::B, ScopedLongEnum::A, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -#endif - -enum UnscopedEnum { - UNSCOPED_ENUM_A, UNSCOPED_ENUM_B -}; - -static void ENUMS_EQUAL_INTWithUnscopedEnumTestMethod_() -{ - ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_B); - ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A); -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, TestENUMS_EQUAL_INTWithUnscopedEnum) -{ - fixture.runTestWithMethod(ENUMS_EQUAL_INTWithUnscopedEnumTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <1>"); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <0>"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_INTWithUnscopedEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A); - else ENUMS_EQUAL_INT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_B); -} - -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_() -{ - 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_); - 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"); -} - -TEST(UnitTestMacros, ENUMS_EQUAL_INT_TEXTWithUnscopedEnumBehavesAsProperMacro) -{ - if (false) ENUMS_EQUAL_INT_TEXT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A, "Failed because it failed"); - else ENUMS_EQUAL_INT_TEXT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_B, "Failed because it failed"); -} - -IGNORE_TEST(UnitTestMacros, ENUMS_EQUAL_EQUAL_INT_TEXTWithUnscopedEnumWorksInAnIgnoredTest) -{ - ENUMS_EQUAL_INT_TEXT(UNSCOPED_ENUM_B, UNSCOPED_ENUM_A, "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -#if CPPUTEST_HAVE_EXCEPTIONS -static void failingTestMethod_NoThrowWithCHECK_THROWS_() -{ - CHECK_THROWS(int, (void) (1+2)); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_THROWS_whenDoesntThrow) -{ - 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_() -{ - CHECK_THROWS(int, throw 4); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestMacros, SuccessWithCHECK_THROWS) -{ - fixture.runTestWithMethod(succeedingTestMethod_CorrectThrowWithCHECK_THROWS_); - LONGS_EQUAL(1, fixture.getCheckCount()); -} - -static void failingTestMethod_WrongThrowWithCHECK_THROWS_() -{ - CHECK_THROWS(int, throw 4.3); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestMacros, FailureWithCHECK_THROWS_whenWrongThrow) -{ - 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()); -} - -TEST(UnitTestMacros, MultipleCHECK_THROWS_inOneScope) -{ - CHECK_THROWS(int, throw 4); - CHECK_THROWS(int, throw 4); -} -#endif diff --git a/tests/CppUTest/TestUTestStringMacro.cpp b/tests/CppUTest/TestUTestStringMacro.cpp deleted file mode 100644 index e51f18c67..000000000 --- a/tests/CppUTest/TestUTestStringMacro.cpp +++ /dev/null @@ -1,467 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" - -#define CHECK_TEST_FAILS_PROPER_WITH_TEXT(text) fixture.checkTestFailsWithProperTestLocation(text, __FILE__, __LINE__) - -TEST_GROUP(UnitTestStringMacros) -{ - TestTestingFixture fixture; -}; - -static void STRCMP_EQUALWithActualIsNULLTestMethod_() -{ - STRCMP_EQUAL("ok", NULLPTR); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUALAndActualIsNULL) -{ - fixture.runTestWithMethod(STRCMP_EQUALWithActualIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>"); -} - -static void STRCMP_EQUALWithExpectedIsNULLTestMethod_() -{ - STRCMP_EQUAL(NULLPTR, "ok"); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUALAndExpectedIsNULL) -{ - fixture.runTestWithMethod(STRCMP_EQUALWithExpectedIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>"); -} - -static void STRCMP_CONTAINSWithActualIsNULLTestMethod_() -{ - STRCMP_CONTAINS("ok", NULLPTR); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINSAndActualIsNULL) -{ - fixture.runTestWithMethod(STRCMP_CONTAINSWithActualIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain "); -} - -static void STRCMP_CONTAINSWithExpectedIsNULLTestMethod_() -{ - STRCMP_CONTAINS(NULLPTR, "ok"); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINSAndExpectedIsNULL) -{ - fixture.runTestWithMethod(STRCMP_CONTAINSWithExpectedIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain <>"); -} - -static void STRNCMP_EQUALWithActualIsNULLTestMethod_() -{ - STRNCMP_EQUAL("ok", NULLPTR, 2); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUALAndActualIsNULL) -{ - fixture.runTestWithMethod(STRNCMP_EQUALWithActualIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>"); -} - -static void STRNCMP_EQUALWithExpectedIsNULLTestMethod_() -{ - STRNCMP_EQUAL(NULLPTR, "ok", 2); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUALAndExpectedIsNULL) -{ - fixture.runTestWithMethod(STRNCMP_EQUALWithExpectedIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>"); -} - -static void STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod_() -{ - STRCMP_NOCASE_EQUAL("ok", NULLPTR); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndActualIsNULL) -{ - fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithActualIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was <(null)>"); -} - -static void STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod_() -{ - STRCMP_NOCASE_EQUAL(NULLPTR, "ok"); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndExpectedIsNULL) -{ - fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithExpectedIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected <(null)>"); -} - -static void STRCMP_NOCASE_EQUALWithUnequalInputTestMethod_() -{ - STRCMP_NOCASE_EQUAL("no", "ok"); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUALAndUnequalInput) -{ - fixture.runTestWithMethod(STRCMP_NOCASE_EQUALWithUnequalInputTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was "); -} - -static void STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod_() -{ - STRCMP_NOCASE_CONTAINS("ok", NULLPTR); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINSAndActualIsNULL) -{ - fixture.runTestWithMethod(STRCMP_NOCASE_CONTAINSWithActualIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain "); -} - -static void STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod_() -{ - STRCMP_NOCASE_CONTAINS(NULLPTR, "ok"); -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINSAndExpectedIsNULL) -{ - fixture.runTestWithMethod(STRCMP_NOCASE_CONTAINSWithExpectedIsNULLTestMethod_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain <>"); -} - -static void failingTestMethodWithSTRCMP_EQUAL_() -{ - STRCMP_EQUAL("hello", "hell"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithSTRCMP_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected "); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was "); -} - -TEST(UnitTestStringMacros, STRCMP_EQUALBehavesAsProperMacro) -{ - if (false) STRCMP_EQUAL("1", "2"); - else STRCMP_EQUAL("1", "1"); -} - -IGNORE_TEST(UnitTestStringMacros, STRCMP_EQUALWorksInAnIgnoredTest) -{ - STRCMP_EQUAL("Hello", "World"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSTRCMP_EQUAL_TEXT_() -{ - STRCMP_EQUAL_TEXT("hello", "hell", "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_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"); -} - -TEST(UnitTestStringMacros, STRCMP_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) STRCMP_EQUAL_TEXT("1", "2", "Failed because it failed"); - else STRCMP_EQUAL_TEXT("1", "1", "Failed because it failed"); -} - -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_() -{ - STRNCMP_EQUAL("hello", "hallo", 5); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRNCMP_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithSTRNCMP_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected "); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was "); -} - -TEST(UnitTestStringMacros, STRNCMP_EQUALBehavesAsProperMacro) -{ - if (false) STRNCMP_EQUAL("1", "2", 1); - else STRNCMP_EQUAL("1", "1", 1); -} - -IGNORE_TEST(UnitTestStringMacros, STRNCMP_EQUALWorksInAnIgnoredTest) -{ - STRNCMP_EQUAL("Hello", "World", 3); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSTRNCMP_EQUAL_TEXT_() -{ - STRNCMP_EQUAL_TEXT("hello", "hallo", 5, "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRNCMP_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"); -} - -TEST(UnitTestStringMacros, STRNCMP_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) STRNCMP_EQUAL_TEXT("1", "2", 1, "Failed because it failed"); - else STRNCMP_EQUAL_TEXT("1", "1", 1, "Failed because it failed"); -} - -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_() -{ - STRCMP_NOCASE_EQUAL("hello", "Hell"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_EQUAL) -{ - fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_EQUAL_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("expected "); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("but was "); -} - -TEST(UnitTestStringMacros, STRCMP_NOCASE_EQUALBehavesAsProperMacro) -{ - if (false) STRCMP_NOCASE_EQUAL("1", "2"); - else STRCMP_NOCASE_EQUAL("1", "1"); -} - -IGNORE_TEST(UnitTestStringMacros, STRCMP_NOCASE_EQUALWorksInAnIgnoredTest) -{ - STRCMP_NOCASE_EQUAL("Hello", "World"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSTRCMP_NOCASE_EQUAL_TEXT_() -{ - STRCMP_NOCASE_EQUAL_TEXT("hello", "hell", "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_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"); -} - -TEST(UnitTestStringMacros, STRCMP_NOCASE_EQUAL_TEXTBehavesAsProperMacro) -{ - if (false) STRCMP_NOCASE_EQUAL_TEXT("1", "2", "Failed because it failed"); - else STRCMP_NOCASE_EQUAL_TEXT("1", "1", "Failed because it failed"); -} - -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_() -{ - STRCMP_CONTAINS("hello", "world"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_CONTAINS) -{ - fixture.runTestWithMethod(failingTestMethodWithSTRCMP_CONTAINS_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual "); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain "); -} - -TEST(UnitTestStringMacros, STRCMP_CONTAINSBehavesAsProperMacro) -{ - if (false) STRCMP_CONTAINS("1", "2"); - else STRCMP_CONTAINS("1", "1"); -} - -IGNORE_TEST(UnitTestStringMacros, STRCMP_CONTAINSWorksInAnIgnoredTest) -{ - STRCMP_CONTAINS("Hello", "World"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSTRCMP_CONTAINS_TEXT_() -{ - STRCMP_CONTAINS_TEXT("hello", "world", "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, FailureWithSTRCMP_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"); -} - -TEST(UnitTestStringMacros, STRCMP_CONTAINS_TEXTBehavesAsProperMacro) -{ - if (false) STRCMP_CONTAINS_TEXT("1", "2", "Failed because it failed"); - else STRCMP_CONTAINS_TEXT("1", "1", "Failed because it failed"); -} - -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_() -{ - STRCMP_NOCASE_CONTAINS("hello", "WORLD"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestStringMacros, FailureWithSTRCMP_NOCASE_CONTAINS) -{ - fixture.runTestWithMethod(failingTestMethodWithSTRCMP_NOCASE_CONTAINS_); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("actual "); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("did not contain "); -} - -TEST(UnitTestStringMacros, STRCMP_NOCASE_CONTAINSBehavesAsProperMacro) -{ - if (false) STRCMP_NOCASE_CONTAINS("never", "executed"); - else STRCMP_NOCASE_CONTAINS("hello", "HELLO WORLD"); -} - -IGNORE_TEST(UnitTestStringMacros, STRCMP_NO_CASE_CONTAINSWorksInAnIgnoredTest) -{ - STRCMP_NOCASE_CONTAINS("Hello", "World"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -static void failingTestMethodWithSTRCMP_NOCASE_CONTAINS_TEXT_() -{ - STRCMP_NOCASE_CONTAINS_TEXT("hello", "WORLD", "Failed because it failed"); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} - -TEST(UnitTestStringMacros, FailureWithSTRCMP_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"); -} - -TEST(UnitTestStringMacros, STRCMP_NOCASE_CONTAINS_TEXTBehavesAsProperMacro) -{ - if (false) STRCMP_NOCASE_CONTAINS_TEXT("never", "executed", "Failed because it failed"); - else STRCMP_NOCASE_CONTAINS_TEXT("hello", "HELLO WORLD", "Failed because it failed"); -} - -IGNORE_TEST(UnitTestStringMacros, STRCMP_NO_CASE_CONTAINS_TEXTWorksInAnIgnoredTest) -{ - STRCMP_NOCASE_CONTAINS_TEXT("Hello", "World", "Failed because it failed"); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, NFirstCharsComparison) -{ - STRNCMP_EQUAL("Hello World!", "Hello Peter!", 0); - STRNCMP_EQUAL("Hello World!", "Hello Peter!", 1); - STRNCMP_EQUAL("Hello World!", "Hello Peter!", 6); - STRNCMP_EQUAL("Hello World!", "Hello", 5); -} - -static void compareNFirstCharsWithUpperAndLowercase_() -{ - STRNCMP_EQUAL("hello world!", "HELLO WORLD!", 12); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, 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_() -{ - STRNCMP_EQUAL("Hello World!", "Hello Peter!", 12); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, 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_() -{ - STRNCMP_EQUAL("", "Not empty string", 5); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, 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_() -{ - STRNCMP_EQUAL("Not empty string?", "Not empty string!", 17); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(UnitTestStringMacros, 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 deleted file mode 100644 index 4faf52695..000000000 --- a/tests/CppUTest/UtestPlatformTest.cpp +++ /dev/null @@ -1,211 +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/TestHarness.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/PlatformSpecificFunctions.h" -#include "CppUTest/StandardCLibrary.h" -#include "CppUTest/TestMemoryAllocator.h" - -#if CPPUTEST_USE_STD_C_LIB - -// This will cause a crash in VS2010 due to PlatformSpecificFree being uninitialized -static const SimpleString str1("abc"); -static const SimpleString str2("def"); -static const SimpleString str3(str1 + str2); - -TEST_GROUP(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess) -{ - TestTestingFixture fixture; -}; - -// 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) -{ - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("-p doesn't work on this platform, as it is lacking fork.\b"); -} - -#else - -static void failFunction_() -{ - FAIL("This test fails"); -} - -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()); - exit(1); -} - -#include - -static int waitpid_while_debugging_stub_number_called = 0; -static int waitpid_while_debugging_stub_forced_failures = 0; - -extern "C" { - - static int (*original_waitpid)(int, int*, int) = NULLPTR; - - static int fork_failed_stub(void) { return -1; } - - static int waitpid_while_debugging_stub(int pid, int* status, int options) - { - static int saved_status; - - if (waitpid_while_debugging_stub_number_called++ < waitpid_while_debugging_stub_forced_failures) { - saved_status = *status; - errno=EINTR; - return -1; - } - else { - *status = saved_status; - return original_waitpid(pid, status, options); - } - } - - static int waitpid_failed_stub(int, int*, int) { return -1; } -} - -#include -#include - -static void stoppedTestFunction_() -{ - kill(getpid(), SIGSTOP); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, TestInSeparateProcessWorks) -{ - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("OK (1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out"); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, FailureInSeparateProcessWorks) -{ - fixture.setRunTestsInSeperateProcess(); - 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"); -} - -#if (! CPPUTEST_SANITIZE_ADDRESS) - -static int accessViolationTestFunction_() -{ - return *(volatile int*) NULLPTR; // NOLINT(clang-analyzer-core.NullDereference) -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, AccessViolationInSeparateProcessWorks) -{ - fixture.setRunTestsInSeperateProcess(); - 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"); -} - -#endif - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, StoppedInSeparateProcessWorks) -{ - fixture.setRunTestsInSeperateProcess(); - fixture.setTestFunction(stoppedTestFunction_); - fixture.runAllTests(); - fixture.assertPrintContains("Stopped in separate process - continuing"); - fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran"); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, CallToForkFailedInSeparateProcessWorks) -{ - UT_PTR_SET(PlatformSpecificFork, fork_failed_stub); - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("Call to fork() failed"); - fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran"); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, CallToWaitPidWhileDebuggingInSeparateProcessWorks) -{ - UT_PTR_SET(original_waitpid, PlatformSpecificWaitPid); - UT_PTR_SET(PlatformSpecificWaitPid, waitpid_while_debugging_stub); - waitpid_while_debugging_stub_number_called = 0; - waitpid_while_debugging_stub_forced_failures = 10; - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("OK (1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out"); - // extra check to confirm that waitpid() was polled until it passed (and passed call adds one) - CHECK(waitpid_while_debugging_stub_number_called > waitpid_while_debugging_stub_forced_failures); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, CallToWaitPidStopsAndReportsAnErrorAfter20TimesRetry) -{ - UT_PTR_SET(original_waitpid, PlatformSpecificWaitPid); - UT_PTR_SET(PlatformSpecificWaitPid, waitpid_while_debugging_stub); - waitpid_while_debugging_stub_number_called = 0; - waitpid_while_debugging_stub_forced_failures = 40; - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("Call to waitpid() failed with EINTR. Tried 30 times and giving up! Sometimes happens in debugger"); - // extra check to confirm that waitpid() was polled until it passed (and passed call adds one) - CHECK(waitpid_while_debugging_stub_number_called > 30); -} - - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, CallToWaitPidFailedInSeparateProcessWorks) -{ - UT_PTR_SET(PlatformSpecificWaitPid, waitpid_failed_stub); - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("Call to waitpid() failed"); - fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran"); -} - -TEST(UTestPlatformsTest_PlatformSpecificRunTestInASeperateProcess, MultipleTestsInSeparateProcessAreCountedProperly) -{ - fixture.setRunTestsInSeperateProcess(); - fixture.runTestWithMethod(NULLPTR); - fixture.runTestWithMethod(stoppedTestFunction_); - fixture.runTestWithMethod(NULLPTR); - fixture.runTestWithMethod(exitNonZeroFunction_); - fixture.runTestWithMethod(NULLPTR); - fixture.assertPrintContains("Failed in separate process"); - fixture.assertPrintContains("Stopped in separate process"); - fixture.assertPrintContains("Errors (2 failures, 5 tests, 5 ran, 0 checks, 0 ignored, 0 filtered out"); -} - -#endif -#endif diff --git a/tests/CppUTest/UtestTest.cpp b/tests/CppUTest/UtestTest.cpp deleted file mode 100644 index b1e2fb421..000000000 --- a/tests/CppUTest/UtestTest.cpp +++ /dev/null @@ -1,675 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTest/PlatformSpecificFunctions.h" - -#if CPPUTEST_USE_STD_C_LIB -#include -#endif - -TEST_GROUP(UtestShell) -{ - TestTestingFixture fixture; -}; - -static void failMethod_() -{ - FAIL("This test fails"); -} - -static void passingTestMethod_() -{ - CHECK(true); -} - -static void passingCheckEqualTestMethod_() -{ - CHECK_EQUAL(1, 1); -} - -static void exitTestMethod_() -{ - TEST_EXIT; - FAIL("Should not get here"); -} - -TEST(UtestShell, compareDoubles) -{ - CHECK(doubles_equal(1.0, 1.001, 0.01)); - CHECK(!doubles_equal(1.0, 1.1, 0.05)); - 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.runAllTests(); - LONGS_EQUAL(1, fixture.getCheckCount()); -} - -TEST(UtestShell, PassedCheckEqualWillIncreaseTheAmountOfChecks) -{ - fixture.setTestFunction(passingCheckEqualTestMethod_); - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getCheckCount()); -} - -IGNORE_TEST(UtestShell, IgnoreTestAccessingFixture) -{ - CHECK(&fixture != NULLPTR); -} - -TEST(UtestShell, MacrosUsedInSetup) -{ - IGNORE_ALL_LEAKS_IN_TEST(); - fixture.setSetup(failMethod_); - fixture.setTestFunction(passingTestMethod_); - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getFailureCount()); -} - -TEST(UtestShell, MacrosUsedInTearDown) -{ - IGNORE_ALL_LEAKS_IN_TEST(); - fixture.setTeardown(failMethod_); - fixture.setTestFunction(passingTestMethod_); - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getFailureCount()); -} - -TEST(UtestShell, ExitLeavesQuietly) -{ - 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_() -{ - teardownCalled++; -} - -TEST(UtestShell, TeardownCalledAfterTestFailure) -{ - teardownCalled = 0; - IGNORE_ALL_LEAKS_IN_TEST(); - fixture.setTeardown(teardownMethod_); - fixture.setTestFunction(failMethod_); - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getFailureCount()); - LONGS_EQUAL(1, teardownCalled); -} - -static int stopAfterFailure = 0; -static void stopAfterFailureMethod_() -{ - FAIL("fail"); - stopAfterFailure++; -} - -TEST(UtestShell, TestStopsAfterTestFailure) -{ - IGNORE_ALL_LEAKS_IN_TEST(); - stopAfterFailure = 0; - fixture.setTestFunction(stopAfterFailureMethod_); - fixture.runAllTests(); - CHECK(fixture.hasTestFailed()); - LONGS_EQUAL(1, fixture.getFailureCount()); - LONGS_EQUAL(0, stopAfterFailure); -} - -TEST(UtestShell, TestStopsAfterSetupFailure) -{ - stopAfterFailure = 0; - 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__); - StringBufferTestOutput normalOutput; - normalOutput.verbose(TestOutput::level_veryVerbose); - NullTestPlugin plugin; - - TestResult result(normalOutput); - shell.runOneTestInCurrentProcess(&plugin, result); - STRCMP_CONTAINS("\n------ before runTest", normalOutput.getOutput().asCharString()); -} - -class defaultUtestShell: public UtestShell -{ -}; - -TEST(UtestShell, this_test_covers_the_UtestShell_createTest_and_Utest_testBody_methods) -{ - defaultUtestShell shell; - fixture.addTest(&shell); - fixture.runAllTests(); - LONGS_EQUAL(2, fixture.getTestCount()); -} - - -static void StubPlatformSpecificRunTestInASeperateProcess(UtestShell* shell, TestPlugin*, TestResult* result) -{ - result->addFailure(TestFailure(shell, "Failed in separate process")); -} - -TEST(UtestShell, RunInSeparateProcessTest) -{ - UT_PTR_SET(PlatformSpecificRunTestInASeperateProcess, StubPlatformSpecificRunTestInASeperateProcess); - fixture.getRegistry()->setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("Failed in separate process"); -} - -// 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 - -TEST(UtestShell, TestDefaultCrashMethodInSeparateProcessTest) -{ - fixture.setTestFunction(UtestShell::crash); - fixture.setRunTestsInSeperateProcess(); - fixture.runAllTests(); - fixture.assertPrintContains("Failed in separate process - killed by signal"); -} - -#endif - -#if CPPUTEST_HAVE_EXCEPTIONS - -static bool destructorWasCalledOnFailedTest = false; - -static void destructorCalledForLocalObjects_() -{ - SetBooleanOnDestructorCall pleaseCallTheDestructor(destructorWasCalledOnFailedTest); - destructorWasCalledOnFailedTest = false; - FAIL("fail"); -} - -TEST(UtestShell, DestructorIsCalledForLocalObjectsWhenTheTestFails) -{ - fixture.setTestFunction(destructorCalledForLocalObjects_); - fixture.runAllTests(); - CHECK(destructorWasCalledOnFailedTest); -} - -#endif - -TEST_GROUP(IgnoredUtestShell) -{ - TestTestingFixture fixture; - IgnoredUtestShell ignoredTest; - ExecFunctionTestShell normalUtestShell; - - void setup() CPPUTEST_OVERRIDE - { - fixture.addTest(&ignoredTest); - fixture.addTest(&normalUtestShell); - } -}; - -TEST(IgnoredUtestShell, doesIgnoreCount) -{ - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getIgnoreCount()); -} - -TEST(IgnoredUtestShell, printsIGNORE_TESTwhenVerbose) -{ - fixture.setOutputVerbose(); - fixture.runAllTests(); - fixture.assertPrintContains("IGNORE_TEST"); -} - -TEST(IgnoredUtestShell, runIgnoredOptionSpecifiedThenIncreaseRunCount) -{ - ignoredTest.setRunIgnored(); - fixture.runAllTests(); - LONGS_EQUAL(3, fixture.getRunCount()); - LONGS_EQUAL(0, fixture.getIgnoreCount()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionNotSpecifiedThenIncreaseIgnoredCount) -{ - fixture.runAllTests(); - LONGS_EQUAL(2, fixture.getRunCount()); - LONGS_EQUAL(1, fixture.getIgnoreCount()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionSpecifiedWillNotInfluenceNormalTestCount) -{ - normalUtestShell.setRunIgnored(); - fixture.runAllTests(); - LONGS_EQUAL(2, fixture.getRunCount()); - LONGS_EQUAL(1, fixture.getIgnoreCount()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionSpecifiedThenReturnTESTInFormattedName) -{ - ignoredTest.setGroupName("TestGroup"); - ignoredTest.setTestName("TestName"); - ignoredTest.setRunIgnored(); - fixture.runAllTests(); - STRCMP_EQUAL("TEST(TestGroup, TestName)", ignoredTest.getFormattedName().asCharString()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionNotSpecifiedThenReturnIGNORETESTInFormattedName) -{ - ignoredTest.setGroupName("TestGroup"); - ignoredTest.setTestName("TestName"); - fixture.runAllTests(); - STRCMP_EQUAL("IGNORE_TEST(TestGroup, TestName)", ignoredTest.getFormattedName().asCharString()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionNotSpecifiedThenWillRunReturnFalse) -{ - CHECK_FALSE(ignoredTest.willRun()); -} - -TEST(IgnoredUtestShell, runIgnoredOptionSpecifiedThenWillRunReturnTrue) -{ - ignoredTest.setRunIgnored(); - CHECK_TRUE(ignoredTest.willRun()); -} - -TEST_BASE(MyOwnTest) -{ - MyOwnTest() : - inTest(false) - { - } - bool inTest; - - void setup() CPPUTEST_OVERRIDE - { - CHECK(!inTest); - inTest = true; - } - void teardown() CPPUTEST_OVERRIDE - { - CHECK(inTest); - inTest = false; - } -}; - -TEST_GROUP_BASE(UtestMyOwn, MyOwnTest) -{ -}; - -TEST(UtestMyOwn, test) -{ - CHECK(inTest); -} - -class NullParameterTest: public UtestShell -{ -}; - -TEST(UtestMyOwn, NullParameters) -{ - NullParameterTest nullTest; /* Bug fix tests for creating a test without a name, fix in SimpleString */ - TestFilter emptyFilter; - CHECK(nullTest.shouldRun(&emptyFilter, &emptyFilter)); -} - -class AllocateAndDeallocateInConstructorAndDestructor -{ - char* memory_; - char* morememory_; -public: - AllocateAndDeallocateInConstructorAndDestructor() - { - memory_ = new char[100]; - morememory_ = NULLPTR; - } - void allocateMoreMemory() - { - morememory_ = new char[123]; - } - - ~AllocateAndDeallocateInConstructorAndDestructor() - { - delete [] memory_; - delete [] morememory_; - } -}; - -TEST_GROUP(CanHaveMemberVariablesInTestGroupThatAllocateMemoryWithoutCausingMemoryLeaks) -{ - AllocateAndDeallocateInConstructorAndDestructor dummy; -}; - -TEST(CanHaveMemberVariablesInTestGroupThatAllocateMemoryWithoutCausingMemoryLeaks, testInTestGroupName) -{ - dummy.allocateMoreMemory(); -} - -static int getZero() -{ - return 0; -} - -static int getOne() -{ - return 1; -} - -TEST_GROUP(UtestShellPointerArrayTest) -{ - UtestShell* test0; - UtestShell* test1; - UtestShell* test2; - - void setup() CPPUTEST_OVERRIDE - { - test0 = new IgnoredUtestShell(); - test1 = new IgnoredUtestShell(); - test2 = new IgnoredUtestShell(); - - test0->addTest(test1); - test1->addTest(test2); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete test0; - delete test1; - delete test2; - } -}; - - -TEST(UtestShellPointerArrayTest, empty) -{ - UtestShellPointerArray tests(NULLPTR); - tests.shuffle(0); - CHECK(NULLPTR == tests.getFirstTest()); -} - -TEST(UtestShellPointerArrayTest, testsAreInOrder) -{ - UtestShellPointerArray tests(test0); - CHECK(tests.get(0) == test0); - CHECK(tests.get(1) == test1); - CHECK(tests.get(2) == test2); -} - -TEST(UtestShellPointerArrayTest, relinkingTestsWillKeepThemTheSameWhenNothingWasDone) -{ - UtestShellPointerArray tests(test0); - tests.relinkTestsInOrder(); - CHECK(tests.get(0) == test0); - CHECK(tests.get(1) == test1); - CHECK(tests.get(2) == test2); -} - - -TEST(UtestShellPointerArrayTest, firstTestisNotTheFirstTestWithSeed1234) -{ - UtestShellPointerArray tests(test0); - tests.shuffle(1234); - CHECK(tests.getFirstTest() != test0); -} - -TEST(UtestShellPointerArrayTest, ShuffleListTestWithRandomAlwaysReturningZero) -{ - UT_PTR_SET(PlatformSpecificRand, getZero); - - UtestShellPointerArray tests(test0); - tests.shuffle(3); - CHECK(tests.get(0) == test1); - CHECK(tests.get(1) == test2); - CHECK(tests.get(2) == test0); -} - -// swaps with 4 mod 3 (1) then 4 mod 2 (0): 1, [2], [0] --> [1], [0], 2 --> 0, 1, 2 -TEST(UtestShellPointerArrayTest, ShuffleListTestWithRandomAlwaysReturningOne) -{ - UT_PTR_SET(PlatformSpecificRand, getOne); - - UtestShellPointerArray tests(test0); - tests.shuffle(3); - CHECK(tests.get(0) == test0); - CHECK(tests.get(1) == test2); - CHECK(tests.get(2) == test1); -} - -TEST(UtestShellPointerArrayTest, reverse) -{ - UT_PTR_SET(PlatformSpecificRand, getOne); - - UtestShellPointerArray tests(test0); - tests.reverse(); - CHECK(tests.get(0) == test2); - CHECK(tests.get(1) == test1); - CHECK(tests.get(2) == test0); -} diff --git a/tests/CppUTestExt/AllTests.cpp b/tests/CppUTestExt/AllTests.cpp deleted file mode 100644 index 6b4ca8666..000000000 --- a/tests/CppUTestExt/AllTests.cpp +++ /dev/null @@ -1,69 +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 "CppUTest/SimpleStringInternalCache.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 *const *av) -{ - int result = 0; - GlobalSimpleStringCache simpleStringCache; - - { -#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 - result = CommandLineTestRunner::RunAllTests(ac, av); -#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, TestRegistry::getCurrentRegistry()); - result = runner.runAllTestsMain(); -#endif - } - - return result; -} - diff --git a/tests/CppUTestExt/CMakeLists.txt b/tests/CppUTestExt/CMakeLists.txt deleted file mode 100644 index c50179852..000000000 --- a/tests/CppUTestExt/CMakeLists.txt +++ /dev/null @@ -1,139 +0,0 @@ -add_library(CppUTestExtTests_main OBJECT - AllTests.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 - GTest2ConvertorTest.cpp -) - -add_cpputestext_test(2 - MockFailureReporterForTest.cpp - MemoryReportAllocatorTest.cpp - MemoryReportFormatterTest.cpp - MemoryReporterPluginTest.cpp - MockActualCallTest.cpp - MockCheatSheetTest.cpp - MockComparatorCopierTest.cpp - MockExpectedCallTest.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 -) - -add_cpputestext_test(5 - MockFailureReporterForTest.cpp - MockPluginTest.cpp - MockSupport_cTest.cpp - MockSupport_cTestCFile.c -) - -add_cpputestext_test(6 - MockFailureReporterForTest.cpp - ExpectedFunctionsListTest.cpp - MockCallTest.cpp -) - -add_cpputestext_test(7 - MockFailureReporterForTest.cpp - MockComparatorCopierTest.cpp - MockHierarchyTest.cpp - MockParameterTest.cpp -) - -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 deleted file mode 100644 index c2b390504..000000000 --- a/tests/CppUTestExt/CodeMemoryReporterTest.cpp +++ /dev/null @@ -1,199 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTestExt/CodeMemoryReportFormatter.h" - -#define TESTOUTPUT_EQUAL(a) STRCMP_EQUAL_LOCATION(a, testOutput.getOutput().asCharString(), "", __FILE__, __LINE__) -#define TESTOUTPUT_CONTAINS(a) STRCMP_CONTAINS_LOCATION(a, testOutput.getOutput().asCharString(), "", __FILE__, __LINE__) - -TEST_GROUP(CodeMemoryReportFormatter) -{ - TestMemoryAllocator* cAllocator; - TestMemoryAllocator* newAllocator; - TestMemoryAllocator* newArrayAllocator; - char* memory01; - char* memory02; - - StringBufferTestOutput testOutput; - TestResult* testResult; - CodeMemoryReportFormatter* formatter; - - void setup() CPPUTEST_OVERRIDE - { - cAllocator = defaultMallocAllocator(); - newAllocator = defaultNewAllocator(); - newArrayAllocator= defaultNewArrayAllocator(); - memory01 = (char*) 0x01; - memory02 = (char*) 0x02; - - formatter = new CodeMemoryReportFormatter(cAllocator); - testResult = new TestResult(testOutput); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete testResult; - delete formatter; - } -}; - - -TEST(CodeMemoryReportFormatter, mallocCreatesAnMallocCall) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "file", 9); - TESTOUTPUT_EQUAL("\tvoid* file_9_1 = malloc(10);\n"); -} - -TEST(CodeMemoryReportFormatter, freeCreatesAnFreeCall) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "file", 9); - testOutput.flush(); - formatter->report_free_memory(testResult, cAllocator, memory01, "boo", 6); - TESTOUTPUT_EQUAL("\tfree(file_9_1); /* at boo:6 */\n"); -} - -TEST(CodeMemoryReportFormatter, twoMallocAndTwoFree) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "file", 2); - formatter->report_alloc_memory(testResult, cAllocator, 10, memory02, "boo", 4); - testOutput.flush(); - formatter->report_free_memory(testResult, cAllocator, memory01, "foo", 6); - formatter->report_free_memory(testResult, cAllocator, memory02, "bar", 8); - TESTOUTPUT_CONTAINS("\tfree(file_2_1); /* at foo:6 */\n"); - TESTOUTPUT_CONTAINS("\tfree(boo_4_1); /* at bar:8 */\n"); -} - -TEST(CodeMemoryReportFormatter, variableNamesShouldNotContainSlahses) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "dir/file", 2); - TESTOUTPUT_CONTAINS("\tvoid* file_2"); -} - -TEST(CodeMemoryReportFormatter, variableNamesShouldNotContainDotButUseUnderscore) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "foo.cpp", 2); - TESTOUTPUT_CONTAINS("foo_cpp"); -} - -TEST(CodeMemoryReportFormatter, newArrayAllocatorGeneratesNewArrayCode) -{ - formatter->report_alloc_memory(testResult, newArrayAllocator, 10, memory01, "file", 8); - TESTOUTPUT_CONTAINS("char* file_8_1 = new char[10]; /* using new [] */"); -} - -TEST(CodeMemoryReportFormatter, newArrayGeneratesNewCode) -{ - formatter->report_alloc_memory(testResult, newAllocator, 6, memory01, "file", 4); - TESTOUTPUT_CONTAINS("new char[6]; /* using new */"); -} - -TEST(CodeMemoryReportFormatter, NewAllocatorGeneratesDeleteCode) -{ - formatter->report_alloc_memory(testResult, newAllocator, 10, memory01, "file", 8); - testOutput.flush(); - formatter->report_free_memory(testResult, newAllocator, memory01, "boo", 4); - TESTOUTPUT_CONTAINS("delete [] file_8_1; /* using delete at boo:4 */"); -} - -TEST(CodeMemoryReportFormatter, DeleteNullWorksFine) -{ - formatter->report_free_memory(testResult, newAllocator, NULLPTR, "boo", 4); - TESTOUTPUT_CONTAINS("delete [] NULL; /* using delete at boo:4 */"); -} - -TEST(CodeMemoryReportFormatter, NewArrayAllocatorGeneratesDeleteArrayCode) -{ - formatter->report_alloc_memory(testResult, newArrayAllocator, 10, memory01, "file", 8); - testOutput.flush(); - formatter->report_free_memory(testResult, newArrayAllocator, memory01, "boo", 4); - TESTOUTPUT_CONTAINS("delete [] file_8_1; /* using delete [] at boo:4 */"); -} - -TEST(CodeMemoryReportFormatter, allocationUsingMallocOnTheSameLineDoesntGenerateTheSameVariableTwice) -{ - formatter->report_alloc_memory(testResult, cAllocator, 10, memory01, "file", 8); - testOutput.flush(); - formatter->report_alloc_memory(testResult, cAllocator, 10, memory02, "file", 8); - CHECK(testOutput.getOutput().contains("2")); -} - -TEST(CodeMemoryReportFormatter, allocationUsingNewcOnTheSameLineDoesntGenerateTheSameVariableTwice) -{ - formatter->report_alloc_memory(testResult, newAllocator, 10, memory01, "file", 8); - testOutput.flush(); - formatter->report_alloc_memory(testResult, newAllocator, 10, memory01, "file", 8); - CHECK(testOutput.getOutput().contains("2")); -} - -TEST(CodeMemoryReportFormatter, allocationUsingNewcOnTheSameLineDoesntGenerateVariableTwiceExceptWhenInANewTest) -{ - formatter->report_alloc_memory(testResult, newAllocator, 10, memory01, "file", 8); - formatter->report_test_start(testResult, *UtestShell::getCurrent()); - testOutput.flush(); - formatter->report_alloc_memory(testResult, newAllocator, 10, memory01, "file", 8); - CHECK(testOutput.getOutput().contains("char*")); -} - -TEST(CodeMemoryReportFormatter, testStartGeneratesTESTcode) -{ - UtestShell test("groupName", "testName", "fileName", 1); - formatter->report_test_start(testResult, test); - TESTOUTPUT_EQUAL("*/\nTEST(groupName_memoryReport, testName)\n{ /* at fileName:1 */\n"); -} - -TEST(CodeMemoryReportFormatter, testEndGeneratesTESTcode) -{ - UtestShell test("groupName", "testName", "fileName", 1); - formatter->report_test_end(testResult, test); - TESTOUTPUT_EQUAL("}/*"); -} - -TEST(CodeMemoryReportFormatter, TestGroupGeneratesTestGroupCode) -{ - UtestShell test("groupName", "testName", "fileName", 1); - formatter->report_testgroup_start(testResult, test); - TESTOUTPUT_EQUAL("*/TEST_GROUP(groupName_memoryReport)\n{\n};\n/*"); -} - -TEST(CodeMemoryReportFormatter, VariableFromFileLineInfoAlreadyExists) -{ - for(int i = 1; i < 100; i++) { - formatter->report_alloc_memory(testResult, newArrayAllocator, 10, memory01, "file", 8); - } - formatter->report_alloc_memory(testResult, newArrayAllocator, 10, memory01, "file", 8); - testOutput.flush(); - formatter->report_free_memory(testResult, newArrayAllocator, memory01, "boo", 8); - TESTOUTPUT_CONTAINS("delete [] ; /* using delete [] at boo:8 */"); -} - -// TODO: do! -/* Dealloc without alloc */ -/* Remove the ugly comments by controlling the output! */ -/* Write tests for the variable name lengths */ diff --git a/tests/CppUTestExt/ExpectedFunctionsListTest.cpp b/tests/CppUTestExt/ExpectedFunctionsListTest.cpp deleted file mode 100644 index 526db2393..000000000 --- a/tests/CppUTestExt/ExpectedFunctionsListTest.cpp +++ /dev/null @@ -1,354 +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/TestHarness.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockFailure.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockExpectedCallsList) -{ - MockExpectedCallsList * list; - MockCheckedExpectedCall* call1; - MockCheckedExpectedCall* call2; - MockCheckedExpectedCall* call3; - MockCheckedExpectedCall* call4; - void setup() CPPUTEST_OVERRIDE - { - list = new MockExpectedCallsList; - call1 = new MockCheckedExpectedCall; - call2 = new MockCheckedExpectedCall; - call3 = new MockCheckedExpectedCall; - call4 = new MockCheckedExpectedCall; - call1->withName("foo"); - call2->withName("bar"); - call3->withName("boo"); - } - void teardown() CPPUTEST_OVERRIDE - { - delete call1; - delete call2; - delete call3; - delete call4; - delete list; - CHECK_NO_MOCK_FAILURE(); - MockFailureReporterForTest::clearReporter(); - } -}; - -TEST(MockExpectedCallsList, emptyList) -{ - CHECK(! list->hasUnfulfilledExpectations()); - CHECK(! list->hasFinalizedMatchingExpectations()); - LONGS_EQUAL(0, list->size()); -} - -TEST(MockExpectedCallsList, addingCalls) -{ - list->addExpectedCall(call1); - list->addExpectedCall(call2); - LONGS_EQUAL(2, list->size()); -} - -TEST(MockExpectedCallsList, listWithFulfilledExpectationHasNoUnfulfilledOnes) -{ - call1->callWasMade(1); - call2->callWasMade(2); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - CHECK(! list->hasUnfulfilledExpectations()); -} - -TEST(MockExpectedCallsList, listWithFulfilledExpectationButOutOfOrder) -{ - call1->withCallOrder(1); - call2->withCallOrder(2); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - call2->callWasMade(1); - call1->callWasMade(2); - CHECK(! list->hasUnfulfilledExpectations()); - CHECK(list->hasCallsOutOfOrder()); -} - -TEST(MockExpectedCallsList, listWithUnFulfilledExpectationHasNoUnfillfilledOnes) -{ - call1->callWasMade(1); - call3->callWasMade(2); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - CHECK(list->hasUnfulfilledExpectations()); -} - -TEST(MockExpectedCallsList, deleteAllExpectationsAndClearList) -{ - list->addExpectedCall(new MockCheckedExpectedCall); - list->addExpectedCall(new MockCheckedExpectedCall); - list->deleteAllExpectationsAndClearList(); -} - -TEST(MockExpectedCallsList, onlyKeepUnmatchingExpectations) -{ - call1->withName("relate"); - call2->withName("unrelate"); - call3->withName("relate").withParameter("param",1); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - list->onlyKeepUnmatchingExpectations(); - LONGS_EQUAL(1, list->size()); -} - -TEST(MockExpectedCallsList, onlyKeepExpectationsRelatedTo) -{ - call1->withName("relate"); - call2->withName("unrelate"); - call3->withName("unrelate"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - list->onlyKeepExpectationsRelatedTo("relate"); - LONGS_EQUAL(1, list->size()); -} - -TEST(MockExpectedCallsList, removeAllExpectationsExceptThisThatRelateToTheWoleList) -{ - call1->withName("relate"); - call2->withName("relate"); - call3->withName("relate"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - list->onlyKeepExpectationsRelatedTo("unrelate"); - LONGS_EQUAL(0, list->size()); -} - -TEST(MockExpectedCallsList, removeAllExpectationsExceptThisThatRelateToFirstOne) -{ - call1->withName("relate"); - call2->withName("unrelate"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->onlyKeepExpectationsRelatedTo("unrelate"); - LONGS_EQUAL(1, list->size()); -} - -TEST(MockExpectedCallsList, removeAllExpectationsExceptThisThatRelateToLastOne) -{ - call1->withName("unrelate"); - call2->withName("relate"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->onlyKeepExpectationsRelatedTo("unrelate"); - LONGS_EQUAL(1, list->size()); -} - -TEST(MockExpectedCallsList, onlyKeepExpectationsWithInputParameterName) -{ - call1->withName("func").withParameter("param", 1); - call2->withName("func").withParameter("diffname", 1); - call3->withName("func").withParameter("diffname", 1); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - list->onlyKeepExpectationsWithInputParameterName("diffname"); - LONGS_EQUAL(2, list->size()); -} - -TEST(MockExpectedCallsList, onlyKeepExpectationsWithInputParameter) -{ - MockNamedValue parameter("diffname"); - parameter.setValue(1); - call1->withName("func").withParameter("param", 1); - call2->withName("func").withParameter("diffname", 1); - call3->withName("func").withParameter("diffname", 1); - call4->withName("func").withParameter("diffname", 2); - call3->callWasMade(1); - call3->inputParameterWasPassed("diffname"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - list->addExpectedCall(call4); - list->onlyKeepExpectationsWithInputParameter(parameter); - LONGS_EQUAL(2, list->size()); -} - -TEST(MockExpectedCallsList, addPotentiallyMatchingExpectationsWithEmptyList) -{ - MockExpectedCallsList newList; - newList.addPotentiallyMatchingExpectations(*list); - LONGS_EQUAL(0, newList.size()); -} - -TEST(MockExpectedCallsList, addPotentiallyMatchingExpectationsMultipleUnmatchedExpectations) -{ - call2->callWasMade(1); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - MockExpectedCallsList newList; - newList.addPotentiallyMatchingExpectations(*list); - LONGS_EQUAL(2, newList.size()); -} - -TEST(MockExpectedCallsList, amountOfActualCallsFulfilledFor_HasOneRelated) -{ - call1->withName("foo"); - call1->callWasMade(1); - call2->withName("bar"); - call2->callWasMade(2); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - LONGS_EQUAL(1, list->amountOfActualCallsFulfilledFor("bar")); -} - -TEST(MockExpectedCallsList, amountOfActualCallsFulfilledFor_HasNone) -{ - call1->withName("foo"); - call1->callWasMade(1); - call2->withName("bar"); - list->addExpectedCall(call1); - LONGS_EQUAL(0, list->amountOfActualCallsFulfilledFor("bar")); -} - -TEST(MockExpectedCallsList, callToStringForUnfulfilledFunctions) -{ - call1->withName("foo"); - call2->withName("bar"); - call3->withName("blah"); - call3->callWasMade(1); - - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - - SimpleString expectedString; - expectedString = StringFromFormat("%s\n%s", call1->callToString().asCharString(), call2->callToString().asCharString()); - 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"); - call2->withName("bar"); - - call2->callWasMade(1); - call1->callWasMade(2); - - list->addExpectedCall(call1); - list->addExpectedCall(call2); - - SimpleString expectedString; - expectedString = StringFromFormat("%s\n%s", call1->callToString().asCharString(), call2->callToString().asCharString()); - STRCMP_EQUAL(expectedString.asCharString(), list->fulfilledCallsToString().asCharString()); -} - -TEST(MockExpectedCallsList, removeOneFinalizedMatchingExpectationFromEmptyList) -{ - POINTERS_EQUAL(NULLPTR, list->removeFirstFinalizedMatchingExpectation()); -} - -TEST(MockExpectedCallsList, getOneMatchingExpectationFromEmptyList) -{ - POINTERS_EQUAL(NULLPTR, list->getFirstMatchingExpectation()); -} - -TEST(MockExpectedCallsList, toStringOnEmptyList) -{ - STRCMP_EQUAL("", list->unfulfilledCallsToString().asCharString()); -} - -TEST(MockExpectedCallsList, hasFinalizedMatchingExpectations_emptyList) -{ - CHECK(! list->hasFinalizedMatchingExpectations()); -} - -TEST(MockExpectedCallsList, hasFinalizedMatchingExpectations_listHasNonMatchingCalls) -{ - call1->withParameter("param", 0); - call2->withParameter("param", 0); - call3->withParameter("param", 0); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - list->addExpectedCall(call3); - - CHECK(! list->hasFinalizedMatchingExpectations()); -} - -TEST(MockExpectedCallsList, hasFinalizedMatchingExpectations_listHasMatchingButNotFinalizedCall) -{ - list->addExpectedCall(call1); - list->addExpectedCall(call2); - call1->ignoreOtherParameters(); - call2->withParameter("param", 0); - - CHECK(! list->hasFinalizedMatchingExpectations()); -} - -TEST(MockExpectedCallsList, hasFinalizedMatchingExpectations_listHasFinalizedCallThatIgnoresParameters) -{ - list->addExpectedCall(call1); - list->addExpectedCall(call2); - call1->ignoreOtherParameters(); - call2->withParameter("param", 0); - - call1->finalizeActualCallMatch(); - - CHECK(list->hasFinalizedMatchingExpectations()); -} - -TEST(MockExpectedCallsList, hasFinalizedMatchingExpectations_listHasFinalizedCallThatDoesntIgnoreParameters) -{ - list->addExpectedCall(call1); - list->addExpectedCall(call2); - call1->withParameter("param", 1); - call2->withParameter("param", 0); - - call1->inputParameterWasPassed("param"); - - CHECK(list->hasFinalizedMatchingExpectations()); -} diff --git a/tests/CppUTestExt/GMockTest.cpp b/tests/CppUTestExt/GMockTest.cpp deleted file mode 100644 index 88b00e93d..000000000 --- a/tests/CppUTestExt/GMockTest.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifdef CPPUTEST_INCLUDE_GTEST_TESTS - -#include "CppUTestExt/GMock.h" -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestTestingFixture.h" - - -TEST_GROUP(GMock) -{ - TestTestingFixture *fixture; - void setup() CPPUTEST_OVERRIDE - { - fixture = new TestTestingFixture; - } - - void teardown() CPPUTEST_OVERRIDE - { - delete fixture; - - } -}; - -class myMock -{ -public: - MOCK_METHOD0(methodName, int()); -}; - -static void failedMockCall() -{ - myMock mock; - EXPECT_CALL(mock, methodName()).WillOnce(Return(1)); -} - -TEST(GMock, GMockFailuresWorkAsExpected) -{ - fixture->setTestFunction(failedMockCall); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); -} - -static void failedMockCallAfterOneSuccess() -{ - myMock mock; - EXPECT_CALL(mock, methodName()).Times(2).WillRepeatedly(Return(1)); - - mock.methodName(); -} - -TEST(GMock, GMockFailuresWorkAsExpectedWithTwoExpectedCallButJustOneActual) -{ - fixture->setTestFunction(failedMockCallAfterOneSuccess); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); -} - -TEST(GMock, GMockNiceMocksWorkFine) -{ - NiceMock mock; - mock.methodName(); -} - -#endif diff --git a/tests/CppUTestExt/GTest1Test.cpp b/tests/CppUTestExt/GTest1Test.cpp deleted file mode 100644 index 8f23d3482..000000000 --- a/tests/CppUTestExt/GTest1Test.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifdef CPPUTEST_INCLUDE_GTEST_TESTS -#undef new - -#include "CppUTestExt/GTest.h" -#include "CppUTestExt/GMock.h" - -static bool g_GTestEqual_has_been_called = false; -TEST(GTestSimpleTest, GTestEqual) -{ - EXPECT_EQ(1, 1); - g_GTestEqual_has_been_called = true; -} - -TEST(GTestSimpleTest, GTestAssertEq) -{ - ASSERT_EQ(1, 1); -} - -TEST(GTestSimpleTest, GTestExpectTrue) -{ - EXPECT_TRUE(true); -} - -TEST(GTestSimpleTest, GTestAssertTrue) -{ - ASSERT_TRUE(true); -} - -TEST(GTestSimpleTest, GTestExpectFalse) -{ - EXPECT_FALSE(false); -} - -TEST(GTestSimpleTest, GTestExpectStreq) -{ - EXPECT_STREQ("hello world", "hello world"); -} - -/* Death tests are IMHO not a good idea at all. But for compatibility reason, we'll support it */ - -static void crashMe () -{ - fprintf(stderr, "Crash me!"); - *((int*) 0) = 10; -} - -TEST(GTestSimpleTest, GTestDeathTest) -{ -#if defined(GTEST_VERSION_GTEST_1_7) - CppuTestGTestIgnoreLeaksInTest(); -#endif - ASSERT_DEATH(crashMe(), "Crash me!"); -} - -#undef TEST - -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" - -TEST_GROUP(gtest) -{ -}; - -TEST(gtest, SimpleGoogleTestExists) -{ - TestRegistry* registry = TestRegistry::getCurrentRegistry(); - CHECK(registry->findTestWithName("GTestEqual")); -} - -TEST(gtest, SimpleGoogleTestGroupExists) -{ - TestRegistry* registry = TestRegistry::getCurrentRegistry(); - CHECK(registry->findTestWithGroup("GTestSimpleTest")); -} - -TEST(gtest, SimpleGoogleTestGetCalled) -{ - StringBufferTestOutput output; - TestResult result(output); - TestPlugin plugin("dummy"); - - TestRegistry* registry = TestRegistry::getCurrentRegistry(); - UtestShell * shell = registry->findTestWithName("GTestEqual"); - g_GTestEqual_has_been_called = false; - shell->runOneTest(&plugin, result); - - CHECK(g_GTestEqual_has_been_called); -} - -static bool afterCheck; - -static void failMethodEXPECT_EQ_() -{ - EXPECT_EQ(1, 2); - afterCheck = true; -} - -static void failMethodASSERT_EQ_() -{ - ASSERT_EQ(1, 2); - afterCheck = true; -} - -static void failMethodEXPECT_TRUE_() -{ - EXPECT_TRUE(false); - afterCheck = true; -} - -static void failMethodASSERT_TRUE_() -{ - ASSERT_TRUE(false); - afterCheck = true; -} - -static void failMethodEXPECT_FALSE_() -{ - EXPECT_FALSE(true); - afterCheck = true; -} - -static void failMethodEXPECT_STREQ_() -{ - EXPECT_STREQ("hello", "world"); - afterCheck = true; -} - -TEST_GROUP(gtestMacros) -{ - TestTestingFixture* fixture; - void setup() CPPUTEST_OVERRIDE - { - fixture = new TestTestingFixture(); - afterCheck = false; - } - void teardown() CPPUTEST_OVERRIDE - { - delete fixture; - } - - void testFailureWith(void(*method)()) - { - fixture->setTestFunction(method); - fixture->runAllTests(); - LONGS_EQUAL(1, fixture->getFailureCount()); - CHECK(!afterCheck); - } - -}; - -TEST(gtestMacros, EXPECT_EQFails) -{ - testFailureWith(failMethodEXPECT_EQ_); -} - -TEST(gtestMacros, EXPECT_TRUEFails) -{ - testFailureWith(failMethodEXPECT_TRUE_); -} - -TEST(gtestMacros, EXPECT_FALSEFails) -{ - testFailureWith(failMethodEXPECT_FALSE_); -} - -TEST(gtestMacros, EXPECT_STREQFails) -{ - testFailureWith(failMethodEXPECT_STREQ_); -} - -TEST(gtestMacros, ASSERT_EQFails) -{ - testFailureWith(failMethodASSERT_EQ_); -} - -TEST(gtestMacros, ASSERT_TRUEFails) -{ - testFailureWith(failMethodASSERT_TRUE_); -} - -#endif diff --git a/tests/CppUTestExt/GTest2ConvertorTest.cpp b/tests/CppUTestExt/GTest2ConvertorTest.cpp deleted file mode 100644 index f8c390fb7..000000000 --- a/tests/CppUTestExt/GTest2ConvertorTest.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2011, 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. - */ - -#ifdef CPPUTEST_INCLUDE_GTEST_TESTS - -#include "CppUTestExt/GTestConvertor.h" - -class GTestTestingFixtureTest : public testing::Test { -protected: - bool setup_was_called; - char* freed_during_teardown; - - void SetUp() CPPUTEST_OVERRIDE - { - setup_was_called = true; - freed_during_teardown = NULL; - } - - void TearDown() CPPUTEST_OVERRIDE - { - delete [] freed_during_teardown; - } -}; - -TEST_F(GTestTestingFixtureTest, setupBeenCalled) -{ - EXPECT_TRUE(setup_was_called); -} - -TEST_F(GTestTestingFixtureTest, teardownMustBeCalledOrElseThisWillLeak) -{ - freed_during_teardown = new char[100]; -} - -#endif - -#undef TEST - -#include "CppUTest/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestTestingFixture.h" - -TEST_GROUP(GTestConvertor) -{ -}; - -#ifdef CPPUTEST_INCLUDE_GTEST_TESTS - -/* - * These tests depend on the amount of GTests that are actually added (also in other files). - * This is due to the singleton in gtest. - * - */ - -TEST(GTestConvertor, correctNumberOfTestCases) -{ - LONGS_EQUAL(2, ::testing::UnitTest::GetInstance()->total_test_case_count()); - CHECK(::testing::UnitTest::GetInstance()->GetTestCase(0)); - CHECK(::testing::UnitTest::GetInstance()->GetTestCase(1)); - CHECK(::testing::UnitTest::GetInstance()->GetTestCase(2) == NULL); -} - -TEST(GTestConvertor, correctNumberOfTestsInTheTestCases) -{ - const ::testing::TestCase* firstTestCase = ::testing::UnitTest::GetInstance()->GetTestCase(0); - const ::testing::TestCase* secondTestCase = ::testing::UnitTest::GetInstance()->GetTestCase(1); - - STRCMP_EQUAL("GTestSimpleTest", firstTestCase->name()); - STRCMP_EQUAL("GTestTestingFixtureTest", secondTestCase->name()); - LONGS_EQUAL(7, firstTestCase->total_test_count()); - LONGS_EQUAL(2, secondTestCase->total_test_count()); -} - -TEST(GTestConvertor, testsGetAddedToCurrentTestRegistry) -{ - TestTestingFixture fixture; - TestRegistry::getCurrentRegistry()->unDoLastAddTest(); - - GTestConvertor convertor(false); - convertor.addAllGTestToTestRegistry(); - - LONGS_EQUAL(9, TestRegistry::getCurrentRegistry()->countTests()); -} - -#endif diff --git a/tests/CppUTestExt/IEEE754PluginTest.cpp b/tests/CppUTestExt/IEEE754PluginTest.cpp deleted file mode 100644 index e37e309cb..000000000 --- a/tests/CppUTestExt/IEEE754PluginTest.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2015, Michael Feathers, James Grenning, Bas Vodde - * and Arnd R. Strube. 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/TestHarness.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTestExt/IEEE754ExceptionsPlugin.h" - -#if CPPUTEST_HAVE_FENV - -#include "IEEE754PluginTest_c.h" - -TEST_GROUP(FE_with_Plugin) -{ - TestTestingFixture fixture; - IEEE754ExceptionsPlugin ieee754Plugin; - void setup(void) CPPUTEST_OVERRIDE - { - fixture.installPlugin(&ieee754Plugin); - } -}; - -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) -{ - 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) -{ - 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) -{ - IEEE754ExceptionsPlugin::enableInexact(); - fixture.setTestFunction(set_inexact_c); - fixture.runAllTests(); - fixture.assertPrintContains("IEEE754_CHECK_CLEAR(FE_INEXACT) failed"); -} - -TEST(FE_with_Plugin, should_succeed_when_FE_INEXACT_is_set_and_disabled) -{ - IEEE754ExceptionsPlugin::enableInexact(); - IEEE754ExceptionsPlugin::disableInexact(); - fixture.setTestFunction(set_inexact_c); - fixture.runAllTests(); - fixture.assertPrintContains("OK"); -} - -TEST(FE_with_Plugin, should_succeed_with_5_checks_when_no_flags_are_set) -{ - IEEE754ExceptionsPlugin::enableInexact(); - fixture.setTestFunction(set_nothing_c); - fixture.runAllTests(); - fixture.assertPrintContains("OK (1 tests, 1 ran, 5 checks, 0 ignored, 0 filtered out"); - IEEE754ExceptionsPlugin::disableInexact(); -} - -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) -{ - fixture.setTestFunction(set_everything_c); - fixture.runAllTests(); - LONGS_EQUAL(1, fixture.getFailureCount()); -} - -static void set_everything_but_already_failed(void) -{ - set_everything_c(); - CHECK(1 == 2); -} - -TEST(FE_with_Plugin, should_not_fail_again_when_test_has_already_failed) -{ - fixture.setTestFunction(set_everything_but_already_failed); - fixture.runAllTests(); - CHECK(IEEE754ExceptionsPlugin::checkIeee754OverflowExceptionFlag()); - CHECK(IEEE754ExceptionsPlugin::checkIeee754UnderflowExceptionFlag()); - CHECK(IEEE754ExceptionsPlugin::checkIeee754InexactExceptionFlag()); - CHECK(IEEE754ExceptionsPlugin::checkIeee754DivByZeroExceptionFlag()); - LONGS_EQUAL(1, fixture.getCheckCount()); - LONGS_EQUAL(1, fixture.getFailureCount()); -} - -static IEEE754ExceptionsPlugin ip; - -TEST_GROUP(IEEE754ExceptionsPlugin2) -{ - void setup(void) CPPUTEST_OVERRIDE - { - TestRegistry::getCurrentRegistry()->installPlugin(&ip); - } -}; - -IGNORE_TEST(IEEE754ExceptionsPlugin2, should_not_fail_in_ignored_test) -{ - set_everything_c(); -} - -#endif diff --git a/tests/CppUTestExt/IEEE754PluginTest_c.c b/tests/CppUTestExt/IEEE754PluginTest_c.c deleted file mode 100644 index 644ea6462..000000000 --- a/tests/CppUTestExt/IEEE754PluginTest_c.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, Michael Feathers, James Grenning, Bas Vodde - * and Arnd R. Strube. 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 "IEEE754PluginTest_c.h" - -static volatile float f; -static volatile float zero_float = 0.0f; - -void set_divisionbyzero_c(void) -{ - f = 1.0f; - f /= zero_float; -} - -void set_overflow_c(void) -{ - f = 1e38f; - f *= f; -} - -void set_underflow_c(void) -{ - f = 1e-38f; - f *= f; -} - -void set_inexact_c(void) -{ - f = 10.0f; - f /= 3.0f; -} - -void set_nothing_c(void) -{ -} - -void set_everything_c(void) -{ - set_divisionbyzero_c(); - set_overflow_c(); - set_underflow_c(); - set_inexact_c(); -} diff --git a/tests/CppUTestExt/IEEE754PluginTest_c.h b/tests/CppUTestExt/IEEE754PluginTest_c.h deleted file mode 100644 index 6f1f02e91..000000000 --- a/tests/CppUTestExt/IEEE754PluginTest_c.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015, Michael Feathers, James Grenning, Bas Vodde - * and Arnd R. Strube. 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. - */ - -#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 deleted file mode 100644 index 13500be4c..000000000 --- a/tests/CppUTestExt/MemoryReportAllocatorTest.cpp +++ /dev/null @@ -1,51 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTestExt/MemoryReportFormatter.h" - -TEST_GROUP(MemoryReportAllocator) -{ - MemoryReportAllocator allocator; -}; - -TEST(MemoryReportAllocator, FunctionsAreForwardedForMallocAllocator) -{ - allocator.setRealAllocator(getCurrentMallocAllocator()); - - STRCMP_EQUAL("malloc", allocator.alloc_name()); - STRCMP_EQUAL("free", allocator.free_name()); -} - -TEST(MemoryReportAllocator, keepingTrackOfActualAllocator) -{ - TestMemoryAllocator* originalAllocator = getCurrentMallocAllocator(); - allocator.setRealAllocator(getCurrentMallocAllocator()); - POINTERS_EQUAL(originalAllocator->actualAllocator(), allocator.actualAllocator()); -} diff --git a/tests/CppUTestExt/MemoryReportFormatterTest.cpp b/tests/CppUTestExt/MemoryReportFormatterTest.cpp deleted file mode 100644 index 13b0b190d..000000000 --- a/tests/CppUTestExt/MemoryReportFormatterTest.cpp +++ /dev/null @@ -1,87 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTestExt/MemoryReportAllocator.h" -#include "CppUTestExt/MemoryReportFormatter.h" - -#define TESTOUTPUT_EQUAL(a) STRCMP_EQUAL_LOCATION(a, testOutput.getOutput().asCharString(), "", __FILE__, __LINE__) - -TEST_GROUP(NormalMemoryReportFormatter) -{ - char* memory01; - - StringBufferTestOutput testOutput; - TestResult* testResult; - NormalMemoryReportFormatter formatter; - - void setup() CPPUTEST_OVERRIDE - { - memory01 = (char*) 0x01; - testResult = new TestResult(testOutput); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete testResult; - } -}; - - -TEST(NormalMemoryReportFormatter, mallocCreatesAnMallocCall) -{ - formatter.report_alloc_memory(testResult, defaultMallocAllocator(), 10, memory01, "file", 9); - TESTOUTPUT_EQUAL(StringFromFormat("\tAllocation using malloc of size: 10 pointer: %p at file:9\n", (void*) memory01).asCharString()); -} - -TEST(NormalMemoryReportFormatter, freeCreatesAnFreeCall) -{ - formatter.report_free_memory(testResult, defaultMallocAllocator(), memory01, "boo", 6); - TESTOUTPUT_EQUAL(StringFromFormat("\tDeallocation using free of pointer: %p at boo:6\n", (void*) memory01).asCharString()); -} - -TEST(NormalMemoryReportFormatter, testStarts) -{ - UtestShell test("groupName", "TestName", "file", 1); - formatter.report_test_start(testResult, test); - TESTOUTPUT_EQUAL("TEST(groupName, TestName)\n"); -} - -TEST(NormalMemoryReportFormatter, testEnds) -{ - UtestShell test("groupName", "TestName", "file", 1); - formatter.report_test_end(testResult, test); - TESTOUTPUT_EQUAL("ENDTEST(groupName, TestName)\n"); -} - -TEST(NormalMemoryReportFormatter, testGroupStarts) -{ - UtestShell test("groupName", "TestName", "file", 1); - formatter.report_testgroup_start(testResult, test); - TESTOUTPUT_EQUAL("------------------------------TEST GROUP(groupName)-----------------------------\n"); -} diff --git a/tests/CppUTestExt/MemoryReporterPluginTest.cpp b/tests/CppUTestExt/MemoryReporterPluginTest.cpp deleted file mode 100644 index 2a94646d4..000000000 --- a/tests/CppUTestExt/MemoryReporterPluginTest.cpp +++ /dev/null @@ -1,316 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTestExt/MemoryReporterPlugin.h" -#include "CppUTestExt/MemoryReportFormatter.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockNamedValue.h" - -static TestMemoryAllocator* previousNewAllocator; - -class TemporaryDefaultNewAllocator -{ - TestMemoryAllocator* newAllocator; -public: - TemporaryDefaultNewAllocator(TestMemoryAllocator* oldAllocator) - { - newAllocator = getCurrentNewAllocator(); - setCurrentNewAllocator(oldAllocator); - } - ~TemporaryDefaultNewAllocator() - { - setCurrentNewAllocator(newAllocator); - } -}; - -class MockMemoryReportFormatter : public MemoryReportFormatter -{ -public: - 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) 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) 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) 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 ) 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 ) CPPUTEST_OVERRIDE - { - TemporaryDefaultNewAllocator tempAlloc(previousNewAllocator); - mock("formatter").actualCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", allocator); - } -}; - -static MockMemoryReportFormatter formatterForPluginTest; - -class MemoryReporterPluginUnderTest : public MemoryReporterPlugin -{ -public: - MemoryReportFormatter* createMemoryFormatter(const SimpleString& type) CPPUTEST_OVERRIDE - { - 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) CPPUTEST_OVERRIDE - { - return ((const TestMemoryAllocator*)object1)->name() == ((const TestMemoryAllocator*)object2)->name(); - } - SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE - { - return ((const TestMemoryAllocator*)object)->name(); - } - -}; - -TEST_GROUP(MemoryReporterPlugin) -{ - MemoryReporterPluginUnderTest* reporter; - StringBufferTestOutput output; - TestMemoryAllocatorComparator memLeakAllocatorComparator; - - TestResult* result; - UtestShell* test; - - void setup() CPPUTEST_OVERRIDE - { - previousNewAllocator = getCurrentNewAllocator(); - result = new TestResult(output); - test = new UtestShell("groupname", "testname", "filename", 1); - reporter = new MemoryReporterPluginUnderTest; - - mock("formatter").installComparator("TestMemoryAllocator", memLeakAllocatorComparator); - - mock("reporter").disable(); - const char *cmd_line[] = {"-pmemoryreport=normal"}; - reporter->parseArguments(1, cmd_line, 0); - mock("reporter").enable(); - } - void teardown() CPPUTEST_OVERRIDE - { - setCurrentNewAllocator(previousNewAllocator); - mock().clear(); - delete reporter; - delete test; - delete result; - } -}; - -TEST(MemoryReporterPlugin, offReportsNothing) -{ - MemoryReporterPluginUnderTest freshReporter; - freshReporter.preTestAction(*test, *result); - char* memory = new char; - delete memory; - freshReporter.postTestAction(*test, *result); -} - -TEST(MemoryReporterPlugin, meaninglessArgumentsAreIgnored) -{ - const char *cmd_line[] = {"-nothing", "-pnotmemoryreport=normal", "alsomeaningless", "-pmemoryreportnonsensebutnotus"}; - CHECK(reporter->parseArguments(3, cmd_line, 1) == false); -} - -TEST(MemoryReporterPlugin, commandLineParameterTurnsOnNormalLogging) -{ - mock("reporter").expectOneCall("createMemoryFormatter").onObject(reporter).withParameter("type", "normal"); - - const char *cmd_line[] = {"-nothing", "-pmemoryreport=normal", "alsomeaningless" }; - CHECK(reporter->parseArguments(3, cmd_line, 1)); -} - -TEST(MemoryReporterPlugin, preTestActionReportsTest) -{ - mock("formatter").expectOneCall("report_testgroup_start").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_test_start").withParameter("result", result).withParameter("test", test); - reporter->preTestAction(*test, *result); -} - -TEST(MemoryReporterPlugin, postTestActionReportsTest) -{ - mock("formatter").expectOneCall("report_test_end").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_testgroup_end").withParameter("result", result).withParameter("test", test); - - reporter->postTestAction(*test, *result); -} - -TEST(MemoryReporterPlugin, newAllocationsAreReportedTest) -{ - mock("formatter").expectOneCall("report_alloc_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getNewAllocator()); - mock("formatter").expectOneCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getNewAllocator()); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(*test, *result); - char *memory = getCurrentNewAllocator()->allocMemoryLeakNode(100); - getCurrentNewAllocator()->free_memory(memory, 100, "unknown", 1); -} - -TEST(MemoryReporterPlugin, whenUsingOnlyMallocAllocatorNoOtherOfTheAllocatorsAreUsed) -{ - mock("formatter").expectOneCall("report_test_start").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_alloc_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getMallocAllocator()); - mock("formatter").expectOneCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getMallocAllocator()); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(*test, *result); - char *memory = getCurrentMallocAllocator()->allocMemoryLeakNode(100); - getCurrentMallocAllocator()->free_memory(memory, 100, "unknown", 1); -} - -TEST(MemoryReporterPlugin, newArrayAllocationsAreReportedTest) -{ - mock("formatter").expectOneCall("report_alloc_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getNewArrayAllocator()); - mock("formatter").expectOneCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getNewArrayAllocator()); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(*test, *result); - char *memory = getCurrentNewArrayAllocator()->allocMemoryLeakNode(100); - getCurrentNewArrayAllocator()->free_memory(memory, 100, "unknown", 1); -} - -TEST(MemoryReporterPlugin, mallocAllocationsAreReportedTest) -{ - mock("formatter").expectOneCall("report_alloc_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getMallocAllocator()); - mock("formatter").expectOneCall("report_free_memory").withParameter("result", result).withParameterOfType("TestMemoryAllocator", "allocator", reporter->getMallocAllocator()); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(*test, *result); - char *memory = getCurrentMallocAllocator()->allocMemoryLeakNode(100); - getCurrentMallocAllocator()->free_memory(memory, 100, "unknown", 1); -} - -TEST(MemoryReporterPlugin, startOfANewTestWillReportTheTestGroupStart) -{ - mock("formatter").expectOneCall("report_testgroup_start").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_test_start").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_test_end").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_test_start").withParameter("result", result).withParameter("test", test); - mock("formatter").expectOneCall("report_test_end").withParameter("result", result).withParameter("test", test); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(*test, *result); - reporter->postTestAction(*test, *result); - reporter->preTestAction(*test, *result); - reporter->postTestAction(*test, *result); -} - -class UtestForMemoryReportingPlugingTest : public UtestShell -{ -public: - UtestForMemoryReportingPlugingTest(const char* groupname, UtestShell* test) : UtestShell(groupname, "testname", "filename", 1, test) - { - - } -}; - -TEST(MemoryReporterPlugin, endOfaTestGroupWillReportSo) -{ - UtestForMemoryReportingPlugingTest fourthTest("differentGroupName", NULLPTR); - UtestForMemoryReportingPlugingTest thirdTest("differentGroupName", &fourthTest); - UtestForMemoryReportingPlugingTest secondTest("groupname", &thirdTest); - UtestForMemoryReportingPlugingTest firstTest("groupname", &secondTest); - - mock("formatter").expectOneCall("report_testgroup_end").withParameter("result", result).withParameter("test", &secondTest); - mock("formatter").ignoreOtherCalls(); - - reporter->preTestAction(firstTest, *result); - reporter->postTestAction(firstTest, *result); - reporter->preTestAction(secondTest, *result); - reporter->postTestAction(secondTest, *result); - reporter->preTestAction(thirdTest, *result); - reporter->postTestAction(thirdTest, *result); -} - -TEST(MemoryReporterPlugin, preActionReplacesAllocators) -{ - mock("formatter").ignoreOtherCalls(); - - TestMemoryAllocator* allocator = getCurrentMallocAllocator(); - reporter->preTestAction(*test, *result); - CHECK(allocator != getCurrentMallocAllocator()); -} - -TEST(MemoryReporterPlugin, postActionRestoresAllocators) -{ - mock("formatter").ignoreOtherCalls(); - - TestMemoryAllocator* allocator = getCurrentMallocAllocator(); - reporter->preTestAction(*test, *result); - reporter->postTestAction(*test, *result); - CHECK(allocator == getCurrentMallocAllocator()); -} - -TEST(MemoryReporterPlugin, shouldCreateNormalMemoryReportFormatterWithoutMock) -{ - MemoryReporterPlugin realReporter; - const char *cmd_line[] = {"-pmemoryreport=normal"}; - CHECK(realReporter.parseArguments(1, cmd_line, 0)); -} - -TEST(MemoryReporterPlugin, shouldCreateCodeMemoryReportFormatterWithoutMock) -{ - MemoryReporterPlugin realReporter; - const char *cmd_line[] = {"-pmemoryreport=code"}; - CHECK(realReporter.parseArguments(1, cmd_line, 0)); -} - -TEST(MemoryReporterPlugin, shouldntCrashCreateInvalidMemoryReportFormatterWithoutMock) -{ - MemoryReporterPlugin realReporter; - const char *cmd_line[] = {"-pmemoryreport=foo"}; - CHECK(realReporter.parseArguments(1, cmd_line, 0)); - realReporter.preTestAction(*test, *result); - realReporter.postTestAction(*test, *result); -} diff --git a/tests/CppUTestExt/MockActualCallTest.cpp b/tests/CppUTestExt/MockActualCallTest.cpp deleted file mode 100644 index a38b85200..000000000 --- a/tests/CppUTestExt/MockActualCallTest.cpp +++ /dev/null @@ -1,272 +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/TestHarness.h" -#include "CppUTestExt/MockCheckedActualCall.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "CppUTestExt/MockFailure.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockCheckedActualCall) -{ - MockExpectedCallsList* emptyList; - MockExpectedCallsList* list; - MockFailureReporter* reporter; - - void setup() CPPUTEST_OVERRIDE - { - emptyList = new MockExpectedCallsList; - list = new MockExpectedCallsList; - reporter = MockFailureReporterForTest::getReporter(); - } - - void teardown() CPPUTEST_OVERRIDE - { - CHECK_NO_MOCK_FAILURE(); - - MockFailureReporterForTest::clearReporter(); - - delete emptyList; - delete list; - } -}; - -TEST(MockCheckedActualCall, unExpectedCall) -{ - MockCheckedActualCall actualCall(1, reporter, *emptyList); - actualCall.withName("unexpected"); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "unexpected", *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCheckedActualCall, unExpectedCallWithAParameter) -{ - MockCheckedActualCall actualCall(1, reporter, *emptyList); - actualCall.withName("unexpected").withParameter("bar", 0); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "unexpected", *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCheckedActualCall, unExpectedCallWithAnOutputParameter) -{ - MockCheckedActualCall actualCall(1, reporter, *emptyList); - actualCall.withName("unexpected").withOutputParameter("bar", NULLPTR); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "unexpected", *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCheckedActualCall, unExpectedCallOnObject) -{ - int object; - - MockCheckedActualCall actualCall(1, reporter, *emptyList); - actualCall.withName("unexpected").onObject(&object); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "unexpected", *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - - CHECK(actualCall.hasFailed()); // Checks that onObject() doesn't "reset" call state -} - -TEST(MockCheckedActualCall, actualCallWithNoReturnValueAndMeaninglessCallOrderForCoverage) -{ - MockCheckedActualCall actualCall(1, reporter, *emptyList); - actualCall.withName("noreturn").withCallOrder(0).returnValue(); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "noreturn", *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCheckedActualCall, unExpectedParameterName) -{ - MockCheckedExpectedCall call1; - call1.withName("func"); - list->addExpectedCall(&call1); - - MockCheckedActualCall actualCall(1, reporter, *list); - actualCall.withName("func").withParameter("integer", 1); - - MockNamedValue parameter("integer"); - parameter.setValue(1); - - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "func", parameter, *list); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCheckedActualCall, multipleSameFunctionsExpectingAndHappenGradually) -{ - MockCheckedExpectedCall* call1 = new MockCheckedExpectedCall(); - MockCheckedExpectedCall* call2 = new MockCheckedExpectedCall(); - call1->withName("func"); - call2->withName("func"); - list->addExpectedCall(call1); - list->addExpectedCall(call2); - - LONGS_EQUAL(2, list->amountOfUnfulfilledExpectations()); - - MockCheckedActualCall actualCall1(1, reporter, *list); - actualCall1.withName("func"); - actualCall1.checkExpectations(); - - LONGS_EQUAL(1, list->amountOfUnfulfilledExpectations()); - - MockCheckedActualCall actualCall2(2, reporter, *list); - actualCall2.withName("func"); - actualCall2.checkExpectations(); - - LONGS_EQUAL(0, list->amountOfUnfulfilledExpectations()); - - list->deleteAllExpectationsAndClearList(); -} - -TEST(MockCheckedActualCall, MockIgnoredActualCallWorksAsItShould) -{ - MockIgnoredActualCall actual; - actual.withName("func"); - actual.withCallOrder(1); - - CHECK(false == actual.returnBoolValue()); - CHECK(true == actual.returnBoolValueOrDefault(true)); - CHECK(false == actual.returnBoolValueOrDefault(false)); - CHECK(0 == actual.returnUnsignedLongIntValue()); - CHECK(0 == actual.returnIntValue()); - CHECK(1ul == actual.returnUnsignedLongIntValueOrDefault(1ul)); - CHECK(1 == actual.returnIntValueOrDefault(1)); - CHECK(0 == actual.returnLongIntValue()); - CHECK(1l == actual.returnLongIntValueOrDefault(1l)); - CHECK(0 == actual.returnUnsignedIntValue()); - CHECK(1u == actual.returnUnsignedIntValueOrDefault(1u)); -#if CPPUTEST_USE_LONG_LONG - CHECK(0 == actual.returnLongLongIntValue()); - CHECK(1ll == actual.returnLongLongIntValueOrDefault(1ll)); - CHECK(0 == actual.returnUnsignedLongLongIntValue()); - CHECK(1ull == actual.returnUnsignedLongLongIntValueOrDefault(1ull)); -#endif - DOUBLES_EQUAL(0.0, actual.returnDoubleValue(), 0.0); - DOUBLES_EQUAL(1.5, actual.returnDoubleValueOrDefault(1.5), 0.0); - STRCMP_EQUAL("bla", actual.returnStringValueOrDefault("bla")); - STRCMP_EQUAL("", actual.returnStringValue()); - CHECK(NULLPTR == actual.returnPointerValue()); - CHECK((void*) 0x2 == actual.returnPointerValueOrDefault((void*) 0x2)); - CHECK(NULLPTR == actual.returnConstPointerValue()); - CHECK((const void*) 0x2 == actual.returnConstPointerValueOrDefault((const void*) 0x2)); - CHECK(NULLPTR == actual.returnFunctionPointerValue()); - CHECK((void(*)()) 1 == actual.returnFunctionPointerValueOrDefault((void(*)()) 0x1)); - CHECK_FALSE(actual.hasReturnValue()); - CHECK(actual.returnValue().equals(MockNamedValue(""))); -} - -TEST(MockCheckedActualCall, remainderOfMockActualCallTraceWorksAsItShould) -{ - int value; - const int const_value = 1; - const unsigned char mem_buffer[] = { 0xFE, 0x15 }; - void (*function_value)() = (void (*)())0xDEAD; - MockActualCallTrace actual; - actual.withName("func"); - actual.withCallOrder(1); - actual.onObject(&value); - - actual.withBoolParameter("bool", true); - actual.withUnsignedIntParameter("unsigned_int", (unsigned int) 1); - actual.withUnsignedLongIntParameter("unsigned_long", (unsigned long)1); - actual.withLongIntParameter("long_int", (long int) 1); -#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 - actual.withPointerParameter("pointer", &value); - actual.withConstPointerParameter("const_pointer", &const_value); - actual.withFunctionPointerParameter("function_pointer", function_value); - actual.withMemoryBufferParameter("mem_buffer", mem_buffer, sizeof(mem_buffer)); - actual.withParameterOfType("int", "named_type", &const_value); - - SimpleString expectedString("\nFunction name:func"); - expectedString += " withCallOrder:1"; - expectedString += " onObject:0x"; - expectedString += HexStringFrom(&value); - expectedString += " bool:true"; - expectedString += " unsigned_int:1 (0x1)"; - expectedString += " unsigned_long:1 (0x1)"; - expectedString += " long_int:1 (0x1)"; -#if CPPUTEST_USE_LONG_LONG - expectedString += " long_long_int:1 (0x1)"; - expectedString += " unsigned_long_long_int:1 (0x1)"; -#endif - expectedString += " pointer:0x"; - expectedString += HexStringFrom(&value); - expectedString += " const_pointer:0x"; - expectedString += HexStringFrom(&const_value); - expectedString += " function_pointer:0x"; - expectedString += HexStringFrom(function_value); - expectedString += " mem_buffer:Size = 2 | HexContents = FE 15"; - expectedString += " int named_type:0x"; - expectedString += HexStringFrom(&const_value); - STRCMP_EQUAL(expectedString.asCharString(), actual.getTraceOutput()); - - CHECK_FALSE(actual.hasReturnValue()); - CHECK(actual.returnValue().equals(MockNamedValue(""))); - CHECK(false == actual.returnBoolValue()); - CHECK(false == actual.returnBoolValueOrDefault(true)); - CHECK(0 == actual.returnLongIntValue()); - CHECK(0 == actual.returnUnsignedLongIntValue()); - CHECK(0 == actual.returnIntValue()); - CHECK(0 == actual.returnUnsignedLongIntValueOrDefault(1ul)); - CHECK(0 == actual.returnIntValueOrDefault(1)); - CHECK(0 == actual.returnLongIntValue()); - CHECK(0 == actual.returnLongIntValueOrDefault(1l)); -#if CPPUTEST_USE_LONG_LONG - CHECK(0 == actual.returnLongLongIntValue()); - CHECK(0 == actual.returnLongLongIntValueOrDefault(1ll)); - CHECK(0 == actual.returnUnsignedLongLongIntValue()); - CHECK(0 == actual.returnUnsignedLongLongIntValueOrDefault(1ull)); -#endif - CHECK(0 == actual.returnUnsignedIntValue()); - CHECK(0 == actual.returnUnsignedIntValueOrDefault(1u)); - DOUBLES_EQUAL(0.0, actual.returnDoubleValue(), 0.0); - DOUBLES_EQUAL(0.0, actual.returnDoubleValueOrDefault(1.0), 0.0); - STRCMP_EQUAL("", actual.returnStringValueOrDefault("bla")); - STRCMP_EQUAL("", actual.returnStringValue()); - CHECK(NULLPTR == actual.returnPointerValue()); - CHECK(NULLPTR == actual.returnPointerValueOrDefault((void*) NULLPTR)); - CHECK(NULLPTR == actual.returnConstPointerValue()); - CHECK(NULLPTR == actual.returnConstPointerValueOrDefault((const void*) NULLPTR)); - CHECK(NULLPTR == actual.returnFunctionPointerValue()); - CHECK(NULLPTR == actual.returnFunctionPointerValueOrDefault((void (*)()) NULLPTR)); -} - -TEST(MockCheckedActualCall, MockActualCallTraceClear) -{ - MockActualCallTrace actual; - actual.withName("func"); - actual.clear(); - STRCMP_EQUAL("", actual.getTraceOutput()); -} diff --git a/tests/CppUTestExt/MockCallTest.cpp b/tests/CppUTestExt/MockCallTest.cpp deleted file mode 100644 index 2e36c9aa6..000000000 --- a/tests/CppUTestExt/MockCallTest.cpp +++ /dev/null @@ -1,513 +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/TestHarness.h" -#include "CppUTest/TestTestingFixture.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockCallTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().checkExpectations(); - mock().clear(); - } -}; - -TEST(MockCallTest, clear) -{ - mock().expectOneCall("func"); - mock().clear(); - CHECK(! mock().expectedCallsLeft()); -} - -TEST(MockCallTest, checkExpectationsDoesntFail) -{ - mock().checkExpectations(); -} - -TEST(MockCallTest, expectASingleCallThatHappens) -{ - mock().expectOneCall("func"); - MockCheckedActualCall& actualCall = (MockCheckedActualCall&) mock().actualCall("func"); - actualCall.checkExpectations(); - CHECK(! mock().expectedCallsLeft()); -} - -TEST(MockCallTest, expectASingleCallThatDoesntHappen) -{ - mock().expectOneCall("func"); - CHECK(mock().expectedCallsLeft()); - mock().clear(); -} - -TEST(MockCallTest, expectAMultiCallThatHappensTheExpectedTimes) -{ - mock().expectNCalls(2, "func"); - mock().actualCall("func"); - MockCheckedActualCall& actualCall = (MockCheckedActualCall&) mock().actualCall("func"); - actualCall.checkExpectations(); - CHECK(! mock().expectedCallsLeft()); -} - -TEST(MockCallTest, expectAMultiCallThatDoesntHappenTheExpectedTimes) -{ - mock().expectNCalls(2, "func"); - MockCheckedActualCall& actualCall = (MockCheckedActualCall&) mock().actualCall("func"); - actualCall.checkExpectations(); - CHECK(mock().expectedCallsLeft()); - mock().clear(); -} - -TEST(MockCallTest, checkExpectationsClearsTheExpectations) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foobar"); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectOneCall("foobar"); - mock().checkExpectations(); - - CHECK(! mock().expectedCallsLeft()); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectOneCallInScopeButNotHappen) -{ - - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("scope::foobar"); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock("scope").expectOneCall("foobar"); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - -} - -TEST(MockCallTest, unexpectedCallHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest emptyExpectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "func", emptyExpectations); - - mock().actualCall("func"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, unexpectedScopeCallHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest emptyExpectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "scope::func", emptyExpectations); - - mock("scope").actualCall("func"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectOneCallInOneScopeButActualCallInAnotherScope) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest emptyExpectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "class::foo", emptyExpectations); - - mock("scope").expectOneCall("foo"); - mock("class").actualCall("foo"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - mock().clear(); -} - -TEST(MockCallTest, expectOneCallInScopeButActualCallInGlobal) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest emptyExpectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "foo", emptyExpectations); - - mock("scope").expectOneCall("foo"); - mock().actualCall("foo"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - mock().clear(); -} - - -TEST(MockCallTest, expectMultipleSingleCallsThatHappen) -{ - mock().expectOneCall("foo"); - mock().expectOneCall("foo"); - mock().actualCall("foo"); - mock().actualCall("foo"); - mock().checkExpectations(); -} - -TEST(MockCallTest, expectOneCallHoweverMultipleHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->callWasMade(1); - expectations.addFunction("foo")->callWasMade(2); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "foo", expectations); - - mock().expectOneCall("foo"); - mock().expectOneCall("foo"); - mock().actualCall("foo"); - mock().actualCall("foo"); - mock().actualCall("foo"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNoCallThatHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(0, "lazy"); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "lazy", expectations); - - mock().expectNoCall("lazy"); - mock().actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNoCallDoesntInfluenceExpectOneCall) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(0, "lazy"); - expectations.addFunction("influence")->callWasMade(1); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "lazy", expectations); - - mock().expectNoCall("lazy"); - mock().expectOneCall("influence"); - mock().actualCall("influence"); - mock().actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNoCallOnlyFailureOnceWhenMultipleHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(0, "lazy"); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "lazy", expectations); - - mock().expectNoCall("lazy"); - mock().actualCall("lazy"); - mock().actualCall("lazy"); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, ignoreOtherCallsExceptForTheUnExpectedOne) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(0, "lazy"); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "lazy", expectations); - - mock().expectNoCall("lazy"); - mock().ignoreOtherCalls(); - mock().actualCall("bar").withParameter("foo", 1); - mock().actualCall("bar1").withParameter("foo", 1); - mock().actualCall("bar2").withParameter("foo", 1); - mock().actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - - -TEST(MockCallTest, expectNoCallInScopeThatHappened) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(0, "scope::lazy"); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "scope::lazy", expectations); - - mock("scope").expectNoCall("lazy"); - mock("scope").actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNoCallInScopeButActualCallInAnotherScope) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "scope2::lazy", expectations); - - mock("scope1").expectNoCall("lazy"); - mock("scope2").actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNoCallInScopeButActualCallInGlobal) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "lazy", expectations); - - mock("scope1").expectNoCall("lazy"); - mock().actualCall("lazy"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, ignoreOtherCallsExceptForTheExpectedOne) -{ - mock().expectOneCall("foo"); - mock().ignoreOtherCalls(); - mock().actualCall("bar").withParameter("foo", 1); - - mock().clear(); -} - -TEST(MockCallTest, ignoreOtherCallsDoesntIgnoreMultipleCallsOfTheSameFunction) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->callWasMade(1); - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "foo", expectations); - - mock().expectOneCall("foo"); - mock().ignoreOtherCalls(); - mock().actualCall("bar"); - mock().actualCall("foo"); - mock().actualCall("foo"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, ignoreOtherStillFailsIfExpectedOneDidntHappen) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo"); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectOneCall("foo"); - mock().ignoreOtherCalls(); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, threeExpectedAndActual) -{ - mock().expectOneCall("function1"); - mock().expectOneCall("function2"); - mock().expectOneCall("function3"); - mock().actualCall("function1"); - mock().actualCall("function2"); - mock().actualCall("function3"); - - mock().checkExpectations(); -} - -TEST(MockCallTest, disableEnable) -{ - mock().disable(); - mock().expectOneCall("function"); - mock().actualCall("differenFunction"); - CHECK(! mock().expectedCallsLeft()); - mock().enable(); - mock().expectOneCall("function"); - CHECK(mock().expectedCallsLeft()); - mock().actualCall("function"); - - mock().checkExpectations(); -} - -TEST(MockCallTest, OnObject) -{ - void* objectPtr = (void*) 0x001; - mock().expectOneCall("boo").onObject(objectPtr); - mock().actualCall("boo").onObject(objectPtr); -} - -TEST(MockCallTest, OnObjectIgnored_MatchingAlreadyWhenObjectPassed) -{ - void* objectPtr = (void*) 0x001; - mock().expectOneCall("boo"); - mock().actualCall("boo").onObject(objectPtr); -} - -TEST(MockCallTest, OnObjectIgnored_NotMatchingYetWhenObjectPassed) -{ - void* objectPtr = (void*) 0x001; - mock().expectOneCall("boo").withBoolParameter("p", true); - mock().actualCall("boo").onObject(objectPtr).withBoolParameter("p", true); -} - -TEST(MockCallTest, OnObjectIgnored_InitialMatchDiscarded) -{ - void* objectPtr1 = (void*) 0x001; - void* objectPtr2 = (void*) 0x002; - - mock().expectOneCall("boo"); - mock().expectOneCall("boo").withBoolParameter("p", true); - mock().actualCall("boo").onObject(objectPtr2).withBoolParameter("p", true); - mock().actualCall("boo").onObject(objectPtr1); -} - -TEST(MockCallTest, OnObjectFails) -{ - MockFailureReporterInstaller failureReporterInstaller; - - void* objectPtr = (void*) 0x001; - void* objectPtr2 = (void*) 0x002; - MockExpectedCallsListForTest expectations; - expectations.addFunction("boo")->onObject(objectPtr); - - mock().expectOneCall("boo").onObject(objectPtr); - mock().actualCall("boo").onObject(objectPtr2); - - MockUnexpectedObjectFailure expectedFailure(mockFailureTest(), "boo", objectPtr2, expectations); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, OnObjectExpectedButNotCalled) -{ - MockFailureReporterInstaller failureReporterInstaller; - - void* objectPtr = (void*) 0x001; - MockExpectedCallsListForTest expectations; - expectations.addFunction("boo")->onObject(objectPtr); - expectations.addFunction("boo")->onObject(objectPtr); - - mock().expectOneCall("boo").onObject(objectPtr); - mock().expectOneCall("boo").onObject(objectPtr); - mock().actualCall("boo"); - mock().actualCall("boo"); - - MockExpectedObjectDidntHappenFailure expectedFailure(mockFailureTest(), "boo", expectations); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, expectNCalls_Fulfilled) -{ - mock().expectNCalls(2, "boo"); - mock().actualCall("boo"); - mock().actualCall("boo"); - mock().checkExpectations(); -} - -TEST(MockCallTest, expectNCalls_NotFulfilled) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction(2, "boo")->callWasMade(1); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectNCalls(2, "boo"); - mock().actualCall("boo"); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockCallTest, shouldntFailTwice) -{ - MockFailureReporterInstaller failureReporterInstaller; - - mock().strictOrder(); - mock().expectOneCall("foo"); - mock().expectOneCall("boo"); - mock().actualCall("boo"); - mock().actualCall("bar"); - mock().checkExpectations(); - - CHECK(!MockFailureReporterForTest::getReporter()->mockFailureString.contains("bar")); - CHECK(MockFailureReporterForTest::getReporter()->mockFailureString.contains("boo")); -} - -TEST(MockCallTest, shouldReturnDefaultWhenThereIsntAnythingToReturn) -{ - CHECK(mock().returnValue().equals(MockNamedValue(""))); -} - -IGNORE_TEST(MockCallTest, testForPerformanceProfiling) -{ - /* TO fix! */ - mock().expectNCalls(2000, "SimpleFunction"); - for (int i = 0; i < 2000; i++) { - mock().actualCall("SimpleFunction"); - } -} - -static void mocksAreCountedAsChecksTestFunction_() -{ - mock().expectOneCall("foo"); - mock().expectNCalls(3, "bar"); - mock().expectNoCall("lazy"); - mock().clear(); -} - -TEST(MockCallTest, mockExpectationShouldIncreaseNumberOfChecks) -{ - TestTestingFixture fixture; - fixture.setTestFunction(mocksAreCountedAsChecksTestFunction_); - fixture.runAllTests(); - 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 deleted file mode 100644 index ec74a22ce..000000000 --- a/tests/CppUTestExt/MockCheatSheetTest.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -/* Additional include from CppUTestExt */ -#include "CppUTest/TestHarness.h" -#include "CppUTestExt/MockSupport.h" - -/* Stubbed out product code using linker, function pointer, or overriding */ -static int foo(const char* param_string, int param_int) -{ - /* Tell CppUTest Mocking what we mock. Also return recorded value */ - return mock().actualCall("Foo") - .withParameter("param_string", param_string) - .withParameter("param_int", param_int) - .returnValue().getIntValue(); -} - -static void bar(double param_double, const char* param_string) -{ - mock().actualCall("Bar") - .withParameter("param_double", param_double) - .withParameter("param_string", param_string); -} - -/* Production code calls to the methods we stubbed */ -static int productionCodeFooCalls() -{ - int return_value; - return_value = foo("value_string", 10); - (void)return_value; - return_value = foo("value_string", 10); - return return_value; -} - -static void productionCodeBarCalls() -{ - bar(1.5, "more"); - bar(1.5, "more"); -} - -/* Actual test */ -TEST_GROUP(MockCheatSheet) -{ - void teardown() CPPUTEST_OVERRIDE - { - /* Check expectations. Alternatively use MockSupportPlugin */ - mock().checkExpectations(); - - mock().clear(); - } -}; - -TEST(MockCheatSheet, foo) -{ - /* Record 2 calls to Foo. Return different values on each call */ - mock().expectOneCall("Foo") - .withParameter("param_string", "value_string") - .withParameter("param_int", 10) - .andReturnValue(30); - mock().expectOneCall("Foo") - .ignoreOtherParameters() - .andReturnValue(50); - - /* Call production code */ - productionCodeFooCalls(); -} - -TEST(MockCheatSheet, bar) -{ - /* Expect 2 calls on Bar. Check only one parameter */ - mock().expectNCalls(2, "Bar") - .withParameter("param_double", 1.5) - .ignoreOtherParameters(); - - /* And the production code call */ - productionCodeBarCalls(); -} diff --git a/tests/CppUTestExt/MockComparatorCopierTest.cpp b/tests/CppUTestExt/MockComparatorCopierTest.cpp deleted file mode 100644 index 5cad7a4a5..000000000 --- a/tests/CppUTestExt/MockComparatorCopierTest.cpp +++ /dev/null @@ -1,600 +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/TestHarness.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockComparatorCopierTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().checkExpectations(); - mock().clear(); - mock().removeAllComparatorsAndCopiers(); - } -}; - -class MyTypeForTesting -{ -public: - MyTypeForTesting(long val) - { - value = new long(val); - } - virtual ~MyTypeForTesting() - { - delete value; - } - long *value; -}; - -class MyTypeForTestingComparator : public MockNamedValueComparator -{ -public: - 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) CPPUTEST_OVERRIDE - { - const MyTypeForTesting* obj = (const MyTypeForTesting*) object; - return StringFrom(*(obj->value)); - } -}; - -class MyTypeForTestingCopier : public MockNamedValueCopier -{ -public: - virtual void copy(void* dst_, const void* src_) CPPUTEST_OVERRIDE - { - MyTypeForTesting* dst = (MyTypeForTesting*) dst_; - const MyTypeForTesting* src = (const MyTypeForTesting*) src_; - *(dst->value) = *(src->value); - } -}; - -TEST(MockComparatorCopierTest, customObjectParameterFailsWhenNotHavingAComparisonRepository) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting object(1); - mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock().actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - MockNoWayToCompareCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting"); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockComparatorCopierTest, customObjectParameterFailsWhenNotHavingACopierRepository) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting object(1); - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &object); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &object); - - MockNoWayToCopyCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting"); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockComparatorCopierTest, customObjectParameterSucceeds) -{ - MyTypeForTesting object(1); - MyTypeForTestingComparator comparator; - mock().installComparator("MyTypeForTesting", comparator); - - mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock().actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - mock().checkExpectations(); - - mock().removeAllComparatorsAndCopiers(); -} - -static bool myTypeIsEqual(const void* object1, const void* object2) -{ - return ((const MyTypeForTesting*)object1)->value == ((const MyTypeForTesting*)object2)->value; -} - -static SimpleString myTypeValueToString(const void* object) -{ - return StringFrom(((const MyTypeForTesting*)object)->value); -} - -TEST(MockComparatorCopierTest, customObjectWithFunctionComparator) -{ - MyTypeForTesting object(1); - MockFunctionComparator comparator(myTypeIsEqual, myTypeValueToString); - mock().installComparator("MyTypeForTesting", comparator); - - mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock().actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - mock().checkExpectations(); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customObjectWithFunctionComparatorThatFailsCoversValueToString) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting object(5); - MockFunctionComparator comparator(myTypeIsEqual, myTypeValueToString); - mock().installComparator("MyTypeForTesting", comparator); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("function")->withParameterOfType("MyTypeForTesting", "parameterName", &object); - MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), expectations); - - mock().expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE_LOCATION(failure, __FILE__, __LINE__); -} - -TEST(MockComparatorCopierTest, customTypeOutputParameterSucceeds) -{ - MyTypeForTesting expectedObject(55); - MyTypeForTesting actualObject(99); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject); - - mock().checkExpectations(); - CHECK_EQUAL(55, *(expectedObject.value)); - CHECK_EQUAL(55, *(actualObject.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, noActualCallForCustomTypeOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting expectedObject(1); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, unexpectedCustomTypeOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting actualObject(8834); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo"); - MockNamedValue parameter("parameterName"); - parameter.setConstObjectPointer("MyTypeForTesting", &actualObject); - MockUnexpectedOutputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo"); - mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject); - mock().checkExpectations(); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputParameterMissing) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting expectedObject(123464); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - mock().actualCall("foo"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputParameterOfWrongType) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting expectedObject(123464); - MyTypeForTesting actualObject(75646); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - MockNamedValue parameter("output"); - parameter.setConstObjectPointer("OtherTypeForTesting", &actualObject); - MockUnexpectedOutputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - mock().actualCall("foo").withOutputParameterOfType("OtherTypeForTesting", "output", &actualObject); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, noCopierForCustomTypeOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting expectedObject(123464); - MyTypeForTesting actualObject(8834); - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - MockNoWayToCopyCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting"); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "output", &expectedObject); - mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "output", &actualObject); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockComparatorCopierTest, twoCustomTypeOutputParameters) -{ - MyTypeForTesting expectedObject1(545); - MyTypeForTesting actualObject1(979); - MyTypeForTesting expectedObject2(123); - MyTypeForTesting actualObject2(4567); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject1).withParameter("id", 1); - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject2).withParameter("id", 2); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject1).withParameter("id", 1); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject2).withParameter("id", 2); - - mock().checkExpectations(); - CHECK_EQUAL(545, *(expectedObject1.value)); - CHECK_EQUAL(545, *(actualObject1.value)); - CHECK_EQUAL(123, *(expectedObject2.value)); - CHECK_EQUAL(123, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, twoInterleavedCustomTypeOutputParameters) -{ - MyTypeForTesting expectedObject1(9545); - MyTypeForTesting actualObject1(79); - MyTypeForTesting expectedObject2(132); - MyTypeForTesting actualObject2(743); - MyTypeForTestingCopier copier; - - mock().installCopier("MyTypeForTesting", copier); - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject1).withParameter("id", 1); - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject2).withParameter("id", 2); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject2).withParameter("id", 2); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject1).withParameter("id", 1); - - mock().checkExpectations(); - CHECK_EQUAL(9545, *(expectedObject1.value)); - CHECK_EQUAL(9545, *(actualObject1.value)); - CHECK_EQUAL(132, *(expectedObject2.value)); - CHECK_EQUAL(132, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, twoDifferentCustomTypeOutputParametersInSameFunctionCallSucceeds) -{ - MyTypeForTesting expectedObject1(11); - MyTypeForTesting actualObject1(22); - MyTypeForTesting expectedObject2(33); - MyTypeForTesting actualObject2(44); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - mock().expectOneCall("foo") - .withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject1) - .withOutputParameterOfTypeReturning("MyTypeForTesting", "foobar", &expectedObject2); - mock().actualCall("foo") - .withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject1) - .withOutputParameterOfType("MyTypeForTesting", "foobar", &actualObject2); - - mock().checkExpectations(); - CHECK_EQUAL(11, *(expectedObject1.value)); - CHECK_EQUAL(11, *(actualObject1.value)); - CHECK_EQUAL(33, *(expectedObject2.value)); - CHECK_EQUAL(33, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputAndInputParametersOfSameNameInDifferentFunctionCallsOfSameFunctionSucceeds) -{ - MyTypeForTesting expectedObject1(911); - MyTypeForTesting actualObject1(6576878); - MyTypeForTesting expectedObject2(123); - MyTypeForTesting actualObject2(123); - MyTypeForTestingCopier copier; - MyTypeForTestingComparator comparator; - mock().installCopier("MyTypeForTesting", copier); - mock().installComparator("MyTypeForTesting", comparator); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject1); - mock().expectOneCall("foo").withParameterOfType("MyTypeForTesting", "bar", &expectedObject2); - mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject1); - mock().actualCall("foo").withParameterOfType("MyTypeForTesting", "bar", &actualObject2); - - mock().checkExpectations(); - CHECK_EQUAL(911, *(expectedObject1.value)); - CHECK_EQUAL(911, *(actualObject1.value)); - CHECK_EQUAL(123, *(expectedObject2.value)); - CHECK_EQUAL(123, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, twoCustomTypeOutputParametersOfSameNameInDifferentFunctionsSucceeds) -{ - MyTypeForTesting expectedObject1(657); - MyTypeForTesting actualObject1(984465); - MyTypeForTesting expectedObject2(987); - MyTypeForTesting actualObject2(987); - MyTypeForTestingCopier copier; - MyTypeForTestingComparator comparator; - mock().installCopier("MyTypeForTesting", copier); - mock().installComparator("MyTypeForTesting", comparator); - - mock().expectOneCall("foo1").withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject1); - mock().expectOneCall("foo2").withParameterOfType("MyTypeForTesting", "bar", &expectedObject2); - mock().actualCall("foo1").withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject1); - mock().actualCall("foo2").withParameterOfType("MyTypeForTesting", "bar", &actualObject2); - - mock().checkExpectations(); - CHECK_EQUAL(657, *(expectedObject1.value)); - CHECK_EQUAL(657, *(actualObject1.value)); - CHECK_EQUAL(987, *(expectedObject2.value)); - CHECK_EQUAL(987, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputAndInputParameterOfSameTypeInSameFunctionCall) -{ - MyTypeForTesting expectedObject1(45); - MyTypeForTesting actualObject1(45); - MyTypeForTesting expectedObject2(987765443); - MyTypeForTesting actualObject2(0); - MyTypeForTestingCopier copier; - MyTypeForTestingComparator comparator; - mock().installCopier("MyTypeForTesting", copier); - mock().installComparator("MyTypeForTesting", comparator); - - mock().expectOneCall("foo") - .withParameterOfType("MyTypeForTesting", "bar", &expectedObject1) - .withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject2); - mock().actualCall("foo") - .withParameterOfType("MyTypeForTesting", "bar", &actualObject1) - .withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject2); - - mock().checkExpectations(); - CHECK_EQUAL(45, *(expectedObject1.value)); - CHECK_EQUAL(45, *(actualObject1.value)); - CHECK_EQUAL(987765443, *(expectedObject2.value)); - CHECK_EQUAL(987765443, *(actualObject2.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputParameterTraced) -{ - MyTypeForTesting actualObject(676789); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - mock().tracing(true); - - mock().actualCall("someFunc").withOutputParameterOfType("MyTypeForTesting", "someParameter", &actualObject); - - mock().checkExpectations(); - STRCMP_CONTAINS("Function name:someFunc MyTypeForTesting someParameter:", mock().getTraceOutput()); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, customTypeOutputParameterWithIgnoredParameters) -{ - MyTypeForTesting expectedObject(444537909); - MyTypeForTesting actualObject(98765); - MyTypeForTestingCopier copier; - mock().installCopier("MyTypeForTesting", copier); - - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &expectedObject).ignoreOtherParameters(); - mock().actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "bar", &actualObject).withParameter("other", 1); - - mock().checkExpectations(); - CHECK_EQUAL(444537909, *(expectedObject.value)); - CHECK_EQUAL(444537909, *(actualObject.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -static void myTypeCopy(void* dst_, const void* src_) -{ - MyTypeForTesting* dst = (MyTypeForTesting*) dst_; - const MyTypeForTesting* src = (const MyTypeForTesting*) src_; - *(dst->value) = *(src->value); -} - -TEST(MockComparatorCopierTest, customObjectWithFunctionCopier) -{ - MyTypeForTesting expectedObject(9874452); - MyTypeForTesting actualObject(2034); - MockFunctionCopier copier(myTypeCopy); - mock().installCopier("MyTypeForTesting", copier); - - mock().expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &expectedObject); - mock().actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &actualObject); - - mock().checkExpectations(); - CHECK_EQUAL(9874452, *(expectedObject.value)); - CHECK_EQUAL(9874452, *(actualObject.value)); - - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, removingComparatorsWorksHierachically) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MyTypeForTesting object(1); - MyTypeForTestingComparator comparator; - - mock("scope").installComparator("MyTypeForTesting", comparator); - mock().removeAllComparatorsAndCopiers(); - mock("scope").expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock("scope").actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - MockNoWayToCompareCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting"); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockComparatorCopierTest, removingCopiersWorksHierachically) -{ - MockFailureReporterInstaller failureReporterInstaller; - MyTypeForTesting object(1); - - MyTypeForTestingCopier copier; - - mock("scope").installCopier("MyTypeForTesting", copier); - mock().removeAllComparatorsAndCopiers(); - mock("scope").expectOneCall("foo").withOutputParameterOfTypeReturning("MyTypeForTesting", "bar", &object); - mock("scope").actualCall("foo").withOutputParameterOfType("MyTypeForTesting", "bar", &object); - - MockNoWayToCopyCustomTypeFailure expectedFailure(mockFailureTest(), "MyTypeForTesting"); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockComparatorCopierTest, installComparatorWorksHierarchicalOnBothExistingAndDynamicallyCreatedMockSupports) -{ - MyTypeForTesting object(1); - MyTypeForTestingComparator comparator; - - mock("existing"); - mock().installComparator("MyTypeForTesting", comparator); - mock("existing").expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock("existing").actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock("dynamic").expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock("dynamic").actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - mock().checkExpectations(); - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, installComparatorsWorksHierarchical) -{ - MyTypeForTesting object(1); - MyTypeForTestingComparator comparator; - MockNamedValueComparatorsAndCopiersRepository repos; - repos.installComparator("MyTypeForTesting", comparator); - - mock("existing"); - mock().installComparatorsAndCopiers(repos); - mock("existing").expectOneCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - mock("existing").actualCall("function").withParameterOfType("MyTypeForTesting", "parameterName", &object); - - mock().checkExpectations(); - mock().removeAllComparatorsAndCopiers(); -} - -TEST(MockComparatorCopierTest, installCopiersWorksHierarchically) -{ - MyTypeForTesting object(1); - MyTypeForTestingCopier copier; - - mock("existing"); - mock().installCopier("MyTypeForTesting", copier); - mock("existing").expectOneCall("function").withOutputParameterOfTypeReturning("MyTypeForTesting", "parameterName", &object); - mock("existing").actualCall("function").withOutputParameterOfType("MyTypeForTesting", "parameterName", &object); - - mock().checkExpectations(); - mock().removeAllComparatorsAndCopiers(); -} - -class StubComparator : public MockNamedValueComparator -{ -public: - virtual bool isEqual(const void*, const void*) CPPUTEST_OVERRIDE - { - return true; - } - virtual SimpleString valueToString(const void*) CPPUTEST_OVERRIDE - { - return ""; - } -}; - -struct SomeClass -{ - int someDummy_; -}; - -static void functionWithConstParam(const SomeClass param) -{ - mock().actualCall("functionWithConstParam").withParameterOfType("SomeClass", "param", ¶m); -} - -TEST(MockComparatorCopierTest, shouldSupportConstParameters) -{ - StubComparator comparator; - mock().installComparator("SomeClass", comparator); - - SomeClass param; - mock().expectOneCall("functionWithConstParam").withParameterOfType("SomeClass", "param", ¶m); - functionWithConstParam(param); - - mock().checkExpectations(); -} diff --git a/tests/CppUTestExt/MockExpectedCallTest.cpp b/tests/CppUTestExt/MockExpectedCallTest.cpp deleted file mode 100644 index 7bd76aa73..000000000 --- a/tests/CppUTestExt/MockExpectedCallTest.cpp +++ /dev/null @@ -1,813 +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/TestHarness.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockFailure.h" -#include "MockFailureReporterForTest.h" - -class TypeForTestingExpectedFunctionCall -{ -public: - TypeForTestingExpectedFunctionCall(int val) - { - value = new int(val); - } - virtual ~TypeForTestingExpectedFunctionCall() - { - delete value; - } - int *value; -}; - -class TypeForTestingExpectedFunctionCallComparator : public MockNamedValueComparator -{ -public: - 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) CPPUTEST_OVERRIDE - { - const TypeForTestingExpectedFunctionCall* obj = (const TypeForTestingExpectedFunctionCall*) object; - return StringFrom(*(obj->value)); - } -}; - -class TypeForTestingExpectedFunctionCallCopier : public MockNamedValueCopier -{ -public: - virtual void copy(void* dst_, const void* src_) CPPUTEST_OVERRIDE - { - TypeForTestingExpectedFunctionCall* dst = (TypeForTestingExpectedFunctionCall*) dst_; - const TypeForTestingExpectedFunctionCall* src = (const TypeForTestingExpectedFunctionCall*) src_; - *(dst->value) = *(src->value); - } -}; - -TEST_GROUP(MockNamedValueHandlerRepository) -{ - void teardown() CPPUTEST_OVERRIDE - { - CHECK_NO_MOCK_FAILURE(); - MockFailureReporterForTest::clearReporter(); - } -}; - -TEST(MockNamedValueHandlerRepository, getComparatorForNonExistingName) -{ - MockNamedValueComparatorsAndCopiersRepository repository; - POINTERS_EQUAL(NULLPTR, repository.getComparatorForType("typeName")); -} - -TEST(MockNamedValueHandlerRepository, installComparator) -{ - TypeForTestingExpectedFunctionCallComparator comparator; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installComparator("typeName", comparator); - POINTERS_EQUAL(&comparator, repository.getComparatorForType("typeName")); -} - -TEST(MockNamedValueHandlerRepository, installMultipleComparators) -{ - TypeForTestingExpectedFunctionCallComparator comparator1, comparator2, comparator3; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installComparator("type1", comparator1); - repository.installComparator("type2", comparator2); - repository.installComparator("type3", comparator3); - POINTERS_EQUAL(&comparator3, repository.getComparatorForType("type3")); - POINTERS_EQUAL(&comparator2, repository.getComparatorForType("type2")); - POINTERS_EQUAL(&comparator1, repository.getComparatorForType("type1")); -} - -TEST(MockNamedValueHandlerRepository, getCopierForNonExistingName) -{ - MockNamedValueComparatorsAndCopiersRepository repository; - POINTERS_EQUAL(NULLPTR, repository.getCopierForType("typeName")); -} - -TEST(MockNamedValueHandlerRepository, installCopier) -{ - TypeForTestingExpectedFunctionCallCopier copier; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installCopier("typeName", copier); - POINTERS_EQUAL(&copier, repository.getCopierForType("typeName")); -} - -TEST(MockNamedValueHandlerRepository, installMultipleCopiers) -{ - TypeForTestingExpectedFunctionCallCopier copier1, copier2, copier3; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installCopier("type1", copier1); - repository.installCopier("type2", copier2); - repository.installCopier("type3", copier3); - POINTERS_EQUAL(&copier3, repository.getCopierForType("type3")); - POINTERS_EQUAL(&copier2, repository.getCopierForType("type2")); - POINTERS_EQUAL(&copier1, repository.getCopierForType("type1")); -} - -TEST(MockNamedValueHandlerRepository, installMultipleHandlers) -{ - TypeForTestingExpectedFunctionCallCopier copier1, copier2, copier3; - TypeForTestingExpectedFunctionCallComparator comparator1, comparator2, comparator3; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installCopier("type1", copier1); - repository.installComparator("type1", comparator1); - repository.installCopier("type2", copier2); - repository.installCopier("type3", copier3); - repository.installComparator("type2", comparator2); - repository.installComparator("type3", comparator3); - POINTERS_EQUAL(&comparator3, repository.getComparatorForType("type3")); - POINTERS_EQUAL(&comparator2, repository.getComparatorForType("type2")); - POINTERS_EQUAL(&comparator1, repository.getComparatorForType("type1")); - POINTERS_EQUAL(&copier3, repository.getCopierForType("type3")); - POINTERS_EQUAL(&copier2, repository.getCopierForType("type2")); - POINTERS_EQUAL(&copier1, repository.getCopierForType("type1")); -} - -TEST_GROUP(MockExpectedCall) -{ - MockCheckedExpectedCall* call; - MockNamedValueComparatorsAndCopiersRepository* originalComparatorRepository; - void setup() CPPUTEST_OVERRIDE - { - originalComparatorRepository = MockNamedValue::getDefaultComparatorsAndCopiersRepository(); - call = new MockCheckedExpectedCall(1); - call->withName("funcName"); - } - void teardown() CPPUTEST_OVERRIDE - { - MockNamedValue::setDefaultComparatorsAndCopiersRepository(originalComparatorRepository); - delete call; - CHECK_NO_MOCK_FAILURE(); - MockFailureReporterForTest::clearReporter(); - } -}; - -TEST(MockExpectedCall, callWithoutParameterSetOrNotFound) -{ - STRCMP_EQUAL("", call->getInputParameterType("nonexisting").asCharString()); - LONGS_EQUAL(0, call->getInputParameter("nonexisting").getIntValue()); - CHECK(!call->hasInputParameterWithName("nonexisting")); -} - -TEST(MockExpectedCall, callWithUnsignedIntegerParameter) -{ - const SimpleString paramName = "paramName"; - unsigned int value = 356; - call->withParameter(paramName, value); - STRCMP_EQUAL("unsigned int", call->getInputParameterType(paramName).asCharString()); - LONGS_EQUAL(value, call->getInputParameter(paramName).getUnsignedIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> unsigned int paramName: <356 (0x164)>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithIntegerParameter) -{ - const SimpleString paramName = "paramName"; - int value = 2; - call->withParameter(paramName, value); - STRCMP_EQUAL("int", call->getInputParameterType(paramName).asCharString()); - LONGS_EQUAL(value, call->getInputParameter(paramName).getIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> int paramName: <2 (0x2)>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithBooleanParameter) -{ - const SimpleString paramName = "paramName"; - bool value = true; - call->withParameter(paramName, value); - STRCMP_EQUAL("bool", call->getInputParameterType(paramName).asCharString()); - CHECK_EQUAL(value, call->getInputParameter(paramName).getBoolValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> bool paramName: ", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithUnsignedLongIntegerParameter) -{ - const SimpleString paramName = "paramName"; - unsigned long value = 888; - call->withParameter(paramName, value); - STRCMP_EQUAL("unsigned long int", call->getInputParameterType(paramName).asCharString()); - LONGS_EQUAL(value, call->getInputParameter(paramName).getUnsignedLongIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> unsigned long int paramName: <888 (0x378)>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithLongIntegerParameter) -{ - const SimpleString paramName = "paramName"; - long value = 777; - call->withParameter(paramName, value); - STRCMP_EQUAL("long int", call->getInputParameterType(paramName).asCharString()); - LONGS_EQUAL(value, call->getInputParameter(paramName).getLongIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> long int paramName: <777 (0x309)>", call->callToString().asCharString()); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockExpectedCall, callWithUnsignedLongLongIntegerParameter) -{ - const SimpleString paramName = "paramName"; - unsigned long long value = 888; - call->withParameter(paramName, value); - STRCMP_EQUAL("unsigned long long int", call->getInputParameterType(paramName).asCharString()); - UNSIGNED_LONGLONGS_EQUAL(value, call->getInputParameter(paramName).getUnsignedLongLongIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> unsigned long long int paramName: <888 (0x378)>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithLongLongIntegerParameter) -{ - const SimpleString paramName = "paramName"; - long long value = 777; - call->withParameter(paramName, value); - STRCMP_EQUAL("long long int", call->getInputParameterType(paramName).asCharString()); - LONGLONGS_EQUAL(value, call->getInputParameter(paramName).getLongLongIntValue()); - CHECK(call->hasInputParameterWithName(paramName)); - STRCMP_CONTAINS("funcName -> long long int paramName: <777 (0x309)>", call->callToString().asCharString()); -} - -#endif - -TEST(MockExpectedCall, callWithDoubleParameter) -{ - const SimpleString paramName = "paramName"; - double value = 1.2; - call->withParameter(paramName, value); - STRCMP_EQUAL("double", call->getInputParameterType(paramName).asCharString()); - DOUBLES_EQUAL(value, call->getInputParameter(paramName).getDoubleValue(), 0.0); - STRCMP_CONTAINS("funcName -> double paramName: <1.2>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithDoubleParameterAndTolerance) -{ - const SimpleString paramName = "paramName"; - double value = 1.2; - double tolerance = 0.2; - call->withParameter(paramName, value, tolerance); - STRCMP_EQUAL("double", call->getInputParameterType(paramName).asCharString()); - DOUBLES_EQUAL(value, call->getInputParameter(paramName).getDoubleValue(), 0.0); - DOUBLES_EQUAL(tolerance, call->getInputParameter(paramName).getDoubleTolerance(), 0.0); - STRCMP_CONTAINS("funcName -> double paramName: <1.2>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithStringParameter) -{ - const SimpleString paramName = "paramName"; - const char* value = "hello world"; - call->withParameter(paramName, value); - STRCMP_EQUAL("const char*", call->getInputParameterType(paramName).asCharString()); - STRCMP_EQUAL(value, call->getInputParameter(paramName).getStringValue()); - STRCMP_CONTAINS("funcName -> const char* paramName: ", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithPointerParameter) -{ - const SimpleString paramName = "paramName"; - void* value = (void*) 0x123; - call->withParameter(paramName, value); - STRCMP_EQUAL("void*", call->getInputParameterType(paramName).asCharString()); - POINTERS_EQUAL(value, call->getInputParameter(paramName).getPointerValue()); - STRCMP_CONTAINS("funcName -> void* paramName: <0x123>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithConstPointerParameter) -{ - const SimpleString paramName = "paramName"; - const void* value = (const void*) 0x345; - call->withParameter(paramName, value); - STRCMP_EQUAL("const void*", call->getInputParameterType(paramName).asCharString()); - POINTERS_EQUAL(value, call->getInputParameter(paramName).getConstPointerValue()); - STRCMP_CONTAINS("funcName -> const void* paramName: <0x345>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithFunctionPointerParameter) -{ - const SimpleString paramName = "paramName"; - void (*value)() = (void (*)()) 0xdead; - call->withParameter(paramName, value); - STRCMP_EQUAL("void (*)()", call->getInputParameterType(paramName).asCharString()); - FUNCTIONPOINTERS_EQUAL(value, call->getInputParameter(paramName).getFunctionPointerValue()); - STRCMP_CONTAINS("funcName -> void (*)() paramName: <0xdead>", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithMemoryBuffer) -{ - const SimpleString paramName = "paramName"; - const unsigned char value[] = { 0x12, 0xFE, 0xA1 }; - call->withParameter(paramName, value, sizeof(value)); - STRCMP_EQUAL("const unsigned char*", call->getInputParameterType(paramName).asCharString()); - 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()); -} - -TEST(MockExpectedCall, callWithObjectParameter) -{ - const SimpleString paramName = "paramName"; - void* value = (void*) 0x123; - call->withParameterOfType("ClassName", paramName, value); - POINTERS_EQUAL(value, call->getInputParameter(paramName).getConstObjectPointer()); - STRCMP_EQUAL("ClassName", call->getInputParameterType(paramName).asCharString()); - STRCMP_CONTAINS("funcName -> ClassName paramName: ", call->callToString().asCharString()); -} - -TEST(MockExpectedCall, callWithObjectParameterUnequalComparison) -{ - TypeForTestingExpectedFunctionCall type(1), unequalType(2); - MockNamedValue parameter("name"); - parameter.setConstObjectPointer("type", &unequalType); - call->withParameterOfType("type", "name", &type); - CHECK(!call->hasInputParameter(parameter)); -} - -TEST(MockExpectedCall, callWithObjectParameterEqualComparisonButFailsWithoutRepository) -{ - TypeForTestingExpectedFunctionCall type(1), equalType(1); - MockNamedValue parameter("name"); - parameter.setConstObjectPointer("type", &equalType); - call->withParameterOfType("type", "name", &type); - CHECK(!call->hasInputParameter(parameter)); -} - -TEST(MockExpectedCall, callWithObjectParameterEqualComparisonButFailsWithoutComparator) -{ - MockNamedValueComparatorsAndCopiersRepository repository; - MockNamedValue::setDefaultComparatorsAndCopiersRepository(&repository); - - TypeForTestingExpectedFunctionCall type(1), equalType(1); - MockNamedValue parameter("name"); - parameter.setConstObjectPointer("type", &equalType); - call->withParameterOfType("type", "name", &type); - CHECK(!call->hasInputParameter(parameter)); -} - -TEST(MockExpectedCall, callWithObjectParameterEqualComparison) -{ - TypeForTestingExpectedFunctionCallComparator comparator; - MockNamedValueComparatorsAndCopiersRepository repository; - MockNamedValue::setDefaultComparatorsAndCopiersRepository(&repository); - repository.installComparator("type", comparator); - - TypeForTestingExpectedFunctionCall type(1), equalType(1); - MockNamedValue parameter("name"); - parameter.setConstObjectPointer("type", &equalType); - - call->withParameterOfType("type", "name", &type); - CHECK(call->hasInputParameter(parameter)); -} - -TEST(MockExpectedCall, getParameterValueOfObjectType) -{ - TypeForTestingExpectedFunctionCallComparator comparator; - MockNamedValueComparatorsAndCopiersRepository repository; - MockNamedValue::setDefaultComparatorsAndCopiersRepository(&repository); - repository.installComparator("type", comparator); - - TypeForTestingExpectedFunctionCall type(1); - call->withParameterOfType("type", "name", &type); - POINTERS_EQUAL(&type, call->getInputParameter("name").getConstObjectPointer()); - STRCMP_EQUAL("1", call->getInputParameterValueString("name").asCharString()); -} - -TEST(MockExpectedCall, getParameterValueOfObjectTypeWithoutRepository) -{ - TypeForTestingExpectedFunctionCall type(1); - call->withParameterOfType("type", "name", &type); - STRCMP_EQUAL("No comparator found for type: \"type\"", call->getInputParameterValueString("name").asCharString()); -} - -TEST(MockExpectedCall, getParameterValueOfObjectTypeWithoutComparator) -{ - TypeForTestingExpectedFunctionCall type(1); - MockNamedValueComparatorsAndCopiersRepository repository; - MockNamedValue::setDefaultComparatorsAndCopiersRepository(&repository); - call->withParameterOfType("type", "name", &type); - STRCMP_EQUAL("No comparator found for type: \"type\"", call->getInputParameterValueString("name").asCharString()); -} - -TEST(MockExpectedCall, callWithTwoUnsignedIntegerParameter) -{ - unsigned int expected_value = 1; - unsigned int another_expected_value = 2; - - call->withParameter("unsigned-integer1", expected_value); - call->withParameter("unsigned-integer2", another_expected_value); - STRCMP_EQUAL("unsigned int", call->getInputParameterType("unsigned-integer1").asCharString()); - STRCMP_EQUAL("unsigned int", call->getInputParameterType("unsigned-integer2").asCharString()); - LONGS_EQUAL(expected_value, call->getInputParameter("unsigned-integer1").getUnsignedIntValue()); - LONGS_EQUAL(another_expected_value, call->getInputParameter("unsigned-integer2").getUnsignedIntValue()); -} - -TEST(MockExpectedCall, callWithTwoIntegerParameter) -{ - int expected_value = 1; - int another_expected_value = -1; - - call->withParameter("integer1", expected_value); - call->withParameter("integer2", another_expected_value); - STRCMP_EQUAL("int", call->getInputParameterType("integer1").asCharString()); - STRCMP_EQUAL("int", call->getInputParameterType("integer2").asCharString()); - LONGS_EQUAL(expected_value, call->getInputParameter("integer1").getIntValue()); - LONGS_EQUAL(another_expected_value, call->getInputParameter("integer2").getIntValue()); -} - -TEST(MockExpectedCall, callWithThreeDifferentParameter) -{ - call->withParameter("integer", 1); - call->withParameter("string", "hello world"); - call->withParameter("double", 0.12); - STRCMP_EQUAL("int", call->getInputParameterType("integer").asCharString()); - STRCMP_EQUAL("const char*", call->getInputParameterType("string").asCharString()); - STRCMP_EQUAL("double", call->getInputParameterType("double").asCharString()); - LONGS_EQUAL(1, call->getInputParameter("integer").getIntValue()); - STRCMP_EQUAL("hello world", call->getInputParameter("string").getStringValue()); - DOUBLES_EQUAL(0.12, call->getInputParameter("double").getDoubleValue(), 0.05); -} - -TEST(MockExpectedCall, singleCallNotMadeIsNotFulfilledButCanMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - CHECK(!expectedCall.isFulfilled()); - CHECK(expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, singleCallMadeIsFulFilledAndCannotMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.callWasMade(1); - CHECK(expectedCall.isFulfilled()); - CHECK(!expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, multiCallNotMadeIsNotFulfilledButCanMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(2); - expectedCall.withName("name"); - CHECK(!expectedCall.isFulfilled()); - CHECK(expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, multiCallNotMadeExpectedTimesIsNotFulfilledButCanMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(2); - expectedCall.withName("name"); - expectedCall.callWasMade(1); - CHECK(!expectedCall.isFulfilled()); - CHECK(expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, multiCallsMadeExpectedTimesIsFulfilledAndCannotMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(3); - expectedCall.withName("name"); - expectedCall.callWasMade(1); - expectedCall.callWasMade(2); - expectedCall.callWasMade(3); - CHECK(expectedCall.isFulfilled()); - CHECK(!expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, multiCallsMadeMoreThanExpectedTimesIsNotFulfilledAndCannotMatchActualCalls) -{ - MockCheckedExpectedCall expectedCall(3); - expectedCall.withName("name"); - expectedCall.callWasMade(1); - expectedCall.callWasMade(2); - expectedCall.callWasMade(3); - expectedCall.callWasMade(4); - CHECK(!expectedCall.isFulfilled()); - CHECK(!expectedCall.canMatchActualCalls()); -} - -TEST(MockExpectedCall, callsWithoutParameterAlwaysMatch) -{ - MockCheckedExpectedCall expectedCall(1); - CHECK(expectedCall.isMatchingActualCall()); -} - -TEST(MockExpectedCall, callsWithParameterNotFulfilledDontMatch) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withParameter("para", 1); - CHECK(!expectedCall.isMatchingActualCall()); -} - -TEST(MockExpectedCall, callsWithParameterFulfilledDoMatch) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withParameter("para", 1); - expectedCall.inputParameterWasPassed("para"); - CHECK(expectedCall.isMatchingActualCall()); -} - -TEST(MockExpectedCall, callsWithSomeParametersNotFulfilledDontMatch) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withParameter("para", 1).withParameter("two", 2); - expectedCall.inputParameterWasPassed("para"); - CHECK(!expectedCall.isMatchingActualCall()); -} - -TEST(MockExpectedCall, toStringForNoParametersSingleCallNotCalled) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - STRCMP_EQUAL("name -> no parameters (expected 1 call, called 0 times)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForNoParametersMultiCallCalledLessThanExpectedTimes) -{ - MockCheckedExpectedCall expectedCall(2); - expectedCall.withName("name"); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> no parameters (expected 2 calls, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForNoParametersMultiCallCalledExpectedTimes) -{ - MockCheckedExpectedCall expectedCall(2); - expectedCall.withName("name"); - expectedCall.callWasMade(1); - expectedCall.callWasMade(2); - STRCMP_EQUAL("name -> no parameters (expected 2 calls, called 2 times)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForIgnoredParameters) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.ignoreOtherParameters(); - STRCMP_EQUAL("name -> all parameters ignored (expected 1 call, called 0 times)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForMultipleInputParameters) -{ - int int_value = 10; - unsigned int uint_value = 7; - - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withParameter("string", "value"); - expectedCall.withParameter("integer", int_value); - expectedCall.withParameter("unsigned-integer", uint_value); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> const char* string: , int integer: <10 (0xa)>, unsigned int unsigned-integer: <7 (0x7)> " - "(expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForMultipleInputAndOutputParameters) -{ - int int_value = 10; - unsigned int uint_value = 7; - unsigned char buffer_value[3]; - - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withParameter("string", "value"); - expectedCall.withParameter("integer", int_value); - expectedCall.withParameter("unsigned-integer", uint_value); - expectedCall.withOutputParameterReturning("buffer", buffer_value, sizeof(buffer_value)); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> const char* string: , int integer: <10 (0xa)>, unsigned int unsigned-integer: <7 (0x7)>, " - "const void* buffer: (expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForMultipleOutputParameters) -{ - unsigned char buffer_value[3]; - - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withOutputParameterReturning("buffer1", buffer_value, sizeof(buffer_value)); - expectedCall.withOutputParameterReturning("buffer2", buffer_value, sizeof(buffer_value)); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> const void* buffer1: , const void* buffer2: (expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForUnmodifiedOutputParameter) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withUnmodifiedOutputParameter("buffer1"); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> const void* buffer1: (expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForParameterAndIgnored) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withParameter("string", "value"); - expectedCall.ignoreOtherParameters(); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> const char* string: , other parameters are ignored (expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForCallOrderSingle) -{ - MockCheckedExpectedCall expectedCall(1); - expectedCall.withName("name"); - expectedCall.withCallOrder(2); - expectedCall.callWasMade(1); - STRCMP_EQUAL("name -> expected call order: <2> -> no parameters (expected 1 call, called 1 time)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, toStringForCallOrderMultiple) -{ - MockCheckedExpectedCall expectedCall(5); - expectedCall.withName("name"); - expectedCall.withCallOrder(5, 9); - expectedCall.callWasMade(5); - expectedCall.callWasMade(6); - expectedCall.callWasMade(7); - expectedCall.callWasMade(8); - expectedCall.callWasMade(9); - STRCMP_EQUAL("name -> expected calls order: <5..9> -> no parameters (expected 5 calls, called 5 times)", expectedCall.callToString().asCharString()); -} - -TEST(MockExpectedCall, callOrderIsFulfilledButWithWrongOrderSingle) -{ - call->withName("name"); - call->withCallOrder(2); - call->callWasMade(1); - CHECK(call->isFulfilled()); - CHECK(call->isOutOfOrder()); -} - -TEST(MockExpectedCall, callOrderIsFulfilledButWithWrongOrderMultipleTooEarly) -{ - MockCheckedExpectedCall expectedCall(3); - expectedCall.withName("name"); - expectedCall.withCallOrder(10, 12); - expectedCall.callWasMade(9); - expectedCall.callWasMade(10); - expectedCall.callWasMade(11); - CHECK(expectedCall.isFulfilled()); - CHECK(expectedCall.isOutOfOrder()); -} - -TEST(MockExpectedCall, callOrderIsFulfilledButWithWrongOrderMultipleTooLate) -{ - MockCheckedExpectedCall expectedCall(3); - expectedCall.withName("name"); - expectedCall.withCallOrder(10, 12); - expectedCall.callWasMade(11); - expectedCall.callWasMade(12); - expectedCall.callWasMade(13); - CHECK(expectedCall.isFulfilled()); - CHECK(expectedCall.isOutOfOrder()); -} - -TEST(MockExpectedCall, callOrderIsFulfilledSingle) -{ - call->withName("name"); - call->withCallOrder(1); - call->callWasMade(1); - CHECK(call->isFulfilled()); - CHECK_FALSE(call->isOutOfOrder()); -} - -TEST(MockExpectedCall, callOrderIsFulfilledMultiple) -{ - MockCheckedExpectedCall expectedCall(4); - expectedCall.withName("name"); - expectedCall.withCallOrder(150, 153); - expectedCall.callWasMade(150); - expectedCall.callWasMade(151); - expectedCall.callWasMade(152); - expectedCall.callWasMade(153); - CHECK(expectedCall.isFulfilled()); - CHECK_FALSE(expectedCall.isOutOfOrder()); -} - -TEST(MockExpectedCall, hasOutputParameter) -{ - const int value = 1; - call->withOutputParameterReturning("foo", &value, sizeof(value)); - MockNamedValue foo("foo"); - foo.setValue(&value); - CHECK(call->hasOutputParameter(foo)); -} - -TEST(MockExpectedCall, hasUnmodifiedOutputParameter) -{ - call->withUnmodifiedOutputParameter("foo"); - MockNamedValue foo("foo"); - foo.setValue((const void *)NULLPTR); - foo.setSize(0); - CHECK(call->hasOutputParameter(foo)); -} - -TEST(MockExpectedCall, hasNoOutputParameter) -{ - call->withIntParameter("foo", (int)1); - MockNamedValue foo("foo"); - foo.setValue((int)1); - CHECK_FALSE(call->hasOutputParameter(foo)); -} - -TEST(MockExpectedCall, hasOutputParameterOfType) -{ - TypeForTestingExpectedFunctionCall object(6789); - call->withOutputParameterOfTypeReturning("TypeForTestingExpectedFunctionCall", "foo", &object); - MockNamedValue foo("foo"); - foo.setConstObjectPointer("TypeForTestingExpectedFunctionCall", &object); - CHECK(call->hasOutputParameter(foo)); -} - -TEST(MockExpectedCall, hasNoOutputParameterOfTypeSameTypeButInput) -{ - TypeForTestingExpectedFunctionCall object(543); - call->withParameterOfType("TypeForTestingExpectedFunctionCall", "foo", &object); - MockNamedValue foo("foo"); - foo.setConstObjectPointer("TypeForTestingExpectedFunctionCall", &object); - CHECK_FALSE(call->hasOutputParameter(foo)); -} - -TEST(MockExpectedCall, hasNoOutputParameterOfTypeDifferentType) -{ - TypeForTestingExpectedFunctionCall object(543); - call->withOutputParameterOfTypeReturning("TypeForTestingExpectedFunctionCall", "foo", &object); - MockNamedValue foo("foo"); - foo.setConstObjectPointer("OtherTypeForTestingExpectedFunctionCall", &object); - CHECK_FALSE(call->hasOutputParameter(foo)); -} - -TEST_GROUP(MockIgnoredExpectedCall) -{ - MockIgnoredExpectedCall ignored; -}; - -TEST(MockIgnoredExpectedCall, worksAsItShould) -{ - ignored.withName("func"); - ignored.withCallOrder(1); - ignored.withCallOrder(1, 1); - ignored.onObject(NULLPTR); - ignored.withBoolParameter("umm", true); - ignored.withIntParameter("bla", (int) 1); - ignored.withUnsignedIntParameter("foo", (unsigned int) 1); - ignored.withLongIntParameter("hey", (long int) 1); - ignored.withUnsignedLongIntParameter("bah", (unsigned long int) 1); -#if CPPUTEST_USE_LONG_LONG - ignored.withLongLongIntParameter("yo", (long long int) 1); - ignored.withUnsignedLongLongIntParameter("grr", (unsigned long long int) 1); -#endif - ignored.withDoubleParameter("hah", (double) 1.1f); - ignored.withDoubleParameter("gah", 2.1, 0.3); - ignored.withStringParameter("goo", "hello"); - ignored.withPointerParameter("pie", (void*) NULLPTR); - ignored.withConstPointerParameter("woo", (const void*) NULLPTR); - ignored.withFunctionPointerParameter("fop", (void(*)()) NULLPTR); - ignored.withMemoryBufferParameter("waa", (const unsigned char*) NULLPTR, 0); - ignored.withParameterOfType( "mytype", "top", (const void*) NULLPTR); - ignored.withOutputParameterReturning("bar", (void*) NULLPTR, 1); - ignored.withOutputParameterOfTypeReturning("mytype", "bar", (const void*) NULLPTR); - ignored.withUnmodifiedOutputParameter("unmod"); - ignored.ignoreOtherParameters(); - ignored.andReturnValue(true); - ignored.andReturnValue((double) 1.0f); - ignored.andReturnValue((unsigned int) 1); - ignored.andReturnValue((int) 1); - ignored.andReturnValue((unsigned long int) 1); - ignored.andReturnValue((long int) 1); -#if CPPUTEST_USE_LONG_LONG - ignored.andReturnValue((unsigned long long int) 1); - ignored.andReturnValue((long long int) 1); -#endif - ignored.andReturnValue("boo"); - ignored.andReturnValue((void*) NULLPTR); - ignored.andReturnValue((const void*) NULLPTR); - ignored.andReturnValue((void(*)()) NULLPTR); -} diff --git a/tests/CppUTestExt/MockFailureReporterForTest.cpp b/tests/CppUTestExt/MockFailureReporterForTest.cpp deleted file mode 100644 index 5330b7472..000000000 --- a/tests/CppUTestExt/MockFailureReporterForTest.cpp +++ /dev/null @@ -1,133 +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 "MockFailureReporterForTest.h" - -void MockFailureReporterForTest::failTest(const MockFailure& failure) -{ - mockFailureString = failure.getMessage(); -} - -MockFailureReporterForTest* MockFailureReporterForTest::instance_ = NULLPTR; - -MockFailureReporterForTest* MockFailureReporterForTest::getReporter() -{ - if (instance_ == NULLPTR) - instance_ = new MockFailureReporterForTest; - - return instance_; -} - -void MockFailureReporterForTest::clearReporter() -{ - delete instance_; - instance_ = NULLPTR; -} - -MockFailureReporterInstaller::MockFailureReporterInstaller() -{ - mock().setMockFailureStandardReporter(MockFailureReporterForTest::getReporter()); -} - -MockFailureReporterInstaller::~MockFailureReporterInstaller() -{ - mock().setMockFailureStandardReporter(NULLPTR); - MockFailureReporterForTest::clearReporter(); -} - -UtestShell* mockFailureTest() -{ - return MockFailureReporterForTest::getReporter()->getTestToFail(); -} - -SimpleString mockFailureString() -{ - return MockFailureReporterForTest::getReporter()->mockFailureString; -} - -void CLEAR_MOCK_FAILURE() -{ - MockFailureReporterForTest::getReporter()->mockFailureString = ""; -} - -void CHECK_EXPECTED_MOCK_FAILURE_LOCATION(const MockFailure& expectedFailure, const char* file, size_t line) -{ - SimpleString expectedFailureString = expectedFailure.getMessage(); - SimpleString actualFailureString = mockFailureString(); - CLEAR_MOCK_FAILURE(); - if (expectedFailureString != actualFailureString) - { - SimpleString error = "MockFailures are different.\n"; - error += "Expected MockFailure:\n\t"; - error += expectedFailureString; - error += "\nActual MockFailure:\n\t"; - error += actualFailureString; - FAIL_LOCATION(error.asCharString(), file, line); - } -} - -void CHECK_NO_MOCK_FAILURE_LOCATION(const char* file, size_t line) -{ - if (mockFailureString() != "") { - SimpleString error = "Unexpected mock failure:\n"; - error += mockFailureString(); - CLEAR_MOCK_FAILURE(); - FAIL_LOCATION(error.asCharString(), file, line); - - } - CLEAR_MOCK_FAILURE(); -} - -MockExpectedCallsListForTest::~MockExpectedCallsListForTest() -{ - deleteAllExpectationsAndClearList(); -} - -MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunction(const SimpleString& name) -{ - MockCheckedExpectedCall* newCall = new MockCheckedExpectedCall; - newCall->withName(name); - addExpectedCall(newCall); - return newCall; -} - -MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunction(unsigned int numCalls, const SimpleString& name) -{ - MockCheckedExpectedCall* newCall = new MockCheckedExpectedCall(numCalls); - newCall->withName(name); - addExpectedCall(newCall); - return newCall; -} - -MockCheckedExpectedCall* MockExpectedCallsListForTest::addFunctionOrdered(const SimpleString& name, unsigned int order) -{ - MockCheckedExpectedCall* newCall = addFunction(name); - newCall->withCallOrder(order); - return newCall; -} - - diff --git a/tests/CppUTestExt/MockFailureReporterForTest.h b/tests/CppUTestExt/MockFailureReporterForTest.h deleted file mode 100644 index f1b599f60..000000000 --- a/tests/CppUTestExt/MockFailureReporterForTest.h +++ /dev/null @@ -1,70 +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. - */ - -#ifndef D_MockFailureReporterForTest_h -#define D_MockFailureReporterForTest_h - -#include "CppUTestExt/MockSupport.h" - -#define CHECK_EXPECTED_MOCK_FAILURE(expectedFailure) CHECK_EXPECTED_MOCK_FAILURE_LOCATION(expectedFailure, __FILE__, __LINE__) -#define CHECK_NO_MOCK_FAILURE() CHECK_NO_MOCK_FAILURE_LOCATION(__FILE__, __LINE__) - -class MockFailureReporterForTest : public MockFailureReporter -{ -public: - SimpleString mockFailureString; - - virtual void failTest(const MockFailure& failure) CPPUTEST_OVERRIDE; - static MockFailureReporterForTest* getReporter(); - static void clearReporter(); -private: - static MockFailureReporterForTest* instance_; -}; - -class MockFailureReporterInstaller -{ - public: - MockFailureReporterInstaller(); - ~MockFailureReporterInstaller(); -}; - -UtestShell* mockFailureTest(); -SimpleString mockFailureString(); -void CLEAR_MOCK_FAILURE(); -void CHECK_EXPECTED_MOCK_FAILURE_LOCATION(const MockFailure& expectedFailure, const char* file, size_t line); -void CHECK_NO_MOCK_FAILURE_LOCATION(const char* file, size_t line); - -class MockExpectedCallsListForTest : public MockExpectedCallsList -{ - public: - ~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 deleted file mode 100644 index 0e1aea2b5..000000000 --- a/tests/CppUTestExt/MockFailureTest.cpp +++ /dev/null @@ -1,321 +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/TestHarness.h" -#include "CppUTestExt/MockFailure.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockFailureTest) -{ - MockFailureReporter reporter; - - MockExpectedCallsList *list; - MockCheckedExpectedCall* call1; - MockCheckedExpectedCall* call2; - MockCheckedExpectedCall* call3; - MockCheckedExpectedCall* call4; - MockCheckedExpectedCall* call5; - - void setup () CPPUTEST_OVERRIDE - { - list = new MockExpectedCallsList; - call1 = new MockCheckedExpectedCall; - call2 = new MockCheckedExpectedCall; - call3 = new MockCheckedExpectedCall; - call4 = new MockCheckedExpectedCall; - call5 = new MockCheckedExpectedCall; - } - void teardown () CPPUTEST_OVERRIDE - { - delete list; - delete call1; - delete call2; - delete call3; - delete call4; - delete call5; - CHECK_NO_MOCK_FAILURE(); - MockFailureReporterForTest::clearReporter(); - } - - 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; - MockCheckedExpectedCall expectedCallSingle(1); - MockCheckedExpectedCall expectedCallMulti(count-1); - - expectedCallSingle.withName("bar"); - expectedCallMulti.withName("bar"); - - if (count > 1) { - callList.addExpectedCall(&expectedCallSingle); - expectedCallSingle.callWasMade(1); - } - - if (count > 2) { - callList.addExpectedCall(&expectedCallMulti); - for (unsigned int i = 1; i < (count - 1); i++) { - expectedCallMulti.callWasMade(i+1); - } - } - - MockUnexpectedCallHappenedFailure failure(UtestShell::getCurrent(), "bar", callList); - - SimpleString expectedMessage = StringFromFormat("Mock Failure: Unexpected additional (%s) call to function: bar\n\tEXPECTED", expectedOrdinal); - STRCMP_CONTAINS(expectedMessage.asCharString(), failure.getMessage().asCharString()); - } -}; - -TEST(MockFailureTest, noErrorFailureSomethingGoneWrong) -{ - MockFailure failure(UtestShell::getCurrent()); - STRCMP_EQUAL("Test failed with MockFailure without an error! Something went seriously wrong.", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, unexpectedCallHappened) -{ - MockUnexpectedCallHappenedFailure failure(UtestShell::getCurrent(), "foobar", *list); - STRCMP_EQUAL("Mock Failure: Unexpected call to function: foobar\n" - "\tEXPECTED calls that WERE NOT fulfilled:\n" - "\t\t\n" - "\tEXPECTED calls that WERE fulfilled:\n" - "\t\t", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, expectedCallDidNotHappen) -{ - call1->withName("foobar"); - call2->withName("world").withParameter("boo", 2).withParameter("hello", "world"); - call3->withName("haphaphap"); - call3->callWasMade(1); - addThreeCallsToList(); - - MockExpectedCallsDidntHappenFailure failure(UtestShell::getCurrent(), *list); - STRCMP_EQUAL("Mock Failure: Expected call WAS NOT fulfilled.\n" - "\tEXPECTED calls that WERE NOT fulfilled:\n" - "\t\tfoobar -> no parameters (expected 1 call, called 0 times)\n" - "\t\tworld -> int boo: <2 (0x2)>, const char* hello: (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled:\n" - "\t\thaphaphap -> no parameters (expected 1 call, called 1 time)", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockUnexpectedNthAdditionalCallFailure) -{ - checkUnexpectedNthCallMessage(2, "2nd"); - checkUnexpectedNthCallMessage(3, "3rd"); - checkUnexpectedNthCallMessage(4, "4th"); - checkUnexpectedNthCallMessage(11, "11th"); - checkUnexpectedNthCallMessage(12, "12th"); - checkUnexpectedNthCallMessage(13, "13th"); - checkUnexpectedNthCallMessage(14, "14th"); - checkUnexpectedNthCallMessage(21, "21st"); - checkUnexpectedNthCallMessage(22, "22nd"); - checkUnexpectedNthCallMessage(23, "23rd"); -} - -TEST(MockFailureTest, MockUnexpectedInputParameterFailure) -{ - call1->withName("foo").withParameter("boo", 2); - call2->withName("foo").withParameter("boo", 3.3); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockNamedValue actualParameter("bar"); - actualParameter.setValue(2); - - MockUnexpectedInputParameterFailure failure(UtestShell::getCurrent(), "foo", actualParameter, *list); - STRCMP_EQUAL("Mock Failure: Unexpected parameter name to function \"foo\": bar\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\tfoo -> int boo: <2 (0x2)> (expected 1 call, called 0 times)\n" - "\t\tfoo -> double boo: <3.3> (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t\n" - "\tACTUAL unexpected parameter passed to function: foo\n" - "\t\tint bar: <2 (0x2)>", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockUnexpectedOutputParameterFailure) -{ - int out1; - int out2; - call1->withName("foo").withOutputParameterReturning("boo", &out1, sizeof(out1)); - call2->withName("foo").withOutputParameterReturning("boo", &out2, sizeof(out2)); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockNamedValue actualParameter("bar"); - actualParameter.setValue((void *)0x123); - - MockUnexpectedOutputParameterFailure failure(UtestShell::getCurrent(), "foo", actualParameter, *list); - STRCMP_EQUAL("Mock Failure: Unexpected output parameter name to function \"foo\": bar\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\tfoo -> const void* boo: (expected 1 call, called 0 times)\n" - "\t\tfoo -> const void* boo: (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t\n" - "\tACTUAL unexpected output parameter passed to function: foo\n" - "\t\tvoid* bar", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockUnexpectedUnmodifiedOutputParameterFailure) -{ - int out1; - call1->withName("foo").withOutputParameterReturning("boo", &out1, sizeof(out1)); - call2->withName("foo").withUnmodifiedOutputParameter("boo"); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockNamedValue actualParameter("bar"); - actualParameter.setValue((void *)0x123); - - MockUnexpectedOutputParameterFailure failure(UtestShell::getCurrent(), "foo", actualParameter, *list); - STRCMP_EQUAL("Mock Failure: Unexpected output parameter name to function \"foo\": bar\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\tfoo -> const void* boo: (expected 1 call, called 0 times)\n" - "\t\tfoo -> const void* boo: (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t\n" - "\tACTUAL unexpected output parameter passed to function: foo\n" - "\t\tvoid* bar", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockUnexpectedParameterValueFailure) -{ - call1->withName("foo").withParameter("boo", 2); - call2->withName("foo").withParameter("boo", 10); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockNamedValue actualParameter("boo"); - actualParameter.setValue(20); - - MockUnexpectedInputParameterFailure failure(UtestShell::getCurrent(), "foo", actualParameter, *list); - STRCMP_EQUAL("Mock Failure: Unexpected parameter value to parameter \"boo\" to function \"foo\": <20 (0x14)>\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\tfoo -> int boo: <2 (0x2)> (expected 1 call, called 0 times)\n" - "\t\tfoo -> int boo: <10 (0xa)> (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t\n" - "\tACTUAL unexpected parameter passed to function: foo\n" - "\t\tint boo: <20 (0x14)>", failure.getMessage().asCharString()); -} - -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("foo").withParameter("bar", 2).withParameter("boo", "blah").withParameter("baa", 0u); - call3->inputParameterWasPassed("bar"); - call4->withName("foo").withParameter("bar", 20); - call5->withName("unrelated"); - addFiveCallsToList(); - - 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)", - failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockNoWayToCompareCustomTypeFailure) -{ - MockNoWayToCompareCustomTypeFailure failure(UtestShell::getCurrent(), "myType"); - STRCMP_EQUAL("MockFailure: No way to compare type . Please install a MockNamedValueComparator.", failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockUnexpectedObjectFailure) -{ - call1->withName("foo").onObject((void*) 0x02); - call2->withName("foo").onObject((void*) 0x03); - call2->callWasMade(1); - call2->wasPassedToObject(); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockUnexpectedObjectFailure failure(UtestShell::getCurrent(), "foo", (void*)0x1, *list); - STRCMP_EQUAL(StringFromFormat ( - "MockFailure: Function called on an unexpected object: foo\n" - "\tActual object for call has address: <%p>\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\t(object address: %p)::foo -> no parameters (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t(object address: %p)::foo -> no parameters (expected 1 call, called 1 time)", - (void*) 0x01, (void*) 0x02, (void*) 0x03).asCharString(), failure.getMessage().asCharString()); -} - -TEST(MockFailureTest, MockExpectedObjectDidntHappenFailure) -{ - call1->withName("foo").onObject((void*) 0x02); - call2->withName("foo").onObject((void*) 0x03); - call2->callWasMade(1); - call2->wasPassedToObject(); - call3->withName("unrelated"); - addThreeCallsToList(); - - MockExpectedObjectDidntHappenFailure failure(UtestShell::getCurrent(), "foo", *list); - STRCMP_EQUAL(StringFromFormat( - "Mock Failure: Expected call on object for function \"foo\" but it did not happen.\n" - "\tEXPECTED calls that WERE NOT fulfilled related to function: foo\n" - "\t\t(object address: %p)::foo -> no parameters (expected 1 call, called 0 times)\n" - "\tEXPECTED calls that WERE fulfilled related to function: foo\n" - "\t\t(object address: %p)::foo -> no parameters (expected 1 call, called 1 time)", - (void*) 0x2, (void*) 0x3).asCharString(), failure.getMessage().asCharString()); -} diff --git a/tests/CppUTestExt/MockFakeLongLong.cpp b/tests/CppUTestExt/MockFakeLongLong.cpp deleted file mode 100644 index e0cd1a61b..000000000 --- a/tests/CppUTestExt/MockFakeLongLong.cpp +++ /dev/null @@ -1,171 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTestExt/MockCheckedActualCall.h" -#include "CppUTestExt/MockCheckedExpectedCall.h" -#include "CppUTestExt/MockExpectedCallsList.h" -#include "CppUTestExt/MockFailure.h" -#include "MockFailureReporterForTest.h" - - -TEST_GROUP(FakeLongLongs) -{ - TestTestingFixture fixture; -}; - -#ifndef CPPUTEST_USE_LONG_LONG - -#define CHECK_TEST_FAILS_PROPER_WITH_TEXT(text) fixture.checkTestFailsWithProperTestLocation(text, __FILE__, __LINE__) - -static void actualCallWithFakeLongLongParameter_() -{ - cpputest_longlong value = {0}; - - mock().expectOneCall("foo").withParameter("bar", 0); - mock().actualCall("foo").withParameter("bar", value); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ActualCallWithFakeLongLongParameterFAILS) -{ - fixture.runTestWithMethod(actualCallWithFakeLongLongParameter); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported"); -} - -static void actualCallWithFakeUnsignedLongLongParameter_() -{ - cpputest_ulonglong value = {0}; - - mock().expectOneCall("foo").withParameter("bar", 0); - mock().actualCall("foo").withParameter("bar", value); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ActualCallWithFakeUnsignedLongLongParameterFAILS) -{ - fixture.runTestWithMethod(actualCallWithFakeUnsignedLongLongParameter_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported"); -} - -static void actualCallWithFakeLongLongReturn_() -{ - mock().expectOneCall("foo").andReturnValue(0); - mock().actualCall("foo").returnLongLongIntValue(); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ActualCallWithFakeLongLongReturnFAILS) -{ - fixture.runTestWithMethod(actualCallWithFakeLongLongReturn_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported"); -} - -static void actualCallWithFakeUnsignedLongLongReturn_() -{ - mock().expectOneCall("foo").andReturnValue(0); - mock().actualCall("foo").returnUnsignedLongLongIntValue(); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ActualCallWithFakeUnsignedLongLongReturnFAILS) -{ - fixture.runTestWithMethod(actualCallWithFakeUnsignedLongLongReturn_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported"); -} - -static void expectOneCallWithFakeLongLongParameter_() -{ - cpputest_longlong value = {0}; - - mock().expectOneCall("foo").withParameter("bar", value); - mock().actualCall("foo").withParameter("bar", 0); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ExpectedCallWithFakeLongLongParameterFAILS) -{ - fixture.runTestWithMethod(expectOneCallWithFakeLongLongParameter_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported"); -} - -static void expectOneCallWithFakeUnsignedLongLongParameter_() -{ - cpputest_ulonglong value = {0}; - - mock().expectOneCall("foo").withParameter("bar", value); - mock().actualCall("foo").withParameter("bar", 0); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ExpectedCallWithFakeUnsignedLongLongParameterFAILS) -{ - fixture.runTestWithMethod(expectOneCallWithFakeUnsignedLongLongParameter_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported"); -} - -static void expectOneCallWithFakeLongLongReturn_() -{ - cpputest_longlong value = {0}; - - mock().expectOneCall("foo").andReturnValue(value); - mock().actualCall("foo").returnIntValue(); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ExpectedCallWithFakeLongLongReturnFAILS) -{ - fixture.runTestWithMethod(expectOneCallWithFakeLongLongReturn_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Long Long type is not supported"); -} - -static void expectOneCallWithFakeUnsignedLongLongReturn_() -{ - cpputest_ulonglong value = {0}; - - mock().expectOneCall("foo").andReturnValue(value); - mock().actualCall("foo").returnIntValue(); - TestTestingFixture::lineExecutedAfterCheck(); // LCOV_EXCL_LINE -} // LCOV_EXCL_LINE - -TEST(FakeLongLongs, ExpectedCallWithFakeUnsignedLongLongReturnFAILS) -{ - fixture.runTestWithMethod(expectOneCallWithFakeUnsignedLongLongReturn_); - mock().clear(); - CHECK_TEST_FAILS_PROPER_WITH_TEXT("Unsigned Long Long type is not supported"); -} - -#endif diff --git a/tests/CppUTestExt/MockHierarchyTest.cpp b/tests/CppUTestExt/MockHierarchyTest.cpp deleted file mode 100644 index 8ee5901df..000000000 --- a/tests/CppUTestExt/MockHierarchyTest.cpp +++ /dev/null @@ -1,153 +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/TestHarness.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockHierarchyTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().clear(); - } -}; - -TEST(MockHierarchyTest, getMockSupportScope) -{ - MockSupport* mock1 = mock().getMockSupportScope("name"); - MockSupport* mock2 = mock().getMockSupportScope("differentName"); - - CHECK(!mock().hasData("name")); - CHECK(mock1 != mock2); - POINTERS_EQUAL(mock1, mock().getMockSupportScope("name")); - CHECK(mock1 != &mock()); -} - -TEST(MockHierarchyTest, usingTwoMockSupportsByName) -{ - mock("first").expectOneCall("boo"); - - LONGS_EQUAL(0, mock("other").expectedCallsLeft()); - LONGS_EQUAL(1, mock("first").expectedCallsLeft()); - - mock("first").clear(); -} - -TEST(MockHierarchyTest, EnableDisableWorkHierarchically) -{ - mock("first"); - - mock().disable(); - mock("first").expectOneCall("boo"); - LONGS_EQUAL(0, mock("first").expectedCallsLeft()); - - mock().enable(); - mock("first").expectOneCall("boo"); - LONGS_EQUAL(1, mock("first").expectedCallsLeft()); - - mock("first").clear(); -} - -TEST(MockHierarchyTest, EnableDisableWorkHierarchicallyWhenSupportIsDynamicallyCreated) -{ - mock().disable(); - mock("first").expectOneCall("boo"); - LONGS_EQUAL(0, mock("first").expectedCallsLeft()); - - mock().enable(); - mock("second").expectOneCall("boo"); - LONGS_EQUAL(1, mock("second").expectedCallsLeft()); - - mock().clear(); -} - -TEST(MockHierarchyTest, ExpectedCallsLeftWorksHierarchically) -{ - mock("first").expectOneCall("foobar"); - LONGS_EQUAL(1, mock().expectedCallsLeft()); - - mock().clear(); -} - -TEST(MockHierarchyTest, checkExpectationsWorksHierarchically) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("first::foobar"); - expectations.addFunction("second::helloworld"); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock("first").expectOneCall("foobar"); - mock("second").expectOneCall("helloworld"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockHierarchyTest, ignoreOtherCallsWorksHierarchically) -{ - mock("first"); - mock().ignoreOtherCalls(); - mock("first").actualCall("boo"); - - mock().checkExpectations(); -} - -TEST(MockHierarchyTest, ignoreOtherCallsWorksHierarchicallyWhenDynamicallyCreated) -{ - mock().ignoreOtherCalls(); - mock("first").actualCall("boo"); - - mock().checkExpectations(); -} - -TEST(MockHierarchyTest, checkExpectationsWorksHierarchicallyForLastCallNotFinished) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("first::foobar")->withParameter("boo", 1); - MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "first::foobar", expectations, expectations); - - mock("first").expectOneCall("foobar").withParameter("boo", 1); - mock("first").actualCall("foobar"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockHierarchyTest, reporterIsInheritedInHierarchicalMocks) -{ - MockFailureReporterInstaller failureReporterInstaller; - MockExpectedCallsListForTest expectations; - - mock("differentScope").actualCall("foobar"); - - MockUnexpectedCallHappenedFailure expectedFailure(mockFailureTest(), "differentScope::foobar", expectations); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} diff --git a/tests/CppUTestExt/MockNamedValueTest.cpp b/tests/CppUTestExt/MockNamedValueTest.cpp deleted file mode 100644 index 0a0286f8f..000000000 --- a/tests/CppUTestExt/MockNamedValueTest.cpp +++ /dev/null @@ -1,141 +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/TestHarness.h" -#include "CppUTestExt/MockNamedValue.h" - -TEST_GROUP(ComparatorsAndCopiersRepository) -{ -}; - -class MyComparator : public MockNamedValueComparator -{ - public: - - MyComparator() {} - virtual ~MyComparator() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - virtual bool isEqual(const void*, const void*) CPPUTEST_OVERRIDE { return false; } - virtual SimpleString valueToString(const void*) CPPUTEST_OVERRIDE { return ""; } -}; - -class MyCopier : public MockNamedValueCopier -{ - public: - - MyCopier() {} - virtual ~MyCopier() CPPUTEST_DESTRUCTOR_OVERRIDE {} - - virtual void copy(void*, const void*) CPPUTEST_OVERRIDE {} -}; - -TEST(ComparatorsAndCopiersRepository, InstallCopierAndRetrieveIt) -{ - MyCopier copier; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installCopier("MyType", copier); - POINTERS_EQUAL(&copier, repository.getCopierForType("MyType")); - repository.clear(); -} - -TEST(ComparatorsAndCopiersRepository, ComparatorAndCopierByTheSameNameShouldBothBeFound) -{ - MyComparator comparator; - MyCopier copier; - MockNamedValueComparatorsAndCopiersRepository repository; - repository.installCopier("MyType", copier); - repository.installComparator("MyType", comparator); - POINTERS_EQUAL(&comparator, repository.getComparatorForType("MyType")); - POINTERS_EQUAL(&copier, repository.getCopierForType("MyType")); - repository.clear(); -} - -TEST(ComparatorsAndCopiersRepository, InstallComparatorsAndCopiersFromRepository) -{ - MyComparator comparator; - MyCopier copier; - MockNamedValueComparatorsAndCopiersRepository source; - MockNamedValueComparatorsAndCopiersRepository target; - - 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(); -} - -TEST_GROUP(MockNamedValue) -{ - MockNamedValue * value; - void setup() CPPUTEST_OVERRIDE - { - value = new MockNamedValue("param"); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete value; - } -}; - -TEST(MockNamedValue, DefaultToleranceUsedWhenNoToleranceGiven) -{ - value->setValue(0.2); - DOUBLES_EQUAL(MockNamedValue::defaultDoubleTolerance, value->getDoubleTolerance(), 0.0); -} - -TEST(MockNamedValue, GivenToleranceUsed) -{ - value->setValue(0.2, 3.2); - STRCMP_EQUAL("double", value->getType().asCharString()); - DOUBLES_EQUAL(0.2, value->getDoubleValue(), 0.0); - DOUBLES_EQUAL(3.2, value->getDoubleTolerance(), 0.0); -} - -TEST(MockNamedValue, DoublesEqualIfWithinTolerance) -{ - value->setValue(5.0, 0.4); - MockNamedValue other("param2"); - other.setValue(5.3); - - CHECK_TRUE(value->equals(other)); -} - - -TEST(MockNamedValue, DoublesNotEqualIfOutsideTolerance) -{ - value->setValue(5.0, 0.4); - MockNamedValue other("param2"); - other.setValue(5.5); - - CHECK_FALSE(value->equals(other)); -} diff --git a/tests/CppUTestExt/MockParameterTest.cpp b/tests/CppUTestExt/MockParameterTest.cpp deleted file mode 100644 index 54f719662..000000000 --- a/tests/CppUTestExt/MockParameterTest.cpp +++ /dev/null @@ -1,932 +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/TestHarness.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockParameterTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().checkExpectations(); - mock().clear(); - } -}; - -TEST(MockParameterTest, expectOneBooleanParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", true); - mock().actualCall("foo").withParameter("parameter", true); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneUnsignedIntegerParameterAndValue) -{ - unsigned int value = 14400; - mock().expectOneCall("foo").withParameter("parameter", value); - mock().actualCall("foo").withParameter("parameter", value); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneIntegerParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", 10); - mock().actualCall("foo").withParameter("parameter", 10); - - mock().checkExpectations(); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockParameterTest, expectOneUnsignedLongLongIntegerParameterAndValue) -{ - unsigned long long value = 0xFFFFAAAAFFFFAAAAULL; - mock().expectOneCall("foo").withParameter("parameter", value); - mock().actualCall("foo").withParameter("parameter", value); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneLongLongIntegerParameterAndValue) -{ - long long value = 0x7FFFAAAAFFFFAAAAULL; - - mock().expectOneCall("foo").withParameter("parameter", value); - mock().actualCall("foo").withParameter("parameter", value); - - mock().checkExpectations(); -} - -#endif - -TEST(MockParameterTest, mismatchedIntegerTypesIntAndLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (int)1); - mock().actualCall("foo").withParameter("parameter", (long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long)1); - mock().actualCall("foo").withParameter("parameter", (int)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesIntAndUnsignedAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (int)1); - mock().actualCall("foo").withParameter("parameter", (unsigned)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned)1); - mock().actualCall("foo").withParameter("parameter", (int)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesIntAndUnsignedLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (int)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)1); - mock().actualCall("foo").withParameter("parameter", (int)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedAndLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned)1); - mock().actualCall("foo").withParameter("parameter", (long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedAndUnsignedLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesLongAndUnsignedLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)1); - mock().actualCall("foo").withParameter("parameter", (long)1); - - mock().checkExpectations(); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockParameterTest, mismatchedIntegerTypesIntAndLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (int)1); - mock().actualCall("foo").withParameter("parameter", (long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long long)1); - mock().actualCall("foo").withParameter("parameter", (int)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesIntAndUnsignedLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (int)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long long)1); - mock().actualCall("foo").withParameter("parameter", (int)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedAndLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned)1); - mock().actualCall("foo").withParameter("parameter", (long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedAndUnsignedLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedLongAndUnsignedLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesLongAndLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (long)1); - mock().actualCall("foo").withParameter("parameter", (long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long long)1); - mock().actualCall("foo").withParameter("parameter", (long)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesLongAndUnsignedLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long long)1); - mock().actualCall("foo").withParameter("parameter", (long)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesUnsignedLongAndLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)1); - mock().actualCall("foo").withParameter("parameter", (long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (long long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, mismatchedIntegerTypesLongLongAndUnsignedLongLongAreAllowed) -{ - mock().expectOneCall("foo").withParameter("parameter", (long long)1); - mock().actualCall("foo").withParameter("parameter", (unsigned long long)1); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long long)1); - mock().actualCall("foo").withParameter("parameter", (long long)1); - - mock().checkExpectations(); -} - -#endif - -TEST(MockParameterTest, longAndUnsignedLongWithSameBitRepresentationShouldNotBeTreatedAsEqual) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", (long)-1); - MockNamedValue parameter("parameter"); - parameter.setValue((unsigned long)-1); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", (long)-1); - mock().actualCall("foo").withParameter("parameter", (unsigned long)-1); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, unsignedLongAndLongWithSameBitRepresentationShouldnotBeTreatedAsEqual) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", (unsigned long)-1); - MockNamedValue parameter("parameter"); - parameter.setValue((long)-1); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", (unsigned long)-1); - mock().actualCall("foo").withParameter("parameter", (long)-1); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneDoubleParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", 1.0); - mock().actualCall("foo").withParameter("parameter", 1.0); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneDoubleParameterAndValueAndTolerance) -{ - mock( ).expectOneCall("foo").withParameter("parameter", 100.0, 5.0); - mock( ).actualCall("foo").withParameter("parameter", 96.0); - - mock( ).checkExpectations(); -} - -TEST(MockParameterTest, doubleParameterNotEqualIfOutsideTolerance) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", 100.0); - MockNamedValue parameter("parameter"); - parameter.setValue(106.0); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock( ).expectOneCall("foo").withParameter("parameter", 100.0, 5.0); - mock( ).actualCall("foo").withParameter("parameter", 106.0); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - - -TEST(MockParameterTest, expectOneStringParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", "string"); - mock().actualCall("foo").withParameter("parameter", "string"); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOnePointerParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", (void*) 0x01); - mock().actualCall("foo").withParameter("parameter", (void*) 0x01); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneConstPointerParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", (const void*) 0x01); - mock().actualCall("foo").withParameter("parameter", (const void*) 0x01); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneFunctionPointerParameterAndValue) -{ - mock().expectOneCall("foo").withParameter("parameter", (void(*)()) 0x01); - mock().actualCall("foo").withParameter("parameter", (void(*)()) 0x01); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneMemBufferParameterAndValue) -{ - unsigned char memBuffer1[] = { 0x12, 0x15, 0xFF }; - unsigned char memBuffer2[] = { 0x12, 0x15, 0xFF }; - mock().expectOneCall("foo").withParameter("parameter", memBuffer1, sizeof(memBuffer1)); - mock().actualCall("foo").withParameter("parameter", memBuffer2, sizeof(memBuffer2)); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectOneMemBufferParameterAndValueFailsDueToContents) -{ - MockFailureReporterInstaller failureReporterInstaller; - - unsigned char memBuffer1[] = { 0x12, 0x15, 0xFF }; - unsigned char memBuffer2[] = { 0x12, 0x05, 0xFF }; - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", memBuffer1, sizeof(memBuffer1)); - MockNamedValue parameter("parameter"); - parameter.setMemoryBuffer( memBuffer2, sizeof(memBuffer2) ); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", memBuffer1, sizeof(memBuffer1)); - mock().actualCall("foo").withParameter("parameter", memBuffer2, sizeof(memBuffer2)); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneMemBufferParameterAndValueFailsDueToSize) -{ - MockFailureReporterInstaller failureReporterInstaller; - - unsigned char memBuffer1[] = { 0x12, 0x15, 0xFF }; - unsigned char memBuffer2[] = { 0x12, 0x15, 0xFF, 0x90 }; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", memBuffer1, sizeof(memBuffer1)); - MockNamedValue parameter("parameter"); - parameter.setMemoryBuffer( memBuffer2, sizeof(memBuffer2) ); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", memBuffer1, sizeof(memBuffer1)); - mock().actualCall("foo").withParameter("parameter", memBuffer2, sizeof(memBuffer2)); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneStringParameterAndValueFails) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", "string"); - MockNamedValue parameter("parameter"); - parameter.setValue("different"); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", "string"); - mock().actualCall("foo").withParameter("parameter", "different"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneUnsignedIntegerParameterAndFailsDueToParameterName) -{ - MockFailureReporterInstaller failureReporterInstaller; - - unsigned int value = 7; - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", value); - MockNamedValue parameter("different"); - parameter.setValue(value); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", value); - mock().actualCall("foo").withParameter("different", value); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneIntegerParameterAndFailsDueToParameterName) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", 10); - MockNamedValue parameter("different"); - parameter.setValue(10); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", 10); - mock().actualCall("foo").withParameter("different", 10); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneUnsignedIntegerParameterAndFailsDueToValue) -{ - MockFailureReporterInstaller failureReporterInstaller; - - unsigned int actual_value = 8; - unsigned int expected_value = actual_value + 1; - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", expected_value); - MockNamedValue parameter("parameter"); - parameter.setValue(actual_value); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", expected_value); - mock().actualCall("foo").withParameter("parameter", actual_value); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneIntegerParameterAndFailsDueToValue) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", 10); - MockNamedValue parameter("parameter"); - parameter.setValue(8); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", 10); - mock().actualCall("foo").withParameter("parameter", 8); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectOneIntegerParameterAndFailsDueToTypes) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("parameter", 10); - MockNamedValue parameter("parameter"); - parameter.setValue("heh"); - MockUnexpectedInputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().expectOneCall("foo").withParameter("parameter", 10); - mock().actualCall("foo").withParameter("parameter", "heh"); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, expectMultipleCallsWithDifferentParametersThatHappenOutOfOrder) -{ - mock().expectOneCall("foo").withParameter("p1", 1); - mock().expectOneCall("foo").withParameter("p1", 2); - mock().actualCall("foo").withParameter("p1", 2); - mock().actualCall("foo").withParameter("p1", 1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectMultipleCallsWithMultipleDifferentParametersThatHappenOutOfOrder) -{ - mock().expectOneCall("foo").withParameter("p1", 1).withParameter("p2", 2); - mock().expectOneCall("foo").withParameter("p1", 1).withParameter("p2", 20); - - mock().actualCall("foo").withParameter("p1", 1).withParameter("p2", 20); - mock().actualCall("foo").withParameter("p1", 1).withParameter("p2", 2); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, twiceCalledWithSameParameters) -{ - mock().expectOneCall("foo").withParameter("p1", 1).withParameter("p2", 2); - mock().expectOneCall("foo").withParameter("p1", 1).withParameter("p2", 2); - mock().actualCall("foo").withParameter("p1", 1).withParameter("p2", 2); - mock().actualCall("foo").withParameter("p1", 1).withParameter("p2", 2); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, calledWithoutParameters) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("p1", 1); - MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations); - - mock().expectOneCall("foo").withParameter("p1", 1); - mock().actualCall("foo"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, ignoreOtherParameters) -{ - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters(); - mock().actualCall("foo").withParameter("p1", 1).withParameter("p2", 2); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, ignoreOtherParametersButStillPassAll) -{ - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters(); - mock().actualCall("foo").withParameter("p1", 1); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, ignoreOtherParametersButExpectedParameterDidntHappen) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("p1", 1).ignoreOtherParameters(); - 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); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, ignoreOtherParametersMultipleCalls) -{ - mock().expectOneCall("foo").ignoreOtherParameters(); - mock().expectOneCall("foo").ignoreOtherParameters(); - mock().actualCall("foo").withParameter("p2", 2).withParameter("p3", 3).withParameter("p4", 4); - LONGS_EQUAL(1, mock().expectedCallsLeft()); - mock().actualCall("foo").withParameter("p2", 2).withParameter("p3", 3).withParameter("p4", 4); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, ignoreOtherParametersMultipleCallsButOneDidntHappen) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - MockCheckedExpectedCall* call = expectations.addFunction("boo"); - call->ignoreOtherParameters(); - call->callWasMade(1); - call->finalizeActualCallMatch(); - call->ignoreOtherParameters(); - expectations.addFunction("boo")->ignoreOtherParameters(); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectOneCall("boo").ignoreOtherParameters(); - mock().expectOneCall("boo").ignoreOtherParameters(); - mock().actualCall("boo"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, newCallStartsWhileNotAllParametersWerePassed) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foo")->withParameter("p1", 1); - MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations); - - mock().expectOneCall("foo").withParameter("p1", 1); - mock().actualCall("foo"); - mock().actualCall("foo").withParameter("p1", 1); - - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, outputParameterSucceeds) -{ - int param = 1; - int retval = 2; - - mock().expectOneCall("function").withOutputParameterReturning("parameterName", &retval, sizeof(retval)); - mock().actualCall("function").withOutputParameter("parameterName", ¶m); - - CHECK_EQUAL(param, 2); - CHECK_EQUAL(retval, 2); - mock().checkExpectations(); -} - -TEST(MockParameterTest, unmodifiedOutputParameterSucceeds) -{ - int param = 1; - - mock().expectOneCall("function").withUnmodifiedOutputParameter("parameterName"); - mock().actualCall("function").withOutputParameter("parameterName", ¶m); - - CHECK_EQUAL(param, 1); - mock().checkExpectations(); -} - -TEST(MockParameterTest, noActualCallForOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - int output; - MockExpectedCallsListForTest expectations; - mock().expectOneCall("foo").withOutputParameterReturning("output", &output, sizeof(output)); - - expectations.addFunction("foo")->withOutputParameterReturning("output", &output, sizeof(output)); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, noActualCallForUnmodifiedOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - mock().expectOneCall("foo").withUnmodifiedOutputParameter("output"); - - expectations.addFunction("foo")->withUnmodifiedOutputParameter("output"); - MockExpectedCallsDidntHappenFailure expectedFailure(mockFailureTest(), expectations); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, unexpectedOutputParameter) -{ - MockFailureReporterInstaller failureReporterInstaller; - - int param; - MockExpectedCallsListForTest expectations; - mock().expectOneCall("foo"); - mock().actualCall("foo").withOutputParameter("parameterName", ¶m); - - expectations.addFunction("foo"); - MockNamedValue parameter("parameterName"); - parameter.setValue(¶m); - MockUnexpectedOutputParameterFailure expectedFailure(mockFailureTest(), "foo", parameter, expectations); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, outputParameterMissing) -{ - MockFailureReporterInstaller failureReporterInstaller; - - int output; - MockExpectedCallsListForTest expectations; - mock().expectOneCall("foo").withOutputParameterReturning("output", &output, sizeof(output)); - mock().actualCall("foo"); - - expectations.addFunction("foo")->withOutputParameterReturning("output", &output, sizeof(output)); - MockExpectedParameterDidntHappenFailure expectedFailure(mockFailureTest(), "foo", expectations, expectations); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockParameterTest, twoOutputParameters) -{ - int param1 = 55; - int retval1 = 1; - int param2 = 77; - int retval2 = 2; - - mock().expectOneCall("function").withOutputParameterReturning("parameterName", &retval1, sizeof(retval1)).withParameter("id", 1); - mock().expectOneCall("function").withOutputParameterReturning("parameterName", &retval2, sizeof(retval2)).withParameter("id", 2); - mock().actualCall("function").withOutputParameter("parameterName", ¶m1).withParameter("id", 1); - mock().actualCall("function").withOutputParameter("parameterName", ¶m2).withParameter("id", 2); - - CHECK_EQUAL(retval1, param1); - CHECK_EQUAL(retval2, param2); - mock().checkExpectations(); -} - -TEST(MockParameterTest, twoInterleavedOutputParameters) -{ - int param1 = 55; - int retval1 = 1; - int param2 = 77; - int retval2 = 2; - - mock().expectOneCall("function").withOutputParameterReturning("parameterName", &retval1, sizeof(retval1)).withParameter("id", 1); - mock().expectOneCall("function").withOutputParameterReturning("parameterName", &retval2, sizeof(retval2)).withParameter("id", 2); - mock().actualCall("function").withOutputParameter("parameterName", ¶m2).withParameter("id", 2); - mock().actualCall("function").withOutputParameter("parameterName", ¶m1).withParameter("id", 1); - - CHECK_EQUAL(retval1, param1); - CHECK_EQUAL(retval2, param2); - mock().checkExpectations(); -} - -TEST(MockParameterTest, twoDifferentOutputParametersInSameFunctionCallSucceeds) -{ - int param1 = 1; - int param2 = 1; - int retval1 = 2; - int retval2 = 3; - - mock().expectOneCall("foo") - .withOutputParameterReturning("bar", &retval1, sizeof(retval1)) - .withOutputParameterReturning("foobar", &retval2, sizeof(retval2)); - mock().actualCall("foo") - .withOutputParameter("bar", ¶m1) - .withOutputParameter("foobar", ¶m2); - - CHECK_EQUAL(2, retval1); - CHECK_EQUAL(2, param1); - CHECK_EQUAL(3, retval2); - CHECK_EQUAL(3, param2); - mock().checkExpectations(); -} - -TEST(MockParameterTest, outputAndIntParametersOfSameNameInDifferentFunctionCallsOfSameFunctionSucceeds) -{ - int param = 1; - int retval = 2; - - mock().expectOneCall("foo").withOutputParameterReturning("bar", &retval, sizeof(retval)); - mock().expectOneCall("foo").withIntParameter("bar", 25); - mock().actualCall("foo").withOutputParameter("bar", ¶m); - mock().actualCall("foo").withIntParameter("bar", 25); - - CHECK_EQUAL(2, retval); - CHECK_EQUAL(2, param); - mock().checkExpectations(); -} - -TEST(MockParameterTest, twoOutputParameterOfSameNameInDifferentFunctionCallsOfSameFunctionSucceeds) -{ - int param1 = 1; - int param2 = 1; - int retval1 = 2; - int retval2 = 3; - - mock().expectOneCall("foo").withOutputParameterReturning("bar", &retval1, sizeof(retval1)); - mock().expectOneCall("foo").withOutputParameterReturning("bar", &retval2, sizeof(retval2)); - mock().actualCall("foo").withOutputParameter("bar", ¶m1); - mock().actualCall("foo").withOutputParameter("bar", ¶m2); - - CHECK_EQUAL(2, retval1); - CHECK_EQUAL(2, param1); - CHECK_EQUAL(3, retval2); - CHECK_EQUAL(3, param2); - mock().checkExpectations(); -} - -TEST(MockParameterTest, twoOutputParametersOfSameNameInDifferentFunctionsSucceeds) -{ - int param = 1; - int retval = 2; - - mock().expectOneCall("foo1").withOutputParameterReturning("bar", &retval, sizeof(retval)); - mock().expectOneCall("foo2").withIntParameter("bar", 25); - mock().actualCall("foo1").withOutputParameter("bar", ¶m); - mock().actualCall("foo2").withIntParameter("bar", 25); - - CHECK_EQUAL(2, retval); - CHECK_EQUAL(2, param); - mock().checkExpectations(); -} - -TEST(MockParameterTest, outputAndInputParameter) -{ - int return_value = 5; - int returned_value = 7; - - mock().expectOneCall("foo").withParameter("bar", 10).withOutputParameterReturning("bar", &return_value, sizeof(return_value)); - mock().actualCall("foo").withParameter("bar", 10).withOutputParameter("bar", &returned_value); - - LONGS_EQUAL(5, returned_value); - mock().checkExpectations(); -} - -TEST(MockParameterTest, outputParameterTraced) -{ - mock().tracing(true); - - int param = 1; - mock().actualCall("someFunc").withOutputParameter("someParameter", ¶m); - mock().checkExpectations(); - STRCMP_CONTAINS("Function name:someFunc someParameter:", mock().getTraceOutput()); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, outputParameterThatIsIgnoredShouldNotFail) -{ - int param; - mock().expectOneCall("function").ignoreOtherParameters(); - mock().actualCall("function").withOutputParameter("parameterName", ¶m); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, outputParameterWithIgnoredParameters) -{ - int param = 1; - int retval = 2; - - mock().expectOneCall("foo").withOutputParameterReturning("bar", ¶m, sizeof(param)).ignoreOtherParameters(); - mock().actualCall("foo").withOutputParameter("bar", &retval).withParameter("other", 1); - - LONGS_EQUAL(param, retval); - - mock().checkExpectations(); -} - -/* - * This test checks that the proper output parameters are copied when multiple calls to the same - * function are expected. - */ -TEST(MockParameterTest, properOutputParametersAreCopied) -{ - int expectedValue1 = 1; - int expectedValue2 = 2; - mock().expectOneCall("foo").withOutputParameterReturning("param", &expectedValue1, sizeof(expectedValue1)).ignoreOtherParameters(); - mock().expectOneCall("foo").withOutputParameterReturning("param", &expectedValue2, sizeof(expectedValue2)); - - int returnedValue1 = 0; - int returnedValue2 = 0; - mock().actualCall("foo").withOutputParameter("param", &returnedValue1); - mock().actualCall("foo").withOutputParameter("param", &returnedValue2).withParameter("optional", 50); - - CHECK_EQUAL_TEXT(expectedValue2, returnedValue1, "Wrong output value in 1st call"); - CHECK_EQUAL_TEXT(expectedValue1, returnedValue2, "Wrong output value in 2nd call"); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, ignoreOtherCallsIgnoresWithAllKindsOfParameters) -{ - mock().ignoreOtherCalls(); - mock().actualCall("boo") - .withParameter("umm", true) - .withParameter("bar", 1u) - .withParameter("foo", 1l) - .withParameter("hey", 1ul) -#if CPPUTEST_USE_LONG_LONG - .withParameter("ick", 1ll) - .withParameter("grr", 1ull) -#endif - .withParameter("duh", 1.0) - .withParameter("yoo", (const void*) NULLPTR) - .withParameter("func", (void(*)()) NULLPTR) - .withParameter("mem", (const unsigned char*) NULLPTR, 0) - .withParameterOfType("hoo", "int", (const void*) NULLPTR) - .withOutputParameter("gah", (void*) NULLPTR) - .withOutputParameterOfType("goo", "int", (void*) NULLPTR); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectMultipleCallsWithParameters) -{ - int expected_int = -7; - unsigned int expected_uint = 7; - - mock().expectNCalls(2, "boo").withParameter("double", 1.0).withParameter("int", expected_int). - withParameter("string", "string").withParameter("uint", expected_uint); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", expected_int).withParameter("string", "string"). - withParameter("uint", expected_uint); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", expected_int).withParameter("string", "string"). - withParameter("uint", expected_uint); - - mock().checkExpectations(); -} - -TEST(MockParameterTest, expectMultipleMultipleCallsWithParameters) -{ - mock().expectNCalls(2, "boo").withParameter("double", 1.0).ignoreOtherParameters(); - mock().expectNCalls(2, "boo").withParameter("double", 1.0).ignoreOtherParameters(); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - - mock().checkExpectations(); -} diff --git a/tests/CppUTestExt/MockPluginTest.cpp b/tests/CppUTestExt/MockPluginTest.cpp deleted file mode 100644 index e3c13a20b..000000000 --- a/tests/CppUTestExt/MockPluginTest.cpp +++ /dev/null @@ -1,176 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockSupportPlugin.h" -#include "MockFailureReporterForTest.h" -#include "CppUTest/TestTestingFixture.h" - -TEST_GROUP(MockPlugin) -{ - StringBufferTestOutput output; - - UtestShell *test; - TestResult *result; - - MockSupportPlugin plugin; - - void setup() CPPUTEST_OVERRIDE - { - test = new UtestShell("group", "name", "file", 1); - result = new TestResult(output); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete test; - delete result; - mock().clear(); - mock().removeAllComparatorsAndCopiers(); - } -}; - -TEST(MockPlugin, checkExpectationsAndClearAtEnd) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("foobar"); - MockExpectedCallsDidntHappenFailure expectedFailure(test, expectations); - - mock().expectOneCall("foobar"); - - plugin.postTestAction(*test, *result); - - STRCMP_CONTAINS(expectedFailure.getMessage().asCharString(), output.getOutput().asCharString()); - LONGS_EQUAL(0, mock().expectedCallsLeft()); - CHECK_NO_MOCK_FAILURE(); -} - -TEST(MockPlugin, checkExpectationsWorksAlsoWithHierachicalObjects) -{ - MockFailureReporterInstaller failureReporterInstaller; - - MockExpectedCallsListForTest expectations; - expectations.addFunction("differentScope::foobar")->onObject((void*) 1); - MockExpectedObjectDidntHappenFailure expectedFailure(test, "differentScope::foobar", expectations); - - mock("differentScope").expectOneCall("foobar").onObject((void*) 1); - mock("differentScope").actualCall("foobar"); - - plugin.postTestAction(*test, *result); - - STRCMP_CONTAINS(expectedFailure.getMessage().asCharString(), output.getOutput().asCharString()); - CHECK_NO_MOCK_FAILURE(); -} - -class DummyComparator : public MockNamedValueComparator -{ -public: - bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE - { - return object1 == object2; - } - SimpleString valueToString(const void*) CPPUTEST_OVERRIDE - { - return "string"; - } -}; - -TEST(MockPlugin, installComparatorRecordsTheComparatorButNotInstallsItYet) -{ - MockFailureReporterInstaller failureReporterInstaller; - - DummyComparator comparator; - plugin.installComparator("myType", comparator); - mock().expectOneCall("foo").withParameterOfType("myType", "name", NULLPTR); - mock().actualCall("foo").withParameterOfType("myType", "name", NULLPTR); - - MockNoWayToCompareCustomTypeFailure failure(test, "myType"); - CHECK_EXPECTED_MOCK_FAILURE(failure); - - plugin.clear(); -} - -class DummyCopier : public MockNamedValueCopier -{ -public: - void copy(void* dst, const void* src) CPPUTEST_OVERRIDE - { - *(int*)dst = *(const int*)src; - } -}; - -TEST(MockPlugin, installCopierRecordsTheCopierButNotInstallsItYet) -{ - MockFailureReporterInstaller failureReporterInstaller; - - DummyCopier copier; - plugin.installCopier("myType", copier); - mock().expectOneCall("foo").withOutputParameterOfTypeReturning("myType", "name", NULLPTR); - mock().actualCall("foo").withOutputParameterOfType("myType", "name", NULLPTR); - - MockNoWayToCopyCustomTypeFailure failure(test, "myType"); - CHECK_EXPECTED_MOCK_FAILURE(failure); - - plugin.clear(); -} - -TEST(MockPlugin, preTestActionWillEnableMultipleComparatorsToTheGlobalMockSupportSpace) -{ - DummyComparator comparator; - DummyComparator comparator2; - plugin.installComparator("myType", comparator); - plugin.installComparator("myOtherType", comparator2); - - plugin.preTestAction(*test, *result); - mock().expectOneCall("foo").withParameterOfType("myType", "name", &comparator); - mock().expectOneCall("foo").withParameterOfType("myOtherType", "name", &comparator); - mock().actualCall("foo").withParameterOfType("myType", "name", &comparator); - mock().actualCall("foo").withParameterOfType("myOtherType", "name", &comparator); - - mock().checkExpectations(); - LONGS_EQUAL(0, result->getFailureCount()); - - plugin.clear(); -} - -static void failTwiceFunction_() -{ - mock().expectOneCall("foobar"); - FAIL("This failed"); -} - -TEST(MockPlugin, shouldNotFailAgainWhenTestAlreadyFailed) -{ - TestTestingFixture fixture; - fixture.installPlugin(&plugin); - 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 deleted file mode 100644 index e99890605..000000000 --- a/tests/CppUTestExt/MockReturnValueTest.cpp +++ /dev/null @@ -1,747 +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/TestHarness.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockReturnValueTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().checkExpectations(); - mock().clear(); - } -}; - -TEST(MockReturnValueTest, hasReturnValue) -{ - CHECK(!mock().hasReturnValue()); - mock().expectOneCall("foo"); - CHECK(!mock().actualCall("foo").hasReturnValue()); - CHECK(!mock().hasReturnValue()); - - mock().expectOneCall("foo2").andReturnValue(1); - CHECK(mock().actualCall("foo2").hasReturnValue()); - CHECK(mock().hasReturnValue()); -} - -TEST(MockReturnValueTest, UnsignedIntegerReturnValue) -{ - unsigned int expected_value = 7; - - mock().expectOneCall("foo").andReturnValue(expected_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - - LONGS_EQUAL(expected_value, actual_call.returnValue().getUnsignedIntValue()); - LONGS_EQUAL(expected_value, actual_call.returnUnsignedIntValue()); - - LONGS_EQUAL(expected_value, mock().returnValue().getUnsignedIntValue()); - LONGS_EQUAL(expected_value, mock().unsignedIntReturnValue()); -} - -TEST(MockReturnValueTest, PositiveIntReturnValueCanBeRetrievedAsUnsignedInt) -{ - int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedIntValue()); -} - -TEST(MockReturnValueTest, IntReturnValueCanBeRetrievedAsLongInt) -{ - int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedIntReturnValueCanBeRetrievedAsLongInt) -{ - unsigned int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveIntReturnValueCanBeRetrievedAsUnsignedLongInt) -{ - int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveLongIntReturnValueCanBeRetrievedAsUnsignedLongInt) -{ - long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedIntReturnValueCanBeRetrievedAsUnsignedLongInt) -{ - unsigned int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue()); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockReturnValueTest, PositiveIntReturnValueCanBeRetrievedAsUnsignedLongLongInt) -{ - int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveLongIntReturnValueCanBeRetrievedAsUnsignedLongLongInt) -{ - long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveLongLongIntReturnValueCanBeRetrievedAsUnsignedLongLongInt) -{ - long long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedIntReturnValueCanBeRetrievedAsUnsignedLongLongInt) -{ - unsigned int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongIntReturnValueCanBeRetrievedAsUnsignedLongLongInt) -{ - unsigned long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongLongIntReturnValueCanBeRetrieved) -{ - unsigned long long int expected_value = 2ULL; - mock().expectOneCall("foo").andReturnValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveIntReturnValueCanBeRetrievedAsLongLongInt) -{ - int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, PositiveLongIntReturnValueCanBeRetrievedAsLongLongInt) -{ - long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedIntReturnValueCanBeRetrievedAsLongLongInt) -{ - unsigned int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongIntReturnValueCanBeRetrievedAsLongLongInt) -{ - unsigned long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, LongLongIntReturnValueCanBeRetrieved) -{ - long long int expected_value = 2LL; - mock().expectOneCall("foo").andReturnValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); -} - -#endif - -TEST(MockReturnValueTest, UnsignedIntegerReturnValueSetsDifferentValues) -{ - unsigned int expected_value = 1; - unsigned int another_expected_value = 2; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getUnsignedIntValue()); - LONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getUnsignedIntValue()); - LONGS_EQUAL(another_expected_value, mock().returnValue().getUnsignedIntValue()); -} - -TEST(MockReturnValueTest, UnsignedIntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - unsigned int ret_value = 1; - unsigned int another_ret_value = 2; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - LONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedIntValue()); - LONGS_EQUAL(ret_value, mock().returnValue().getUnsignedIntValue()); - LONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedIntValue()); - LONGS_EQUAL(another_ret_value, mock().returnValue().getUnsignedIntValue()); -} - -TEST(MockReturnValueTest, WhenADoubleReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - double default_return_value = 10.7; - double expected_return_value = default_return_value + 1.3; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - - DOUBLES_EQUAL(expected_return_value, mock().actualCall("foo").returnDoubleValueOrDefault(default_return_value), 0.05); - DOUBLES_EQUAL(expected_return_value, mock().returnDoubleValueOrDefault(default_return_value), 0.05); -} - -TEST(MockReturnValueTest, WhenNoDoubleReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - double default_return_value = 7.7; - mock().expectOneCall("foo"); - DOUBLES_EQUAL(default_return_value, mock().actualCall("foo").returnDoubleValueOrDefault(default_return_value), 0.05); - DOUBLES_EQUAL(default_return_value, mock().returnDoubleValueOrDefault(default_return_value), 0.05); -} - -TEST(MockReturnValueTest, WhenAUnsignedIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - unsigned int default_return_value = 10; - unsigned int expected_return_value = default_return_value + 1; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnUnsignedIntValueOrDefault(default_return_value)); - LONGS_EQUAL(expected_return_value, mock().returnUnsignedIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoUnsignedIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - unsigned int default_return_value = 10; - mock().expectOneCall("foo"); - LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnUnsignedIntValueOrDefault(default_return_value)); - LONGS_EQUAL(default_return_value, mock().returnUnsignedIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenAUnsignedLongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - unsigned long int default_return_value = 121487; - unsigned long int expected_return_value = default_return_value + 1; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnUnsignedLongIntValueOrDefault(default_return_value)); - LONGS_EQUAL(expected_return_value, mock().returnUnsignedLongIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoUnsignedLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - unsigned long int default_return_value = 7710144; - mock().expectOneCall("foo"); - LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnUnsignedLongIntValueOrDefault(default_return_value)); - LONGS_EQUAL(default_return_value, mock().returnUnsignedLongIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenALongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - long int default_return_value = 748797; - long int expected_return_value = default_return_value + 1; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnLongIntValueOrDefault(default_return_value)); - LONGS_EQUAL(expected_return_value, mock().returnLongIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - long int default_return_value = 123659; - mock().expectOneCall("foo"); - LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnLongIntValueOrDefault(default_return_value)); - LONGS_EQUAL(default_return_value, mock().returnLongIntValueOrDefault(default_return_value)); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockReturnValueTest, WhenAUnsignedLongLongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - 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)); - LONGS_EQUAL(expected_return_value, mock().returnUnsignedLongLongIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoUnsignedLongLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - 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)); -} - -TEST(MockReturnValueTest, WhenALongLongIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - 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)); - LONGS_EQUAL(expected_return_value, mock().returnLongLongIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoLongLongIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - 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)); -} - -#endif - -TEST(MockReturnValueTest, WhenABooleanReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - bool default_return_value = true; - bool expected_return_value = false; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - CHECK_EQUAL(expected_return_value, mock().actualCall("foo").returnBoolValueOrDefault(default_return_value)); - CHECK_EQUAL(expected_return_value, mock().returnBoolValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoBooleanReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - bool default_return_value = true; - mock().expectOneCall("foo"); - CHECK_EQUAL(default_return_value, mock().actualCall("foo").returnBoolValueOrDefault(default_return_value)); - CHECK_EQUAL(default_return_value, mock().returnBoolValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenAIntegerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - int default_return_value = 777; - int expected_return_value = default_return_value + 1; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - LONGS_EQUAL(expected_return_value, mock().actualCall("foo").returnIntValueOrDefault(default_return_value)); - LONGS_EQUAL(expected_return_value, mock().returnIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoIntegerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - int default_return_value = 777; - mock().expectOneCall("foo"); - LONGS_EQUAL(default_return_value, mock().actualCall("foo").returnIntValueOrDefault(default_return_value)); - LONGS_EQUAL(default_return_value, mock().returnIntValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, BooleanReturnValue) -{ - bool expected_value = true; - mock().expectOneCall("foo").andReturnValue(true); - MockActualCall& actual_call = mock().actualCall("foo"); - - CHECK_EQUAL(expected_value, actual_call.returnValue().getBoolValue()); - CHECK_EQUAL(expected_value, actual_call.returnBoolValue()); - - CHECK_EQUAL(expected_value, mock().returnValue().getBoolValue()); - CHECK_EQUAL(expected_value, mock().boolReturnValue()); -} - -TEST(MockReturnValueTest, BooleanReturnValueSetsDifferentValues) -{ - bool expected_value = true; - bool another_expected_value = false; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - CHECK_EQUAL(expected_value, mock().actualCall("foo").returnValue().getBoolValue()); - CHECK_EQUAL(expected_value, mock().returnValue().getBoolValue()); - CHECK_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getBoolValue()); - CHECK_EQUAL(another_expected_value, mock().returnValue().getBoolValue()); -} - -TEST(MockReturnValueTest, BooleanReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - bool ret_value = true; - bool another_ret_value = false; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - CHECK_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getBoolValue()); - CHECK_EQUAL(ret_value, mock().returnValue().getBoolValue()); - CHECK_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getBoolValue()); - CHECK_EQUAL(another_ret_value, mock().returnValue().getBoolValue()); -} - -TEST(MockReturnValueTest, IntegerReturnValue) -{ - int expected_value = 1; - mock().expectOneCall("foo").andReturnValue(1); - MockActualCall& actual_call = mock().actualCall("foo"); - - LONGS_EQUAL(expected_value, actual_call.returnValue().getIntValue()); - LONGS_EQUAL(expected_value, actual_call.returnIntValue()); - - LONGS_EQUAL(expected_value, mock().returnValue().getIntValue()); - LONGS_EQUAL(expected_value, mock().intReturnValue()); -} - -TEST(MockReturnValueTest, IntegerReturnValueSetsDifferentValues) -{ - int expected_value = 1; - int another_expected_value = -1; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getIntValue()); - LONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getIntValue()); - LONGS_EQUAL(another_expected_value, mock().returnValue().getIntValue()); -} - -TEST(MockReturnValueTest, IntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - int ret_value = 1; - int another_ret_value = -1; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - LONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getIntValue()); - LONGS_EQUAL(ret_value, mock().returnValue().getIntValue()); - LONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getIntValue()); - LONGS_EQUAL(another_ret_value, mock().returnValue().getIntValue()); -} - -TEST(MockReturnValueTest, LongIntegerReturnValue) -{ - long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - LONGS_EQUAL(expected_value, actual_call.returnValue().getLongIntValue()); - LONGS_EQUAL(expected_value, actual_call.returnLongIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getLongIntValue()); - LONGS_EQUAL(expected_value, mock().longIntReturnValue()); -} - -TEST(MockReturnValueTest, LongIntegerReturnValueSetsDifferentValues) -{ - long int expected_value = 1; - long int another_expected_value = 2; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getLongIntValue()); - LONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getLongIntValue()); - LONGS_EQUAL(another_expected_value, mock().returnValue().getLongIntValue()); -} - -TEST(MockReturnValueTest, LongIntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - long int ret_value = 1; - long int another_ret_value = 2; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - LONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getLongIntValue()); - LONGS_EQUAL(ret_value, mock().returnValue().getLongIntValue()); - LONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getLongIntValue()); - LONGS_EQUAL(another_ret_value, mock().returnValue().getLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongIntegerReturnValue) -{ - unsigned long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - LONGS_EQUAL(expected_value, actual_call.returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(expected_value, actual_call.returnUnsignedLongIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(expected_value, mock().unsignedLongIntReturnValue()); -} - -TEST(MockReturnValueTest, UnsignedLongIntegerReturnValueSetsDifferentValues) -{ - unsigned long int expected_value = 1; - unsigned long int another_expected_value = 2; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - LONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(expected_value, mock().returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(another_expected_value, mock().returnValue().getUnsignedLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongIntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - unsigned long int ret_value = 1; - unsigned long int another_ret_value = 2; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - LONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(ret_value, mock().returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedLongIntValue()); - LONGS_EQUAL(another_ret_value, mock().returnValue().getUnsignedLongIntValue()); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockReturnValueTest, LongLongIntegerReturnValue) -{ - long long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - LONGLONGS_EQUAL(expected_value, actual_call.returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(expected_value, actual_call.returnLongLongIntValue()); - LONGLONGS_EQUAL(expected_value, mock().returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(expected_value, mock().longLongIntReturnValue()); -} - -TEST(MockReturnValueTest, LongLongIntegerReturnValueSetsDifferentValues) -{ - long long int expected_value = 1; - long long int another_expected_value = 2; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(expected_value, mock().returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(another_expected_value, mock().returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, LongLongIntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - long long int ret_value = 1; - long long int another_ret_value = 2; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - LONGLONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(ret_value, mock().returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getLongLongIntValue()); - LONGLONGS_EQUAL(another_ret_value, mock().returnValue().getLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongLongIntegerReturnValue) -{ - unsigned long long int expected_value = 7; - mock().expectOneCall("foo").andReturnValue(expected_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - UNSIGNED_LONGLONGS_EQUAL(expected_value, actual_call.returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(expected_value, actual_call.returnUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().unsignedLongLongIntReturnValue()); -} - -TEST(MockReturnValueTest, UnsignedLongLongIntegerReturnValueSetsDifferentValues) -{ - unsigned long long int expected_value = 1; - unsigned long long int another_expected_value = 2; - - mock().expectOneCall("foo").andReturnValue(expected_value); - mock().expectOneCall("foo").andReturnValue(another_expected_value); - - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock().returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(another_expected_value, mock().actualCall("foo").returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(another_expected_value, mock().returnValue().getUnsignedLongLongIntValue()); -} - -TEST(MockReturnValueTest, UnsignedLongLongIntegerReturnValueSetsDifferentValuesWhileParametersAreIgnored) -{ - unsigned long long int ret_value = 1; - unsigned long long int another_ret_value = 2; - - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(ret_value); - mock().expectOneCall("foo").withParameter("p1", 1).ignoreOtherParameters().andReturnValue(another_ret_value); - - UNSIGNED_LONGLONGS_EQUAL(ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(ret_value, mock().returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(another_ret_value, mock().actualCall("foo").withParameter("p1", 1).returnValue().getUnsignedLongLongIntValue()); - UNSIGNED_LONGLONGS_EQUAL(another_ret_value, mock().returnValue().getUnsignedLongLongIntValue()); -} - -#endif - -TEST(MockReturnValueTest, MatchingReturnValueOnWhileSignature) -{ - mock().expectOneCall("foo").withParameter("p1", 1).andReturnValue(1); - mock().expectOneCall("foo").withParameter("p1", 2).andReturnValue(2); - mock().expectOneCall("foo").withParameter("p1", 3).andReturnValue(3); - mock().expectOneCall("foo").ignoreOtherParameters().andReturnValue(4); - - LONGS_EQUAL(3, mock().actualCall("foo").withParameter("p1", 3).returnValue().getIntValue()); - LONGS_EQUAL(4, mock().actualCall("foo").withParameter("p1", 4).returnValue().getIntValue()); - LONGS_EQUAL(1, mock().actualCall("foo").withParameter("p1", 1).returnValue().getIntValue()); - LONGS_EQUAL(2, mock().actualCall("foo").withParameter("p1", 2).returnValue().getIntValue()); -} - -TEST(MockReturnValueTest, WhenAStringReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - const char * default_return_value = "default"; - const char * expected_return_value = "expected"; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - STRCMP_EQUAL(expected_return_value, mock().actualCall("foo").returnStringValueOrDefault(default_return_value)); - STRCMP_EQUAL(expected_return_value, mock().returnStringValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoStringReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - const char * default_return_value = "default"; - mock().expectOneCall("foo"); - STRCMP_EQUAL(default_return_value, mock().actualCall("foo").returnStringValueOrDefault(default_return_value)); - STRCMP_EQUAL(default_return_value, mock().returnStringValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, StringReturnValue) -{ - mock().expectOneCall("foo").andReturnValue("hello world"); - MockActualCall& actual_call = mock().actualCall("foo"); - - STRCMP_EQUAL("hello world", actual_call.returnValue().getStringValue()); - STRCMP_EQUAL("hello world", actual_call.returnStringValue()); - STRCMP_EQUAL("hello world", mock().stringReturnValue()); -} - -TEST(MockReturnValueTest, DoubleReturnValue) -{ - double expected_return_value = 7.8; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - - MockActualCall& actual_call = mock().actualCall("foo"); - DOUBLES_EQUAL(expected_return_value, actual_call.returnValue().getDoubleValue(), 0.05); - DOUBLES_EQUAL(expected_return_value, actual_call.returnDoubleValue(), 0.05); - DOUBLES_EQUAL(expected_return_value, mock().doubleReturnValue(), 0.05); -} - -TEST(MockReturnValueTest, WhenAConstPointerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - const void * default_return_value = (void*) 0x7778; - const void * expected_return_value = (void*) 0x144010; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - POINTERS_EQUAL(expected_return_value, mock().actualCall("foo").returnConstPointerValueOrDefault(default_return_value)); - POINTERS_EQUAL(expected_return_value, mock().returnConstPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoConstPointerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - const void * default_return_value = (void*) 0x11; - mock().expectOneCall("foo"); - POINTERS_EQUAL(default_return_value, mock().actualCall("foo").returnConstPointerValueOrDefault(default_return_value)); - POINTERS_EQUAL(default_return_value, mock().returnConstPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenAPointerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - void * default_return_value = (void*) 0x777; - void * expected_return_value = (void*) 0x144000; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - POINTERS_EQUAL(expected_return_value, mock().actualCall("foo").returnPointerValueOrDefault(default_return_value)); - POINTERS_EQUAL(expected_return_value, mock().returnPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoPointerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - void * default_return_value = (void*) 0x10; - mock().expectOneCall("foo"); - POINTERS_EQUAL(default_return_value, mock().actualCall("foo").returnPointerValueOrDefault(default_return_value)); - POINTERS_EQUAL(default_return_value, mock().returnPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenAFunctionPointerReturnValueIsExpectedAndAlsoThereIsADefaultShouldlIgnoreTheDefault) -{ - void (*default_return_value)() = (void(*)()) 0x777; - void (*expected_return_value)() = (void(*)()) 0x144000; - mock().expectOneCall("foo").andReturnValue(expected_return_value); - FUNCTIONPOINTERS_EQUAL(expected_return_value, mock().actualCall("foo").returnFunctionPointerValueOrDefault(default_return_value)); - FUNCTIONPOINTERS_EQUAL(expected_return_value, mock().returnFunctionPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, WhenNoFunctionPointerReturnValueIsExpectedButThereIsADefaultShouldlUseTheDefaultValue) -{ - void (*default_return_value)() = (void(*)()) 0x10; - mock().expectOneCall("foo"); - FUNCTIONPOINTERS_EQUAL(default_return_value, mock().actualCall("foo").returnFunctionPointerValueOrDefault(default_return_value)); - FUNCTIONPOINTERS_EQUAL(default_return_value, mock().returnFunctionPointerValueOrDefault(default_return_value)); -} - -TEST(MockReturnValueTest, PointerReturnValue) -{ - void* ptr = (void*) 0x00107; - mock().expectOneCall("foo").andReturnValue(ptr); - MockActualCall& actual_call = mock().actualCall("foo"); - - POINTERS_EQUAL(ptr, actual_call.returnValue().getPointerValue()); - POINTERS_EQUAL(ptr, actual_call.returnPointerValue()); - POINTERS_EQUAL(ptr, mock().pointerReturnValue()); -} - -TEST(MockReturnValueTest, ConstPointerReturnValue) -{ - const void* ptr = (const void*) 0x001074; - mock().expectOneCall("foo").andReturnValue(ptr); - MockActualCall& actual_call = mock().actualCall("foo"); - POINTERS_EQUAL(ptr, actual_call.returnValue().getConstPointerValue()); - POINTERS_EQUAL(ptr, actual_call.returnConstPointerValue()); - POINTERS_EQUAL(ptr, mock().constPointerReturnValue()); -} - -TEST(MockReturnValueTest, FunctionPointerReturnValue) -{ - void (*ptr)() = (void(*)()) 0x00107; - mock().expectOneCall("foo").andReturnValue(ptr); - MockActualCall& actual_call = mock().actualCall("foo"); - - FUNCTIONPOINTERS_EQUAL(ptr, actual_call.returnValue().getFunctionPointerValue()); - FUNCTIONPOINTERS_EQUAL(ptr, actual_call.returnFunctionPointerValue()); - FUNCTIONPOINTERS_EQUAL(ptr, mock().functionPointerReturnValue()); -} - -TEST(MockReturnValueTest, whenCallingDisabledOrIgnoredActualCallsThenTheyDontReturnPreviousCallsValues) -{ - mock().expectOneCall("boo").ignoreOtherParameters().andReturnValue(10); - mock().ignoreOtherCalls(); - mock().actualCall("boo"); - mock().actualCall("An Ignored Call"); - - CHECK(!mock().hasReturnValue()); -} diff --git a/tests/CppUTestExt/MockStrictOrderTest.cpp b/tests/CppUTestExt/MockStrictOrderTest.cpp deleted file mode 100644 index 9151ffa5e..000000000 --- a/tests/CppUTestExt/MockStrictOrderTest.cpp +++ /dev/null @@ -1,199 +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/TestHarness.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockStrictOrderTest) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock().clear(); - } -}; - -TEST(MockStrictOrderTest, OrderObserved) -{ - mock().strictOrder(); - - mock().expectOneCall("foo1"); - mock().expectOneCall("foo2"); - mock().actualCall("foo1"); - mock().actualCall("foo2"); - - mock().checkExpectations(); -} - -TEST(MockStrictOrderTest, someOrderObserved) -{ - mock().expectOneCall("foo3").withCallOrder(3); - mock().expectOneCall("foo1"); - mock().expectOneCall("foo2"); - mock().actualCall("foo2"); - mock().actualCall("foo1"); - mock().actualCall("foo3"); - - mock().checkExpectations(); -} - -TEST(MockStrictOrderTest, orderViolated) -{ - MockFailureReporterInstaller failureReporterInstaller; - mock().strictOrder(); - - MockExpectedCallsListForTest expectations; - expectations.addFunctionOrdered("foo1", 1)->callWasMade(1); - expectations.addFunctionOrdered("foo1", 2)->callWasMade(3); - expectations.addFunctionOrdered("foo2", 3)->callWasMade(2); - MockCallOrderFailure expectedFailure(mockFailureTest(), expectations); - - mock().expectOneCall("foo1"); - mock().expectOneCall("foo1"); - mock().expectOneCall("foo2"); - mock().actualCall("foo1"); - mock().actualCall("foo2"); - mock().actualCall("foo1"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockStrictOrderTest, orderViolatedWorksHierarchically) -{ - MockFailureReporterInstaller failureReporterInstaller; - mock().strictOrder(); - mock("bla").strictOrder(); - - MockExpectedCallsListForTest expectations; - expectations.addFunctionOrdered("foo::foo1", 1)->callWasMade(2); - expectations.addFunctionOrdered("foo::foo2", 2)->callWasMade(1); - MockCallOrderFailure expectedFailure(mockFailureTest(), expectations); - - mock("bla").expectOneCall("foo1"); - mock("foo").expectOneCall("foo1"); - mock("foo").expectOneCall("foo2"); - - mock("bla").actualCall("foo1"); - mock("foo").actualCall("foo2"); - mock("foo").actualCall("foo1"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockStrictOrderTest, orderViolatedWorksWithExtraUnexpectedCall) -{ - MockFailureReporterInstaller failureReporterInstaller; - mock().strictOrder(); - mock("bla").strictOrder(); - mock().ignoreOtherCalls(); - - MockExpectedCallsListForTest expectations; - expectations.addFunctionOrdered("foo::foo1", 1)->callWasMade(2); - expectations.addFunctionOrdered("foo::foo2", 2)->callWasMade(1); - MockCallOrderFailure expectedFailure(mockFailureTest(), expectations); - - mock("bla").expectOneCall("foo1"); - mock("foo").expectOneCall("foo1"); - mock("foo").expectOneCall("foo2"); - - mock("bla").actualCall("foo1"); - mock("foo").actualCall("foo2"); - mock("foo").actualCall("unexpected1"); - mock("foo").actualCall("foo1"); - mock("foo").actualCall("unexpected2"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockStrictOrderTest, orderViolatedWithinAScope) -{ - MockFailureReporterInstaller failureReporterInstaller; - mock().strictOrder(); - - MockExpectedCallsListForTest expectations; - expectations.addFunctionOrdered("scope::foo1", 1)->callWasMade(2); - expectations.addFunctionOrdered("scope::foo2", 2)->callWasMade(1); - MockCallOrderFailure expectedFailure(mockFailureTest(), expectations); - - mock("scope").expectOneCall("foo1"); - mock("scope").expectOneCall("foo2"); - mock("scope").actualCall("foo2"); - mock("scope").actualCall("foo1"); - - mock().checkExpectations(); - CHECK_EXPECTED_MOCK_FAILURE(expectedFailure); -} - -TEST(MockStrictOrderTest, orderNotViolatedAcrossScopes) -{ - mock("mock1").strictOrder(); - mock("mock2").strictOrder(); - - mock("mock1").expectOneCall("foo1"); - mock("mock2").expectOneCall("foo2"); - mock("mock1").actualCall("foo1"); - mock("mock2").actualCall("foo2"); - - mock("mock1").checkExpectations(); - mock("mock2").checkExpectations(); -} - -TEST(MockStrictOrderTest, orderViolatedAcrossScopes) -{ - mock("mock1").strictOrder(); - mock("mock2").strictOrder(); - - mock("mock1").expectOneCall("foo1"); - mock("mock2").expectOneCall("foo2"); - mock("mock2").actualCall("foo2"); - mock("mock1").actualCall("foo1"); - - mock("mock1").checkExpectations(); - mock("mock2").checkExpectations(); -} - -TEST(MockStrictOrderTest, orderUsingNCalls) -{ - mock().strictOrder(); - - mock().expectOneCall("foo1"); - mock().expectNCalls(2, "foo2"); - mock().expectOneCall("foo1"); - mock().expectNCalls(3, "foo2"); - - mock().actualCall("foo1"); - mock().actualCall("foo2"); - mock().actualCall("foo2"); - mock().actualCall("foo1"); - mock().actualCall("foo2"); - mock().actualCall("foo2"); - mock().actualCall("foo2"); - - mock().checkExpectations(); -} diff --git a/tests/CppUTestExt/MockSupportTest.cpp b/tests/CppUTestExt/MockSupportTest.cpp deleted file mode 100644 index 7f9be3153..000000000 --- a/tests/CppUTestExt/MockSupportTest.cpp +++ /dev/null @@ -1,300 +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/TestHarness.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTestExt/MockSupport.h" -#include "CppUTestExt/MockExpectedCall.h" -#include "CppUTestExt/MockFailure.h" -#include "MockFailureReporterForTest.h" - -TEST_GROUP(MockSupportTest) -{ - MockExpectedCallsListForTest expectations; - MockFailureReporterInstaller failureReporterInstaller; - - void teardown() CPPUTEST_OVERRIDE - { - mock().checkExpectations(); - CHECK_NO_MOCK_FAILURE(); - MockFailureReporterForTest::clearReporter(); - mock().clear(); - } -}; - -TEST(MockSupportTest, setDataForUnsignedIntegerValues) -{ - unsigned int expected_data = 7; - mock().setData("data", expected_data); - LONGS_EQUAL(expected_data, mock().getData("data").getUnsignedIntValue()); -} - -TEST(MockSupportTest, setDataForIntegerValues) -{ - int expected_data = 10; - mock().setData("data", expected_data); - LONGS_EQUAL(expected_data, mock().getData("data").getIntValue()); -} - -TEST(MockSupportTest, setDataForBooleanValues) -{ - bool expected_data = true; - mock().setData("data", expected_data); - CHECK_EQUAL(expected_data, mock().getData("data").getBoolValue()); -} - -TEST(MockSupportTest, hasDataBeenSet) -{ - CHECK(!mock().hasData("data")); - mock().setData("data", 10); - CHECK(mock().hasData("data")); -} - -TEST(MockSupportTest, dataCanBeChanged) -{ - mock().setData("data", 10); - mock().setData("data", 15); - LONGS_EQUAL(15, mock().getData("data").getIntValue()); -} - -TEST(MockSupportTest, uninitializedData) -{ - LONGS_EQUAL(0, mock().getData("nonexisting").getIntValue()); - STRCMP_EQUAL("int", mock().getData("nonexisting").getType().asCharString()); -} - -TEST(MockSupportTest, setMultipleData) -{ - mock().setData("data", 1); - mock().setData("data2", 10); - LONGS_EQUAL(1, mock().getData("data").getIntValue()); - LONGS_EQUAL(10, mock().getData("data2").getIntValue()); -} - -TEST(MockSupportTest, setDataString) -{ - mock().setData("data", "string"); - STRCMP_EQUAL("string", mock().getData("data").getStringValue()); -} - -TEST(MockSupportTest, setDataDouble) -{ - mock().setData("data", 1.0); - DOUBLES_EQUAL(1.0, mock().getData("data").getDoubleValue(), 0.05); -} - -TEST(MockSupportTest, setDataLongInt) -{ - long int i = 100; - mock().setData("data", i); - LONGS_EQUAL(i, mock().getData("data").getLongIntValue()); -} - -TEST(MockSupportTest, setDataUnsignedLongInt) -{ - unsigned long int i = 100; - mock().setData("data", i); - UNSIGNED_LONGS_EQUAL(i, mock().getData("data").getUnsignedLongIntValue()); -} - -TEST(MockSupportTest, setDataPointer) -{ - void * ptr = (void*) 0x001; - mock().setData("data", ptr); - POINTERS_EQUAL(ptr, mock().getData("data").getPointerValue()); -} - -TEST(MockSupportTest, setConstDataPointer) -{ - const void * ptr = (const void*) 0x001; - mock().setData("data", ptr); - POINTERS_EQUAL(ptr, mock().getData("data").getConstPointerValue()); -} - -TEST(MockSupportTest, setDataFunctionPointer) -{ - void (*ptr)() = (void(*)()) 0x001; - mock().setData("data", ptr); - FUNCTIONPOINTERS_EQUAL(ptr, mock().getData("data").getFunctionPointerValue()); -} - -TEST(MockSupportTest, setDataObject) -{ - void * ptr = (void*) 0x001; - mock().setDataObject("data", "type", ptr); - POINTERS_EQUAL(ptr, mock().getData("data").getObjectPointer()); - STRCMP_EQUAL("type", mock().getData("data").getType().asCharString()); -} - -TEST(MockSupportTest, setDataConstObject) -{ - void * ptr = (void*) 0x011; - mock().setDataConstObject("data", "type", ptr); - POINTERS_EQUAL(ptr, mock().getData("data").getConstObjectPointer()); - STRCMP_EQUAL("type", mock().getData("data").getType().asCharString()); -} - -TEST(MockSupportTest, tracing) -{ - mock().tracing(true); - - mock().actualCall("boo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - mock("scope").actualCall("foo").withParameter("double", 1.0).withParameter("int", 1).withParameter("string", "string"); - mock().checkExpectations(); - - STRCMP_CONTAINS("boo", mock().getTraceOutput()); - STRCMP_CONTAINS("foo", mock().getTraceOutput()); -} - -TEST(MockSupportTest, tracingWorksHierarchically) -{ - mock("scope").tracing(true); - mock().tracing(true); - - mock().actualCall("boo"); - mock("scope").actualCall("foo"); - mock().checkExpectations(); - - STRCMP_CONTAINS("boo", mock().getTraceOutput()); - STRCMP_CONTAINS("foo", mock().getTraceOutput()); -} - -TEST_GROUP(MockSupportTestWithFixture) -{ - TestTestingFixture fixture; - - void teardown() CPPUTEST_OVERRIDE - { - mock().clear(); - MockFailureReporterForTest::clearReporter(); - } -}; - -static void CHECK_EXPECTED_MOCK_FAILURE_LOCATION_failedTestMethod_() -{ - MockExpectedCallsList list; - MockUnexpectedCallHappenedFailure expectedFailure(UtestShell::getCurrent(), "unexpected", list); - mock().actualCall("boo"); - CHECK_EXPECTED_MOCK_FAILURE_LOCATION(expectedFailure, "file", 1); -} - -TEST(MockSupportTestWithFixture, CHECK_EXPECTED_MOCK_FAILURE_LOCATION_failed) -{ - mock().setMockFailureStandardReporter(MockFailureReporterForTest::getReporter()); - fixture.setTestFunction(CHECK_EXPECTED_MOCK_FAILURE_LOCATION_failedTestMethod_); - fixture.runAllTests(); - fixture.assertPrintContains("MockFailures are different."); - fixture.assertPrintContains("Expected MockFailure:"); - fixture.assertPrintContains("Mock Failure: Unexpected call to function: unexpected"); - fixture.assertPrintContains("Actual MockFailure:"); - fixture.assertPrintContains("Mock Failure: Unexpected call to function: boo"); -} - -static void CHECK_NO_MOCK_FAILURE_LOCATION_failedTestMethod_() -{ - mock().actualCall("boo"); - CHECK_NO_MOCK_FAILURE_LOCATION("file", 1); -} - -TEST(MockSupportTestWithFixture, CHECK_NO_MOCK_FAILURE_LOCATION_failed) -{ - mock().setMockFailureStandardReporter(MockFailureReporterForTest::getReporter()); - fixture.setTestFunction(CHECK_NO_MOCK_FAILURE_LOCATION_failedTestMethod_); - fixture.runAllTests(); - fixture.assertPrintContains("Unexpected mock failure:"); - fixture.assertPrintContains("Mock Failure: Unexpected call to function: boo"); -} - -static bool cpputestHasCrashed; - -static void crashMethod() -{ - cpputestHasCrashed = true; -} - -static void unexpectedCallTestFunction_(void) -{ - mock().actualCall("unexpected"); -} // LCOV_EXCL_LINE - -#include "CppUTestExt/OrderedTest.h" - -TEST(MockSupportTestWithFixture, shouldCrashOnFailure) -{ - cpputestHasCrashed = false; - mock().crashOnFailure(true); - UtestShell::setCrashMethod(crashMethod); - fixture.setTestFunction(unexpectedCallTestFunction_); - - fixture.runAllTests(); - - CHECK(cpputestHasCrashed); - - mock().crashOnFailure(false); - UtestShell::resetCrashMethod(); -} - -TEST(MockSupportTestWithFixture, ShouldNotCrashOnFailureAfterCrashMethodWasReset) -{ - cpputestHasCrashed = false; - UtestShell::setCrashMethod(crashMethod); - fixture.setTestFunction(unexpectedCallTestFunction_); - UtestShell::resetCrashMethod(); - - fixture.runAllTests(); - - fixture.assertPrintContains("Unexpected call to function: unexpected"); - 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_); - int repeatCount = 2; - while(repeatCount--) - { - fixture.runAllTests(); - fixture.assertPrintContains("Unexpected call to function: unexpected"); - fixture.assertPrintContains("Errors (1 failures, 1 tests, 1 ran, 0 checks, 0 ignored, 0 filtered out"); - fixture.flushOutputAndResetResult(); - } -} diff --git a/tests/CppUTestExt/MockSupport_cTest.cpp b/tests/CppUTestExt/MockSupport_cTest.cpp deleted file mode 100644 index 0ce86bedf..000000000 --- a/tests/CppUTestExt/MockSupport_cTest.cpp +++ /dev/null @@ -1,797 +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/TestHarness.h" - -#include "CppUTest/TestHarness_c.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTestExt/MockSupport_c.h" -#include "MockSupport_cTestCFile.h" -#include "CppUTestExt/OrderedTest.h" - -extern "C" { - static void dummy_function_for_mock_c_test() - { - } - static void dummy_function_for_mock_c_test_two() - { - } -} - -TEST_GROUP(MockSupport_c) -{ - void teardown() CPPUTEST_OVERRIDE - { - mock_c()->clear(); - } -}; - -TEST(MockSupport_c, OrderObserved) -{ - mock_c()->strictOrder(); - - mock_c()->expectOneCall("foo1"); - mock_c()->expectOneCall("foo2"); - mock_c()->actualCall("foo1"); - mock_c()->actualCall("foo2"); - - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, hasReturnValue) -{ - mock_c()->expectOneCall("foo"); - CHECK(mock_c()->actualCall("foo")->hasReturnValue() == 0); - CHECK(mock_c()->hasReturnValue() == 0); - - mock_c()->expectOneCall("foo2")->andReturnIntValue(1); - CHECK(mock_c()->actualCall("foo2")->hasReturnValue() != 0); - CHECK(mock_c()->hasReturnValue() != 0); -} - -TEST(MockSupport_c, expectAndActualOneCall) -{ - mock_c()->expectOneCall("boo"); - mock_c()->actualCall("boo"); - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, expectAndActualThreeCalls) -{ - mock_c()->expectNCalls(3, "boo"); - mock_c()->actualCall("boo"); - mock_c()->actualCall("boo"); - mock_c()->actualCall("boo"); - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, expectNoCall) -{ - mock_c()->expectNoCall("foo"); - mock_c()->expectOneCall("bar"); - mock_c()->actualCall("bar"); - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, expectAndActualParameters) -{ - mock_c()->expectOneCall("boo")->withIntParameters("integer", 1)->withDoubleParameters("double", 1.0)-> - withStringParameters("string", "string")->withPointerParameters("pointer", (void*) 1)-> - withFunctionPointerParameters("functionPointer", dummy_function_for_mock_c_test); - mock_c()->actualCall("boo")->withIntParameters("integer", 1)->withDoubleParameters("double", 1.0)-> - withStringParameters("string", "string")->withPointerParameters("pointer", (void*) 1)-> - withFunctionPointerParameters("functionPointer", dummy_function_for_mock_c_test); -} - -extern "C"{ - - static int typeNameIsEqual(const void* object1, const void* object2) - { - return object1 == object2; - } - - static const char* typeNameValueToString(const void* PUNUSED(object)) - { - return "valueToString"; - } - - static void typeCopy(void* dst, const void* src) - { - *(int*) dst = *(const int*) src; - } - -} - -TEST(MockSupport_c, expectAndActualParametersOnObject) -{ - mock_c()->installComparator("typeName", typeNameIsEqual, typeNameValueToString); - mock_c()->expectOneCall("boo")->withParameterOfType("typeName", "name", (const void*) 1); - mock_c()->actualCall("boo")->withParameterOfType("typeName", "name", (const void*) 1); - mock_c()->checkExpectations(); - mock_c()->removeAllComparatorsAndCopiers(); -} - -TEST(MockSupport_c, boolParameter) -{ - mock_c()->expectOneCall("foo")->withBoolParameters("p", 1); - mock_c()->actualCall("foo")->withBoolParameters("p", 1); -} - -TEST(MockSupport_c, unsignedIntParameter) -{ - mock_c()->expectOneCall("foo")->withUnsignedIntParameters("p", 1); - mock_c()->actualCall("foo")->withUnsignedIntParameters("p", 1); -} - -TEST(MockSupport_c, longIntParameter) -{ - mock_c()->expectOneCall("foo")->withLongIntParameters("p", 1); - mock_c()->actualCall("foo")->withLongIntParameters("p", 1); -} - -TEST(MockSupport_c, unsignedLongIntParameter) -{ - mock_c()->expectOneCall("foo")->withUnsignedLongIntParameters("p", 1); - mock_c()->actualCall("foo")->withUnsignedLongIntParameters("p", 1); -} - -TEST(MockSupport_c, doubleParameterWithTolerance) -{ - mock_c( )->expectOneCall("foo")->withDoubleParametersAndTolerance("p", 2.0, 0.2); - mock_c( )->actualCall("foo")->withDoubleParameters("p", 1.9); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockSupport_c, longLongIntParameter) -{ - mock_c()->expectOneCall("foo")->withLongLongIntParameters("p", 1); - mock_c()->actualCall("foo")->withLongLongIntParameters("p", 1); -} - -TEST(MockSupport_c, unsignedLongLongIntParameter) -{ - mock_c()->expectOneCall("foo")->withUnsignedLongLongIntParameters("p", 1); - mock_c()->actualCall("foo")->withUnsignedLongLongIntParameters("p", 1); -} - -#endif - -TEST(MockSupport_c, memoryBufferParameter) -{ - const unsigned char mem_buffer[] = { 1, 2, 3}; - mock_c()->expectOneCall("foo")->withMemoryBufferParameter("out", mem_buffer, sizeof(mem_buffer)); - mock_c()->actualCall("foo")->withMemoryBufferParameter("out", mem_buffer, sizeof(mem_buffer)); - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, outputParameters) -{ - int param = 1; - const int retval = 2; - mock_c()->expectOneCall("foo")->withOutputParameterReturning("out", &retval, sizeof(retval)); - mock_c()->actualCall("foo")->withOutputParameter("out", ¶m); - mock_c()->checkExpectations(); - LONGS_EQUAL(2, param); - LONGS_EQUAL(2, retval); -} - -TEST(MockSupport_c, unmodifiedOutputParameter) -{ - int param = 1; - mock_c()->expectOneCall("foo")->withUnmodifiedOutputParameter("out"); - mock_c()->actualCall("foo")->withOutputParameter("out", ¶m); - mock_c()->checkExpectations(); - LONGS_EQUAL(1, param); -} - -TEST(MockSupport_c, outputParameters_differentType) -{ - long param = 1; - const long retval = 2; - mock_c()->expectOneCall("foo")->withOutputParameterReturning("out", &retval, sizeof(retval)); - mock_c()->actualCall("foo")->withOutputParameter("out", ¶m); - mock_c()->checkExpectations(); - LONGS_EQUAL(2, param); - LONGS_EQUAL(2, retval); -} - -TEST(MockSupport_c, outputParametersOfType) -{ - int param = 1; - const int retval = 2; - mock_c()->installCopier("typeName", typeCopy); - mock_c()->expectOneCall("foo")->withOutputParameterOfTypeReturning("typeName", "out", &retval); - mock_c()->actualCall("foo")->withOutputParameterOfType("typeName", "out", ¶m); - LONGS_EQUAL(2, param); - LONGS_EQUAL(2, retval); - mock_c()->checkExpectations(); - mock_c()->removeAllComparatorsAndCopiers(); -} - -TEST(MockSupport_c, ignoreOtherParameters) -{ - mock_c()->expectOneCall("foo")->withIntParameters("int", 1)->ignoreOtherParameters(); - mock_c()->actualCall("foo")->withIntParameters("int", 1)->withDoubleParameters("double", 0.01); - mock_c()->checkExpectations(); -} - -TEST(MockSupport_c, returnBoolValue) -{ - int expected_value = 1; - mock_c()->expectOneCall("boo")->andReturnBoolValue(expected_value); - CHECK_EQUAL(expected_value, mock_c()->actualCall("boo")->boolReturnValue()); - CHECK_EQUAL(expected_value, mock_c()->boolReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_BOOL, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnBoolValueOrDefaultShouldIgnoreTheDefault) -{ - int defaultValue = 1; - int expectedValue = 0; - mock_c()->expectOneCall("foo")->andReturnBoolValue(expectedValue); - LONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnBoolValueOrDefault(defaultValue)); - LONGS_EQUAL(expectedValue, mock_c()->returnBoolValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnBoolValueOrDefaultShouldlUseTheDefaultValue) -{ - int defaultValue = 1; - mock_c()->expectOneCall("foo"); - LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnBoolValueOrDefault(defaultValue)); - LONGS_EQUAL(defaultValue, mock_c()->returnBoolValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnIntValue) -{ - int expected_value = -10; - mock_c()->expectOneCall("boo")->andReturnIntValue(expected_value); - LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->intReturnValue()); - LONGS_EQUAL(expected_value, mock_c()->intReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnIntValueOrDefaultShouldIgnoreTheDefault) -{ - int defaultValue = -10; - int expectedValue = defaultValue - 1; - mock_c()->expectOneCall("foo")->andReturnIntValue(expectedValue); - LONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnIntValueOrDefault(defaultValue)); - LONGS_EQUAL(expectedValue, mock_c()->returnIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnIntValueOrDefaultShouldlUseTheDefaultValue) -{ - int defaultValue = -10; - mock_c()->expectOneCall("foo"); - LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnIntValueOrDefault(defaultValue)); - LONGS_EQUAL(defaultValue, mock_c()->returnIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnUnsignedIntValue) -{ - unsigned int expected_value = 7; - mock_c()->expectOneCall("boo")->andReturnUnsignedIntValue(expected_value); - LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->unsignedIntReturnValue()); - LONGS_EQUAL(expected_value, mock_c()->unsignedIntReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_UNSIGNED_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnUnsignedIntValueOrDefaultShouldIgnoreTheDefault) -{ - unsigned int defaultValue = 10; - unsigned int expectedValue = defaultValue + 1; - mock_c()->expectOneCall("foo")->andReturnUnsignedIntValue(expectedValue); - LONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnUnsignedIntValueOrDefault(defaultValue)); - LONGS_EQUAL(expectedValue, mock_c()->returnUnsignedIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnUnsignedIntValueOrDefaultShouldlUseTheDefaultValue) -{ - unsigned int defaultValue = 10; - mock_c()->expectOneCall("foo"); - LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnUnsignedIntValueOrDefault(defaultValue)); - LONGS_EQUAL(defaultValue, mock_c()->returnUnsignedIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnLongIntValue) -{ - long int expected_value = -10L; - mock_c()->expectOneCall("boo")->andReturnLongIntValue(expected_value); - LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->longIntReturnValue()); - LONGS_EQUAL(expected_value, mock_c()->longIntReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_LONG_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnLongIntValueOrDefaultShouldIgnoreTheDefault) -{ - long int defaultValue = -10L; - long int expectedValue = defaultValue - 1L; - mock_c()->expectOneCall("foo")->andReturnLongIntValue(expectedValue); - LONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnLongIntValueOrDefault(defaultValue)); - LONGS_EQUAL(expectedValue, mock_c()->returnLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnLongIntValueOrDefaultShouldlUseTheDefaultValue) -{ - long int defaultValue = -10L; - mock_c()->expectOneCall("foo"); - LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnLongIntValueOrDefault(defaultValue)); - LONGS_EQUAL(defaultValue, mock_c()->returnLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnUnsignedLongIntValue) -{ - unsigned long int expected_value = 10; - mock_c()->expectOneCall("boo")->andReturnUnsignedLongIntValue(expected_value); - LONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->unsignedLongIntReturnValue()); - LONGS_EQUAL(expected_value, mock_c()->unsignedLongIntReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_UNSIGNED_LONG_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnUnsignedLongIntValueOrDefaultShouldIgnoreTheDefault) -{ - unsigned long int defaultValue = 10L; - unsigned long int expectedValue = defaultValue + 1L; - mock_c()->expectOneCall("foo")->andReturnUnsignedLongIntValue(expectedValue); - LONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnUnsignedLongIntValueOrDefault(defaultValue)); - LONGS_EQUAL(expectedValue, mock_c()->returnUnsignedLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnUnsignedLongIntValueOrDefaultShouldlUseTheDefaultValue) -{ - unsigned long int defaultValue = 10L; - mock_c()->expectOneCall("foo"); - LONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnUnsignedLongIntValueOrDefault(defaultValue)); - LONGS_EQUAL(defaultValue, mock_c()->returnUnsignedLongIntValueOrDefault(defaultValue)); -} - -#if CPPUTEST_USE_LONG_LONG - -TEST(MockSupport_c, returnLongLongIntValue) -{ - long long int expected_value = -10L; - mock_c()->expectOneCall("boo")->andReturnLongLongIntValue(expected_value); - LONGLONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->longLongIntReturnValue()); - LONGLONGS_EQUAL(expected_value, mock_c()->longLongIntReturnValue()); - LONGLONGS_EQUAL(MOCKVALUETYPE_LONG_LONG_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnLongLongIntValueOrDefaultShouldIgnoreTheDefault) -{ - long long int defaultValue = -10L; - long long int expectedValue = defaultValue - 1L; - mock_c()->expectOneCall("foo")->andReturnLongLongIntValue(expectedValue); - LONGLONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnLongLongIntValueOrDefault(defaultValue)); - LONGLONGS_EQUAL(expectedValue, mock_c()->returnLongLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnLongLongIntValueOrDefaultShouldlUseTheDefaultValue) -{ - long long int defaultValue = -10L; - mock_c()->expectOneCall("foo"); - LONGLONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnLongLongIntValueOrDefault(defaultValue)); - LONGLONGS_EQUAL(defaultValue, mock_c()->returnLongLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnUnsignedLongLongIntValue) -{ - unsigned long long int expected_value = 10; - mock_c()->expectOneCall("boo")->andReturnUnsignedLongLongIntValue(expected_value); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock_c()->actualCall("boo")->unsignedLongLongIntReturnValue()); - UNSIGNED_LONGLONGS_EQUAL(expected_value, mock_c()->unsignedLongLongIntReturnValue()); - UNSIGNED_LONGLONGS_EQUAL(MOCKVALUETYPE_UNSIGNED_LONG_LONG_INTEGER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnUnsignedLongLongIntValueOrDefaultShouldIgnoreTheDefault) -{ - unsigned long long int defaultValue = 10L; - unsigned long long int expectedValue = defaultValue + 1L; - mock_c()->expectOneCall("foo")->andReturnUnsignedLongLongIntValue(expectedValue); - UNSIGNED_LONGLONGS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnUnsignedLongLongIntValueOrDefault(defaultValue)); - UNSIGNED_LONGLONGS_EQUAL(expectedValue, mock_c()->returnUnsignedLongLongIntValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnUnsignedLongLongIntValueOrDefaultShouldlUseTheDefaultValue) -{ - unsigned long long int defaultValue = 10L; - mock_c()->expectOneCall("foo"); - UNSIGNED_LONGLONGS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnUnsignedLongLongIntValueOrDefault(defaultValue)); - UNSIGNED_LONGLONGS_EQUAL(defaultValue, mock_c()->returnUnsignedLongLongIntValueOrDefault(defaultValue)); -} - -#endif - -TEST(MockSupport_c, returnStringValue) -{ - mock_c()->expectOneCall("boo")->andReturnStringValue("hello world"); - STRCMP_EQUAL("hello world", mock_c()->actualCall("boo")->stringReturnValue()); - STRCMP_EQUAL("hello world", mock_c()->stringReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_STRING, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnStringValueOrDefaultShouldIgnoreTheDefault) -{ - const char defaultValue[] = "bar"; - const char expectedValue[] = "bla"; - mock_c()->expectOneCall("foo")->andReturnStringValue(expectedValue); - STRCMP_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnStringValueOrDefault(defaultValue)); - STRCMP_EQUAL(expectedValue, mock_c()->returnStringValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnStringValueOrDefaultShouldlUseTheDefaultValue) -{ - const char defaultValue[] = "bar"; - mock_c()->expectOneCall("foo"); - STRCMP_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnStringValueOrDefault(defaultValue)); - STRCMP_EQUAL(defaultValue, mock_c()->returnStringValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnDoubleValue) -{ - mock_c()->expectOneCall("boo")->andReturnDoubleValue(1.0); - DOUBLES_EQUAL(1.0, mock_c()->actualCall("boo")->doubleReturnValue(), 0.005); - DOUBLES_EQUAL(1.0, mock_c()->doubleReturnValue(), 0.005); - LONGS_EQUAL(MOCKVALUETYPE_DOUBLE, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnDoubleValueOrDefaultShouldIgnoreTheDefault) -{ - double defaultValue = 2.2; - double expectedValue = defaultValue + 0.1; - mock_c()->expectOneCall("foo")->andReturnDoubleValue(expectedValue); - DOUBLES_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnDoubleValueOrDefault(defaultValue), 0.005); - DOUBLES_EQUAL(expectedValue, mock_c()->returnDoubleValueOrDefault(defaultValue), 0.005); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnDoubleValueOrDefaultShouldlUseTheDefaultValue) -{ - double defaultValue = 2.2; - mock_c()->expectOneCall("foo"); - DOUBLES_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnDoubleValueOrDefault(defaultValue), 0.005); - DOUBLES_EQUAL(defaultValue, mock_c()->returnDoubleValueOrDefault(defaultValue), 0.005); -} - -TEST(MockSupport_c, returnPointerValue) -{ - mock_c()->expectOneCall("boo")->andReturnPointerValue((void*) 10); - POINTERS_EQUAL((void*) 10, mock_c()->actualCall("boo")->pointerReturnValue()); - POINTERS_EQUAL((void*) 10, mock_c()->pointerReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_POINTER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnPointerValueOrDefaultShouldIgnoreTheDefault) -{ - void* defaultValue = (void*) 10; - void* expectedValue = (void*) 27; - mock_c()->expectOneCall("foo")->andReturnPointerValue(expectedValue); - POINTERS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnPointerValueOrDefault(defaultValue)); - POINTERS_EQUAL(expectedValue, mock_c()->returnPointerValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnPointerValueOrDefaultShouldlUseTheDefaultValue) -{ - void* defaultValue = (void*) 10; - mock_c()->expectOneCall("foo"); - POINTERS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnPointerValueOrDefault(defaultValue)); - POINTERS_EQUAL(defaultValue, mock_c()->returnPointerValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnConstPointerValue) -{ - mock_c()->expectOneCall("boo")->andReturnConstPointerValue((const void*) 10); - POINTERS_EQUAL((const void*) 10, mock_c()->actualCall("boo")->constPointerReturnValue()); - POINTERS_EQUAL((const void*) 10, mock_c()->constPointerReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_CONST_POINTER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnConstPointerValueOrDefaultShouldIgnoreTheDefault) -{ - const void* defaultValue = (void*) 10; - const void* expectedValue = (void*) 27; - mock_c()->expectOneCall("foo")->andReturnConstPointerValue(expectedValue); - POINTERS_EQUAL(expectedValue, mock_c()->actualCall("foo")->returnConstPointerValueOrDefault(defaultValue)); - POINTERS_EQUAL(expectedValue, mock_c()->returnConstPointerValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnConstPointerValueOrDefaultShouldlUseTheDefaultValue) -{ - const void* defaultValue = (void*) 10; - mock_c()->expectOneCall("foo"); - POINTERS_EQUAL(defaultValue, mock_c()->actualCall("foo")->returnConstPointerValueOrDefault(defaultValue)); - POINTERS_EQUAL(defaultValue, mock_c()->returnConstPointerValueOrDefault(defaultValue)); -} - -TEST(MockSupport_c, returnFunctionPointerValue) -{ - mock_c()->expectOneCall("boo")->andReturnFunctionPointerValue(dummy_function_for_mock_c_test); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->actualCall("boo")->functionPointerReturnValue()); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->functionPointerReturnValue()); - LONGS_EQUAL(MOCKVALUETYPE_FUNCTIONPOINTER, mock_c()->returnValue().type); -} - -TEST(MockSupport_c, whenReturnValueIsGivenReturnFunctionPointerValueOrDefaultShouldIgnoreTheDefault) -{ - mock_c()->expectOneCall("foo")->andReturnFunctionPointerValue(dummy_function_for_mock_c_test); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->actualCall("foo")->returnFunctionPointerValueOrDefault(dummy_function_for_mock_c_test_two)); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->returnFunctionPointerValueOrDefault(dummy_function_for_mock_c_test_two)); -} - -TEST(MockSupport_c, whenNoReturnValueIsGivenReturnFunctionPointerValueOrDefaultShouldlUseTheDefaultValue) -{ - mock_c()->expectOneCall("foo"); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test_two, mock_c()->actualCall("foo")->returnFunctionPointerValueOrDefault(dummy_function_for_mock_c_test_two)); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test_two, mock_c()->returnFunctionPointerValueOrDefault(dummy_function_for_mock_c_test_two)); -} - -TEST(MockSupport_c, MockSupportWithScope) -{ - mock_scope_c("scope")->expectOneCall("boo"); - LONGS_EQUAL(0, mock_scope_c("other")->expectedCallsLeft()); - LONGS_EQUAL(1, mock_scope_c("scope")->expectedCallsLeft()); - mock_scope_c("scope")->actualCall("boo"); -} - -TEST(MockSupport_c, MockSupportSetBoolData) -{ - mock_c()->setBoolData("boolean", 1); - CHECK_EQUAL(1, mock_c()->getData("boolean").value.boolValue); -} - -TEST(MockSupport_c, MockSupportSetIntData) -{ - mock_c()->setIntData("integer", 10); - LONGS_EQUAL(10, mock_c()->getData("integer").value.intValue); -} - -TEST(MockSupport_c, MockSupportSetLongIntData) -{ - long int i = 100; - mock_c()->setLongIntData("long integer", i); - LONGS_EQUAL(i, mock_c()->getData("long integer").value.longIntValue); -} - -TEST(MockSupport_c, MockSupportSetUnsignedLongIntData) -{ - unsigned long int i = 100; - mock_c()->setUnsignedLongIntData("unsigned long integer", i); - UNSIGNED_LONGS_EQUAL(i, mock_c()->getData("unsigned long integer").value.unsignedLongIntValue); -} - -TEST(MockSupport_c, MockSupportSetDoubleData) -{ - mock_c()->setDoubleData("double", 1.0); - DOUBLES_EQUAL(1.00, mock_c()->getData("double").value.doubleValue, 0.05); -} - -TEST(MockSupport_c, MockSupportSetStringData) -{ - mock_c()->setStringData("string", "hello world"); - STRCMP_EQUAL("hello world", mock_c()->getData("string").value.stringValue); -} - -TEST(MockSupport_c, MockSupportSetPointerData) -{ - mock_c()->setPointerData("pointer", (void*) 1); - POINTERS_EQUAL((void*) 1, mock_c()->getData("pointer").value.pointerValue); -} - -TEST(MockSupport_c, MockSupportSetConstPointerData) -{ - mock_c()->setConstPointerData("constPointer", (const void*) 1); - POINTERS_EQUAL((const void*) 1, mock_c()->getData("constPointer").value.constPointerValue); -} - -TEST(MockSupport_c, MockSupportMemoryBufferData) -{ - mock_c()->setDataObject("name", "const unsigned char*", (void *) 0xDEAD); - POINTERS_EQUAL(0xDEAD, mock_c()->getData("name").value.memoryBufferValue); - LONGS_EQUAL(MOCKVALUETYPE_MEMORYBUFFER, mock_c()->getData("name").type); -} - -TEST(MockSupport_c, MockSupportSetFunctionPointerData) -{ - mock_c()->setFunctionPointerData("functionPointer", dummy_function_for_mock_c_test); - FUNCTIONPOINTERS_EQUAL(dummy_function_for_mock_c_test, mock_c()->getData("functionPointer").value.functionPointerValue); -} - -TEST(MockSupport_c, MockSupportSetDataObject) -{ - mock_c()->setDataObject("name", "type", (void*) 1); - POINTERS_EQUAL((void*) 1, mock_c()->getData("name").value.objectValue); -} - -TEST(MockSupport_c, MockSupportSetDataConstObject) -{ - mock_c()->setDataConstObject("name", "type", (const void*) 5); - POINTERS_EQUAL((void*) 5, mock_c()->getData("name").value.constObjectValue); -} - -TEST(MockSupport_c, WorksInCFile) -{ - all_mock_support_c_calls(); -} - -static bool destructorWasCalled = false; - -static void failedCallToMockC() -{ - SetBooleanOnDestructorCall setOneDestructor(destructorWasCalled); - mock_c()->actualCall("Not a call"); -} // LCOV_EXCL_LINE - -// Silly wrapper because of a test that only fails in Visual C++ due to different -// destructor behaviors -#ifdef _MSC_VER -#define MSC_SWITCHED_TEST(testGroup, testName) IGNORE_TEST(testGroup, testName) -#else -#define MSC_SWITCHED_TEST(testGroup, testName) TEST(testGroup, testName) -#endif - -MSC_SWITCHED_TEST(MockSupport_c, NoExceptionsAreThrownWhenAMock_cCallFailed) -{ - TestTestingFixture fixture; - - fixture.setTestFunction(failedCallToMockC); - fixture.runAllTests(); - - LONGS_EQUAL(1, fixture.getFailureCount()); - // Odd behavior in Visual C++, destructor still gets called here - CHECK(!destructorWasCalled); -} - -static bool cpputestHasCrashed; - -static void crashMethod() -{ - cpputestHasCrashed = true; -} - -TEST_ORDERED(MockSupport_c, shouldCrashOnFailure, 21) -{ - cpputestHasCrashed = false; - TestTestingFixture fixture; - UtestShell::setCrashMethod(crashMethod); - mock_c()->crashOnFailure(true); - fixture.setTestFunction(failedCallToMockC); - - fixture.runAllTests(); - - CHECK(cpputestHasCrashed); - - UtestShell::resetCrashMethod(); - mock_c()->crashOnFailure(false); -} - -TEST_ORDERED(MockSupport_c, nextTestShouldNotCrashOnFailure, 22) -{ - cpputestHasCrashed = false; - TestTestingFixture fixture; - UtestShell::setCrashMethod(crashMethod); - fixture.setTestFunction(failedCallToMockC); - - fixture.runAllTests(); - - CHECK_FALSE(cpputestHasCrashed); - - 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); - mock_c()->actualCall("bar")->withParameterOfType("typeName", "name", (const void*) 2); -} // LCOV_EXCL_LINE - -TEST(MockSupport_c, failureWithParameterOfTypeCoversValueToString) -{ - TestTestingFixture fixture; - mock_c()->installComparator("typeName", typeNameIsEqual, typeNameValueToString); - fixture.setTestFunction(failingCallToMockCWithParameterOfType_); - fixture.runAllTests(); - fixture.assertPrintContains("typeName name: "); - mock_c()->removeAllComparatorsAndCopiers(); -} - -static void callToMockCWithOutputParameterOfType_() -{ - int value1 = 7; - const int value2 = 9; - mock_c()->expectOneCall("bar")->withOutputParameterOfTypeReturning("intType", "bla", &value2); - mock_c()->actualCall("bar")->withOutputParameterOfType("intType", "bla", &value1); - LONGS_EQUAL(value1, value2); -} - -TEST(MockSupport_c, successWithOutputParameterOfType) -{ - TestTestingFixture fixture; - mock_c()->installCopier("intType", typeCopy); - fixture.setTestFunction(callToMockCWithOutputParameterOfType_); - fixture.runAllTests(); - LONGS_EQUAL(2, fixture.getCheckCount()); - LONGS_EQUAL(0, fixture.getFailureCount()); - mock_c()->removeAllComparatorsAndCopiers(); -} - -static void failingCallToMockCWithMemoryBuffer_() -{ - unsigned char memBuffer1[] = { 0x12, 0x15, 0xFF }; - unsigned char memBuffer2[] = { 0x12, 0x05, 0xFF }; - mock_c()->expectOneCall("bar")->withMemoryBufferParameter("name", memBuffer1, sizeof(memBuffer1)); - mock_c()->actualCall("bar")->withMemoryBufferParameter("name", memBuffer2, sizeof(memBuffer2)); -} // LCOV_EXCL_LINE - -TEST(MockSupport_c, expectOneMemBufferParameterAndValueFailsDueToContents) -{ - TestTestingFixture fixture; - fixture.setTestFunction(failingCallToMockCWithMemoryBuffer_); - fixture.runAllTests(); - fixture.assertPrintContains("Unexpected parameter value to parameter \"name\" " - "to function \"bar\": "); -} - -TEST(MockSupport_c, ignoreOtherCalls) -{ - mock_c()->expectOneCall("foo"); - mock_c()->ignoreOtherCalls(); - mock_c()->actualCall("foo"); - mock_c()->actualCall("bar"); - mock_c()->checkExpectations(); -} diff --git a/tests/CppUTestExt/MockSupport_cTestCFile.c b/tests/CppUTestExt/MockSupport_cTestCFile.c deleted file mode 100644 index e3ad5fb1a..000000000 --- a/tests/CppUTestExt/MockSupport_cTestCFile.c +++ /dev/null @@ -1,221 +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 "CppUTestExt/MockSupport_c.h" -#include "MockSupport_cTestCFile.h" - -static int typeNameIsEqual(const void* object1, const void* object2) -{ - return object1 == object2; -} - -static const char* typeNameValueToString(const void* object) -{ - return (const char*) object; -} - -void all_mock_support_c_calls(void) -{ - mock_c()->strictOrder(); - mock_c()->expectOneCall("boo"); - mock_c()->expectNoCall("bla"); - mock_c()->expectNCalls(1, "foo"); - mock_c()->actualCall("boo"); - mock_c()->actualCall("foo"); - mock_c()->checkExpectations(); - - mock_c()->expectOneCall("boo")->withIntParameters("integer", 1)-> - withBoolParameters("bool", 1)-> - withUnsignedIntParameters("unsigned", 1)-> - withLongIntParameters("long int", (long int) -1)-> - withUnsignedLongIntParameters("unsigned long int", (unsigned long int) 1)-> -#if CPPUTEST_USE_LONG_LONG - withLongLongIntParameters("long long int", (long long int) -1)-> - withUnsignedLongLongIntParameters("unsigned long long int", (unsigned long long int) 1)-> -#endif - - withDoubleParameters("double", 1.0)-> - withDoubleParametersAndTolerance("doubleWithTolerance", 1.0, 1.0)-> - withStringParameters("string", "string")-> - withPointerParameters("pointer", (void*) 1)-> - withConstPointerParameters("constpointer", (const void*) 1)-> - withFunctionPointerParameters("functionpointer", (void(*)(void)) 1)-> - withMemoryBufferParameter("name", (void*) 1, 0UL)-> - ignoreOtherParameters(); - - mock_c()->actualCall("boo")->withIntParameters("integer", 1)-> - withBoolParameters("bool", 1)-> - withUnsignedIntParameters("unsigned", 1)-> - withLongIntParameters("long int", (long int) -1)-> - withUnsignedLongIntParameters("unsigned long int", (unsigned long int) 1)-> -#if CPPUTEST_USE_LONG_LONG - withLongLongIntParameters("long long int", (long long int) -1)-> - withUnsignedLongLongIntParameters("unsigned long long int", (unsigned long long int) 1)-> -#endif - withDoubleParameters("double", 1.0)-> - withDoubleParameters("doubleWithTolerance", 0.0 )-> - withStringParameters("string", "string")-> - withPointerParameters("pointer", (void*) 1)-> - withConstPointerParameters("constpointer", (const void*) 1)-> - withFunctionPointerParameters("functionpointer", (void(*)(void)) 1)-> - withMemoryBufferParameter("name", (void*) 1, 0UL)-> - hasReturnValue(); - - mock_c()->disable(); - mock_c()->expectOneCall("boo")->withParameterOfType("type", "name", (void*) 1)-> - withOutputParameterReturning("name", (void*)1, 0UL)-> - withOutputParameterOfTypeReturning("type", "name", (void*)1); - mock_c()->actualCall("boo")->withParameterOfType("type", "name", (void*) 1)-> - withOutputParameter("name", (void*)1)-> - withOutputParameterOfType("type", "name", (void*)1); - mock_c()->enable(); - - mock_c()->clear(); - - mock_c()->installComparator("typeName", typeNameIsEqual, typeNameValueToString); - mock_c()->expectOneCall("boo")->withParameterOfType("typeName", "name", (void*) 1); - mock_c()->actualCall("boo")->withParameterOfType("typeName", "name", (void*) 1); - mock_c()->clear(); - mock_c()->removeAllComparatorsAndCopiers(); - - mock_c()->expectOneCall("boo")->andReturnBoolValue(1); - mock_c()->actualCall("boo")->boolReturnValue(); - mock_c()->boolReturnValue(); - - mock_c()->expectOneCall("boo")->andReturnIntValue(-10); - mock_c()->actualCall("boo")->intReturnValue(); - mock_c()->intReturnValue(); - mock_c()->returnValue(); - - mock_c()->expectOneCall("boo2")->andReturnUnsignedIntValue(1); - mock_c()->actualCall("boo2")->unsignedIntReturnValue(); - mock_c()->unsignedIntReturnValue(); - - mock_c()->expectOneCall("boo3")->andReturnLongIntValue(1); - mock_c()->actualCall("boo3")->longIntReturnValue(); - mock_c()->longIntReturnValue(); - - mock_c()->expectOneCall("boo3")->andReturnUnsignedLongIntValue(1); - mock_c()->actualCall("boo3")->unsignedLongIntReturnValue(); - mock_c()->unsignedLongIntReturnValue(); - -#if CPPUTEST_USE_LONG_LONG - mock_c()->expectOneCall("mgrgrgr1")->andReturnLongLongIntValue(1); - mock_c()->actualCall("mgrgrgr1")->longLongIntReturnValue(); - mock_c()->longLongIntReturnValue(); - - mock_c()->expectOneCall("mgrgrgr2")->andReturnUnsignedLongLongIntValue(1); - mock_c()->actualCall("mgrgrgr2")->unsignedLongLongIntReturnValue(); - mock_c()->unsignedLongLongIntReturnValue(); -#endif - - mock_c()->expectOneCall("boo4")->andReturnDoubleValue(1.0); - mock_c()->actualCall("boo4")->doubleReturnValue(); - mock_c()->doubleReturnValue(); - - mock_c()->expectOneCall("boo5")->andReturnStringValue("hello world"); - mock_c()->actualCall("boo5")->stringReturnValue(); - mock_c()->stringReturnValue(); - - mock_c()->expectOneCall("boo6")->andReturnPointerValue((void*) 10); - mock_c()->actualCall("boo6")->pointerReturnValue(); - mock_c()->pointerReturnValue(); - - mock_c()->expectOneCall("boo7")->andReturnConstPointerValue((void*) 10); - mock_c()->actualCall("boo7")->constPointerReturnValue(); - mock_c()->constPointerReturnValue(); - - mock_c()->expectOneCall("boo8")->andReturnFunctionPointerValue((void(*)(void)) 10); - mock_c()->actualCall("boo8")->functionPointerReturnValue(); - mock_c()->functionPointerReturnValue(); - - mock_c()->setBoolData("bool", 1); - mock_c()->expectOneCall("bla")->withBoolParameters("bool", 1); - mock_c()->actualCall("bla")->withBoolParameters("bool", mock_c()->getData("bool").value.boolValue); - - mock_c()->setIntData("int", 5); - mock_c()->expectOneCall("bla")->withIntParameters("int", 5); - mock_c()->actualCall("bla")->withIntParameters("int", mock_c()->getData("int").value.intValue); - - mock_c()->setStringData("string", "lol"); - mock_c()->expectOneCall("bla")->withStringParameters("str", "lol"); - mock_c()->actualCall("bla")->withStringParameters("str", mock_c()->getData("string").value.stringValue); - - mock_c()->setDoubleData("double", 0.001); - mock_c()->expectOneCall("bla")->withDoubleParameters("double", 0.001); - mock_c()->actualCall("bla")->withDoubleParameters("double", mock_c()->getData("double").value.doubleValue); - - mock_c()->setPointerData("ptr", (void*)1); - mock_c()->expectOneCall("bla")->withPointerParameters("ptr", (void*)1); - mock_c()->actualCall("bla")->withPointerParameters("ptr", mock_c()->getData("ptr").value.pointerValue); - - mock_c()->setConstPointerData("cptr", (const void*)1); - mock_c()->expectOneCall("bla")->withConstPointerParameters("cptr", (const void*)1); - mock_c()->actualCall("bla")->withConstPointerParameters("cptr", mock_c()->getData("ptr").value.constPointerValue); - - mock_c()->setFunctionPointerData("ptr", (void(*)(void))1); - mock_c()->expectOneCall("bla")->withFunctionPointerParameters("ptr", (void(*)(void))1); - mock_c()->actualCall("bla")->withFunctionPointerParameters("ptr", mock_c()->getData("ptr").value.functionPointerValue); - - mock_c()->clear(); - - mock_c()->hasReturnValue(); - mock_c()->returnBoolValueOrDefault(1); - mock_c()->returnIntValueOrDefault(-1); - mock_c()->returnUnsignedIntValueOrDefault(1); - mock_c()->returnLongIntValueOrDefault(-1L); - mock_c()->returnUnsignedLongIntValueOrDefault(1L); -#if CPPUTEST_USE_LONG_LONG - mock_c()->returnLongLongIntValueOrDefault(-1LL); - mock_c()->returnUnsignedLongLongIntValueOrDefault(1ULL); -#endif - mock_c()->returnStringValueOrDefault(""); - mock_c()->returnDoubleValueOrDefault(0.01); - mock_c()->returnPointerValueOrDefault(0); - mock_c()->returnConstPointerValueOrDefault(0); - mock_c()->returnFunctionPointerValueOrDefault(0); - - mock_c()->disable(); - mock_c()->actualCall("disabled"); - mock_c()->enable(); - mock_c()->checkExpectations(); - - mock_c()->setIntData("bla1", -2); - mock_c()->setUnsignedIntData("bla2", 2); - mock_c()->setDoubleData("bla3", 0.035); - mock_c()->setStringData("bla4", "abc"); - mock_c()->setPointerData("bla", (void*) 2); - mock_c()->setConstPointerData("bla", (const void*) 2); - mock_c()->setFunctionPointerData("bla", (void (*)(void)) 2); - mock_c()->setDataObject("bla", "type", (void*) 2); - mock_c()->getData("bla"); - - mock_scope_c("scope")->expectOneCall("boo"); - mock_scope_c("other")->expectedCallsLeft(); - mock_scope_c("scope")->expectedCallsLeft(); - mock_scope_c("scope")->actualCall("boo"); -} diff --git a/tests/CppUTestExt/MockSupport_cTestCFile.h b/tests/CppUTestExt/MockSupport_cTestCFile.h deleted file mode 100644 index 245247494..000000000 --- a/tests/CppUTestExt/MockSupport_cTestCFile.h +++ /dev/null @@ -1,42 +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. - */ - -#ifndef TESTMOCKSUPPORTC_CFILE_H -#define TESTMOCKSUPPORTC_CFILE_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern void all_mock_support_c_calls(void); - -#ifdef __cplusplus -} -#endif - -#endif /* TESTMOCKSUPPORTC_CFILE_H */ - diff --git a/tests/CppUTestExt/OrderedTestTest.cpp b/tests/CppUTestExt/OrderedTestTest.cpp deleted file mode 100644 index 0273cf587..000000000 --- a/tests/CppUTestExt/OrderedTestTest.cpp +++ /dev/null @@ -1,246 +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/TestHarness.h" -#include "CppUTest/TestOutput.h" -#include "CppUTest/TestRegistry.h" -#include "CppUTest/TestTestingFixture.h" -#include "CppUTestExt/OrderedTest.h" -#include "OrderedTestTest.h" - -TEST_GROUP(TestOrderedTest) -{ - TestTestingFixture* fixture; - - OrderedTestShell orderedTest; - OrderedTestShell orderedTest2; - OrderedTestShell orderedTest3; - ExecFunctionTestShell normalTest; - ExecFunctionTestShell normalTest2; - ExecFunctionTestShell normalTest3; - - OrderedTestShell* orderedTestCache; - void setup() CPPUTEST_OVERRIDE - { - orderedTestCache = OrderedTestShell::getOrderedTestHead(); - OrderedTestShell::setOrderedTestHead(NULLPTR); - - fixture = new TestTestingFixture(); - fixture->getRegistry()->unDoLastAddTest(); - } - - void teardown() CPPUTEST_OVERRIDE - { - delete fixture; - OrderedTestShell::setOrderedTestHead(orderedTestCache); - } - - void InstallOrderedTest(OrderedTestShell& test, int level) - { - OrderedTestInstaller(test, "testgroup", "testname", __FILE__, __LINE__, level); - } - - void InstallNormalTest(UtestShell& test) - { - TestInstaller(test, "testgroup", "testname", __FILE__, __LINE__); - } - - UtestShell* firstTest() - { - return fixture->getRegistry()->getFirstTest(); - } - - UtestShell* secondTest() - { - return firstTest()->getNext(); - } -}; - -TEST(TestOrderedTest, TestInstallerSetsFields) -{ - 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()); - LONGS_EQUAL(10, orderedTest.getLineNumber()); - LONGS_EQUAL(5, orderedTest.getLevel()); -} - -TEST(TestOrderedTest, InstallOneText) -{ - InstallOrderedTest(orderedTest, 5); - CHECK(firstTest() == &orderedTest); -} - -TEST(TestOrderedTest, OrderedTestsAreLast) -{ - InstallNormalTest(normalTest); - InstallOrderedTest(orderedTest, 5); - CHECK(firstTest() == &normalTest); - CHECK(secondTest() == &orderedTest); -} - -TEST(TestOrderedTest, TwoTestsAddedInReverseOrder) -{ - InstallOrderedTest(orderedTest, 5); - InstallOrderedTest(orderedTest2, 3); - CHECK(firstTest() == &orderedTest2); - CHECK(secondTest() == &orderedTest); -} - -TEST(TestOrderedTest, TwoTestsAddedInOrder) -{ - InstallOrderedTest(orderedTest2, 3); - InstallOrderedTest(orderedTest, 5); - CHECK(firstTest() == &orderedTest2); - CHECK(secondTest() == &orderedTest); -} - -TEST(TestOrderedTest, MultipleOrderedTests) -{ - InstallNormalTest(normalTest); - InstallOrderedTest(orderedTest2, 3); - InstallNormalTest(normalTest2); - InstallOrderedTest(orderedTest, 5); - InstallNormalTest(normalTest3); - InstallOrderedTest(orderedTest3, 7); - - UtestShell * firstOrderedTest = firstTest()->getNext()->getNext()->getNext(); - CHECK(firstOrderedTest == &orderedTest2); - CHECK(firstOrderedTest->getNext() == &orderedTest); - CHECK(firstOrderedTest->getNext()->getNext() == &orderedTest3); -} - -TEST(TestOrderedTest, MultipleOrderedTests2) -{ - InstallOrderedTest(orderedTest, 3); - InstallOrderedTest(orderedTest2, 1); - InstallOrderedTest(orderedTest3, 2); - - CHECK(firstTest() == &orderedTest2); - CHECK(secondTest() == &orderedTest3); - CHECK(secondTest()->getNext() == &orderedTest); - -} - -class OrderedTestTestingFixture -{ -public: - static void checkRun(int run) { - if(run != run_) { - run_ = run; - count_ = 0; - } - } - static int count(void) { - return count_++; - } -private: - static int run_; - static int count_; -}; - -int OrderedTestTestingFixture::run_ = 0; -int OrderedTestTestingFixture::count_ = 0; - -TEST_GROUP(TestOrderedTestMacros) -{ - void setup() CPPUTEST_OVERRIDE - { - OrderedTestTestingFixture::checkRun(TestRegistry::getCurrentRegistry()->getCurrentRepetition()); - } -}; - -TEST(TestOrderedTestMacros, NormalTest) -{ - CHECK(OrderedTestTestingFixture::count() == 0); -} - -TEST_ORDERED(TestOrderedTestMacros, Test2, 2) -{ - CHECK(OrderedTestTestingFixture::count() == 2); -} - -TEST_ORDERED(TestOrderedTestMacros, Test1, 1) -{ - CHECK(OrderedTestTestingFixture::count() == 1); -} - -TEST_ORDERED(TestOrderedTestMacros, Test4, 4) -{ - CHECK(OrderedTestTestingFixture::count() == 4); -} - -TEST_ORDERED(TestOrderedTestMacros, Test3, 3) -{ - CHECK(OrderedTestTestingFixture::count() == 3); -} - -// Test with same level -TEST_ORDERED(TestOrderedTestMacros, Test5_1, 5) -{ - CHECK(OrderedTestTestingFixture::count() == 5); -} - -TEST_ORDERED(TestOrderedTestMacros, Test6_1, 6) -{ - CHECK(OrderedTestTestingFixture::count() == 7); -} - -TEST_ORDERED(TestOrderedTestMacros, Test5_2, 5) -{ - CHECK(OrderedTestTestingFixture::count() == 6); -} - -TEST_ORDERED(TestOrderedTestMacros, Test6_2, 6) -{ - CHECK(OrderedTestTestingFixture::count() == 8); -} - -// Test C-Interface -TEST_ORDERED(TestOrderedTestMacros, Test10, 10) -{ - CHECK(OrderedTestTestingFixture::count() == 12); -} - -TEST_ORDERED(TestOrderedTestMacros, Test8, 8) -{ - CHECK(OrderedTestTestingFixture::count() == 10); -} - -// Export to be usable in OrderedTestTest_c.c -extern "C" { -int orderedTestFixtureCWrapper(void) { - return OrderedTestTestingFixture::count(); -} -} - -TEST_ORDERED_C_WRAPPER(TestOrderedTestMacros, Test11, 11) - -TEST_ORDERED_C_WRAPPER(TestOrderedTestMacros, Test7, 7) - -TEST_ORDERED_C_WRAPPER(TestOrderedTestMacros, Test9, 9) diff --git a/tests/CppUTestExt/OrderedTestTest.h b/tests/CppUTestExt/OrderedTestTest.h deleted file mode 100644 index 4d6afbac4..000000000 --- a/tests/CppUTestExt/OrderedTestTest.h +++ /dev/null @@ -1,42 +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. - */ - -#ifndef ORDEREDTESTTEST_H -#define ORDEREDTESTTEST_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern int orderedTestFixtureCWrapper(void); - -#ifdef __cplusplus -} -#endif - -#endif /* ORDEREDTESTTEST_H */ - diff --git a/tests/CppUTestExt/OrderedTestTest_c.c b/tests/CppUTestExt/OrderedTestTest_c.c deleted file mode 100644 index 8158fd89e..000000000 --- a/tests/CppUTestExt/OrderedTestTest_c.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "CppUTest/TestHarness_c.h" -#include "OrderedTestTest.h" - -TEST_C(TestOrderedTestMacros, Test11) -{ - CHECK_C(orderedTestFixtureCWrapper() == 13); -} - -TEST_C(TestOrderedTestMacros, Test7) -{ - CHECK_C(orderedTestFixtureCWrapper() == 9); -} - -TEST_C(TestOrderedTestMacros, Test9) -{ - CHECK_C(orderedTestFixtureCWrapper() == 11); -} diff --git a/tests/DummyUTestPlatform/DummyUTestPlatform.cpp b/tests/DummyUTestPlatform/DummyUTestPlatform.cpp deleted file mode 100644 index 948c85dbe..000000000 --- a/tests/DummyUTestPlatform/DummyUTestPlatform.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#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; diff --git a/valgrind.suppressions b/valgrind.suppressions deleted file mode 100644 index 515a25f9f..000000000 --- a/valgrind.suppressions +++ /dev/null @@ -1,39 +0,0 @@ -{ - Supressions because the memory leak detector will print content of memory but can't know whether it is initialized or not - Memcheck:Cond - fun:strnlen - fun:vfprintf - fun:__vsnprintf_chk -} -{ - Same as the above, but this one is more specific for clang. This allows the clang to fail on other vprintf errors where it is suppressed at gcc - Memcheck:Cond - ... - fun:_ZN18SimpleStringBuffer3addEPKcz - ... - fun:_ZN18MemoryLeakDetector25ConstructMemoryLeakReportE13MemLeakPeriod - fun:_ZN18MemoryLeakDetector6reportE13MemLeakPeriod - ... -} -{ - Supression because it checks whether the memory was set invalid after a de-alloc - Memcheck:Addr1 - fun:_ZN45TEST_BasicBehavior_freeInvalidatesMemory_Test8testBodyEv - fun:PlatformSpecificSetJmp - ... -} -{ - Supression because it checks whether the memory was set invalid after a de-alloc - Memcheck:Addr1 - fun:_ZN47TEST_BasicBehavior_deleteInvalidatesMemory_Test8testBodyEv - fun:PlatformSpecificSetJmp - ... -} -{ - Supression because it checks whether the memory was set invalid after a de-alloc - Memcheck:Addr1 - fun:_ZN52TEST_BasicBehavior_deleteArrayInvalidatesMemory_Test8testBodyEv - fun:PlatformSpecificSetJmp - ... -} -