chore: migrate project into clean repository

This commit is contained in:
yuuux
2026-08-13 16:50:52 +08:00
commit d1d25a09e7
27405 changed files with 9422808 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
version: 2.1
jobs:
latest-clang-autotools:
docker:
- image: silkeh/clang:latest
environment:
BUILD: autotools
CXX: clang
CPPUTEST_BUILD_DIR: ./cpputest_build
steps:
- checkout
# - run: mkdir -p $CPPUTEST_BUILD_DIR && cd $CPPUTEST_BUILD_DIR && ../scripts/travis_ci_build.sh
workflows:
basic-build-and-test:
jobs:
- latest-clang-autotools

View File

@@ -0,0 +1,41 @@
---
Language: Cpp
Standard: Cpp03
AccessModifierOffset: -4
AlignAfterOpenBracket: BlockIndent
AllowShortBlocksOnASingleLine: Empty
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AlwaysBreakBeforeMultilineStrings: true
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: Never
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: false
BeforeWhile: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakConstructorInitializers: AfterColon
ColumnLimit: 120
NamespaceIndentation: All
NamespaceMacros:
- TEST_GROUP
FixNamespaceComments: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentExternBlock: NoIndent
PackConstructorInitializers: CurrentLine
PointerAlignment: Left
SortIncludes: Never
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterForeachMacros: false

View File

@@ -0,0 +1,11 @@
---
Checks:
- clang-diagnostic-*
- clang-analyzer-*
- bugprone-*
- -bugprone-easily-swappable-parameters
- -bugprone-casting-through-void # No C++ casts allowed
WarningsAsErrors: "*"
FormatStyle: file
UseColor: true
HeaderFilterRegex: .*

View File

@@ -0,0 +1,7 @@
# Enable via `git config blame.ignoreRevsFile .git-blame-ignore-revs`
# Fix line endings
e674cfe759b20c6b78becbc50d8f9f644d32ea8a
# clang-format
2a4942eb93b823c9723d4797222d6d3315f3bef2

106
arcs-sdk/modules/cpputest/.gitignore vendored Normal file
View File

@@ -0,0 +1,106 @@
.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/

View File

@@ -0,0 +1,196 @@
# Global environment
language: cpp
os: linux
dist: bionic
# Avoid double build because of the tagging in the build.
branches:
except:
- latest-passing-build
# Build stages and the conditionals for the stages
stages:
- name: extensive daily tests
if: type = cron
- name: basic build & test
if: type != cron
- name: extended build & test
if: type != cron
- name: deploy latest
if: "(NOT type IN (pull_request)) AND (branch = master) AND (type != cron)"
jobs:
include:
# Basic builds
# Mac OSX
- stage: basic build & test
compiler: gcc
os: osx
env: BUILD=autotools
- compiler: clang
env: BUILD=autotools
os: osx
# Windows
- compiler: msbuild
os: windows
env: BUILD=vc_windows CPP_STD=17
- MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
- VCTargetsPath="C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\VC\VCTargets"
# Linux
- compiler: gcc
env: BUILD=cmake CPP_STD=17
- compiler: gcc
env: BUILD=autotools
- compiler: clang
env: BUILD=autotools
# Extended builds, different C++ version and build tools
- stage: extended build & test
# Mac OSX
compiler: clang
os: osx
env: BUILD=cmake CPP_STD=17
- compiler: gcc
os: osx
env: BUILD=cmake CPP_STD=14
# Linux
# CMake different C++ versions with clang
- compiler: clang
env: BUILD=cmake CPP_STD=98
- compiler: clang
env: BUILD=cmake CPP_STD=11
- compiler: clang
env: BUILD=cmake CPP_STD=14
- compiler: clang
env: BUILD=cmake CPP_STD=17
# CMake different C++ versions with gcc
- compiler: gcc
env: BUILD=cmake CPP_STD=98
- compiler: gcc
env: BUILD=cmake CPP_STD=11
- compiler: gcc
env: BUILD=cmake CPP_STD=14
- compiler: gcc
env: BUILD=cmake CPP_STD=17
# New compilers can be added here. Need to be cleared when compiler becomes standard
- compiler: gcc
env: BUILD=cmake CPP_STD=17
- CC=gcc-10
- CXX=g++-10
addons:
apt:
packages: ['g++-10']
sources:
- sourceline: 'ppa:ubuntu-toolchain-r/test'
- compiler: clang
env: BUILD=cmake CPP_STD=17
- CC=clang-11
- CXX=clang++-11
addons:
apt:
sources:
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
packages: ['clang-11', 'libc++-11-dev', 'libc++abi-11-dev']
# Specific other tests
- compiler: gcc
env: BUILD=test_report
addons:
apt:
packages:
- ant-optional
- compiler: gcc
env: BUILD=cmake_coverage
- compiler: gcc
env: BUILD=cmake_gtest
- compiler: clang
env: BUILD=autotools_gtest
- compiler: gcc
env: BUILD=autotools_cmake_install_test
# MS DOS Build
- env: BUILD=make_dos
addons:
apt:
packages:
- dosbox
# Docker images. Need to be cleared at times
- env: BUILD=docker_ubuntu_autotools
- env: BUILD=docker_ubuntu_dos
- env: BUILD=autotools_dist
- stage: extensive daily tests
compiler: gcc
env: BUILD=extensive_check
- compiler: clang
env: BUILD=extensive_check
- arch: ppc64le
compiler: gcc
env: BUILD=autotools
- arch: s390x
compiler: gcc
env: BUILD=autotools
- arch: arm64
compiler: gcc
env: BUILD=autotools
- compiler: gcc
env: BUILD=makefileworker
- compiler: clang
env: BUILD=autotools_install_and_test_examples
# Deploy to github releases
- stage: deploy latest
env: BUILD=autotools_dist
script:
- export DATE=`date`
- git tag -f latest-passing-build -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER at $DATE"
- git push -f https://cpputest-travis:$GH_TOKEN@github.com/cpputest/cpputest.git --tags
- ../scripts/travis_ci_build.sh
- pwd
- ls
deploy:
provider: releases
#:
edge: true
token: $GH_TOKEN
tag_name: latest-passing-build
name: Latest passing build
release_notes: "This is the automatic release from Travis CI.\n\nWhenever a build passes, it gets released as Latest Passing Build.\n\nBuild number: $TRAVIS_BUILD_NUMBER\nDate: $DATE\nLog: $TRAVIS_BUILD_WEB_URL"
file:
- cpputest-latest.tar.gz
- cpputest-latest.zip
overwrite: true
on:
tags: false
before_script:
- export CPPUTEST_BUILD_DIR=$TRAVIS_BUILD_DIR/cpputest_build
- mkdir -p $CPPUTEST_BUILD_DIR && cd $CPPUTEST_BUILD_DIR
script:
- "../scripts/travis_ci_build.sh"
after_failure:
- "../scripts/travis_ci_after.sh"
after_success:
- "../scripts/travis_ci_after.sh"
notifications:
slack:
secure: oOx4AGIiJB+j1pkIxlLeQh5qp7TF89Sj+3RzJRQuo6z0HocTz9yJgXPlDh1H9rLj5SxK/UKsk+WFafVuPdWakQ40LeYO49C/+e+mCDcS0ujLka6dvIE8v0SEb1PuaAGjJWdhiviAhSqu9YOKPYZs37lD3oqepuEpxeiXwsur9QU=
env:
global:
secure: H6djbn5YP1P62n//ergaRZ4lIkneCzWp1Ok4F71kvvNiwlRzYDGll4kJT6MhVq6bBHeR81W/lwUd+RdjyqsJpVhj7DHXC/0k0h0xpAAm7LUhOl+6mIII1uhcMFqbeHvilwvDCzTQ6qv8Mzd1g0QfUECrmti9/U+/TTFJG0r0Zuc=

