Skip to content

Commit

Permalink
Merge e5c40e8 into bcabc12
Browse files Browse the repository at this point in the history
  • Loading branch information
arstrube committed Apr 28, 2016
2 parents bcabc12 + e5c40e8 commit b00ca48
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 189 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ CppUTestTests_SOURCES = \
tests/TestRegistryTest.cpp \
tests/TestResultTest.cpp \
tests/TestUTestMacro.cpp \
tests/TestUTestMacro2.cpp \
tests/UtestTest.cpp \
tests/UtestPlatformTest.cpp

Expand Down Expand Up @@ -347,7 +348,7 @@ check_examples:
$(MAKE) -C $(srcdir)/examples all clean

@echo "Compiling and running the examples. This will use the old Makefile"
make distclean; $(srcdir)/configure --disable-longlong; make; $(MAKE) -C $(srcdir)/examples all clean CPPUTEST_LIB_LINK_DIR="`pwd`/lib"
make distclean; $(srcdir)/configure; make; $(MAKE) -C $(srcdir)/examples all clean CPPUTEST_LIB_LINK_DIR="`pwd`/lib"

check_all: check_basic check_special_situations check_coverage remove_coverage_output check_examples check_gtest
@echo "Last... one normal build and test"
Expand Down
13 changes: 11 additions & 2 deletions include/CppUTest/CppUTestConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,21 @@
#endif

/*
* Support for "long long" type
* Support for "long long" type.
*
* Not supported when CPUTEST_LONG_LONG_DISABLED is set.
* Can be overridden by using CPPUTEST_USE_LONG_LONG
*
* CPPUTEST_HAVE_LONG_LONG_INT is set by configure
* LLONG_MAX is set in limits.h. This is a crude attempt to detect long long support when no configure is used
*
*/

#if defined(CPPUTEST_HAVE_LONG_LONG_INT) && !defined(CPPUTEST_LONG_LONG_DISABLED) && !defined(CPPUTEST_USE_LONG_LONG)
#if !defined(CPPUTEST_LONG_LONG_DISABLED) && !defined(CPPUTEST_USE_LONG_LONG)
#if defined(CPPUTEST_HAVE_LONG_LONG_INT) || defined(LLONG_MAX)
#define CPPUTEST_USE_LONG_LONG 1
#endif
#endif

#ifdef CPPUTEST_USE_LONG_LONG
typedef long long cpputest_longlong;
Expand Down
31 changes: 31 additions & 0 deletions include/CppUTest/TestTestingFixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "TestRegistry.h"
#include "TestOutput.h"

#define CHECK_TEST_FAILS_PROPER_WITH_TEXT(text) TestTestingFixture::CHECK_TEST_FAILS_PROPER_WITH_TEXT_LOCATION(text, fixture, __FILE__, __LINE__)

class TestTestingFixture
{
public:
Expand Down Expand Up @@ -121,11 +123,40 @@ class TestTestingFixture
return result_->getRunCount();
}

static void CHECK_TEST_FAILS_PROPER_WITH_TEXT_LOCATION(const char* text, TestTestingFixture& fixture, const char* file, int line)
{
if (fixture.getFailureCount() != 1)
FAIL_LOCATION(StringFromFormat("Expected one test failure, but got %d amount of test failures", fixture.getFailureCount()).asCharString(), file, line); // LCOV_EXCL_LINE

STRCMP_CONTAINS_LOCATION(text, fixture.output_->getOutput().asCharString(), "", file, line);

if (getLineOfCodeExecutedAfterCheck())
FAIL_LOCATION("The test should jump/throw on failure and not execute the next line. However, the next line was executed.", file, line); // LCOV_EXCL_LINE

}

static void setLineOfCodeExecutedAfterCheck(const bool executed)
{
lineOfCodeExecutedAfterCheck(&executed);
}

static bool getLineOfCodeExecutedAfterCheck()
{
return lineOfCodeExecutedAfterCheck();
}

TestRegistry* registry_;
ExecFunctionTestShell* genTest_;
StringBufferTestOutput* output_;
TestResult * result_;

private:
static bool lineOfCodeExecutedAfterCheck(const bool* const value = 0)
{
static bool lineOfCodeExecutedAfterCheck;
if (value) lineOfCodeExecutedAfterCheck = *value;
return lineOfCodeExecutedAfterCheck;
}
};

class SetBooleanOnDestructorCall
Expand Down
1 change: 1 addition & 0 deletions platforms/Dos/sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ CPPU3_OBJECTS := \
$(CPPUTEST_HOME)/tests/TestInstallerTest.o \
$(CPPUTEST_HOME)/tests/TestMemoryAllocatorTest.o \
$(CPPUTEST_HOME)/tests/TestUTestMacro.o \
$(CPPUTEST_HOME)/tests/TestUTestMacro2.o \
$(CPPUTEST_HOME)/tests/UtestPlatformTest.o \
$(CPPUTEST_HOME)/tests/UtestTest.o \

Expand Down
2 changes: 1 addition & 1 deletion tests/AllocLetTestFreeTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "CppUTest/StandardCLibrary.h"
#include "CppUTest/TestHarness.h"

extern "C"
{
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(CppUTestTests_src
TestResultTest.cpp
PreprocessorTest.cpp
TestUTestMacro.cpp
TestUTestMacro2.cpp
AllocationInCppFile.cpp
UtestTest.cpp
SimpleMutexTest.cpp
Expand Down

0 comments on commit b00ca48

Please sign in to comment.