git subrepo clone git@github.com:compihu/platform-test-f4-ll.git platforms/platform-test-f4-ll
subrepo: subdir: "platforms/platform-test-f4-ll" merged: "bc41134" upstream: origin: "git@github.com:compihu/platform-test-f4-ll.git" branch: "master" commit: "bc41134" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "87ee373"
This commit is contained in:
parent
46ce55c6a0
commit
95af4ce0d8
460 changed files with 84105 additions and 0 deletions
56
platforms/platform-test-f4-ll/cpputest/examples/.cdtproject
Normal file
56
platforms/platform-test-f4-ll/cpputest/examples/.cdtproject
Normal 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>
|
85
platforms/platform-test-f4-ll/cpputest/examples/.project
Normal file
85
platforms/platform-test-f4-ll/cpputest/examples/.project
Normal 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>
|
|
@ -0,0 +1,3 @@
|
|||
#Thu Apr 19 15:52:43 CDT 2007
|
||||
eclipse.preferences.version=1
|
||||
indexerId=org.eclipse.cdt.core.fastIndexer
|
|
@ -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)
|
||||
{
|
||||
return object1 == object2;
|
||||
}
|
||||
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
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"
|
|
@ -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);
|
|
@ -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,../../include/Platforms/VisualCpp,../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=""$(TargetPath)""
|
||||
/>
|
||||
</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,../../include/Platforms/VisualCpp,../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=""$(TargetPath)""
|
||||
/>
|
||||
</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>
|
|
@ -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>
|
|
@ -0,0 +1,15 @@
|
|||
include_directories(../ApplicationLib)
|
||||
|
||||
add_executable(ExampleTests
|
||||
AllTests.cpp
|
||||
CircularBufferTest.cpp
|
||||
EventDispatcherTest.cpp
|
||||
FEDemoTest.cpp
|
||||
HelloTest.cpp
|
||||
MockDocumentationTest.cpp
|
||||
PrinterTest.cpp
|
||||
)
|
||||
|
||||
cpputest_normalize_test_output_location(ExampleTests)
|
||||
target_link_libraries(ExampleTests ApplicationLib CppUTest CppUTestExt)
|
||||
cpputest_buildtime_discover_tests(ExampleTests)
|
|
@ -0,0 +1,260 @@
|
|||
/*
|
||||
* 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()
|
||||
{
|
||||
buffer = new CircularBuffer();
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
void fillTheQueue(int seed, int howMany)
|
||||
{
|
||||
for (int i = 0; i < howMany; i++)
|
||||
buffer->Put(seed + i);
|
||||
}
|
||||
void removeFromQueue(int howMany)
|
||||
{
|
||||
for (int i = 0; i < howMany; i++)
|
||||
buffer->Get();
|
||||
}
|
||||
};
|
||||
|
||||
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());
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* 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 "EventDispatcher.h"
|
||||
|
||||
class ObserverMock : public EventObserver
|
||||
{
|
||||
public:
|
||||
virtual void notify(const Event& event, int timeOutInSeconds)
|
||||
{
|
||||
mock().actualCall("notify").onObject(this).withParameterOfType("Event", "event", (void*) &event).withParameter("timeOutInSeconds", timeOutInSeconds);
|
||||
}
|
||||
virtual void notifyRegistration(EventObserver* newObserver)
|
||||
{
|
||||
mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver);
|
||||
}
|
||||
};
|
||||
|
||||
class EventComparator : public MockNamedValueComparator
|
||||
{
|
||||
public:
|
||||
virtual bool isEqual(const void* object1, const void* object2)
|
||||
{
|
||||
return ((const Event*)object1)->type == ((const Event*)object2)->type;
|
||||
}
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
return StringFrom(((const Event*)object)->type);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST_GROUP(EventDispatcher)
|
||||
{
|
||||
Event event;
|
||||
EventDispatcher* dispatcher;
|
||||
ObserverMock observer;
|
||||
ObserverMock observer2;
|
||||
EventComparator eventComparator;
|
||||
|
||||
void setup()
|
||||
{
|
||||
dispatcher = new EventDispatcher;
|
||||
mock().installComparator("Event", eventComparator);
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
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);
|
||||
}
|
|
@ -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"
|
||||
|
||||
#ifdef 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>
|
||||
|
||||
static volatile float f;
|
||||
|
||||
TEST_GROUP(FE_Demo)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
IEEE754ExceptionsPlugin::disableInexact();
|
||||
}
|
||||
};
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_DIVBYZERO__is_set)
|
||||
{
|
||||
f = 1.0f;
|
||||
CHECK((f /= 0.0f) >= std::numeric_limits<float>::infinity());
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_UNDERFLOW__is_set)
|
||||
{
|
||||
f = 0.01f;
|
||||
while (f > 0.0f) f *= f;
|
||||
CHECK(f == 0.0f);
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_OVERFLOW__is_set)
|
||||
{
|
||||
f = 1000.0f;
|
||||
while (f < std::numeric_limits<float>::infinity()) f *= f;
|
||||
CHECK(f >= std::numeric_limits<float>::infinity());
|
||||
}
|
||||
|
||||
IGNORE_TEST(FE_Demo, should_fail_when__FE_INEXACT____is_set)
|
||||
{
|
||||
IEEE754ExceptionsPlugin::enableInexact();
|
||||
f = 10.0f;
|
||||
DOUBLES_EQUAL((double) (f / 3.0f), (double) 3.333f, (double) 0.001f);
|
||||
}
|
||||
|
||||
TEST(FE_Demo, should_succeed_when_no_flags_are_set)
|
||||
{
|
||||
CHECK(5.0f == 15.0f / 3.0f);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -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 "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()
|
||||
{
|
||||
buffer = new SimpleString();
|
||||
UT_PTR_SET(PrintFormated, &output_method);
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
delete buffer;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(HelloWorld, PrintOk)
|
||||
{
|
||||
printHelloWorld();
|
||||
STRCMP_EQUAL("Hello World!\n", buffer->asCharString());
|
||||
}
|
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
* 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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
return object1 == object2;
|
||||
}
|
||||
virtual SimpleString valueToString(const void* object)
|
||||
{
|
||||
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);
|
||||
int value = mock().actualCall("function").returnValue().getIntValue();
|
||||
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()
|
||||
{
|
||||
// Init stuff
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
// Uninit stuff
|
||||
}
|
||||
};
|
||||
|
||||
TEST(FooTestGroup, Foo)
|
||||
{
|
||||
// Test FOO
|
||||
}
|
||||
|
||||
TEST(FooTestGroup, MoreFoo)
|
||||
{
|
||||
// Test more FOO
|
||||
}
|
||||
|
||||
TEST_GROUP(BarTestGroup)
|
||||
{
|
||||
void setup()
|
||||
{
|
||||
// Init Bar
|
||||
}
|
||||
};
|
||||
|
||||
TEST(BarTestGroup, Bar)
|
||||
{
|
||||
// Test Bar
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Print(const char* s)
|
||||
{
|
||||
savedOutput.append(s);
|
||||
}
|
||||
|
||||
virtual void Print(long int value)
|
||||
{
|
||||
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
|
|
@ -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()
|
||||
{
|
||||
mockPrinter = new MockPrinter();
|
||||
printer = mockPrinter;
|
||||
}
|
||||
void teardown()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
4
platforms/platform-test-f4-ll/cpputest/examples/AllTests/RunAllTests.sh
Executable file
4
platforms/platform-test-f4-ll/cpputest/examples/AllTests/RunAllTests.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
#put any pre-test execution commands here.
|
||||
echo Running all tests
|
||||
./AllTests $1
|
|
@ -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,../../include/Platforms/VisualCpp"
|
||||
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,../../include/Platforms/VisualCpp"
|
||||
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>
|
|
@ -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>
|
|
@ -0,0 +1,6 @@
|
|||
add_library(ApplicationLib
|
||||
CircularBuffer.cpp
|
||||
EventDispatcher.cpp
|
||||
hello.c
|
||||
Printer.cpp
|
||||
)
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* 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");
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
|
@ -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 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
|
|
@ -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"
|
|
@ -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 "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;
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
||||
#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
|
|
@ -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()
|
||||
{
|
||||
PrintFormated("Hello World!\n");
|
||||
}
|
||||
|
||||
int (*PrintFormated)(const char*, ...) = printf;
|
|
@ -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_*/
|
|
@ -0,0 +1,2 @@
|
|||
add_subdirectory(AllTests)
|
||||
add_subdirectory(ApplicationLib)
|
|
@ -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
|
|
@ -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
|
36
platforms/platform-test-f4-ll/cpputest/examples/Makefile
Normal file
36
platforms/platform-test-f4-ll/cpputest/examples/Makefile
Normal 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
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
@ -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.
|
Loading…
Add table
Add a link
Reference in a new issue