View File

@@ -0,0 +1,5 @@
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

View File

@@ -0,0 +1,146 @@
# 2.6.3 is needed for ctest support
# 3.1 is needed for target_sources
# 3.8 is needed for try_compile improvements (CMP0067)
if(CONFIG_CPPUTEST)
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(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
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)
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()
endif() # CONFIG_CPPUTEST

View File

@@ -0,0 +1,143 @@
# 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(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
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
)
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()

View File

@@ -0,0 +1,183 @@
{
"version": 3,
"configurePresets": [
{
"name": "defaults",
"binaryDir": "cpputest_build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_EXTENSIONS": false
}
},
{
"name": "GNU",
"inherits": ["defaults"],
"environment": {
"CFLAGS": "-Werror",
"CXXFLAGS": "-Werror"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "Clang",
"inherits": ["GNU"],
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
},
{
"name": "clang-tidy",
"inherits": ["Clang"],
"cacheVariables": {
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;-header-filter=.*",
"CMAKE_C_CLANG_TIDY": "clang-tidy;-header-filter=.*"
}
},
{
"name": "MSVC",
"inherits": ["defaults"],
"environment": {
"CFLAGS": "/WX",
"CXXFLAGS": "/WX"
}
},
{
"name": "ClangCL",
"inherits": ["MSVC"],
"generator": "Visual Studio 17 2022",
"toolset": "ClangCL"
},
{
"name": "MinGW",
"inherits": ["GNU"],
"environment": {
"LDFLAGS": "-static"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "x86_64-w64-mingw32-gcc",
"CMAKE_CXX_COMPILER": "x86_64-w64-mingw32-g++",
"CMAKE_SYSTEM_NAME": "Windows",
"CMAKE_CROSSCOMPILING_EMULATOR": "wine"
}
},
{
"name": "arm-embedded",
"inherits": ["defaults"],
"toolchainFile": "${sourceDir}/cmake/Toolchains/arm-none-eabi-gcc.toolchain.cmake",
"cacheVariables": {
"CMAKE_CROSSCOMPILING_EMULATOR": "docker;run;--rm;-v=${sourceDir}:${sourceDir};multiarch/qemu-user-static:arm-7.1.0-2;qemu-arm-static;-cpu;cortex-m4"
}
},
{
"name": "coverage",
"inherits": ["GNU"],
"environment": {
"CFLAGS": "--coverage",
"CXXFLAGS": "--coverage"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_STANDARD": "11",
"CPPUTEST_EXAMPLES": false
}
},
{
"name": "no-std-cpp",
"inherits": ["GNU"],
"environment": {
"CXXFLAGS": "-Werror -nostdinc++"
},
"cacheVariables": {
"CPPUTEST_STD_CPP_LIB_DISABLED": true
}
},
{
"name": "no-rtti",
"inherits": ["GNU"],
"environment": {
"CXXFLAGS": "-Werror -fno-rtti"
}
},
{
"name": "no-exceptions",
"inherits": ["GNU"],
"environment": {
"CXXFLAGS": "-Werror -fno-exceptions"
}
},
{
"name": "no-std-c",
"inherits": ["GNU"],
"environment": {
"CXXFLAGS": "-DCPPUTEST_CHAR_BIT=8 -Werror -nostdinc",
"CFLAGS": "-DCPPUTEST_CHAR_BIT=8 -Werror -nostdinc"
},
"cacheVariables": {
"CPPUTEST_STD_C_LIB_DISABLED": true
}
},
{
"name": "no-long-long",
"inherits": ["GNU"],
"cacheVariables": {
"CPPUTEST_USE_LONG_LONG": false
}
},
{
"name": "asan",
"inherits": ["Clang"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
},
"environment": {
"CFLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CXXFLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"LDFLAGS": "-fsanitize=address"
}
},
{
"name": "detailed",
"inherits": ["defaults"],
"cacheVariables": {
"CPPUTEST_TESTS_DETAILED": true
}
},
{
"name": "gtest",
"inherits": ["defaults"],
"generator": "Ninja Multi-Config",
"cacheVariables": {
"CPPUTEST_TEST_GTEST": true,
"gtest_build_tests": true
}
},
{
"name": "IAR",
"inherits": ["defaults"],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "Generic",
"CMAKE_C_COMPILER": "iccarm",
"CMAKE_C_FLAGS_INIT": "--cpu Cortex-M4F --dlib_config normal",
"CMAKE_CXX_COMPILER": "iccarm",
"CMAKE_CXX_FLAGS_INIT": "--cpu Cortex-M4F --dlib_config normal",
"CMAKE_EXE_LINKER_FLAGS": "--semihosting --config ${sourceDir}/platforms/iar/CppUTestTest.icf"
}
},
{
"name": "DOS",
"inherits": ["defaults"],
"generator": "Watcom WMake",
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "DOS",
"CMAKE_BUILD_TYPE": "MinRelSize",
"CMAKE_CXX_STANDARD": "98",
"CPPUTEST_MEM_LEAK_DETECTION_DISABLED": true,
"CPPUTEST_STD_CPP_LIB_DISABLED": true
}
}
]
}

