You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2013/10/02 11:01:23 UTC
svn commit: r1528380 [2/5] - in /incubator/celix/trunk: ./ cmake/
cmake/cmock/ cmake/cmock/config/ cmake/cmock/lib/ cmake/cmock/src/
cmake/cpputest/ cmake/cpputest/include/ cmake/cpputest/include/CppUTest/
cmake/cpputest/include/CppUTestExt/ cmake/cppu...
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineArguments.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineArguments.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineArguments.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineArguments.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,55 @@
+#ifndef D_CommandLineArguments_H
+#define D_CommandLineArguments_H
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// CommandLineArguments is responsible for ...
+//
+///////////////////////////////////////////////////////////////////////////////
+#include "SimpleString.h"
+#include "TestOutput.h"
+
+class TestPlugin;
+
+class CommandLineArguments
+{
+public:
+ explicit CommandLineArguments(int ac, const char** av);
+ virtual ~CommandLineArguments();
+
+ bool parse(TestPlugin* plugin);
+ bool isVerbose() const;
+ int getRepeatCount() const;
+ SimpleString getGroupFilter() const;
+ SimpleString getNameFilter() const;
+ bool isJUnitOutput() const;
+ bool isEclipseOutput() const;
+ const char* usage() const;
+
+private:
+
+ enum OutputType
+ {
+ OUTPUT_ECLIPSE, OUTPUT_JUNIT
+ };
+ int ac_;
+ const char** av_;
+
+ bool verbose_;
+ int repeat_;
+ SimpleString groupFilter_;
+ SimpleString nameFilter_;
+ OutputType outputType_;
+
+ SimpleString getParameterField(int ac, const char** av, int& i);
+ void SetRepeatCount(int ac, const char** av, int& index);
+ void SetGroupFilter(int ac, const char** av, int& index);
+ void SetNameFilter(int ac, const char** av, int& index);
+ bool SetOutputType(int ac, const char** av, int& index);
+
+ CommandLineArguments(const CommandLineArguments&);
+ CommandLineArguments& operator=(const CommandLineArguments&);
+
+};
+
+#endif // D_CommandLineArguments_H
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineTestRunner.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineTestRunner.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineTestRunner.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/CommandLineTestRunner.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef D_CommandLineTestRunner_H
+#define D_CommandLineTestRunner_H
+
+#include "TestHarness.h"
+#include "TestOutput.h"
+#include "CommandLineArguments.h"
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// Main entry point for running a collection of unit tests
+//
+///////////////////////////////////////////////////////////////////////////////
+
+class JUnitTestOutput;
+
+#define DEF_PLUGIN_MEM_LEAK "MemoryLeakPlugin"
+#define DEF_PLUGIN_SET_POINTER "SetPointerPlugin"
+
+class CommandLineTestRunner
+{
+public:
+ enum OutputType
+ {
+ OUTPUT_NORMAL, OUTPUT_JUNIT
+ };
+
+ static int RunAllTests(int ac, const char** av);
+ static int RunAllTests(int ac, char** av);
+ CommandLineTestRunner(int ac, const char** av, TestOutput*);
+
+ virtual ~CommandLineTestRunner();
+ int runAllTestsMain();
+
+private:
+ TestOutput* output_;
+ JUnitTestOutput* jUnitOutput_;
+ CommandLineArguments* arguments_;
+
+ bool parseArguments(TestPlugin*);
+ int runAllTests();
+ void initializeTestRun();
+ bool isVerbose();
+ int getRepeatCount();
+ SimpleString getGroupFilter();
+ SimpleString getNameFilter();
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/JUnitTestOutput.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/JUnitTestOutput.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/JUnitTestOutput.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/JUnitTestOutput.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef D_JUnitTestOutput_h
+#define D_JUnitTestOutput_h
+
+#include "TestOutput.h"
+#include "SimpleString.h"
+
+struct JUnitTestOutputImpl;
+struct JUnitTestCaseResultNode;
+
+class JUnitTestOutput: public TestOutput
+{
+public:
+ JUnitTestOutput();
+ virtual ~JUnitTestOutput();
+
+ virtual void printTestsStarted();
+ virtual void printTestsEnded(const TestResult& result);
+ virtual void printCurrentTestStarted(const Utest& test);
+ virtual void printCurrentTestEnded(const TestResult& res);
+ virtual void printCurrentGroupStarted(const Utest& test);
+ virtual void printCurrentGroupEnded(const TestResult& res);
+
+ virtual void verbose();
+ virtual void print(const char*);
+ virtual void print(long);
+ virtual void print(const TestFailure& failure);
+ virtual void printTestRun(int number, int total);
+
+ virtual void flush();
+
+protected:
+
+ JUnitTestOutputImpl* impl_;
+ void resetTestGroupResult();
+
+ virtual void openFileForWrite(const SimpleString& fileName);
+ virtual void writeTestGroupToFile();
+ virtual void writeToFile(const SimpleString& buffer);
+ virtual void closeFile();
+
+ virtual void writeXmlHeader();
+ virtual void writeTestSuiteSummery();
+ virtual void writeProperties();
+ virtual void writeTestCases();
+ virtual void writeFailure(JUnitTestCaseResultNode* node);
+ virtual void writeFileEnding();
+
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakAllocator.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakAllocator.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakAllocator.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakAllocator.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,97 @@
+#ifndef D_MemoryLeakAllocator_h
+#define D_MemoryLeakAllocator_h
+
+struct MemoryLeakNode;
+
+class MemoryLeakAllocator
+{
+public:
+ virtual char* alloc_memory(size_t size, const char* file, int line)=0;
+ virtual void free_memory(char* memory, const char* file, int line)=0;
+
+ virtual const char* name()=0;
+ virtual const char* alloc_name()=0;
+ virtual const char* free_name()=0;
+
+ virtual bool isOfEqualType(MemoryLeakAllocator* allocator);
+ virtual ~MemoryLeakAllocator()
+ {
+ }
+
+ virtual bool allocateMemoryLeakNodeSeparately();
+ virtual char* allocMemoryLeakNode(size_t size);
+ virtual void freeMemoryLeakNode(char* memory);
+
+ static void setCurrentNewAllocator(MemoryLeakAllocator* allocator);
+ static MemoryLeakAllocator* getCurrentNewAllocator();
+ static void setCurrentNewAllocatorToDefault();
+
+ static void setCurrentNewArrayAllocator(MemoryLeakAllocator* allocator);
+ static MemoryLeakAllocator* getCurrentNewArrayAllocator();
+ static void setCurrentNewArrayAllocatorToDefault();
+
+ static void setCurrentMallocAllocator(MemoryLeakAllocator* allocator);
+ static MemoryLeakAllocator* getCurrentMallocAllocator();
+ static void setCurrentMallocAllocatorToDefault();
+
+private:
+ static MemoryLeakAllocator* currentNewAllocator;
+ static MemoryLeakAllocator* currentNewArrayAllocator;
+ static MemoryLeakAllocator* currentMallocAllocator;
+};
+
+class StandardMallocAllocator: public MemoryLeakAllocator
+{
+public:
+ virtual char* alloc_memory(size_t size, const char* file, int line);
+ virtual void free_memory(char* memory, const char* file, int line);
+
+ const char* name();
+ const char* alloc_name();
+ const char* free_name();
+
+ virtual bool allocateMemoryLeakNodeSeparately();
+
+ static MemoryLeakAllocator* defaultAllocator();
+};
+
+class StandardNewAllocator: public MemoryLeakAllocator
+{
+public:
+ virtual char* alloc_memory(size_t size, const char* file, int line);
+ virtual void free_memory(char* memory, const char* file, int line);
+
+ const char* name();
+ const char* alloc_name();
+ const char* free_name();
+
+ static MemoryLeakAllocator* defaultAllocator();
+};
+
+class StandardNewArrayAllocator: public MemoryLeakAllocator
+{
+public:
+ virtual char* alloc_memory(size_t size, const char* file, int line);
+ virtual void free_memory(char* memory, const char* file, int line);
+
+ const char* name();
+ const char* alloc_name();
+ const char* free_name();
+
+ static MemoryLeakAllocator* defaultAllocator();
+};
+
+class NullUnknownAllocator: public MemoryLeakAllocator
+{
+public:
+ virtual char* alloc_memory(size_t size, const char* file, int line);
+ virtual void free_memory(char* memory, const char* file, int line);
+
+ const char* name();
+ const char* alloc_name();
+ const char* free_name();
+
+ static MemoryLeakAllocator* defaultAllocator();
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetector.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetector.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetector.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetector.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,199 @@
+#ifndef D_MemoryLeakDetector_h
+#define D_MemoryLeakDetector_h
+
+#define MEM_LEAK_NONE "No memory leaks were detected."
+#define MEM_LEAK_HEADER "Memory leak(s) found.\n"
+#define MEM_LEAK_LEAK "Leak size: %d Allocated at: %s and line: %d. Type: \"%s\" Content: \"%.15s\"\n"
+#define MEM_LEAK_TOO_MUCH "\netc etc etc etc. !!!! Too much memory leaks to report. Bailing out\n"
+#define MEM_LEAK_FOOTER "Total number of leaks: "
+#define MEM_LEAK_ADDITION_MALLOC_WARNING "NOTE:\n" \
+ "\tMemory leak reports about malloc and free can be caused by allocating using the cpputest version of malloc,\n" \
+ "\tbut deallocate using the standard free.\n" \
+ "\tIf this is the case, check whether your malloc/free replacements are working (#define malloc cpputest_malloc etc).\n"
+
+#define MEM_LEAK_NORMAL_FOOTER_SIZE (sizeof(MEM_LEAK_FOOTER) + 10 + sizeof(MEM_LEAK_TOO_MUCH)) /* the number of leaks */
+#define MEM_LEAK_NORMAL_MALLOC_FOOTER_SIZE (MEM_LEAK_NORMAL_FOOTER_SIZE + sizeof(MEM_LEAK_ADDITION_MALLOC_WARNING))
+
+
+#define MEM_LEAK_ALLOC_DEALLOC_MISMATCH "Allocation/deallocation type mismatch\n"
+#define MEM_LEAK_MEMORY_CORRUPTION "Memory corruption (written out of bounds?)\n"
+#define MEM_LEAK_ALLOC_LOCATION " allocated at file: %s line: %d size: %d type: %s\n"
+#define MEM_LEAK_DEALLOC_LOCATION " deallocated at file: %s line: %d type: %s\n"
+#define MEM_LEAK_DEALLOC_NON_ALLOCATED "Deallocating non-allocated memory\n"
+
+enum MemLeakPeriod
+{
+ mem_leak_period_all,
+ mem_leak_period_disabled,
+ mem_leak_period_enabled,
+ mem_leak_period_checking
+};
+
+class MemoryLeakAllocator;
+
+#include <stdlib.h>
+
+class MemoryLeakFailure
+{
+public:
+ virtual ~MemoryLeakFailure()
+ {
+ }
+ ;
+ virtual void fail(char* fail_string)=0;
+};
+
+struct SimpleStringBuffer
+{
+ enum
+ {
+ SIMPLE_STRING_BUFFER_LEN = 4096
+ };
+
+ SimpleStringBuffer();
+ void clear();
+ void add(const char* format, ...);
+ char* toString();
+
+ void setWriteLimit(int write_limit);
+ void resetWriteLimit();
+ bool reachedItsCapacity();
+private:
+ char buffer_[SIMPLE_STRING_BUFFER_LEN];
+ int positions_filled_;
+ int write_limit_;
+};
+
+struct MemoryLeakDetectorNode
+{
+ MemoryLeakDetectorNode() :
+ size_(0), next_(0)
+ {
+ }
+
+ void init(char* memory, size_t size, MemoryLeakAllocator* allocator, MemLeakPeriod period, const char* file, int line);
+
+ size_t size_;
+ char* memory_;
+ const char* file_;
+ int line_;
+ MemoryLeakAllocator* allocator_;
+ MemLeakPeriod period_;
+
+private:
+ friend struct MemoryLeakDetectorList;
+ MemoryLeakDetectorNode* next_;
+};
+
+struct MemoryLeakDetectorList
+{
+ MemoryLeakDetectorList() :
+ head_(0)
+ {}
+
+ void addNewNode(MemoryLeakDetectorNode* node);
+ MemoryLeakDetectorNode* removeNode(char* memory);
+
+ MemoryLeakDetectorNode* getFirstLeak(MemLeakPeriod period);
+ MemoryLeakDetectorNode* getNextLeak(MemoryLeakDetectorNode* node,
+ MemLeakPeriod period);
+ MemoryLeakDetectorNode* getLeakFrom(MemoryLeakDetectorNode* node,
+ MemLeakPeriod period);
+
+ int getTotalLeaks(MemLeakPeriod period);
+ bool hasLeaks(MemLeakPeriod period);
+ void clearAllAccounting(MemLeakPeriod period);
+
+ bool isInPeriod(MemoryLeakDetectorNode* node, MemLeakPeriod period);
+
+private:
+ MemoryLeakDetectorNode* head_;
+};
+
+struct MemoryLeakDetectorTable
+{
+ void clearAllAccounting(MemLeakPeriod period);
+
+ void addNewNode(MemoryLeakDetectorNode* node);
+ MemoryLeakDetectorNode* removeNode(char* memory);
+
+ bool hasLeaks(MemLeakPeriod period);
+ int getTotalLeaks(MemLeakPeriod period);
+
+ MemoryLeakDetectorNode* getFirstLeak(MemLeakPeriod period);
+ MemoryLeakDetectorNode* getNextLeak(MemoryLeakDetectorNode* leak,
+ MemLeakPeriod period);
+
+private:
+ unsigned long hash(char* memory);
+
+ enum
+ {
+ hash_prime = MEMORY_LEAK_HASH_TABLE_SIZE
+ };
+ MemoryLeakDetectorList table_[hash_prime];
+};
+
+class MemoryLeakDetector
+{
+public:
+ MemoryLeakDetector();
+ ~MemoryLeakDetector()
+ {
+ }
+
+ void init(MemoryLeakFailure* reporter);
+
+ void enable();
+ void disable();
+
+ void disableAllocationTypeChecking();
+ void enableAllocationTypeChecking();
+
+ void startChecking();
+ void stopChecking();
+
+ const char* report(MemLeakPeriod period);
+ void markCheckingPeriodLeaksAsNonCheckingPeriod();
+ int totalMemoryLeaks(MemLeakPeriod period);
+ void clearAllAccounting(MemLeakPeriod period);
+
+ char* allocMemory(MemoryLeakAllocator* allocator, size_t size);
+ char* allocMemory(MemoryLeakAllocator* allocator, size_t size,
+ const char* file, int line);
+ void deallocMemory(MemoryLeakAllocator* allocator, void* memory);
+ void deallocMemory(MemoryLeakAllocator* allocator, void* memory, const char* file, int line);
+ char* reallocMemory(MemoryLeakAllocator* allocator, char* memory, size_t size, const char* file, int line);
+
+ void removeMemoryLeakInformationWithoutCheckingOrDeallocating(void* memory);
+ enum
+ {
+ memory_corruption_buffer_size = 3
+ };
+private:
+ MemoryLeakFailure* reporter_;
+ MemLeakPeriod current_period_;
+ SimpleStringBuffer output_buffer_;
+ MemoryLeakDetectorTable memoryTable_;
+ bool doAllocationTypeChecking_;
+
+ bool validMemoryCorruptionInformation(char* memory);
+ bool matchingAllocation(MemoryLeakAllocator *alloc_allocator, MemoryLeakAllocator *free_allocator);
+
+ void storeLeakInformation(MemoryLeakDetectorNode *& node, char *new_memory, size_t size, MemoryLeakAllocator *allocator, const char *file, int line);
+ void ConstructMemoryLeakReport(MemLeakPeriod period);
+ void reportFailure(const char* message, const char* allocFile,
+ int allocLine, size_t allocSize,
+ MemoryLeakAllocator* allocAllocator, const char* freeFile,
+ int freeLine, MemoryLeakAllocator* freeAllocator);
+
+ size_t sizeOfMemoryWithCorruptionInfo(size_t size);
+ MemoryLeakDetectorNode* getNodeFromMemoryPointer(char* memory, size_t size);
+
+ char* reallocateMemoryAndLeakInformation(MemoryLeakAllocator* allocator, char* memory, size_t size, const char* file, int line);
+
+ void addMemoryCorruptionInformation(char* memory);
+ void checkForCorruption(MemoryLeakDetectorNode* node, const char* file, int line, MemoryLeakAllocator* allocator);
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorMallocMacros.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,59 @@
+
+/*
+ * This file can be used to get extra debugging information about memory leaks in your production code.
+ * It defines a preprocessor macro for malloc. This will pass additional information to the
+ * malloc and this will give the line/file information of the memory leaks in your code.
+ *
+ * You can use this by including this file to all your production code. When using gcc, you can use
+ * the -include file to do this for you.
+ *
+ */
+
+/* Warning for maintainers:
+ * This macro code is duplicate from TestHarness.h. The reason for this is to make the two files
+ * completely independent from each other. NewMacros file can be included in production code whereas
+ * TestHarness.h is only included in test code.
+ */
+
+#ifndef CPPUTEST_USE_MEM_LEAK_DETECTION
+#ifdef CPPUTEST_MEM_LEAK_DETECTION_DISABLED
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 0
+#else
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 1
+#endif
+#endif
+
+#if CPPUTEST_USE_MEM_LEAK_DETECTION
+
+/* This prevents the declaration from done twice and makes sure the file only #defines malloc, so it can be included anywhere */
+#ifndef CPPUTEST_USE_MALLOC_MACROS
+
+#include <stdlib.h>
+
+extern void* cpputest_malloc_location(size_t size, const char* file, int line);
+extern void* cpputest_calloc_location(size_t count, size_t size, const char* file, int line);
+extern void* cpputest_ralloc_location(void *, size_t, const char* file, int line);
+extern void cpputest_free_location(void* buffer, const char* file, int line);
+
+#endif
+
+/* NOTE on strdup!
+ *
+ * strdup was implemented earlier, however it is *not* an Standard C function but a POSIX function.
+ * Because of that, it can lead to portability issues by providing more than is available on the local platform.
+ * For that reason, strdup is *not* implemented as a macro. If you still want to use it, an easy implementation would be:
+ *
+ * size_t length = 1 + strlen(str);
+ * char* result = (char*) cpputest_malloc_location(length, file, line);
+ * memcpy(result, str, length);
+ * return result;
+ *
+ */
+
+#define malloc(a) cpputest_malloc_location(a, __FILE__, __LINE__)
+#define calloc(a, b) cpputest_calloc_location(a, b, __FILE__, __LINE__)
+#define realloc(a, b) cpputest_realloc_location(a, b, __FILE__, __LINE__)
+#define free(a) cpputest_free_location(a, __FILE__, __LINE__)
+
+#define CPPUTEST_USE_MALLOC_MACROS 1
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakDetectorNewMacros.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,82 @@
+
+/*
+ * This file can be used to get extra debugging information about memory leaks in your production code.
+ * It defines a preprocessor macro for operator new. This will pass additional information to the
+ * operator new and this will give the line/file information of the memory leaks in your code.
+ *
+ * You can use this by including this file to all your production code. When using gcc, you can use
+ * the -include file to do this for you.
+ *
+ * Warning: Using the new macro can cause a conflict with newly declared operator news. This can be
+ * resolved by:
+ * 1. #undef operator new before including this file
+ * 2. Including the files that override operator new before this file.
+ * This can be done by creating your own NewMacros.h file that includes your operator new overrides
+ * and THEN this file.
+ *
+ * STL (or StdC++ lib) also does overrides for operator new. Therefore, you'd need to include the STL
+ * files *before* this file too.
+ *
+ */
+
+/* Warning for maintainers:
+ * This macro code is duplicate from TestHarness.h. The reason for this is to make the two files
+ * completely independent from each other. NewMacros file can be included in production code whereas
+ * TestHarness.h is only included in test code.
+ */
+
+#include <stdlib.h>
+
+#ifndef CPPUTEST_USE_MEM_LEAK_DETECTION
+#ifdef CPPUTEST_MEM_LEAK_DETECTION_DISABLED
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 0
+#else
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 1
+#endif
+#endif
+
+#if CPPUTEST_USE_MEM_LEAK_DETECTION
+
+#ifndef CPPUTEST_USE_STD_CPP_LIB
+#ifdef CPPUTEST_STD_CPP_LIB_DISABLED
+#define CPPUTEST_USE_STD_CPP_LIB 0
+#else
+#define CPPUTEST_USE_STD_CPP_LIB 1
+#endif
+#endif
+
+/* This #ifndef prevents <new> from being included twice and enables the file to be included anywhere */
+#ifndef CPPUTEST_USE_NEW_MACROS
+
+#if CPPUTEST_USE_STD_CPP_LIB
+ #include <new>
+
+ void* operator new(size_t size, const char* file, int line) throw (std::bad_alloc);
+ void* operator new[](size_t size, const char* file, int line) throw (std::bad_alloc);
+ void* operator new(size_t size) throw(std::bad_alloc);
+ void* operator new[](size_t size) throw(std::bad_alloc);
+
+ #else
+
+ void* operator new(size_t size, const char* file, int line);
+ void* operator new[](size_t size, const char* file, int line);
+ void* operator new(size_t size);
+ void* operator new[](size_t size);
+ #endif
+#endif
+
+
+#define new new(__FILE__, __LINE__)
+
+#ifndef CPPUTEST_USE_NEW_MACROS
+ extern "C" {
+#endif
+ #include "MemoryLeakDetectorMallocMacros.h"
+#ifndef CPPUTEST_USE_NEW_MACROS
+ }
+#endif
+
+
+#define CPPUTEST_USE_NEW_MACROS 1
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/MemoryLeakWarningPlugin.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef D_MemoryLeakWarningPlugin_h
+#define D_MemoryLeakWarningPlugin_h
+
+#include "TestPlugin.h"
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// MemoryLeakWarning.h
+//
+// MemoryLeakWarning defines the inteface to a platform specific
+// memory leak detection class. See Platforms directory for examples
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#define IGNORE_ALL_LEAKS_IN_TEST() MemoryLeakWarningPlugin::getFirstPlugin()->ignoreAllLeaksInTest();
+#define EXPECT_N_LEAKS(n) MemoryLeakWarningPlugin::getFirstPlugin()->expectLeaksInTest(n);
+
+extern "C" { /* include for size_t definition */
+#include "TestHarness_c.h"
+}
+
+#if CPPUTEST_USE_MEM_LEAK_DETECTION
+
+#undef new
+
+#if CPPUTEST_USE_STD_CPP_LIB
+
+#include <new>
+void* operator new(size_t size) throw(std::bad_alloc);
+void* operator new[](size_t size) throw(std::bad_alloc);
+void operator delete(void* mem) throw();
+void operator delete[](void* mem) throw();
+
+#else
+
+void* operator new(size_t size);
+void* operator new[](size_t size);
+void operator delete(void* mem);
+void operator delete[](void* mem);
+
+#endif
+
+#if CPPUTEST_USE_NEW_MACROS
+#include "MemoryLeakDetectorNewMacros.h"
+#endif
+
+#endif
+
+class MemoryLeakDetector;
+
+class MemoryLeakWarningPlugin: public TestPlugin
+{
+public:
+ MemoryLeakWarningPlugin(const SimpleString& name,
+ MemoryLeakDetector* localDetector = 0);
+ virtual ~MemoryLeakWarningPlugin();
+
+ virtual void preTestAction(Utest& test, TestResult& result);
+ virtual void postTestAction(Utest& test, TestResult& result);
+
+ virtual const char* FinalReport(int toBeDeletedLeaks = 0);
+
+ void ignoreAllLeaksInTest();
+ void expectLeaksInTest(int n);
+
+ MemoryLeakDetector* getMemoryLeakDetector();
+ static MemoryLeakWarningPlugin* getFirstPlugin();
+
+ static MemoryLeakDetector* getGlobalDetector();
+private:
+ MemoryLeakDetector* memLeakDetector_;
+ bool ignoreAllWarnings_;
+ int expectedLeaks_;
+ int failureCount_;
+
+ static MemoryLeakWarningPlugin* firstPlugin_;
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/PlatformSpecificFunctions.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/PlatformSpecificFunctions.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/PlatformSpecificFunctions.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/PlatformSpecificFunctions.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PLATFORMSPECIFICFUNCTIONS_H_
+#define PLATFORMSPECIFICFUNCTIONS_H_
+
+/* Platform specific interface we use in order to minimize dependencies with LibC.
+ * This enables porting to different embedded platforms.
+ *
+ */
+
+/* For test execution control (long_jmp set_jmp) */
+
+/* bool Utest::executePlatformSpecificSetup()
+ * void Utest::executePlatformSpecificTestBody()
+ * void Utest::executePlatformSpecificTeardown()
+ * void Utest::executePlatformSpecificRunOneTest(TestPlugin* plugin, TestResult& result)
+ * void Utest::executePlatformSpecificExitCurrentTest()
+ */
+
+/* Time operations */
+long GetPlatformSpecificTimeInMillis();
+void SetPlatformSpecificTimeInMillisMethod(long(*platformSpecific)());
+
+const char* GetPlatformSpecificTimeString();
+void SetPlatformSpecificTimeStringMethod(const char* (*platformMethod)());
+
+/* String operations */
+int PlatformSpecificAtoI(const char*str);
+size_t PlatformSpecificStrLen(const char* str);
+char* PlatformSpecificStrCat(char* s1, const char* s2);
+char* PlatformSpecificStrCpy(char* s1, const char* s2);
+char* PlatformSpecificStrNCpy(char* s1, const char* s2, size_t size);
+int PlatformSpecificStrCmp(const char* s1, const char* s2);
+int PlatformSpecificStrNCmp(const char* s1, const char* s2, size_t size);
+char* PlatformSpecificStrStr(const char* s1, const char* s2);
+int PlatformSpecificVSNprintf(char *str, unsigned int size, const char* format,
+ va_list va_args_list);
+char PlatformSpecificToLower(char c);
+
+/* Misc */
+double PlatformSpecificFabs(double d);
+int PlatformSpecificIsNan(double d);
+int PlatformSpecificAtExit(void(*func)());
+
+/* IO operations */
+typedef void* PlatformSpecificFile;
+
+PlatformSpecificFile PlatformSpecificFOpen(const char* filename,
+ const char* flag);
+void PlatformSpecificFPuts(const char* str, PlatformSpecificFile file);
+void PlatformSpecificFClose(PlatformSpecificFile file);
+
+int PlatformSpecificPutchar(int c);
+void PlatformSpecificFlush();
+
+/* Dynamic Memory operations */
+void* PlatformSpecificMalloc(size_t size);
+void* PlatformSpecificRealloc(void* memory, size_t size);
+void PlatformSpecificFree(void* memory);
+void* PlatformSpecificMemCpy(void* s1, const void* s2, size_t size);
+void* PlatformSpecificMemset(void* mem, int c, size_t size);
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/SimpleString.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/SimpleString.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/SimpleString.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/SimpleString.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// SIMPLESTRING.H
+//
+// One of the design goals of CppUnitLite is to compilation with very old C++
+// compilers. For that reason, the simple string class that provides
+// only the operations needed in CppUnitLite.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef D_SimpleString_h
+#define D_SimpleString_h
+
+#include <stdarg.h>
+#include <stddef.h>
+
+class SimpleStringCollection;
+class MemoryLeakAllocator;
+
+class SimpleString
+{
+ friend bool operator==(const SimpleString& left, const SimpleString& right);
+ friend bool operator!=(const SimpleString& left, const SimpleString& right);
+
+public:
+ SimpleString(const char *value = "");
+ SimpleString(const char *value, size_t repeatCount);
+ SimpleString(const SimpleString& other);
+ ~SimpleString();
+
+ SimpleString& operator=(const SimpleString& other);
+ SimpleString operator+(const SimpleString&);
+ SimpleString& operator+=(const SimpleString&);
+ SimpleString& operator+=(const char*);
+
+ bool contains(const SimpleString& other) const;
+ bool containsNoCase(const SimpleString& other) const;
+ bool startsWith(const SimpleString& other) const;
+ bool endsWith(const SimpleString& other) const;
+ void split(const SimpleString& split,
+ SimpleStringCollection& outCollection) const;
+ bool equalsNoCase(const SimpleString& str) const;
+
+ size_t count(const SimpleString& str) const;
+
+ void replace(char to, char with);
+ void replace(const char* to, const char* with);
+
+ SimpleString toLower() const;
+ SimpleString subString(size_t beginPos, size_t amount) const;
+ void copyToBuffer(char* buffer, size_t bufferSize) const;
+
+ const char *asCharString() const;
+ size_t size() const;
+ bool isEmpty() const;
+
+ static void padStringsToSameLength(SimpleString& str1, SimpleString& str2, char ch);
+
+ static MemoryLeakAllocator* getStringAllocator();
+ static void setStringAllocator(MemoryLeakAllocator* allocator);
+
+ static char* allocStringBuffer(size_t size);
+ static void deallocStringBuffer(char* str);
+private:
+ char *buffer_;
+
+ static MemoryLeakAllocator* stringAllocator_;
+
+ char* getEmptyString() const;
+};
+
+class SimpleStringCollection
+{
+public:
+ SimpleStringCollection();
+ ~SimpleStringCollection();
+
+ void allocate(size_t size);
+
+ size_t size() const;
+ SimpleString& operator[](size_t index);
+
+private:
+ SimpleString* collection_;
+ SimpleString empty_;
+ size_t size_;
+
+ void operator =(SimpleStringCollection&);
+ SimpleStringCollection(SimpleStringCollection&);
+};
+
+SimpleString StringFrom(bool value);
+SimpleString StringFrom(const void* value);
+SimpleString StringFrom(char value);
+SimpleString StringFrom(const char *value);
+SimpleString StringFromOrNull(const char * value);
+SimpleString StringFrom(long value);
+SimpleString StringFrom(int value);
+SimpleString HexStringFrom(long value);
+SimpleString StringFrom(double value, int precision = 6);
+SimpleString StringFrom(const SimpleString& other);
+SimpleString StringFromFormat(const char* format, ...);
+SimpleString VStringFromFormat(const char* format, va_list args);
+
+#if CPPUTEST_USE_STD_CPP_LIB
+
+#undef new
+#include <string>
+#if CPPUTEST_USE_NEW_MACROS
+#include "CppUTest/MemoryLeakDetectorNewMacros.h"
+#endif
+
+#include <stdint.h>
+
+SimpleString StringFrom(const std::string& other);
+SimpleString StringFrom(uint32_t);
+SimpleString StringFrom(uint16_t);
+SimpleString StringFrom(uint8_t);
+
+#endif
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestFailure.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestFailure.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestFailure.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestFailure.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// FAILURE.H
+//
+// Failure is a class which holds information for a specific
+// test failure. It can be overriden for more complex failure messages
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef D_TestFailure_H
+#define D_TestFailure_H
+
+#include "SimpleString.h"
+
+class Utest;
+class TestOutput;
+
+class TestFailure
+{
+
+public:
+ TestFailure(Utest*, const char* fileName, int lineNumber,
+ const SimpleString& theMessage);
+ TestFailure(Utest*, const SimpleString& theMessage);
+ TestFailure(Utest*, const char* fileName, int lineNumber);
+ TestFailure(const TestFailure&);
+ virtual ~TestFailure();
+
+ virtual SimpleString getFileName() const;
+ virtual SimpleString getTestName() const;
+ virtual int getFailureLineNumber() const;
+ virtual SimpleString getMessage() const;
+ virtual SimpleString getTestFileName() const;
+ virtual int getTestLineNumber() const;
+ bool isOutsideTestFile() const;
+ bool isInHelperFunction() const;
+
+
+protected:
+
+ SimpleString createButWasString(const SimpleString& expected, const SimpleString& actual);
+ SimpleString createDifferenceAtPosString(const SimpleString& actual, int position);
+
+ SimpleString testName_;
+ SimpleString fileName_;
+ int lineNumber_;
+ SimpleString testFileName_;
+ int testLineNumber_;
+ SimpleString message_;
+
+ TestFailure& operator=(const TestFailure&);
+
+};
+
+class EqualsFailure: public TestFailure
+{
+public:
+ EqualsFailure(Utest*, const char* fileName, int lineNumber, const char* expected, const char* actual);
+ EqualsFailure(Utest*, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual);
+};
+
+class DoublesEqualFailure: public TestFailure
+{
+public:
+ DoublesEqualFailure(Utest*, const char* fileName, int lineNumber, double expected, double actual, double threshold);
+};
+
+class CheckEqualFailure : public TestFailure
+{
+public:
+ CheckEqualFailure(Utest* test, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual);
+};
+
+class ContainsFailure: public TestFailure
+{
+public:
+ ContainsFailure(Utest*, const char* fileName, int lineNumber, const SimpleString& expected, const SimpleString& actual);
+
+};
+
+class CheckFailure : public TestFailure
+{
+public:
+ CheckFailure(Utest* test, const char* fileName, int lineNumber, const SimpleString& conditionString);
+};
+
+class FailFailure : public TestFailure
+{
+public:
+ FailFailure(Utest* test, const char* fileName, int lineNumber, const SimpleString& message);
+};
+
+class LongsEqualFailure : public TestFailure
+{
+public:
+ LongsEqualFailure(Utest* test, const char* fileName, int lineNumber, long expected, long actual);
+};
+
+class StringEqualFailure : public TestFailure
+{
+public:
+ StringEqualFailure(Utest* test, const char* fileName, int lineNumber, const char* expected, const char* actual);
+};
+
+class StringEqualNoCaseFailure : public TestFailure
+{
+public:
+ StringEqualNoCaseFailure(Utest* test, const char* fileName, int lineNumber, const char* expected, const char* actual);
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,78 @@
+/*
+ * 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_TestHarness_h
+#define D_TestHarness_h
+
+/* Memory leak detector macros:
+ *
+ * CPPUTEST_USE_MEM_LEAK_DETECTION pr CPPUTEST_MEM_LEAK_DETECTION_DISABLED
+ * Controls the override of the global operator new/deleted and malloc/free.
+ * Without this, there will be no memory leak detection in C/C++.
+ */
+#ifndef CPPUTEST_USE_MEM_LEAK_DETECTION
+#ifdef CPPUTEST_MEM_LEAK_DETECTION_DISABLED
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 0
+#else
+#define CPPUTEST_USE_MEM_LEAK_DETECTION 1
+#endif
+#endif
+
+#ifndef CPPUTEST_USE_STD_CPP_LIB
+#ifdef CPPUTEST_STD_CPP_LIB_DISABLED
+#define CPPUTEST_USE_STD_CPP_LIB 0
+#else
+#define CPPUTEST_USE_STD_CPP_LIB 1
+#endif
+#endif
+
+/* original value was 9973 which works well with large programs. Now set to smaller since it takes
+ * a lot of memory in embedded apps. Change it if you experience the memory leak detector to be slow.
+ */
+
+#define MEMORY_LEAK_HASH_TABLE_SIZE 73
+
+/*
+ * Lib C dependencies that are currently still left:
+ *
+ * stdarg.h -> We use formatting functions and va_list requires to include stdarg.h in SimpleString
+ * stdlib.h -> The TestHarness_c.h includes this to try to avoid conflicts in its malloc #define. This dependency can
+ * easily be removed by not enabling the MALLOC overrides.
+ *
+ * Lib C++ dependencies are all under the CPPUTEST_USE_STD_CPP_LIB.
+ * The only dependency is to <new> which has the bad_alloc struct
+ *
+ */
+
+#include "Utest.h"
+#include "UtestMacros.h"
+#include "SimpleString.h"
+#include "TestResult.h"
+#include "TestFailure.h"
+#include "TestPlugin.h"
+#include "MemoryLeakWarningPlugin.h"
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness_c.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness_c.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness_c.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestHarness_c.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+/******************************************************************************
+ *
+ * TESTHARNESS_c.H
+ *
+ * Provides an interface for when working with pure C
+ *
+ * Remember to use extern "C" when including in a cpp file!
+ *
+ *******************************************************************************/
+
+#ifndef D_TestHarness_c_h
+#define D_TestHarness_c_h
+
+#define CHECK_EQUAL_C_INT(expected,actual) \
+ CHECK_EQUAL_C_INT_LOCATION(expected,actual,__FILE__,__LINE__)
+
+#define CHECK_EQUAL_C_REAL(expected,actual,threshold) \
+ CHECK_EQUAL_C_REAL_LOCATION(expected,actual,threshold,__FILE__,__LINE__)
+
+#define CHECK_EQUAL_C_CHAR(expected,actual) \
+ CHECK_EQUAL_C_CHAR_LOCATION(expected,actual,__FILE__,__LINE__)
+
+#define CHECK_EQUAL_C_STRING(expected,actual) \
+ CHECK_EQUAL_C_STRING_LOCATION(expected,actual,__FILE__,__LINE__)
+
+#define FAIL_TEXT_C(text) \
+ FAIL_TEXT_C_LOCATION(text,__FILE__,__LINE__)
+
+#define FAIL_C() \
+ FAIL_C_LOCATION(__FILE__,__LINE__)
+
+#define CHECK_C(condition) \
+ CHECK_C_LOCATION(condition, #condition, __FILE__,__LINE__)
+
+/* CHECKS that can be used from C code */
+extern void CHECK_EQUAL_C_INT_LOCATION(int expected, int actual,
+ const char* fileName, int lineNumber);
+extern void CHECK_EQUAL_C_REAL_LOCATION(double expected, double actual,
+ double threshold, const char* fileName, int lineNumber);
+extern void CHECK_EQUAL_C_CHAR_LOCATION(char expected, char actual,
+ const char* fileName, int lineNumber);
+extern void CHECK_EQUAL_C_STRING_LOCATION(const char* expected,
+ const char* actual, const char* fileName, int lineNumber);
+extern void FAIL_TEXT_C_LOCATION(const char* text, const char* fileName,
+ int lineNumber);
+extern void FAIL_C_LOCATION(const char* fileName, int lineNumber);
+extern void CHECK_C_LOCATION(int condition, const char* conditionString,
+ const char* fileName, int lineNumber);
+
+#include <stddef.h>
+
+extern void* cpputest_malloc(size_t size);
+extern void* cpputest_calloc(size_t num, size_t size);
+extern void* cpputest_realloc(void* ptr, size_t size);
+extern void cpputest_free(void* buffer);
+
+extern void* cpputest_malloc_location(size_t size, const char* file, int line);
+extern void* cpputest_calloc_location(size_t num, size_t size,
+ const char* file, int line);
+extern void* cpputest_realloc_location(void* memory, size_t size,
+ const char* file, int line);
+extern void cpputest_free_location(void* buffer, const char* file, int line);
+
+void cpputest_malloc_set_out_of_memory();
+void cpputest_malloc_set_not_out_of_memory();
+
+/*
+ * Small additional macro for unused arguments. This is common when stubbing, but in C you cannot remove the
+ * name of the parameter (as in C++).
+ */
+
+#ifndef PUNUSED
+#if defined(__GNUC__)
+# define PUNUSED(x) PUNUSED_ ##x __attribute__((unused))
+#else
+# define PUNUSED(x) x
+#endif
+#endif
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestOutput.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestOutput.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestOutput.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestOutput.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,162 @@
+/*
+ * 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_TestOutput_h
+#define D_TestOutput_h
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// TestOutput.h
+//
+// This is a minimal printer inteface.
+// We kept streams out too keep footprint small, and so the test
+// harness could be used with less capable compilers so more
+// platforms could use this test harness
+//
+///////////////////////////////////////////////////////////////////////////////
+
+class Utest;
+class TestFailure;
+class TestResult;
+
+class TestOutput
+{
+public:
+ explicit TestOutput();
+ virtual ~TestOutput();
+
+ virtual void printTestsStarted();
+ virtual void printTestsEnded(const TestResult& result);
+ virtual void printCurrentTestStarted(const Utest& test);
+ virtual void printCurrentTestEnded(const TestResult& res);
+ virtual void printCurrentGroupStarted(const Utest& test);
+ virtual void printCurrentGroupEnded(const TestResult& res);
+
+ virtual void verbose();
+ virtual void print(const char*)=0;
+ virtual void print(long);
+ virtual void printDouble(double);
+ virtual void printHex(long);
+ virtual void print(const TestFailure& failure);
+ virtual void printTestRun(int number, int total);
+ virtual void setProgressIndicator(const char*);
+
+ virtual void flush();
+
+private:
+
+ virtual void printProgressIndicator();
+ void printFileAndLineForTestAndFailure(const TestFailure& failure);
+ void printFileAndLineForFailure(const TestFailure& failure);
+ void printFailureInTest(SimpleString testName);
+ void printFailureMessage(SimpleString reason);
+ void printEclipseErrorInFileOnLine(SimpleString testFile, int lineNumber);
+
+ TestOutput(const TestOutput&);
+ TestOutput& operator=(const TestOutput&);
+
+ int dotCount_;
+ bool verbose_;
+ const char* progressIndication_;
+};
+
+TestOutput& operator<<(TestOutput&, const char*);
+TestOutput& operator<<(TestOutput&, long);
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// ConsoleTestOutput.h
+//
+// Printf Based Solution
+//
+///////////////////////////////////////////////////////////////////////////////
+
+class ConsoleTestOutput: public TestOutput
+{
+public:
+ explicit ConsoleTestOutput()
+ {
+ }
+ ;
+ virtual ~ConsoleTestOutput()
+ {
+ }
+ ;
+
+ virtual void print(const char* s);
+ virtual void flush();
+
+private:
+ ConsoleTestOutput(const ConsoleTestOutput&);
+ ConsoleTestOutput& operator=(const ConsoleTestOutput&);
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// StringBufferTestOutput.h
+//
+// TestOutput for test purposes
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+class StringBufferTestOutput: public TestOutput
+{
+public:
+ explicit StringBufferTestOutput()
+ {
+ }
+ ;
+ virtual ~StringBufferTestOutput()
+ {
+ }
+ ;
+
+ void print(const char* s)
+ {
+ output += s;
+ }
+
+ void flush()
+ {
+ output = "";
+ }
+
+ const SimpleString& getOutput()
+ {
+ return output;
+ }
+
+private:
+ SimpleString output;
+
+ StringBufferTestOutput(const StringBufferTestOutput&);
+ StringBufferTestOutput& operator=(const StringBufferTestOutput&);
+
+};
+
+#endif // D_TestOutput_h
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestPlugin.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestPlugin.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestPlugin.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestPlugin.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// TESTPlugin.H
+//
+// This file contains the ability to plugin_ general checks to all tests.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef D_TestPlugin_h
+#define D_TestPlugin_h
+
+class Utest;
+class TestResult;
+
+class TestPlugin
+{
+public:
+
+ TestPlugin(const SimpleString& name);
+ virtual ~TestPlugin();
+
+ virtual void preTestAction(Utest&, TestResult&)
+ {
+ }
+
+ virtual void postTestAction(Utest&, TestResult&)
+ {
+ }
+
+ virtual bool parseArguments(int /* ac */, const char** /* av */, int /* index */ )
+ {
+ return false;
+ }
+
+ virtual void runAllPreTestAction(Utest&, TestResult&);
+ virtual void runAllPostTestAction(Utest&, TestResult&);
+ virtual bool parseAllArguments(int ac, const char** av, int index);
+ virtual bool parseAllArguments(int ac, char** av, int index);
+
+ virtual TestPlugin* addPlugin(TestPlugin*);
+ virtual TestPlugin* removePluginByName(const SimpleString& name);
+ virtual TestPlugin* getNext();
+
+ virtual void disable();
+ virtual void enable();
+ virtual bool isEnabled();
+
+ const SimpleString& getName();
+ TestPlugin* getPluginByName(const SimpleString& name);
+
+protected:
+ TestPlugin(TestPlugin* next_);
+
+private:
+ TestPlugin* next_;
+ SimpleString name_;
+ bool enabled_;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// SetPointerPlugin
+//
+// This is a very small plugin_ that resets pointers to their original value.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+extern void CppUTestStore(void **location, void *value);
+
+class SetPointerPlugin: public TestPlugin
+{
+public:
+ SetPointerPlugin(const SimpleString& name);
+ virtual ~SetPointerPlugin();
+ virtual void postTestAction(Utest&, TestResult&);
+
+ enum
+ {
+ MAX_SET = 1024
+ };
+};
+
+/* C++ standard says we cannot cast function pointers to object pointers. Extra casting to fool the compiler */
+#define UT_PTR_SET(a, b) { CppUTestStore( (void**)&a, *((void**) &a)); a = b; }
+
+///////////// Null Plugin
+
+class NullTestPlugin: public TestPlugin
+{
+public:
+
+ NullTestPlugin();
+ virtual ~NullTestPlugin()
+ {
+ }
+
+ virtual void runAllPreTestAction(Utest& test, TestResult& result);
+ virtual void runAllPostTestAction(Utest& test, TestResult& result);
+
+ static NullTestPlugin* instance();
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestRegistry.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestRegistry.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestRegistry.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestRegistry.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// TESTREGISTRY.H
+//
+// TestRegistry is a collection of tests that can be run
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef D_TestRegistry_h
+#define D_TestRegistry_h
+
+#include "SimpleString.h"
+
+class Utest;
+class TestResult;
+class TestPlugin;
+
+class TestRegistry
+{
+public:
+ TestRegistry();
+ virtual ~TestRegistry();
+
+ virtual void addTest(Utest *test);
+ virtual void unDoLastAddTest();
+ virtual int countTests();
+ virtual void runAllTests(TestResult& result);
+ virtual void nameFilter(SimpleString);
+ virtual void groupFilter(SimpleString);
+
+ virtual void installPlugin(TestPlugin* plugin);
+ virtual void resetPlugins();
+ virtual TestPlugin* getFirstPlugin();
+ virtual TestPlugin* getPluginByName(const SimpleString& name);
+ virtual void removePluginByName(const SimpleString& name);
+
+ SimpleString getGroupFilter();
+ SimpleString getNameFilter();
+
+ virtual Utest* getFirstTest();
+ virtual Utest* getLastTest();
+ virtual Utest* getTestWithNext(Utest* test);
+
+ static TestRegistry* getCurrentRegistry();
+ virtual void setCurrentRegistry(TestRegistry* registry);
+ void cleanup();
+private:
+
+ bool testShouldRun(Utest* test, TestResult& result);
+ bool endOfGroup(Utest* test);
+
+ Utest * tests_;
+ SimpleString* nameFilter_;
+ SimpleString* groupFilter_;
+ TestPlugin* firstPlugin_;
+ static TestRegistry* currentRegistry_;
+
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestResult.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestResult.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestResult.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestResult.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,114 @@
+/*
+ * 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.
+ */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// TESTRESULT.H
+//
+// A TestResult is a collection of the history of some test runs. Right now
+// it just collects failures. Really it just prints the failures.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef D_TestResult_h
+#define D_TestResult_h
+
+class TestFailure;
+class TestOutput;
+class Utest;
+
+class TestResult
+{
+public:
+ TestResult(TestOutput&);
+ virtual ~TestResult();
+
+ virtual void testsStarted();
+ virtual void testsEnded();
+ virtual void currentGroupStarted(Utest* test);
+ virtual void currentGroupEnded(Utest* test);
+ virtual void currentTestStarted(Utest* test);
+ virtual void currentTestEnded(Utest* test);
+
+ virtual void countTest();
+ virtual void countRun();
+ virtual void countCheck();
+ virtual void countFilteredOut();
+ virtual void countIgnored();
+ virtual void addFailure(const TestFailure& failure);
+ virtual void print(const char* text);
+ virtual void setProgressIndicator(const char*);
+
+ int getTestCount() const
+ {
+ return testCount_;
+ }
+ int getRunCount() const
+ {
+ return runCount_;
+ }
+ int getCheckCount() const
+ {
+ return checkCount_;
+ }
+ int getFilteredOutCount() const
+ {
+ return filteredOutCount_;
+ }
+ int getIgnoredCount() const
+ {
+ return ignoredCount_;
+ }
+ int getFailureCount() const
+ {
+ return failureCount_;
+ }
+
+ long getTotalExecutionTime() const;
+ void setTotalExecutionTime(long exTime);
+
+ long getCurrentTestTotalExecutionTime() const;
+ long getCurrentGroupTotalExecutionTime() const;
+private:
+
+ TestOutput& output_;
+ int testCount_;
+ int runCount_;
+ int checkCount_;
+ int failureCount_;
+ int filteredOutCount_;
+ int ignoredCount_;
+ long totalExecutionTime_;
+ long timeStarted_;
+ long currentTestTimeStarted_;
+ long currentTestTotalExecutionTime_;
+ long currentGroupTimeStarted_;
+ long currentGroupTotalExecutionTime_;
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestTestingFixture.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestTestingFixture.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestTestingFixture.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/TestTestingFixture.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef D_TestTestingFixture_H
+#define D_TestTestingFixture_H
+
+class TestTestingFixture
+{
+public:
+
+ TestTestingFixture()
+ {
+ output_ = new StringBufferTestOutput();
+ result_ = new TestResult(*output_);
+ genTest_ = new ExecFunctionTest();
+ registry_ = new TestRegistry();
+
+ registry_->setCurrentRegistry(registry_);
+ registry_->addTest(genTest_);
+ }
+ ;
+
+ virtual ~TestTestingFixture()
+ {
+ registry_->setCurrentRegistry(0);
+ delete registry_;
+ delete result_;
+ delete output_;
+ delete genTest_;
+ }
+
+ void setTestFunction(void(*testFunction)())
+ {
+ genTest_->testFunction_ = testFunction;
+ }
+
+ void setSetup(void(*setupFunction)())
+ {
+ genTest_->setup_ = setupFunction;
+ }
+
+ void setTeardown(void(*teardownFunction)())
+ {
+ genTest_->teardown_ = teardownFunction;
+ }
+
+ void runAllTests()
+ {
+ registry_->runAllTests(*result_);
+ }
+
+ int getFailureCount()
+ {
+ return result_->getFailureCount();
+ }
+
+ void assertPrintContains(const SimpleString& contains)
+ {
+ assertPrintContains(output_, contains);
+ }
+
+ static void assertPrintContains(StringBufferTestOutput* output,
+ const SimpleString& contains)
+ {
+ if (output->getOutput().contains(contains)) return;
+ SimpleString message("\tActual <");
+ message += output->getOutput().asCharString();
+ message += ">\n";
+ message += "\tdid not contain <";
+ message += contains.asCharString();
+ message += ">\n";
+ FAIL(message.asCharString());
+
+ }
+
+ TestRegistry* registry_;
+ ExecFunctionTest* genTest_;
+ StringBufferTestOutput* output_;
+ TestResult * result_;
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/Utest.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/Utest.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/Utest.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/Utest.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2007, Michael Feathers, James Grenning and Bas Vodde
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the <organization> nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE EARLIER MENTIONED AUTHORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// This file contains the Test class along with the macros which make effective
+// in the harness.
+
+#ifndef D_UTest_h
+#define D_UTest_h
+
+#include "SimpleString.h"
+
+/*! \brief UTest.h
+ * \ingroup someGroup
+ *
+ * Something about UTest.h
+ *
+ * \see TEST_GROUP
+ * \see TEST
+ */
+
+class TestResult;
+class TestPlugin;
+class TestFailure;
+
+extern bool doubles_equal(double d1, double d2, double threshold);
+
+class Utest
+{
+public:
+ Utest(const char* groupName, const char* testName, const char* fileName,
+ int lineNumber);
+ virtual ~Utest();
+
+ virtual void run(TestResult& result);
+ virtual void runOneTestWithPlugins(TestPlugin* plugin, TestResult& result);
+ virtual SimpleString getFormattedName() const;
+
+ virtual Utest* addTest(Utest* test);
+ virtual Utest *getNext() const;
+ virtual bool isNull() const;
+ virtual int countTests();
+
+ bool shouldRun(const SimpleString& groupFilter, const SimpleString& nameFilter) const;
+ const SimpleString getName() const;
+ const SimpleString getGroup() const;
+ const SimpleString getFile() const;
+ int getLineNumber() const;
+ const virtual char *getProgressIndicator() const;
+
+ virtual void setup();
+ virtual void teardown();
+ virtual void testBody();
+
+ static TestResult *getTestResult();
+ static Utest *getCurrent();
+
+ virtual void assertTrue(bool condition, const char *conditionString, const char *fileName, int lineNumber);
+ virtual void assertCstrEqual(const char *expected, const char *actual, const char *fileName, int lineNumber);
+ virtual void assertCstrNoCaseEqual(const char *expected, const char *actual, const char *fileName, int lineNumber);
+ virtual void assertCstrContains(const char *expected, const char *actual, const char *fileName, int lineNumber);
+ virtual void assertCstrNoCaseContains(const char *expected, const char *actual, const char *fileName, int lineNumber);
+ virtual void assertLongsEqual(long expected, long actual, const char *fileName, int lineNumber);
+ virtual void assertPointersEqual(const void *expected, const void *actual, const char *fileName, int lineNumber);
+ virtual void assertDoublesEqual(double expected, double actual, double threshold, const char *fileName, int lineNumber);
+ virtual void fail(const char *text, const char *fileName, int lineNumber);
+
+ virtual void print(const char *text, const char *fileName, int lineNumber);
+ virtual void print(const SimpleString & text, const char *fileName, int lineNumber);
+
+ void setFileName(const char *fileName);
+ void setLineNumber(int lineNumber);
+ void setGroupName(const char *groupName);
+ void setTestName(const char *testName);
+
+ virtual void exitCurrentTest();
+protected:
+ virtual void runOneTest(TestPlugin *plugin, TestResult & result);
+ virtual void executePlatformSpecificRunOneTest(TestPlugin *plugin, TestResult & result);
+ virtual bool executePlatformSpecificSetup();
+ virtual void executePlatformSpecificTestBody();
+ virtual void executePlatformSpecificTeardown();
+ virtual void executePlatformSpecificExitCurrentTest();
+
+ Utest();
+ Utest(const char *groupName, const char *testName, const char *fileName, int lineNumber, Utest *nextTest);
+
+ virtual SimpleString getMacroName() const;
+private:
+ const char *group_;
+ const char *name_;
+ const char *file_;
+ int lineNumber_;
+ Utest *next_;
+
+ void setTestResult(TestResult* result);
+ void setCurrentTest(Utest* test);
+
+ static Utest* currentTest_;
+ static TestResult* testResult_;
+
+ void failWith(const TestFailure& failure);
+};
+
+//////////////////// NulLTest
+
+class NullTest: public Utest
+{
+public:
+ explicit NullTest();
+ explicit NullTest(const char* fileName, int lineNumber);
+ virtual ~NullTest();
+
+ void testBody()
+ {
+ }
+
+ static NullTest& instance();
+
+ virtual int countTests();
+ virtual Utest*getNext() const;
+ virtual bool isNull() const;
+private:
+
+ NullTest(const NullTest&);
+ NullTest& operator=(const NullTest&);
+
+};
+
+//////////////////// ExecFunctionTest
+
+class ExecFunctionTest: public Utest
+{
+public:
+ void (*setup_)();
+ void (*teardown_)();
+ void (*testFunction_)();
+ ExecFunctionTest(void(*set)() = 0, void(*tear)() = 0) :
+ Utest("Generic", "Generic", "Generic", 1), setup_(set), teardown_(
+ tear), testFunction_(0)
+ {
+ }
+ void testBody()
+ {
+ if (testFunction_) testFunction_();
+ }
+ virtual void setup()
+ {
+ if (setup_) setup_();
+ }
+ virtual void teardown()
+ {
+ if (teardown_) teardown_();
+ }
+};
+
+//////////////////// TestInstaller
+
+class TestInstaller
+{
+public:
+ explicit TestInstaller(Utest*, const char* groupName, const char* testName,
+ const char* fileName, int lineNumber);
+ virtual ~TestInstaller();
+
+ void unDo();
+
+private:
+
+ TestInstaller(const TestInstaller&);
+ TestInstaller& operator=(const TestInstaller&);
+
+};
+
+#endif
Added: incubator/celix/trunk/cmake/cpputest/include/CppUTest/UtestMacros.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/cpputest/include/CppUTest/UtestMacros.h?rev=1528380&view=auto
==============================================================================
--- incubator/celix/trunk/cmake/cpputest/include/CppUTest/UtestMacros.h (added)
+++ incubator/celix/trunk/cmake/cpputest/include/CppUTest/UtestMacros.h Wed Oct 2 09:01:20 2013
@@ -0,0 +1,180 @@
+/*
+ * 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_UTestMacros_h
+#define D_UTestMacros_h
+
+/*! \brief Define a group of tests
+ *
+ * All tests in a TEST_GROUP share the same setup
+ * and teardown. setup is run before the opening
+ * curly brace of the test group and teardown is
+ * called after the closing curly brace of the test group.
+ *
+ */
+
+#define TEST_GROUP_BASE(testGroup, baseclass) \
+ int externTestGroup##testGroup = 0; \
+ struct TEST_GROUP_##CppUTestGroup##testGroup : public baseclass
+
+#define TEST_BASE(testBaseClass) \
+ struct testBaseClass : public Utest
+
+#define TEST_GROUP(testGroup) \
+ TEST_GROUP_BASE(testGroup, Utest)
+
+#define TEST_SETUP() \
+ virtual void setup()
+
+#define TEST_TEARDOWN() \
+ virtual void teardown()
+
+#define TEST(testGroup, testName) \
+ class TEST_##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
+{ public: TEST_##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
+ void testBody(); } \
+ TEST_##testGroup##_##testName##_Instance; \
+ TestInstaller TEST_##testGroup##_##testName##_Installer(&TEST_##testGroup##_##testName##_Instance, #testGroup, #testName, __FILE__,__LINE__); \
+ void TEST_##testGroup##_##testName##_Test::testBody()
+
+#define IGNORE_TEST(testGroup, testName)\
+ class IGNORE##testGroup##_##testName##_Test : public TEST_GROUP_##CppUTestGroup##testGroup \
+{ public: IGNORE##testGroup##_##testName##_Test () : TEST_GROUP_##CppUTestGroup##testGroup () {} \
+ virtual void run (TestResult& result_parameter) { \
+ result_parameter.countIgnored(); } \
+ virtual const char* getProgressIndicator() const {return "!";} \
+ protected: virtual SimpleString getMacroName() const \
+ { return "IGNORE_TEST"; } \
+ public: void testBodyThatNeverRuns (); } \
+ TEST_##testGroup##_##testName##_Instance; \
+ TestInstaller TEST_##testGroup##testName##_Installer(&TEST_##testGroup##_##testName##_Instance, #testGroup, #testName, __FILE__,__LINE__); \
+ void IGNORE##testGroup##_##testName##_Test::testBodyThatNeverRuns ()
+
+#define IMPORT_TEST_GROUP(testGroup) \
+ extern int externTestGroup##testGroup;\
+ int* p##testGroup = &externTestGroup##testGroup
+
+//Check any boolean condition
+
+#define CHECK(condition)\
+ CHECK_LOCATION(condition, #condition, __FILE__, __LINE__)
+
+#define CHECK_LOCATION(condition, conditionString, file, line)\
+ { Utest::getCurrent()->assertTrue(condition, conditionString, file, line); }
+
+//This check needs the operator!=(), and a StringFrom(YourType) function
+#define CHECK_EQUAL(expected,actual)\
+ CHECK_EQUAL_LOCATION(expected, actual, __FILE__, __LINE__)
+
+#define CHECK_EQUAL_LOCATION(expected,actual, file, line)\
+ if ((expected) != (actual))\
+ {\
+ { \
+ Utest::getTestResult()->countCheck();\
+ CheckEqualFailure _f(Utest::getCurrent(), file, line, StringFrom(expected), StringFrom(actual)); \
+ Utest::getTestResult()->addFailure(_f);\
+ } \
+ Utest::getCurrent()->exitCurrentTest(); \
+ }\
+ else\
+ Utest::getTestResult()->countCheck();
+
+//This check checks for char* string equality using strcmp.
+//This makes up for the fact that CHECK_EQUAL only compares the pointers to char*'s
+#define STRCMP_EQUAL(expected,actual)\
+ STRCMP_EQUAL_LOCATION(expected, actual, __FILE__, __LINE__)
+
+#define STRCMP_EQUAL_LOCATION(expected,actual, file, line)\
+ { Utest::getCurrent()->assertCstrEqual(expected, actual, file, line); }
+
+#define STRCMP_NOCASE_EQUAL(expected,actual)\
+ STRCMP_NOCASE_EQUAL_LOCATION(expected, actual, __FILE__, __LINE__)
+
+#define STRCMP_NOCASE_EQUAL_LOCATION(expected,actual, file, line)\
+ { Utest::getCurrent()->assertCstrNoCaseEqual(expected, actual, file, line); }
+
+#define STRCMP_CONTAINS(expected,actual)\
+ STRCMP_CONTAINS_LOCATION(expected, actual, __FILE__, __LINE__)
+
+#define STRCMP_CONTAINS_LOCATION(expected,actual, file, line)\
+ { Utest::getCurrent()->assertCstrContains(expected, actual, file, line); }
+
+#define STRCMP_NOCASE_CONTAINS(expected,actual)\
+ STRCMP_NOCASE_CONTAINS_LOCATION(expected, actual, __FILE__, __LINE__)
+
+#define STRCMP_NOCASE_CONTAINS_LOCATION(expected,actual, file, line)\
+ { Utest::getCurrent()->assertCstrNoCaseContains(expected, actual, file, line); }
+
+//Check two long integers for equality
+#define LONGS_EQUAL(expected,actual)\
+ LONGS_EQUAL_LOCATION(expected,actual,__FILE__, __LINE__)
+
+#define LONGS_EQUAL_LOCATION(expected,actual,file,line)\
+ { Utest::getCurrent()->assertLongsEqual(expected, actual, file, line); }
+
+#define BYTES_EQUAL(expected, actual)\
+ LONGS_EQUAL((expected) & 0xff,(actual) & 0xff)
+
+#define POINTERS_EQUAL(expected, actual)\
+ POINTERS_EQUAL_LOCATION((expected),(actual), __FILE__, __LINE__)
+
+#define POINTERS_EQUAL_LOCATION(expected,actual,file,line)\
+ { Utest::getCurrent()->assertPointersEqual(expected, actual, file, line); }
+
+//Check two doubles for equality within a tolerance threshold
+#define DOUBLES_EQUAL(expected,actual,threshold)\
+ DOUBLES_EQUAL_LOCATION(expected,actual,threshold,__FILE__,__LINE__)
+
+#define DOUBLES_EQUAL_LOCATION(expected,actual,threshold,file,line)\
+ { Utest::getCurrent()->assertDoublesEqual(expected, actual, threshold, file, line); }
+
+//Fail if you get to this macro
+//The macro FAIL may already be taken, so allow FAIL_TEST too
+#ifndef FAIL
+#define FAIL(text)\
+ FAIL_LOCATION(text, __FILE__,__LINE__)
+
+#define FAIL_LOCATION(text, file, line)\
+ { Utest::getCurrent()->fail(text, file, line); Utest::getCurrent()->exitCurrentTest(); }
+#endif
+
+#define FAIL_TEST(text)\
+ FAIL_TEST_LOCATION(text, __FILE__,__LINE__)
+
+#define FAIL_TEST_LOCATION(text, file,line)\
+ { Utest::getCurrent()->fail(text, file, line); Utest::getCurrent()->exitCurrentTest(); }
+
+#define UT_PRINT_LOCATION(text, file, line) \
+ { Utest::getCurrent()->print(text, file, line); }
+
+#define UT_PRINT(text) \
+ UT_PRINT_LOCATION(text, __FILE__, __LINE__)
+
+#define UT_CRASH() { UT_PRINT("Going to crash here\n"); Utest* ptr = (Utest*) 0x0; ptr->countTests(); }
+#define RUN_ALL_TESTS(ac, av) CommandLineTestRunner::RunAllTests(ac, av)
+
+#endif /*D_UTestMacros_h*/