Skip to content

Commit

Permalink
Merge fbf00f7 into 1d50e8f
Browse files Browse the repository at this point in the history
  • Loading branch information
arstrube committed Mar 7, 2016
2 parents 1d50e8f + fbf00f7 commit 2b982f3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
10 changes: 10 additions & 0 deletions include/CppUTest/CppUTestConfig.h
Expand Up @@ -189,6 +189,16 @@
#endif
#endif

/* Handling of systems with a different byte-width (e.g. 16 bit).
* Since CHAR_BIT is defined in limits.h (ANSI C), use default of 8 when building without Std C library.
*/
#if CPPUTEST_USE_STD_C_LIB
#include <limits.h>
#define CPPUTEST_CHAR_BIT CHAR_BIT
#else
#define CPPUTEST_CHAR_BIT 8
#endif

/* Visual C++ 10.0+ (2010+) supports the override keyword, but doesn't define the C++ version as C++11 */
#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1600)))
#define CPPUTEST_COMPILER_FULLY_SUPPORTS_CXX11
Expand Down
4 changes: 4 additions & 0 deletions platforms/CCStudio/CppUTestExtRunAllTests1.pjt
Expand Up @@ -54,6 +54,10 @@ Source="..\..\tests\CppUTestExt\MockCheatSheetTest.cpp"
Source="..\..\tests\CppUTestExt\MockExpectedCallTest.cpp"
Source="..\..\tests\CppUTestExt\MockFailureReporterForTest.cpp"
Source="..\..\tests\CppUTestExt\MockFailureTest.cpp"
Source="..\..\tests\CppUTestExt\MockHierarchyTest.cpp"
Source="..\..\tests\CppUTestExt\MockPluginTest.cpp"
Source="..\..\tests\CppUTestExt\MockStrictOrderTest.cpp"
Source="..\..\tests\CppUTestExt\MockSupportTest.cpp"
Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp"
Source="tests\CppUTestExt\AllTestsForTarget.cpp"
Source="sim28335.cmd"
Expand Down
4 changes: 0 additions & 4 deletions platforms/CCStudio/CppUTestExtRunAllTests2.pjt
Expand Up @@ -45,15 +45,11 @@ Source="..\..\src\Platforms\C2000\UtestPlatform.cpp"
Source="..\..\tests\CppUTestExt\MockCallTest.cpp"
Source="..\..\tests\CppUTestExt\MockComparatorCopierTest.cpp"
Source="..\..\tests\CppUTestExt\MockFailureReporterForTest.cpp"
Source="..\..\tests\CppUTestExt\MockHierarchyTest.cpp"
Source="..\..\tests\CppUTestExt\MockNamedValueTest.cpp"
Source="..\..\tests\CppUTestExt\MockParameterTest.cpp"
Source="..\..\tests\CppUTestExt\MockPluginTest.cpp"
Source="..\..\tests\CppUTestExt\MockStrictOrderTest.cpp"
Source="..\..\tests\CppUTestExt\MockReturnValueTest.cpp"
Source="..\..\tests\CppUTestExt\MockSupport_cTest.cpp"
Source="..\..\tests\CppUTestExt\MockSupport_cTestCFile.c"
Source="..\..\tests\CppUTestExt\MockSupportTest.cpp"
Source="..\..\tests\CppUTestExt\OrderedTestTest.cpp"
Source="C:\CCStudio_v3.3\C2000\cgtools\lib\src\farmem_cpp.cpp"
Source="tests\CppUTestExt\AllTestsForTarget.cpp"
Expand Down
2 changes: 1 addition & 1 deletion src/CppUTest/SimpleString.cpp
Expand Up @@ -631,7 +631,7 @@ SimpleString StringFromBinaryWithSizeOrNull(const unsigned char* value, size_t s
SimpleString StringFromMaskedBits(unsigned long value, unsigned long mask, size_t byteCount)
{
SimpleString result;
size_t bitCount = (byteCount > sizeof(unsigned long)) ? (sizeof(unsigned long) * 8) : (byteCount * 8);
size_t bitCount = (byteCount > sizeof(unsigned long)) ? (sizeof(unsigned long) * CPPUTEST_CHAR_BIT) : (byteCount * CPPUTEST_CHAR_BIT);
const unsigned long msbMask = (((unsigned long) 1) << (bitCount - 1));

for (size_t i = 0; i < bitCount; i++) {
Expand Down
24 changes: 16 additions & 8 deletions tests/TestFailureTest.cpp
Expand Up @@ -360,25 +360,33 @@ TEST(TestFailure, BinaryEqualExpectedNull)

TEST(TestFailure, BitsEqualWithText)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, 1, "text");
BitsEqualFailure f(test, failFileName, failLineNumber, 0x0001, 0x0003, 0x00FF, 2*8/CPPUTEST_CHAR_BIT, "text");
FAILURE_EQUAL("Message: text\n"
"\texpected <00000001>\n\tbut was <00000011>", f);
"\texpected <xxxxxxxx 00000001>\n\tbut was <xxxxxxxx 00000011>", f);
}

TEST(TestFailure, BitsEqual1byte)
#if (CPPUTEST_CHAR_BIT == 16)
TEST(TestFailure, BitsEqualChar)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, 1, "");
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), "");
FAILURE_EQUAL("expected <xxxxxxxx 00000001>\n\tbut was <xxxxxxxx 00000011>", f);
}
#else
TEST(TestFailure, BitsEqualChar)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x01, 0x03, 0xFF, sizeof(char), "");
FAILURE_EQUAL("expected <00000001>\n\tbut was <00000011>", f);
}
#endif

TEST(TestFailure, BitsEqual2bytes)
TEST(TestFailure, BitsEqual16Bit)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x0001, 0x0003, 0xFFFF, 2, "");
BitsEqualFailure f(test, failFileName, failLineNumber, 0x0001, 0x0003, 0xFFFF, 2*8/CPPUTEST_CHAR_BIT, "");
FAILURE_EQUAL("expected <00000000 00000001>\n\tbut was <00000000 00000011>", f);
}

TEST(TestFailure, BitsEqual4bytes)
TEST(TestFailure, BitsEqual32Bit)
{
BitsEqualFailure f(test, failFileName, failLineNumber, 0x00000001, 0x00000003, 0xFFFFFFFF, 4, "");
BitsEqualFailure f(test, failFileName, failLineNumber, 0x00000001, 0x00000003, 0xFFFFFFFF, 4*8/CPPUTEST_CHAR_BIT, "");
FAILURE_EQUAL("expected <00000000 00000000 00000000 00000001>\n\tbut was <00000000 00000000 00000000 00000011>", f);
}

0 comments on commit 2b982f3

Please sign in to comment.