View File

@@ -0,0 +1,10 @@
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 <ORGANIZATION> 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.

View File

@@ -0,0 +1,4 @@
For changelog check the github page:
https://github.com/cpputest/cpputest

View File

@@ -0,0 +1,29 @@
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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,299 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F468F539-27BD-468E-BE64-DDE641400B51}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">lib\x86\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">lib\x64\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">cpputest_build\Debug\x86\$(ProjectName)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">cpputest_build\Debug\x64\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">lib\x86\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">lib\x64\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">cpputest_build\Release\x86\$(ProjectName)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">cpputest_build\Release\x64\$(ProjectName)\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)d</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)d</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Debug/CppUTestd.bsc</OutputFile>
</Bscmake>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_LIB;WIN32;_DEBUG;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Debug/CppUTestd.bsc</OutputFile>
</Bscmake>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release/CppUTest.bsc</OutputFile>
</Bscmake>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;STDC_WANT_SECURE_LIB;CPPUTEST_USE_LONG_LONG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Release/CppUTest.bsc</OutputFile>
</Bscmake>
<PreBuildEvent>
<Command>
</Command>
</PreBuildEvent>
<PostBuildEvent />
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\CppUTestExt\CodeMemoryReportFormatter.cpp" />
<ClCompile Include="src\CppUTestExt\GTest.cpp" />
<ClCompile Include="src\CppUTestExt\IEEE754ExceptionsPlugin.cpp" />
<ClCompile Include="src\CppUTestExt\MemoryReportAllocator.cpp" />
<ClCompile Include="src\CppUTestExt\MemoryReporterPlugin.cpp" />
<ClCompile Include="src\CppUTestExt\MemoryReportFormatter.cpp" />
<ClCompile Include="src\CppUTestExt\MockActualCall.cpp" />
<ClCompile Include="src\CppUTestExt\MockExpectedCall.cpp" />
<ClCompile Include="src\CppUTestExt\MockExpectedCallsList.cpp" />
<ClCompile Include="src\CppUTestExt\MockFailure.cpp" />
<ClCompile Include="src\CppUTestExt\MockNamedValue.cpp" />
<ClCompile Include="src\CppUTestExt\MockSupport.cpp" />
<ClCompile Include="src\CppUTestExt\MockSupportPlugin.cpp" />
<ClCompile Include="src\CppUTestExt\MockSupport_c.cpp" />
<ClCompile Include="src\CppUTestExt\OrderedTest.cpp" />
<ClCompile Include="src\CppUTest\CommandLineArguments.cpp" />
<ClCompile Include="src\CppUTest\CommandLineTestRunner.cpp" />
<ClCompile Include="src\CppUTest\JUnitTestOutput.cpp" />
<ClCompile Include="src\CppUTest\TeamCityTestOutput.cpp" />
<ClCompile Include="src\CppUTest\MemoryLeakDetector.cpp" />
<ClCompile Include="src\CppUTest\MemoryLeakWarningPlugin.cpp" />
<ClCompile Include="src\CppUTest\SimpleMutex.cpp" />
<ClCompile Include="src\CppUTest\SimpleString.cpp" />
<ClCompile Include="src\CppUTest\SimpleStringInternalCache.cpp" />
<ClCompile Include="src\CppUTest\TestFailure.cpp" />
<ClCompile Include="src\CppUTest\TestFilter.cpp" />
<ClCompile Include="src\CppUTest\TestHarness_c.cpp" />
<ClCompile Include="src\CppUTest\TestMemoryAllocator.cpp" />
<ClCompile Include="src\CppUTest\TestOutput.cpp" />
<ClCompile Include="src\CppUTest\TestPlugin.cpp" />
<ClCompile Include="src\CppUTest\TestRegistry.cpp" />
<ClCompile Include="src\CppUTest\TestResult.cpp" />
<ClCompile Include="src\CppUTest\TestTestingFixture.cpp" />
<ClCompile Include="src\CppUTest\Utest.cpp" />
<ClCompile Include="src\Platforms\VisualCpp\UtestPlatform.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\CppUTestExt\CodeMemoryReportFormatter.h" />
<ClInclude Include="include\CppUTestExt\GMock.h" />
<ClInclude Include="include\CppUTestExt\GTest.h" />
<ClInclude Include="include\CppUTestExt\GTestSupport.h" />
<ClInclude Include="include\CppUTestExt\GTestConvertor.h" />
<ClInclude Include="include\cpputestext\ieee754exceptionsplugin.h" />
<ClInclude Include="include\CppUTestExt\MemoryReportAllocator.h" />
<ClInclude Include="include\CppUTestExt\MemoryReporterPlugin.h" />
<ClInclude Include="include\CppUTestExt\MemoryReportFormatter.h" />
<ClInclude Include="include\CppUTestExt\MockActualCall.h" />
<ClInclude Include="include\CppUTestExt\MockCheckedActualCall.h" />
<ClInclude Include="include\CppUTestExt\MockCheckedExpectedCall.h" />
<ClInclude Include="include\CppUTestExt\MockExpectedCall.h" />
<ClInclude Include="include\CppUTestExt\MockExpectedCallsList.h" />
<ClInclude Include="include\CppUTestExt\MockFailure.h" />
<ClInclude Include="include\CppUTestExt\MockNamedValue.h" />
<ClInclude Include="include\CppUTestExt\MockSupport.h" />
<ClInclude Include="include\CppUTestExt\MockSupportPlugin.h" />
<ClInclude Include="include\CppUTestExt\MockSupport_c.h" />
<ClInclude Include="include\CppUTestExt\OrderedTest.h" />
<ClInclude Include="include\CppUTest\CommandLineArguments.h" />
<ClInclude Include="include\CppUTest\CommandLineTestRunner.h" />
<ClInclude Include="include\cpputest\cpputestconfig.h" />
<ClInclude Include="include\CppUTest\CppUTestGeneratedConfig.h" />
<ClInclude Include="include\CppUTest\JUnitTestOutput.h" />
<ClInclude Include="include\cpputest\platformspecificfunctions_c.h" />
<ClInclude Include="include\CppUTest\TeamCityTestOutput.h" />
<ClInclude Include="include\CppUTest\MemoryLeakDetector.h" />
<ClInclude Include="include\CppUTest\MemoryLeakDetectorForceInclude.h" />
<ClInclude Include="include\CppUTest\MemoryLeakDetectorMallocMacros.h" />
<ClInclude Include="include\CppUTest\MemoryLeakDetectorNewMacros.h" />
<ClInclude Include="include\CppUTest\MemoryLeakWarningPlugin.h" />
<ClInclude Include="include\CppUTest\PlatformSpecificFunctions.h" />
<ClInclude Include="include\CppUTest\SimpleMutex.h" />
<ClInclude Include="include\CppUTest\SimpleString.h" />
<ClInclude Include="include\CppUTest\SimpleStringInternalCache.h" />
<ClInclude Include="include\CppUTest\StandardCLibrary.h" />
<ClInclude Include="include\CppUTest\TestFailure.h" />
<ClInclude Include="include\CppUTest\TestFilter.h" />
<ClInclude Include="include\CppUTest\TestHarness.h" />
<ClInclude Include="include\CppUTest\TestHarness_c.h" />
<ClInclude Include="include\CppUTest\TestMemoryAllocator.h" />
<ClInclude Include="include\CppUTest\TestOutput.h" />
<ClInclude Include="include\CppUTest\TestPlugin.h" />
<ClInclude Include="include\CppUTest\TestRegistry.h" />
<ClInclude Include="include\CppUTest\TestResult.h" />
<ClInclude Include="include\CppUTest\TestTestingFixture.h" />
<ClInclude Include="include\CppUTest\Utest.h" />
<ClInclude Include="include\CppUTest\UtestMacros.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,9 @@
@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)

