mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-19 05:18:01 +08:00
Merge pull request #29 from bjones1/master
C89 patch for MS Visual Studio 2008 Express Edition
This commit is contained in:
@ -49,8 +49,8 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)());
|
|||||||
void TEST_##group##_##name##_run()
|
void TEST_##group##_##name##_run()
|
||||||
|
|
||||||
#define RUN_TEST_CASE(group, name) \
|
#define RUN_TEST_CASE(group, name) \
|
||||||
DECLARE_TEST_CASE(group, name);\
|
{ DECLARE_TEST_CASE(group, name);\
|
||||||
TEST_##group##_##name##_run();
|
TEST_##group##_##name##_run(); }
|
||||||
|
|
||||||
//This goes at the bottom of each test file or in a separate c file
|
//This goes at the bottom of each test file or in a separate c file
|
||||||
#define TEST_GROUP_RUNNER(group)\
|
#define TEST_GROUP_RUNNER(group)\
|
||||||
@ -63,8 +63,8 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)());
|
|||||||
|
|
||||||
//Call this from main
|
//Call this from main
|
||||||
#define RUN_TEST_GROUP(group)\
|
#define RUN_TEST_GROUP(group)\
|
||||||
void TEST_##group##_GROUP_RUNNER();\
|
{ void TEST_##group##_GROUP_RUNNER();\
|
||||||
TEST_##group##_GROUP_RUNNER();
|
TEST_##group##_GROUP_RUNNER(); }
|
||||||
|
|
||||||
//CppUTest Compatibility Macros
|
//CppUTest Compatibility Macros
|
||||||
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&ptr, (void*)newPointerValue)
|
#define UT_PTR_SET(ptr, newPointerValue) UnityPointer_Set((void**)&ptr, (void*)newPointerValue)
|
||||||
|
@ -49,10 +49,12 @@ TEST(UnityFixture, PointerSetting)
|
|||||||
|
|
||||||
TEST(UnityFixture, ForceMallocFail)
|
TEST(UnityFixture, ForceMallocFail)
|
||||||
{
|
{
|
||||||
|
void* m;
|
||||||
|
void* mfails;
|
||||||
UnityMalloc_MakeMallocFailAfterCount(1);
|
UnityMalloc_MakeMallocFailAfterCount(1);
|
||||||
void* m = malloc(10);
|
m = malloc(10);
|
||||||
CHECK(m);
|
CHECK(m);
|
||||||
void* mfails = malloc(10);
|
mfails = malloc(10);
|
||||||
TEST_ASSERT_POINTERS_EQUAL(0, mfails);
|
TEST_ASSERT_POINTERS_EQUAL(0, mfails);
|
||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
@ -76,8 +78,9 @@ TEST(UnityFixture, ReallocSameIsUnchanged)
|
|||||||
TEST(UnityFixture, ReallocLargerNeeded)
|
TEST(UnityFixture, ReallocLargerNeeded)
|
||||||
{
|
{
|
||||||
void* m1 = malloc(10);
|
void* m1 = malloc(10);
|
||||||
|
void* m2;
|
||||||
strcpy((char*)m1, "123456789");
|
strcpy((char*)m1, "123456789");
|
||||||
void* m2 = realloc(m1, 15);
|
m2 = realloc(m1, 15);
|
||||||
CHECK(m1 != m2);
|
CHECK(m1 != m2);
|
||||||
STRCMP_EQUAL("123456789", m2);
|
STRCMP_EQUAL("123456789", m2);
|
||||||
free(m2);
|
free(m2);
|
||||||
|
Reference in New Issue
Block a user