File examples.obscpio of Package Cpputest

0707010000BFE0000041ED000003E8000000640000000268A04FE700000000000000080000003000000000000000000000001800000000examples/ApplicationLib0707010000BFD0000041ED000003E8000000640000000268A04FE700000000000000080000003000000000000000000000001300000000examples/.settings0707010000BFD2000041ED000003E8000000640000000268A04FE700000000000000080000003000000000000000000000001200000000examples/AllTests0707010000BFF1000081A4000003E8000000640000000168A04FE700000286000000080000003000000000000000000000003300000000examples/Makefile_ExamplesWithCppUTestInstalled.mk
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)

0707010000BFEE000081A4000003E8000000640000000168A04FE7000005FA000000080000003000000000000000000000002400000000examples/CppUTestExample_VS2008.sln
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
0707010000BFED000081A4000003E8000000640000000168A04FE7000001C2000000080000003000000000000000000000001800000000examples/CMakeLists.txtcmake_minimum_required(VERSION 3.8...3.31)

project(CppUTestExample)

if (CMAKE_VERSION GREATER_EQUAL "3.21")
  # PROJECT_IS_TOP_LEVEL is defined automatically
elseif(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
  set(PROJECT_IS_TOP_LEVEL TRUE)
else()
  set(PROJECT_IS_TOP_LEVEL FALSE)
endif()

if(PROJECT_IS_TOP_LEVEL)
  find_package(CppUTest 4.0 REQUIRED)
endif()

include(CTest)

add_subdirectory(AllTests)
add_subdirectory(ApplicationLib)
0707010000BFF2000081A4000003E8000000640000000168A04FE700000070000000080000003000000000000000000000001400000000examples/README.txtTo build the examples

for gcc:
make clean all test gcov

for MS Studio:
The workspace files may be out of date.0707010000BFCE000081A4000003E8000000640000000168A04FE700000883000000080000003000000000000000000000001500000000examples/.cdtproject<?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>
0707010000BFCF000081A4000003E8000000640000000168A04FE700000A3F000000080000003000000000000000000000001200000000examples/.project<?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>
0707010000BFEF000081A4000003E8000000640000000168A04FE70000055C000000080000003000000000000000000000002400000000examples/CppUTestExample_VS201x.sln
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
0707010000BFF0000081A4000003E8000000640000000168A04FE7000002CC000000080000003000000000000000000000001200000000examples/Makefile#---------
#
# 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


0707010000BFEB000081A4000003E8000000640000000168A04FE7000006E1000000080000003000000000000000000000002000000000examples/ApplicationLib/hello.c/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <stdio.h>
#include "hello.h"

void printHelloWorld(void)
{
    PrintFormated("Hello World!\n");
}

int (*PrintFormated)(const char*, ...) = printf;
0707010000BFE7000081A4000003E8000000640000000168A04FE7000008D5000000080000003000000000000000000000002A00000000examples/ApplicationLib/EventDispatcher.h/*
 * 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
0707010000BFE9000081A4000003E8000000640000000168A04FE7000007D9000000080000003000000000000000000000002400000000examples/ApplicationLib/Printer.cpp/*
 * 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;
}
0707010000BFE4000081A4000003E8000000640000000168A04FE700000BCB000000080000003000000000000000000000002B00000000examples/ApplicationLib/CircularBuffer.cpp/*
 * 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");
}
0707010000BFE8000081A4000003E8000000640000000168A04FE700000686000000080000003000000000000000000000002F00000000examples/ApplicationLib/ExamplesNewOverrides.h/*
 * 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"
0707010000BFE3000081A4000003E8000000640000000168A04FE7000000A8000000080000003000000000000000000000002700000000examples/ApplicationLib/CMakeLists.txtadd_library(ApplicationLib
    CircularBuffer.cpp
    EventDispatcher.cpp
    hello.c
    Printer.cpp
)
target_include_directories(ExampleTests
    PUBLIC
        .
)

0707010000BFEA000081A4000003E8000000640000000168A04FE700000886000000080000003000000000000000000000002200000000examples/ApplicationLib/Printer.h/*
 * 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
0707010000BFE2000081A4000003E8000000640000000168A04FE700001F33000000080000003000000000000000000000002F00000000examples/ApplicationLib/ApplicationLib.vcxproj<?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>0707010000BFE6000081A4000003E8000000640000000168A04FE7000008F7000000080000003000000000000000000000002C00000000examples/ApplicationLib/EventDispatcher.cpp/*
 * 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);
    }
}
0707010000BFEC000081A4000003E8000000640000000168A04FE700000714000000080000003000000000000000000000002000000000examples/ApplicationLib/hello.h/*
 * 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_*/
0707010000BFE5000081A4000003E8000000640000000168A04FE70000098D000000080000003000000000000000000000002900000000examples/ApplicationLib/CircularBuffer.h/*
 * 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
0707010000BFE1000081A4000003E8000000640000000168A04FE700001793000000080000003000000000000000000000002E00000000examples/ApplicationLib/ApplicationLib.vcproj<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="9.00"
	Name="ApplicationLib"
	ProjectGUID="{348076B9-303C-4FE0-9380-17CDF11134A9}"
	TargetFrameworkVersion="0"
	>
	<Platforms>
		<Platform
			Name="Win32"
		/>
	</Platforms>
	<ToolFiles>
	</ToolFiles>
	<Configurations>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory=".\Debug"
			IntermediateDirectory=".\Debug"
			ConfigurationType="4"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="false"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="../../include"
				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				PrecompiledHeaderFile=".\Debug/ApplicationLib.pch"
				AssemblerListingLocation=".\Debug/"
				ObjectFile=".\Debug/"
				ProgramDataBaseFileName=".\Debug/"
				WarningLevel="3"
				SuppressStartupBanner="true"
				DebugInformationFormat="4"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="1033"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile=".\Debug\ApplicationLib.lib"
				SuppressStartupBanner="true"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
				SuppressStartupBanner="true"
				OutputFile="./$(ConfigurationName)/ApplicationLib.bsc"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="$(ConfigurationName)"
			IntermediateDirectory="$(ConfigurationName)"
			ConfigurationType="4"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="false"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="2"
				AdditionalIncludeDirectories="../../include"
				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
				BasicRuntimeChecks="0"
				RuntimeLibrary="3"
				PrecompiledHeaderFile="./$(ConfigurationName)/ApplicationLib.pch"
				AssemblerListingLocation="./$(ConfigurationName)/"
				ObjectFile="./$(ConfigurationName)/"
				ProgramDataBaseFileName="./$(ConfigurationName)/"
				WarningLevel="3"
				SuppressStartupBanner="true"
				DebugInformationFormat="0"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="NDEBUG"
				Culture="1033"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLibrarianTool"
				OutputFile="./$(ConfigurationName)/ApplicationLib.lib"
				SuppressStartupBanner="true"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
				SuppressStartupBanner="true"
				OutputFile="./$(ConfigurationName)/ApplicationLib.bsc"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
			/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
			>
			<File
				RelativePath="CircularBuffer.cpp"
				>
				<FileConfiguration
					Name="Debug|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
			</File>
			<File
				RelativePath=".\EventDispatcher.cpp"
				>
			</File>
			<File
				RelativePath="hello.c"
				>
				<FileConfiguration
					Name="Debug|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
			</File>
			<File
				RelativePath="Printer.cpp"
				>
				<FileConfiguration
					Name="Debug|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
				<FileConfiguration
					Name="Release|Win32"
					>
					<Tool
						Name="VCCLCompilerTool"
						AdditionalIncludeDirectories=""
						PreprocessorDefinitions=""
					/>
				</FileConfiguration>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl"
			>
			<File
				RelativePath="AllTests.h"
				>
			</File>
			<File
				RelativePath="CircularBuffer.h"
				>
			</File>
			<File
				RelativePath=".\EventDispatcher.h"
				>
			</File>
			<File
				RelativePath="hello.h"
				>
			</File>
			<File
				RelativePath="MockPrinter.h"
				>
			</File>
			<File
				RelativePath="Printer.h"
				>
			</File>
		</Filter>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>
0707010000BFD1000081A4000003E8000000640000000168A04FE700000067000000080000003000000000000000000000002E00000000examples/.settings/org.eclipse.cdt.core.prefs#Thu Apr 19 15:52:43 CDT 2007
eclipse.preferences.version=1
indexerId=org.eclipse.cdt.core.fastIndexer
0707010000BFDF000081ED000003E8000000640000000168A04FE70000005C000000080000003000000000000000000000002100000000examples/AllTests/RunAllTests.sh#!/bin/bash
#put any pre-test execution commands here.
echo Running all tests
./AllTests $1
0707010000BFD8000081A4000003E8000000640000000168A04FE70000191F000000080000003000000000000000000000002900000000examples/AllTests/CircularBufferTest.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CppUTest/TestHarness.h"
#include "MockPrinter.h"
#include "CircularBuffer.h"

TEST_GROUP(CircularBuffer)
{
    CircularBuffer* buffer;

    void setup() CPPUTEST_OVERRIDE
    {
        buffer = new CircularBuffer();
    }
    void teardown() CPPUTEST_OVERRIDE
    {
        delete buffer;
    }

    void fillTheQueue(int seed, int howMany)
    {
        for (int i = 0; i < howMany; i++)
            buffer->Put(seed + i);
    }
    void removeFromQueue(int howMany)
    {
        for (int i = 0; i < howMany; i++)
            buffer->Get();
    }
};

TEST(CircularBuffer, EmptyAfterCreation)
{
    CHECK(buffer->IsEmpty());
}

TEST(CircularBuffer, NotEmpty)
{
    buffer->Put(10046);
    CHECK(!buffer->IsEmpty());
}

TEST(CircularBuffer, NotEmptyThenEmpty)
{
    buffer->Put(4567);
    CHECK(!buffer->IsEmpty());
    buffer->Get();
    CHECK(buffer->IsEmpty());
}

TEST(CircularBuffer, GetPutOneValue)
{
    buffer->Put(4567);
    LONGS_EQUAL(4567, buffer->Get());
}

TEST(CircularBuffer, GetPutAFew)
{
    buffer->Put(1);
    buffer->Put(2);
    buffer->Put(3);
    LONGS_EQUAL(1, buffer->Get());
    LONGS_EQUAL(2, buffer->Get());
    LONGS_EQUAL(3, buffer->Get());
}

TEST(CircularBuffer, Capacity)
{
    CircularBuffer b(2);
    LONGS_EQUAL(2, b.Capacity());
}

TEST(CircularBuffer, IsFull)
{
    fillTheQueue(0, buffer->Capacity());
    CHECK(buffer->IsFull());
}

TEST(CircularBuffer, EmptyToFullToEmpty)
{
    fillTheQueue(100, buffer->Capacity());

    CHECK(buffer->IsFull());

    removeFromQueue(buffer->Capacity());

    CHECK(buffer->IsEmpty());
}

TEST(CircularBuffer, WrapAround)
{
    fillTheQueue(100, buffer->Capacity());

    CHECK(buffer->IsFull());
    LONGS_EQUAL(100, buffer->Get());
    CHECK(!buffer->IsFull());
    buffer->Put(1000);
    CHECK(buffer->IsFull());

    removeFromQueue(buffer->Capacity() - 1);

    LONGS_EQUAL(1000, buffer->Get());
    CHECK(buffer->IsEmpty());
}

TEST(CircularBuffer, PutToFull)
{
    int capacity = buffer->Capacity();
    fillTheQueue(900, capacity);
    buffer->Put(9999);

    for (int i = 0; i < buffer->Capacity() - 1; i++)
        LONGS_EQUAL(i + 900 + 1, buffer->Get());

    LONGS_EQUAL(9999, buffer->Get());
    CHECK(buffer->IsEmpty());
}

// Sometime people ask what tests the tests.
// Do you know the answer

TEST(CircularBuffer, GetFromEmpty)
{
    LONGS_EQUAL(-1, buffer->Get());
    CHECK(buffer->IsEmpty());
}

/*
 * the next tests demonstrate using a mock object for
 * capturing output
 *
 */

TEST(CircularBuffer, PrintEmpty)
{
    MockPrinter mock;
    Printer* p = &mock;

    buffer->Print(p);
    STRCMP_EQUAL("Circular buffer content:\n<>\n", mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintAfterOnePut)
{
    MockPrinter mock;

    buffer->Put(1);
    buffer->Print(&mock);
    STRCMP_EQUAL("Circular buffer content:\n<1>\n", mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintNotYetWrappedOrFull)
{
    MockPrinter mock;

    buffer->Put(1);
    buffer->Put(2);
    buffer->Put(3);
    buffer->Print(&mock);
    STRCMP_EQUAL("Circular buffer content:\n<1, 2, 3>\n", mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintNotYetWrappedAndIsFull)
{
    MockPrinter mock;

    fillTheQueue(200, buffer->Capacity());

    buffer->Print(&mock);
    const char* expected =
        "Circular buffer content:\n"
        "<200, 201, 202, 203, 204>\n";

    STRCMP_EQUAL(expected, mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintWrappedAndIsFullOldestToNewest)
{
    MockPrinter mock;

    fillTheQueue(200, buffer->Capacity());
    buffer->Get();
    buffer->Put(999);

    buffer->Print(&mock);
    const char* expected =
        "Circular buffer content:\n"
        "<201, 202, 203, 204, 999>\n";

    STRCMP_EQUAL(expected, mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintWrappedAndFullOverwriteOldest)
{
    MockPrinter mock;

    fillTheQueue(200, buffer->Capacity());
    buffer->Put(9999);

    buffer->Print(&mock);
    const char* expected =
        "Circular buffer content:\n"
        "<201, 202, 203, 204, 9999>\n";

    STRCMP_EQUAL(expected, mock.getOutput().c_str());
}

TEST(CircularBuffer, PrintBoundary)
{
    MockPrinter mock;

    fillTheQueue(200, buffer->Capacity());
    removeFromQueue(buffer->Capacity() - 2);
    buffer->Put(888);
    fillTheQueue(300, buffer->Capacity() - 1);

    buffer->Print(&mock);
    const char* expected =
        "Circular buffer content:\n"
        "<888, 300, 301, 302, 303>\n";

    STRCMP_EQUAL(expected, mock.getOutput().c_str());
}

TEST(CircularBuffer, FillEmptyThenPrint)
{
    MockPrinter mock;

    fillTheQueue(200, buffer->Capacity());
    removeFromQueue(buffer->Capacity());
    buffer->Print(&mock);
    const char* expected =
        "Circular buffer content:\n"
        "<>\n";

    STRCMP_EQUAL(expected, mock.getOutput().c_str());
}
0707010000BFD5000081A4000003E8000000640000000168A04FE700001887000000080000003000000000000000000000002200000000examples/AllTests/AllTests.vcproj<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
	ProjectType="Visual C++"
	Version="9.00"
	Name="AllTests"
	ProjectGUID="{95A5F8D0-12C0-4AC1-B46B-292DD3886108}"
	TargetFrameworkVersion="0"
	>
	<Platforms>
		<Platform
			Name="Win32"
		/>
	</Platforms>
	<ToolFiles>
	</ToolFiles>
	<Configurations>
		<Configuration
			Name="Release|Win32"
			OutputDirectory="./$(ConfigurationName)/"
			IntermediateDirectory="./$(ConfigurationName)/"
			ConfigurationType="1"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="false"
			CharacterSet="2"
			BuildLogFile="$(IntDir)/BuildLog.htm"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
				TypeLibraryName=".\Debug/AllTests.tlb"
				HeaderFileName=""
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="2"
				AdditionalIncludeDirectories="../../include,../ApplicationLib"
				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
				BasicRuntimeChecks="0"
				RuntimeLibrary="3"
				PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
				AssemblerListingLocation="./$(ConfigurationName)/"
				ObjectFile="./$(ConfigurationName)/"
				ProgramDataBaseFileName="./$(ConfigurationName)/"
				XMLDocumentationFileName="./$(ConfigurationName)/"
				WarningLevel="3"
				SuppressStartupBanner="true"
				DebugInformationFormat="0"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="1033"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalOptions="/NODEFAULTLIB:LIBCMT"
				AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
				OutputFile="./$(ConfigurationName)/AllTests.exe"
				LinkIncremental="2"
				SuppressStartupBanner="true"
				ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
				IgnoreAllDefaultLibraries="false"
				GenerateDebugInformation="false"
				ProgramDatabaseFile=""
				SubSystem="1"
				RandomizedBaseAddress="1"
				DataExecutionPrevention="0"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
				SuppressStartupBanner="true"
				OutputFile=".\$(ConfigurationName)/AllTests.bsc"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
				CommandLine="&quot;$(TargetPath)&quot;"
			/>
		</Configuration>
		<Configuration
			Name="Debug|Win32"
			OutputDirectory=".\Debug"
			IntermediateDirectory=".\Debug"
			ConfigurationType="1"
			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
			UseOfMFC="0"
			ATLMinimizesCRunTimeLibraryUsage="false"
			CharacterSet="2"
			>
			<Tool
				Name="VCPreBuildEventTool"
			/>
			<Tool
				Name="VCCustomBuildTool"
			/>
			<Tool
				Name="VCXMLDataGeneratorTool"
			/>
			<Tool
				Name="VCWebServiceProxyGeneratorTool"
			/>
			<Tool
				Name="VCMIDLTool"
				TypeLibraryName=".\Debug/AllTests.tlb"
				HeaderFileName=""
			/>
			<Tool
				Name="VCCLCompilerTool"
				Optimization="0"
				AdditionalIncludeDirectories="../../include,../ApplicationLib"
				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
				BasicRuntimeChecks="3"
				RuntimeLibrary="3"
				PrecompiledHeaderFile="./$(ConfigurationName)/AllTests.pch"
				AssemblerListingLocation="./$(ConfigurationName)/"
				ObjectFile="./$(ConfigurationName)/"
				ProgramDataBaseFileName="./$(ConfigurationName)/"
				XMLDocumentationFileName="$(ConfigurationName)/"
				WarningLevel="3"
				SuppressStartupBanner="true"
				DebugInformationFormat="4"
			/>
			<Tool
				Name="VCManagedResourceCompilerTool"
			/>
			<Tool
				Name="VCResourceCompilerTool"
				PreprocessorDefinitions="_DEBUG"
				Culture="1033"
			/>
			<Tool
				Name="VCPreLinkEventTool"
			/>
			<Tool
				Name="VCLinkerTool"
				AdditionalDependencies="../../lib/CppUTest.lib ../ApplicationLib/$(ConfigurationName)/ApplicationLib.lib odbc32.lib odbccp32.lib winmm.lib"
				OutputFile="./$(ConfigurationName)/AllTests.exe"
				LinkIncremental="2"
				SuppressStartupBanner="true"
				ManifestFile="./$(ConfigurationName)/$(TargetFileName).intermediate.manifest"
				GenerateDebugInformation="true"
				ProgramDatabaseFile="./$(ConfigurationName)/AllTests.pdb"
				SubSystem="1"
				RandomizedBaseAddress="1"
				DataExecutionPrevention="0"
				TargetMachine="1"
			/>
			<Tool
				Name="VCALinkTool"
			/>
			<Tool
				Name="VCManifestTool"
			/>
			<Tool
				Name="VCXDCMakeTool"
			/>
			<Tool
				Name="VCBscMakeTool"
				SuppressStartupBanner="true"
				OutputFile=".\Debug/AllTests.bsc"
			/>
			<Tool
				Name="VCFxCopTool"
			/>
			<Tool
				Name="VCAppVerifierTool"
			/>
			<Tool
				Name="VCPostBuildEventTool"
				CommandLine="&quot;$(TargetPath)&quot;"
			/>
		</Configuration>
	</Configurations>
	<References>
	</References>
	<Files>
		<Filter
			Name="Source Files"
			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
			>
			<File
				RelativePath=".\AllTests.cpp"
				>
			</File>
			<File
				RelativePath=".\CircularBufferTest.cpp"
				>
			</File>
			<File
				RelativePath=".\EventDispatcherTest.cpp"
				>
			</File>
			<File
				RelativePath=".\HelloTest.cpp"
				>
			</File>
			<File
				RelativePath=".\MockDocumentationTest.cpp"
				>
			</File>
			<File
				RelativePath=".\PrinterTest.cpp"
				>
			</File>
		</Filter>
		<Filter
			Name="Header Files"
			Filter="h;hpp;hxx;hm;inl"
			>
		</Filter>
		<Filter
			Name="Resource Files"
			Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
			>
		</Filter>
	</Files>
	<Globals>
	</Globals>
</VisualStudioProject>
0707010000BFDC000081A4000003E8000000640000000168A04FE7000018FB000000080000003000000000000000000000002C00000000examples/AllTests/MockDocumentationTest.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"
#include "CppUTestExt/MockSupport_c.h"

TEST_GROUP(FirstTestGroup)
{
};

TEST(FirstTestGroup, FirsTest)
{
    //	FAIL("Fail me!");
}

TEST(FirstTestGroup, SecondTest)
{
    //	STRCMP_EQUAL("hello", "world");
}

TEST_GROUP(MockDocumentation)
{
};

static void productionCode()
{
    mock().actualCall("productionCode");
}

TEST(MockDocumentation, SimpleScenario)
{
    mock().expectOneCall("productionCode");
    productionCode();
    mock().checkExpectations();
}

class ClassFromProductionCode
{
public:
    virtual void importantFunction() {}
    virtual ~ClassFromProductionCode() {}
};

class ClassFromProductionCodeMock : public ClassFromProductionCode
{
public:
    virtual void importantFunction() CPPUTEST_OVERRIDE
    {
        mock().actualCall("importantFunction").onObject(this);
    }
};

TEST(MockDocumentation, SimpleScenarioObject)
{
    ClassFromProductionCode* object = new ClassFromProductionCodeMock; /* create mock instead of real thing */

    mock().expectOneCall("importantFunction").onObject(object);
    object->importantFunction();
    mock().checkExpectations();

    delete object;
}

static void parameters_function(int p1, const char* p2)
{
    void* object = (void*)1;
    mock().actualCall("function").onObject(object).withParameter("p1", p1).withParameter("p2", p2);
}

TEST(MockDocumentation, parameters)
{
    void* object = (void*)1;
    mock().expectOneCall("function").onObject(object).withParameter("p1", 2).withParameter("p2", "hah");
    parameters_function(2, "hah");
}

class MyTypeComparator : public MockNamedValueComparator
{
public:
    virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
    {
        return object1 == object2;
    }
    virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
    {
        return StringFrom(object);
    }
};

TEST(MockDocumentation, ObjectParameters)
{
    void* object = (void*)1;
    MyTypeComparator comparator;
    mock().installComparator("myType", comparator);
    mock().expectOneCall("function").withParameterOfType("myType", "parameterName", object);
    mock().clear();
    mock().removeAllComparatorsAndCopiers();
}

TEST(MockDocumentation, returnValue)
{
    mock().expectOneCall("function").andReturnValue(10);
    mock().actualCall("function").returnValue().getIntValue();
    int value = mock().returnValue().getIntValue();
    LONGS_EQUAL(10, value);
}

TEST(MockDocumentation, setData)
{
    ClassFromProductionCode object;
    mock().setData("importantValue", 10);
    mock().setDataObject("importantObject", "ClassFromProductionCode", &object);

    ClassFromProductionCode* pobject;
    int value = mock().getData("importantValue").getIntValue();
    pobject = (ClassFromProductionCode*)mock().getData("importantObject").getObjectPointer();

    LONGS_EQUAL(10, value);
    POINTERS_EQUAL(pobject, &object);
}

static void doSomethingThatWouldOtherwiseBlowUpTheMockingFramework() {}

TEST(MockDocumentation, otherMockSupport)
{
    mock().crashOnFailure();
    //	mock().actualCall("unex");

    mock().expectOneCall("foo");
    mock().ignoreOtherCalls();

    mock().disable();
    doSomethingThatWouldOtherwiseBlowUpTheMockingFramework();
    mock().enable();

    mock().clear();
}

TEST(MockDocumentation, scope)
{
    mock("xmlparser").expectOneCall("open");
    mock("filesystem").ignoreOtherCalls();

    mock("xmlparser").actualCall("open");
}

static int equalMethod(const void* object1, const void* object2)
{
    return object1 == object2;
}

static const char* toStringMethod(const void*)
{
    return "string";
}

TEST(MockDocumentation, CInterface)
{
    void* object = (void*)0x1;

    mock_c()->expectOneCall("foo")->withIntParameters("integer", 10)->andReturnDoubleValue(1.11);
    double d = mock_c()->actualCall("foo")->withIntParameters("integer", 10)->returnValue().value.doubleValue;
    DOUBLES_EQUAL(1.11, d, 0.00001);

    mock_c()->installComparator("type", equalMethod, toStringMethod);
    mock_scope_c("scope")->expectOneCall("bar")->withParameterOfType("type", "name", object);
    mock_scope_c("scope")->actualCall("bar")->withParameterOfType("type", "name", object);
    mock_c()->removeAllComparatorsAndCopiers();

    mock_c()->setIntData("important", 10);
    mock_c()->checkExpectations();
    mock_c()->clear();
}

TEST_GROUP(FooTestGroup)
{
    void setup() CPPUTEST_OVERRIDE
    {
        // Init stuff
    }

    void teardown() CPPUTEST_OVERRIDE
    {
        // Uninit stuff
    }
};

TEST(FooTestGroup, Foo)
{
    // Test FOO
}

TEST(FooTestGroup, MoreFoo)
{
    // Test more FOO
}

TEST_GROUP(BarTestGroup)
{
    void setup() CPPUTEST_OVERRIDE
    {
        // Init Bar
    }
};

TEST(BarTestGroup, Bar)
{
    // Test Bar
}
0707010000BFDB000081A4000003E8000000640000000168A04FE700000905000000080000003000000000000000000000002000000000examples/AllTests/HelloTest.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "hello.h"

#include <stdio.h>
#include <stdarg.h>
#include "CppUTest/TestHarness.h"

static SimpleString* buffer;

TEST_GROUP(HelloWorld)
{
    static int output_method(const char* output, ...)
    {
        va_list arguments;
        va_start(arguments, output);
        *buffer = VStringFromFormat(output, arguments);
        va_end(arguments);
        return 1;
    }
    void setup() CPPUTEST_OVERRIDE
    {
        buffer = new SimpleString();
        UT_PTR_SET(PrintFormated, &output_method);
    }
    void teardown() CPPUTEST_OVERRIDE
    {
        delete buffer;
    }
};

TEST(HelloWorld, PrintOk)
{
    printHelloWorld();
    STRCMP_EQUAL("Hello World!\n", buffer->asCharString());
}
0707010000BFD9000081A4000003E8000000640000000168A04FE70000129A000000080000003000000000000000000000002A00000000examples/AllTests/EventDispatcherTest.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#if CPPUTEST_USE_NEW_MACROS
    #undef realloc
    #undef new
#endif

#include "EventDispatcher.h"

#if CPPUTEST_USE_NEW_MACROS
    #include "CppUTest/MemoryLeakDetectorNewMacros.h"
#endif

#include "CppUTest/TestHarness.h"
#include "CppUTestExt/MockSupport.h"

class ObserverMock : public EventObserver
{
public:
    virtual void notify(const Event& event, int timeOutInSeconds) CPPUTEST_OVERRIDE
    {
        mock()
            .actualCall("notify")
            .onObject(this)
            .withParameterOfType("Event", "event", (void*)&event)
            .withParameter("timeOutInSeconds", timeOutInSeconds);
    }
    virtual void notifyRegistration(EventObserver* newObserver) CPPUTEST_OVERRIDE
    {
        mock().actualCall("notifyRegistration").onObject(this).withParameter("newObserver", newObserver);
    }
};

class EventComparator : public MockNamedValueComparator
{
public:
    virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
    {
        return ((const Event*)object1)->type == ((const Event*)object2)->type;
    }
    virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
    {
        return StringFrom(((const Event*)object)->type);
    }
};

TEST_GROUP(EventDispatcher)
{
    Event event;
    EventDispatcher* dispatcher;
    ObserverMock observer;
    ObserverMock observer2;
    EventComparator eventComparator;

    void setup() CPPUTEST_OVERRIDE
    {
        dispatcher = new EventDispatcher;
        mock().installComparator("Event", eventComparator);
    }
    void teardown() CPPUTEST_OVERRIDE
    {
        delete dispatcher;
        mock().removeAllComparatorsAndCopiers();
    }
};

TEST(EventDispatcher, EventWithoutRegistrationsResultsIntoNoCalls)
{
    dispatcher->dispatchEvent(event, 10);
}

TEST(EventDispatcher, EventWithRegistrationForEventResultsIntoCallback)
{
    mock()
        .expectOneCall("notify")
        .onObject(&observer)
        .withParameterOfType("Event", "event", &event)
        .withParameter("timeOutInSeconds", 10);
    event.type = IMPORTANT_EVENT;

    dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
    dispatcher->dispatchEvent(event, 10);
}

TEST(EventDispatcher, DifferentEventWithRegistrationDoesNotResultIntoCallback)
{
    event.type = LESS_IMPORTANT_EVENT;
    dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
    dispatcher->dispatchEvent(event, 10);
}

TEST(EventDispatcher, RegisterTwoObserversResultIntoTwoCallsAndARegistrationNotification)
{
    mock()
        .expectOneCall("notify")
        .onObject(&observer)
        .withParameterOfType("Event", "event", &event)
        .withParameter("timeOutInSeconds", 10);
    mock()
        .expectOneCall("notify")
        .onObject(&observer2)
        .withParameterOfType("Event", "event", &event)
        .withParameter("timeOutInSeconds", 10);
    mock().expectOneCall("notifyRegistration").onObject(&observer).withParameter("newObserver", &observer2);

    event.type = IMPORTANT_EVENT;
    dispatcher->registerObserver(IMPORTANT_EVENT, &observer);
    dispatcher->registerObserver(IMPORTANT_EVENT, &observer2);
    dispatcher->dispatchEvent(event, 10);
}
0707010000BFD3000081A4000003E8000000640000000168A04FE700000A0A000000080000003000000000000000000000001F00000000examples/AllTests/AllTests.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/TestPlugin.h"
#include "CppUTest/TestRegistry.h"
#include "CppUTestExt/IEEE754ExceptionsPlugin.h"
#include "CppUTestExt/MockSupportPlugin.h"

class MyDummyComparator : public MockNamedValueComparator
{
public:
    virtual bool isEqual(const void* object1, const void* object2) CPPUTEST_OVERRIDE
    {
        return object1 == object2;
    }

    virtual SimpleString valueToString(const void* object) CPPUTEST_OVERRIDE
    {
        return StringFrom(object);
    }
};

int main(int ac, char** av)
{
    MyDummyComparator dummyComparator;
    MockSupportPlugin mockPlugin;
    IEEE754ExceptionsPlugin ieee754Plugin;

    mockPlugin.installComparator("MyDummyType", dummyComparator);
    TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin);
    TestRegistry::getCurrentRegistry()->installPlugin(&ieee754Plugin);
    return CommandLineTestRunner::RunAllTests(ac, av);
}

#include "AllTests.h"
0707010000BFD7000081A4000003E8000000640000000168A04FE7000001EC000000080000003000000000000000000000002100000000examples/AllTests/CMakeLists.txtadd_executable(ExampleTests
    AllTests.cpp
    CircularBufferTest.cpp
    EventDispatcherTest.cpp
    FEDemoTest.cpp
    HelloTest.cpp
    MockDocumentationTest.cpp
    PrinterTest.cpp
)

target_include_directories(ExampleTests
    PRIVATE
        .
)

target_compile_options(ExampleTests
    PRIVATE $<$<BOOL:${MSVC}>:/wd4723>
)

target_link_libraries(ExampleTests
    PRIVATE
        ApplicationLib
        CppUTest::CppUTestExt
)

include(CppUTest)
cpputest_discover_tests(ExampleTests)
0707010000BFD6000081A4000003E8000000640000000168A04FE70000226C000000080000003000000000000000000000002300000000examples/AllTests/AllTests.vcxproj<?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>0707010000BFD4000081A4000003E8000000640000000168A04FE7000006EC000000080000003000000000000000000000001D00000000examples/AllTests/AllTests.h/*
 * 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);
0707010000BFDD000081A4000003E8000000640000000168A04FE700000A6B000000080000003000000000000000000000002000000000examples/AllTests/MockPrinter.h/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef D_MockPrinter_H
#define D_MockPrinter_H

///////////////////////////////////////////////////////////////////////////////
//
//  MockPrinter.h
//
//  MockPrinter is responsible for providing a test stub for Printer
//
///////////////////////////////////////////////////////////////////////////////
#include "Printer.h"
#include "CppUTest/SimpleString.h"
#include <stdlib.h>
#include <string>

class MockPrinter : public Printer
{
public:
    explicit MockPrinter() {}
    virtual ~MockPrinter() CPPUTEST_DESTRUCTOR_OVERRIDE {}

    virtual void Print(const char* s) CPPUTEST_OVERRIDE
    {
        savedOutput.append(s);
    }

    virtual void Print(long int value) CPPUTEST_OVERRIDE
    {
        SimpleString buffer;
        buffer = StringFromFormat("%ld", value);
        savedOutput.append(buffer.asCharString());
    }

    std::string getOutput() const
    {
        return savedOutput;
    }

private:
    std::string savedOutput;

    MockPrinter(const MockPrinter&);
    MockPrinter& operator=(const MockPrinter&);
};

#endif // D_MockPrinter_H
0707010000BFDA000081A4000003E8000000640000000168A04FE700000BB5000000080000003000000000000000000000002100000000examples/AllTests/FEDemoTest.cpp/*
 * Copyright (c) 2016, Michael Feathers, James Grenning, Bas Vodde
 * and Arnd Strube. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CppUTest/CommandLineTestRunner.h"
#include "CppUTest/TestHarness.h"
#include "CppUTest/TestRegistry.h"

#if CPPUTEST_HAVE_FENV
    #include "CppUTestExt/IEEE754ExceptionsPlugin.h"

/*
 * To see a demonstration of tests failing as a result of IEEE754ExceptionsPlugin
 * picking up floating point errors, run the test executable with the -ri option.
 *
 */

extern "C" {
    #include <fenv.h>
}

    #include <limits>

TEST_GROUP(FE_Demo)
{
    void setup() CPPUTEST_OVERRIDE
    {
        IEEE754ExceptionsPlugin::disableInexact();
    }
};

IGNORE_TEST(FE_Demo, should_fail_when_FE_DIVBYZERO_is_set)
{
    float f = 1.0f;
    CHECK((f /= 0.0f) >= std::numeric_limits<float>::infinity());
}

IGNORE_TEST(FE_Demo, should_fail_when_FE_UNDERFLOW_is_set)
{
    volatile float f = 0.01f;
    while (f > 0.0f)
        f = f * f;
    CHECK(f == 0.0f);
}

IGNORE_TEST(FE_Demo, should_fail_when_FE_OVERFLOW_is_set)
{
    volatile float f = 1000.0f;
    while (f < std::numeric_limits<float>::infinity())
        f = f * f;
    CHECK(f >= std::numeric_limits<float>::infinity());
}

IGNORE_TEST(FE_Demo, should_fail_when_FE_INEXACT_is_set)
{
    IEEE754ExceptionsPlugin::enableInexact();
    float f = 10.0f;
    DOUBLES_EQUAL((double)(f / 3.0f), (double)3.333f, (double)0.001f);
}

TEST(FE_Demo, should_succeed_when_no_flags_are_set)
{
    CHECK(5.0f == 15.0f / 3.0f);
}

#endif
0707010000BFDE000081A4000003E8000000640000000168A04FE700000993000000080000003000000000000000000000002200000000examples/AllTests/PrinterTest.cpp/*
 * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "CppUTest/TestHarness.h"
#include "Printer.h"
#include "MockPrinter.h"

TEST_GROUP(Printer)
{
    Printer* printer;
    MockPrinter* mockPrinter;

    void setup() CPPUTEST_OVERRIDE
    {
        mockPrinter = new MockPrinter();
        printer = mockPrinter;
    }
    void teardown() CPPUTEST_OVERRIDE
    {
        delete printer;
    }
};

TEST(Printer, PrintConstCharStar)
{
    printer->Print("hello");
    printer->Print("hello\n");
    const char* expected = "hellohello\n";
    CHECK_EQUAL(expected, mockPrinter->getOutput());
}

TEST(Printer, PrintLong)
{
    printer->Print(1234);
    const char* expected = "1234";
    CHECK_EQUAL(expected, mockPrinter->getOutput());
}

TEST(Printer, StreamOperators)
{
    *printer << "n=" << 1234;
    const char* expected = "n=1234";
    CHECK_EQUAL(expected, mockPrinter->getOutput());
}
07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!
openSUSE Build Service is sponsored by