View File

@@ -0,0 +1,9 @@
@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)

View File

@@ -0,0 +1,36 @@
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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
config CPPUTEST
bool "Enable cpputest"
default n

View File

@@ -0,0 +1,482 @@
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

View File

@@ -0,0 +1,25 @@
#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

View File

@@ -0,0 +1,163 @@
#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

View File

@@ -0,0 +1,3 @@
You can find the main NEWS at:
https://github.com/cpputest/cpputest

View File

@@ -0,0 +1,3 @@
Please see the README.md. This file exists to be compliant to GNU coding standards.

View File

@@ -0,0 +1,264 @@
# 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

View File

@@ -0,0 +1,66 @@
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++

View File

@@ -0,0 +1,60 @@
1. Unzip into <someDirectory>, resulting in
<someDirectory>/CppUTest/
MAKE SURE <someDirectory> DOES NOT HAVE SPACES IN IT
MAKE SURE <someDirectory> DOES NOT HAVE SPACES IN IT
MAKE SURE <someDirectory> DOES NOT HAVE SPACES IN IT
2. Build CppUTest and examples
2a. For unix/gcc (including cygwin)
> cd <someDirectory>/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 <someDirectory>/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 <someDirectory>/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 <someDirectory>/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/

View File

@@ -0,0 +1,51 @@
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

View File

@@ -0,0 +1,7 @@
#!/bin/sh
#
# cpputest autogen.sh
#
# Run this to generate all the initial makefiles, etc.
autoreconf -i

View File

@@ -0,0 +1,117 @@
set(_CPPUTEST_DISCOVERY_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/_CppUTestDiscovery.cmake
CACHE INTERNAL "CppUTest discovery scripts"
)
option(CPPUTEST_TESTS_DETAILED "Run discovered tests individually")
option(CPPUTEST_JUNIT_REPORT "Output JUnit test reports")
function(cpputest_discover_tests target)
set(options JUNIT)
set(oneValueArgs DETAILED)
set(multiValueArgs EXTRA_ARGS)
cmake_parse_arguments(
""
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
# Validate arguments.
if(NOT TARGET ${target})
message(FATAL_ERROR
"Cannot discover tests for target \"${target}\" "
"which is not built by this project."
)
endif()
get_property(target_type
TARGET ${target}
PROPERTY TYPE
)
if(NOT target_type STREQUAL "EXECUTABLE")
message(FATAL_ERROR
"Cannot discover tests for target \"${target}\" "
"which is not an executable."
)
endif()
get_property(emulator
TARGET ${target}
PROPERTY CROSSCOMPILING_EMULATOR
)
if(CMAKE_CROSSCOMPILING)
if(NOT emulator)
message(WARNING "Cannot discover cross compiled tests without an emulator")
return()
endif()
endif()
if(NOT DEFINED _EXTRA_ARGS)
set(_EXTRA_ARGS -v)
endif()
if(NOT DEFINED _DETAILED)
set(_DETAILED ${CPPUTEST_TESTS_DETAILED})
endif()
if(_JUNIT OR CPPUTEST_JUNIT_REPORT)
list(APPEND _EXTRA_ARGS -ojunit)
endif()
set(CTEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}_include.cmake")
if(CMAKE_CONFIGURATION_TYPES)
set(CTEST_GENERATED_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}.$<CONFIG>.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=$<TARGET_FILE:${target}>"
-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()

View File

@@ -0,0 +1,55 @@
option(CPPUTEST_TESTS_DETAILED "Run discovered tests individually")
set(_DISCOVER_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/../Scripts/CppUTestBuildTimeDiscoverTests.cmake")
# Create target to discover tests
function (cpputest_buildtime_discover_tests 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=$<TARGET_FILE:${tgt}>"
-D "EMULATOR=$<TARGET_PROPERTY:${tgt},CROSSCOMPILING_EMULATOR>"
-P "${_DISCOVER_SCRIPT}"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Discovering Tests in ${tgt}"
VERBATIM
)
endfunction ()

View File

@@ -0,0 +1,57 @@
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()
if(TESTS_DETAILED)
set(discovery_arg "-ln")
set(select_arg "-st")
else()
set(discovery_arg "-lg")
set(select_arg "-sg")
endif()
execute_process(
COMMAND ${EMULATOR} "${EXECUTABLE}" ${discovery_arg}
OUTPUT_VARIABLE discovered_tests
RESULT_VARIABLE result
ERROR_VARIABLE error
)
if(NOT ${result} EQUAL 0)
message(FATAL_ERROR
"Error executing ${EXECUTABLE}:\n"
"${error}"
)
endif()
separate_arguments(discovered_tests)
foreach(test_name IN LISTS discovered_tests)
add_command(
add_test
"${test_name}"
${EMULATOR}
"${EXECUTABLE}"
${ARGS}
${select_arg}
${test_name}
)
endforeach()
file(WRITE "${CTEST_FILE}" "${script}")

View File

@@ -0,0 +1,94 @@
# 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=<ON|OFF> -DEXECUTABLE=<FULLPATH-TO-EXECUTABLE> -P <PATH-TO-THIS-SCRIPT>
#
# TESTS_DETAILED c.f. top-level CMakeLists.txt
# FULLPATH-TO-EXECUTABLE - use $<TARGET_FILE:${EXECUTABLE}> 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")

View File

@@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-m4)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_C_FLAGS_INIT "-mcpu=cortex-m4")
set(CMAKE_CXX_FLAGS_INIT "-mcpu=cortex-m4")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-specs=rdimon.specs")

View File

@@ -0,0 +1,6 @@
# 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)

View File

@@ -0,0 +1,6 @@
# 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)

View File

@@ -0,0 +1,21 @@
### BEGIN CMAKE_TOOLCHAIN_FILE
# "Generic" is used when compiling for bare-metal
set(CMAKE_SYSTEM_NAME Generic)
# Set the EW installation root directory
#(Avoid spaces in the path or you need to escape them)
set(EW_ROOT_DIR "/opt/iarsystems/bxarm/arm/")
# Compiler flags needed to compile for this CPU
set(CPU_FLAGS "--cpu Cortex-M4F")
# Set up the CMake variables for compiler and assembler
# (The reason for both C and CXX variables is that CMake
# treats C and C++ tools individually)
set(CMAKE_C_COMPILER "${EW_ROOT_DIR}/bin/iccarm" "${CPU_FLAGS} --dlib_config normal")
set(CMAKE_CXX_COMPILER "${EW_ROOT_DIR}/bin/iccarm" "${CPU_FLAGS} --dlib_config normal")
set(CMAKE_ASM_COMPILER "${EW_ROOT_DIR}/bin/iasmarm" "${CPU_FLAGS}")
# Build with cmake -S. -Bbuild -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ewarm-linux.toolchain.cmake
### END CMAKE_TOOLCHAIN_FILE

View File

@@ -0,0 +1,21 @@
### BEGIN CMAKE_TOOLCHAIN_FILE
# "Generic" is used when compiling for bare-metal
set(CMAKE_SYSTEM_NAME Generic)
# Set the EW installation root directory
#(Avoid spaces in the path or you need to escape them)
set(EW_ROOT_DIR "E:/Program Files\ (x86)/IAR\ Systems/Embedded\ Workbench\ Arm 8.50.6/arm")
# Compiler flags needed to compile for this CPU
set(CPU_FLAGS "--cpu Cortex-M4F")
# Set up the CMake variables for compiler and assembler
# (The reason for both C and CXX variables is that CMake
# treats C and C++ tools individually)
set(CMAKE_C_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe" "${CPU_FLAGS} --dlib_config normal")
set(CMAKE_CXX_COMPILER "${EW_ROOT_DIR}/bin/iccarm.exe" "${CPU_FLAGS} --dlib_config normal")
set(CMAKE_ASM_COMPILER "${EW_ROOT_DIR}/bin/iasmarm.exe" "${CPU_FLAGS}")
# Build with cmake -S. -Bbuild -G "NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ewarm-win.toolchain.cmake
### END CMAKE_TOOLCHAIN_FILE

View File

@@ -0,0 +1,65 @@
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
# Pkg-config file.
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
set(includedir "\${prefix}/${INCLUDE_INSTALL_DIR}")
set(PACKAGE_VERSION "${PROJECT_VERSION}")
configure_file(cpputest.pc.in cpputest.pc @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/cpputest.pc"
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/generated/CppUTestGeneratedConfig.h"
DESTINATION "${INCLUDE_INSTALL_DIR}/generated"
)
include(CMakePackageConfigHelpers)
set(CPPUTEST_CONFIG_DEST "${LIB_INSTALL_DIR}/CppUTest/cmake")
configure_package_config_file(CppUTestConfig.cmake.install.in
${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
INSTALL_DESTINATION "${CPPUTEST_CONFIG_DEST}"
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/install/CppUTestConfigVersion.cmake
DESTINATION "${CPPUTEST_CONFIG_DEST}"
)
install(
EXPORT CppUTestTargets
NAMESPACE CppUTest::
DESTINATION "${CPPUTEST_CONFIG_DEST}"
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Scripts/CppUTestBuildTimeDiscoverTests.cmake
DESTINATION "${CPPUTEST_CONFIG_DEST}/Scripts"
)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CppUTest.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/_CppUTestDiscovery.cmake
DESTINATION "${CPPUTEST_CONFIG_DEST}/Modules"
)
configure_package_config_file(CppUTestConfig.cmake.build.in
${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
PATH_VARS INCLUDE_DIR CMAKE_CURRENT_BINARY_DIR
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/CppUTestConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)

View File

@@ -0,0 +1,68 @@
unset(WARNING_COMMON_FLAGS)
unset(WARNING_C_FLAGS)
unset(WARNING_CXX_FLAGS)
if(
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
)
set(WARNING_COMMON_FLAGS
-Wall
-Wextra
-pedantic
-Wshadow
-Wswitch-default
-Wswitch-enum
-Wconversion
-Wsign-conversion
-Wmissing-include-dirs
-Wno-padded
-Wno-disabled-macro-expansion
-Wreserved-id-macro
-Wreserved-identifier
-Wno-long-long
-Wno-unsafe-buffer-usage
)
set(WARNING_C_FLAGS
-Wstrict-prototypes
)
set(WARNING_CXX_FLAGS
-Woverloaded-virtual
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-weak-vtables
-Wno-old-style-cast
)
if(DEFINED CMAKE_CXX_STANDARD AND NOT CMAKE_CXX_STANDARD EQUAL 98)
list(APPEND WARNING_CXX_FLAGS
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-c++14-compat
-Wno-inconsistent-missing-destructor-override
-Wsuggest-override
)
endif()
set(CMAKE_REQUIRED_FLAGS "-Wno-error")
endif()
include(CheckCCompilerFlag)
foreach(flag IN LISTS WARNING_COMMON_FLAGS WARNING_C_FLAGS)
check_c_compiler_flag("${flag}" WARNING_C_FLAG_${flag})
if(WARNING_C_FLAG_${flag})
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${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("$<$<COMPILE_LANGUAGE:CXX>:${flag}>")
endif()
endforeach()

View File

@@ -0,0 +1,18 @@
#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

View File

@@ -0,0 +1,629 @@
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 <cstdio>]])], [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"
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 <new>\nvoid 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 <new>\nvoid* operator new(size_t size) throw(std::bad_alloc);;])], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]); UT_NEW_CANT_HAVE_EXCEPTION_SPECIFIER="yes"])
CXXFLAGS="$saved_cxxflags"
# Flag -Wno-missing-exception-spec
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
# In Travis, do not show warnings. The GTest warnings cause a log overflow that errors the build. Nice :)
if test -n "${TRAVIS_BRANCH}"; then
CPPUTEST_CWARNINGFLAGS=""
CPPUTEST_CXXWARNINGFLAGS=""
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}
----------------------------------------------------------------"

View File

@@ -0,0 +1,11 @@
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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
FROM ubuntu
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends dosbox make openssl ca-certificates git
WORKDIR /cpputest_build
CMD BUILD=make_dos /cpputest/scripts/travis_ci_build.sh

View File

@@ -0,0 +1,8 @@
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
CMD autoreconf -i ../cpputest && ../cpputest/configure && make tdd

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-cdt version="2.0"?>
<cdtproject id="org.eclipse.cdt.make.core.make">
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<data>
<item id="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="true" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="true"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
<buildOutputProvider>
<openAction enabled="false" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="makefileGenerator">
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
<parser enabled="false"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="false" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="false"/>
</scannerInfoProvider>
</profile>
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
<buildOutputProvider>
<openAction enabled="false" filePath=""/>
<parser enabled="true"/>
</buildOutputProvider>
<scannerInfoProvider id="specsFile">
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
<parser enabled="false"/>
</scannerInfoProvider>
</profile>
</item>
<item id="org.eclipse.cdt.core.pathentry">
<pathentry kind="src" path=""/>
<pathentry kind="out" path=""/>
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
</item>
</data>
</cdtproject>

View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CppUTestExample</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.make.core.makeBuilder</name>
<arguments>
<dictionary>
<key>org.eclipse.cdt.make.core.build.arguments</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.core.errorOutputParser</key>
<value>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;</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.environment</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.build.target.inc</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.build.location</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.build.command</key>
<value>make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.build.target.clean</key>
<value>clean depend</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.build.target.auto</key>
<value>all</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>false</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.make.core.makeNature</nature>
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,60 @@
/*
* 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 <organization> 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 <copyright holder> 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"

View File

@@ -0,0 +1,32 @@
/*
* 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 <organization> 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 <copyright holder> 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);

View File

@@ -0,0 +1,252 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="AllTests"
ProjectGUID="{95A5F8D0-12C0-4AC1-B46B-292DD3886108}"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory="./$(ConfigurationName)/"
IntermediateDirectory="./$(ConfigurationName)/"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
BuildLogFile="$(IntDir)/BuildLog.htm"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/AllTests.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="../../include,../ApplicationLib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
AssemblerListingLocation="./$(ConfigurationName)/"
ObjectFile="./$(ConfigurationName)/"
ProgramDataBaseFileName="./$(ConfigurationName)/"
XMLDocumentationFileName="./$(ConfigurationName)/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/NODEFAULTLIB:LIBCMT"
AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
OutputFile="./$(ConfigurationName)/AllTests.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\$(ConfigurationName)/AllTests.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/AllTests.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include,../ApplicationLib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
AssemblerListingLocation="./$(ConfigurationName)/"
ObjectFile="./$(ConfigurationName)/"
ProgramDataBaseFileName="./$(ConfigurationName)/"
XMLDocumentationFileName="$(ConfigurationName)/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
OutputFile="./$(ConfigurationName)/AllTests.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
GenerateDebugInformation="true"
ProgramDatabaseFile="./$(ConfigurationName)/AllTests.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/AllTests.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="&quot;$(TargetPath)&quot;"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath=".\AllTests.cpp"
>
</File>
<File
RelativePath=".\CircularBufferTest.cpp"
>
</File>
<File
RelativePath=".\EventDispatcherTest.cpp"
>
</File>
<File
RelativePath=".\HelloTest.cpp"
>
</File>
<File
RelativePath=".\MockDocumentationTest.cpp"
>
</File>
<File
RelativePath=".\PrinterTest.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{95A5F8D0-12C0-4AC1-B46B-292DD3886108}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">./$(Configuration)/\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">./$(Configuration)/\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<BuildLog>
<Path>$(IntDir)BuildLog.htm</Path>
</BuildLog>
<Midl>
<TypeLibraryName>.\Debug/AllTests.tlb</TypeLibraryName>
<HeaderFileName>
</HeaderFileName>
</Midl>
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>../../include;../ApplicationLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>./$(Configuration)/AllTests.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>./$(Configuration)/</AssemblerListingLocation>
<ObjectFileName>./$(Configuration)/</ObjectFileName>
<ProgramDataBaseFileName>./$(Configuration)/</ProgramDataBaseFileName>
<XMLDocumentationFileName>./$(Configuration)/</XMLDocumentationFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalOptions>/NODEFAULTLIB:LIBCMT /NODEFAULTLIB:MSVCRTD %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>../../lib/CppUTest.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>./$(Configuration)/AllTests.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<ManifestFile>./$(Configuration)/$(TargetFileName).intermediate.manifest</ManifestFile>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>false</GenerateDebugInformation>
<ProgramDatabaseFile>
</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\$(Configuration)/AllTests.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
<Command>"$(TargetPath)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<TypeLibraryName>.\Debug/AllTests.tlb</TypeLibraryName>
<HeaderFileName>
</HeaderFileName>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;../ApplicationLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>./$(Configuration)/AllTests.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>./$(Configuration)/</AssemblerListingLocation>
<ObjectFileName>./$(Configuration)/</ObjectFileName>
<ProgramDataBaseFileName>./$(Configuration)/</ProgramDataBaseFileName>
<XMLDocumentationFileName>$(Configuration)/</XMLDocumentationFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Link>
<AdditionalDependencies>../../lib/CppUTestd.lib;../ApplicationLib/$(Configuration)/ApplicationLib.lib;odbc32.lib;odbccp32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>./$(Configuration)/AllTests.exe</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<ManifestFile>./$(Configuration)/$(TargetFileName).intermediate.manifest</ManifestFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>./$(Configuration)/AllTests.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>.\Debug/AllTests.bsc</OutputFile>
</Bscmake>
<PostBuildEvent>
<Command>"$(TargetPath)"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AllTests.cpp" />
<ClCompile Include="CircularBufferTest.cpp" />
<ClCompile Include="EventDispatcherTest.cpp" />
<ClCompile Include="HelloTest.cpp" />
<ClCompile Include="MockDocumentationTest.cpp" />
<ClCompile Include="PrinterTest.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ApplicationLib\ApplicationLib.vcxproj">
<Project>{348076b9-303c-4fe0-9380-17cdf11134a9}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AllTests.h" />
<ClInclude Include="MockPrinter.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,27 @@
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 $<$<BOOL:${MSVC}>:/wd4723>
)
target_link_libraries(ExampleTests
PRIVATE
ApplicationLib
CppUTest::CppUTestExt
)
include(CppUTest)
cpputest_discover_tests(ExampleTests)

View File

@@ -0,0 +1,262 @@
/*
* 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 <organization> 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 <copyright holder> 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());
}

View File

@@ -0,0 +1,135 @@
/*
* 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 <organization> 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 <copyright holder> 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);
}

View File

@@ -0,0 +1,89 @@
/*
* 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 <organization> 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 <copyright holder> 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 <fenv.h>
}
#include <limits>
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<float>::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<float>::infinity())
f = f * f;
CHECK(f >= std::numeric_limits<float>::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

View File

@@ -0,0 +1,61 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stdio.h>
#include <stdarg.h>
#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());
}

View File

@@ -0,0 +1,234 @@
/*
* 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 <organization> 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 <copyright holder> 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
}

View File

@@ -0,0 +1,73 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stdlib.h>
#include <string>
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

View File

@@ -0,0 +1,68 @@
/*
* 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 <organization> 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 <copyright holder> 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());
}

View File

@@ -0,0 +1,4 @@
#!/bin/bash
#put any pre-test execution commands here.
echo Running all tests
./AllTests $1

View File

@@ -0,0 +1,276 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ApplicationLib"
ProjectGUID="{348076B9-303C-4FE0-9380-17CDF11134A9}"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\Debug/ApplicationLib.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile=".\Debug\ApplicationLib.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile="./$(ConfigurationName)/ApplicationLib.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories="../../include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
PrecompiledHeaderFile="./$(ConfigurationName)/ApplicationLib.pch"
AssemblerListingLocation="./$(ConfigurationName)/"
ObjectFile="./$(ConfigurationName)/"
ProgramDataBaseFileName="./$(ConfigurationName)/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="./$(ConfigurationName)/ApplicationLib.lib"
SuppressStartupBanner="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile="./$(ConfigurationName)/ApplicationLib.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
>
<File
RelativePath="CircularBuffer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath=".\EventDispatcher.cpp"
>
</File>
<File
RelativePath="hello.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="Printer.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="AllTests.h"
>
</File>
<File
RelativePath="CircularBuffer.h"
>
</File>
<File
RelativePath=".\EventDispatcher.h"
>
</File>
<File
RelativePath="hello.h"
>
</File>
<File
RelativePath="MockPrinter.h"
>
</File>
<File
RelativePath="Printer.h"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{348076B9-303C-4FE0-9380-17CDF11134A9}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC60.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\Debug\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>.\Debug/ApplicationLib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\Debug\ApplicationLib.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>./$(Configuration)/ApplicationLib.bsc</OutputFile>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeaderOutputFile>./$(Configuration)/ApplicationLib.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>./$(Configuration)/</AssemblerListingLocation>
<ObjectFileName>./$(Configuration)/</ObjectFileName>
<ProgramDataBaseFileName>./$(Configuration)/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0409</Culture>
</ResourceCompile>
<Lib>
<OutputFile>./$(Configuration)/ApplicationLib.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>./$(Configuration)/ApplicationLib.bsc</OutputFile>
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CircularBuffer.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="EventDispatcher.cpp" />
<ClCompile Include="hello.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="Printer.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CircularBuffer.h" />
<ClInclude Include="EventDispatcher.h" />
<ClInclude Include="hello.h" />
<ClInclude Include="Printer.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,11 @@
add_library(ApplicationLib
CircularBuffer.cpp
EventDispatcher.cpp
hello.c
Printer.cpp
)
target_include_directories(ExampleTests
PUBLIC
.
)

View File

@@ -0,0 +1,106 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stddef.h>
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");
}

View File

@@ -0,0 +1,70 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,47 @@
/*
* 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 <organization> 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 <copyright holder> 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<pair<EventType, EventObserver*> >::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<pair<EventType, EventObserver*> >::iterator i = observerList_.begin(); i != observerList_.end(); i++) {
if (i->first == event.type)
i->second->notify(event, timeoutSeconds);
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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 <organization> 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 <copyright holder> 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 <list>
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<std::pair<EventType, EventObserver*> > observerList_;
public:
EventDispatcher();
void registerObserver(EventType type, EventObserver* observer);
void dispatchEvent(const Event& event, int timeoutSeconds);
};
#endif

View File

@@ -0,0 +1,29 @@
/*
* 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 <organization> 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 <copyright holder> 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 <list>
#include "CppUTest/MemoryLeakDetectorNewMacros.h"

View File

@@ -0,0 +1,56 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stdio.h>
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;
}

View File

@@ -0,0 +1,54 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,36 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stdio.h>
#include "hello.h"
void printHelloWorld(void)
{
PrintFormated("Hello World!\n");
}
int (*PrintFormated)(const char*, ...) = printf;

View File

@@ -0,0 +1,43 @@
/*
* 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 <organization> 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 <copyright holder> 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_*/

View File

@@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 3.8...3.31)
project(CppUTestExample)
if (CMAKE_VERSION GREATER_EQUAL "3.21")
# PROJECT_IS_TOP_LEVEL is defined automatically
elseif(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
set(PROJECT_IS_TOP_LEVEL TRUE)
else()
set(PROJECT_IS_TOP_LEVEL FALSE)
endif()
if(PROJECT_IS_TOP_LEVEL)
find_package(CppUTest 4.0 REQUIRED)
endif()
include(CTest)
add_subdirectory(AllTests)
add_subdirectory(ApplicationLib)

View File

@@ -0,0 +1,29 @@
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

View File

@@ -0,0 +1,26 @@
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

View File

@@ -0,0 +1,36 @@
#---------
#
# 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 <list> 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

View File

@@ -0,0 +1,26 @@
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)

View File

@@ -0,0 +1,7 @@
To build the examples
for gcc:
make clean all test gcov
for MS Studio:
The workspace files may be out of date.

View File

@@ -0,0 +1,6 @@
filter = src/
filter = include/
html = yes
html-details = yes
output = coverage.html
print-summary = yes

View File

@@ -0,0 +1,120 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,68 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,358 @@
/*
* 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 <organization> 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 <copyright holder> 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 <new> 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

View File

@@ -0,0 +1,47 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,81 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,270 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,4 @@
// Not all toolchains support multiple force includes (namely IAR),
// so we wrap the two in a single header.
#include "MemoryLeakDetectorMallocMacros.h"
#include "MemoryLeakDetectorNewMacros.h"

View File

@@ -0,0 +1,68 @@
/*
* 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 */

View File

@@ -0,0 +1,95 @@
/*
* 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 <new> 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 <string.h> or <cstring> included when using <memory> 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 <new>
#include <memory>
#include <string>
#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

View File

@@ -0,0 +1,89 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,46 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,97 @@
/*
* 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 <organization> 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 <copyright holder> 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_ */

View File

@@ -0,0 +1,54 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,244 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,110 @@
/*
* 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 <organization> 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 <copyright holder> 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

View File

@@ -0,0 +1,104 @@
/* 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 <stddef.h>
/* 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 <cstdlib>
#include <cstring>
#include <string>
#endif
#endif
/* Needed for malloc */
#include <stdlib.h>
/* Needed for std::nullptr */
#ifdef __cplusplus
#if CPPUTEST_USE_STD_CPP_LIB
#include <cstddef>
#endif
#endif
/* Needed for ... */
#include <stdarg.h>
/* 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 <limits.h>
/* Needed to ensure that string.h is included prior to strdup redefinition */
#ifdef CPPUTEST_HAVE_STRDUP
#include <string.h>
#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 <linux/acpi.h>
#include <linux/types.h>
#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

View File

@@ -0,0 +1,28 @@
#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

View File

@@ -0,0 +1,200 @@
/*
* 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 <organization> 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 <copyright holder> 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 <stdexcept>
#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

View File

@@ -0,0 +1,63 @@
/*
* 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 <organization> 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 <copyright holder> 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

Some files were not shown because too many files have changed in this diff Show More