Skip to content

Commit

Permalink
Merge pull request #1518 from cgundogan/remove_tabs_tests
Browse files Browse the repository at this point in the history
converting tabs to spaces in tests (#1439)
  • Loading branch information
OlegHahm committed Jul 31, 2014
2 parents 9f0d8d4 + b8009f1 commit db2cf8d
Show file tree
Hide file tree
Showing 30 changed files with 492 additions and 492 deletions.
94 changes: 47 additions & 47 deletions tests/unittests/embunit/embUnit/AssertImpl.c
Expand Up @@ -38,63 +38,63 @@

void assertImplementationInt(int expected,int actual, long line, const char *file)
{
char buffer[32]; /*"exp -2147483647 was -2147483647"*/
char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/
char buffer[32]; /*"exp -2147483647 was -2147483647"*/
char numbuf[12]; /*32bit int decimal maximum column is 11 (-2147483647~2147483647)*/

stdimpl_strcpy(buffer, "exp ");
stdimpl_strcpy(buffer, "exp ");

{ stdimpl_itoa(expected, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); }
{ stdimpl_itoa(expected, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); }

stdimpl_strcat(buffer, " was ");
stdimpl_strcat(buffer, " was ");

{ stdimpl_itoa(actual, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); }
{ stdimpl_itoa(actual, numbuf, 10);
stdimpl_strncat(buffer, numbuf, 11); }

addFailure(buffer, line, file);
addFailure(buffer, line, file);
}

void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file)
{
char buffer[ASSERT_STRING_BUFFER_MAX];
#define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */
int el;
int al;
char buffer[ASSERT_STRING_BUFFER_MAX];
#define exp_act_limit ((ASSERT_STRING_BUFFER_MAX-11-1)/2)/* "exp'' was''" = 11 byte */
int el;
int al;

if (expected) {
el = stdimpl_strlen(expected);
} else {
el = 4;
expected = "null";
}
if (expected) {
el = stdimpl_strlen(expected);
} else {
el = 4;
expected = "null";
}

if (actual) {
al = stdimpl_strlen(actual);
} else {
al = 4;
actual = "null";
}
if (el > exp_act_limit) {
if (al > exp_act_limit) {
al = exp_act_limit;
el = exp_act_limit;
} else {
int w = exp_act_limit + (exp_act_limit - al);
if (el > w) {
el = w;
}
}
} else {
int w = exp_act_limit + (exp_act_limit - el);
if (al > w) {
al = w;
}
}
stdimpl_strcpy(buffer, "exp \"");
stdimpl_strncat(buffer, expected, el);
stdimpl_strcat(buffer, "\" was \"");
stdimpl_strncat(buffer, actual, al);
stdimpl_strcat(buffer, "\"");
if (actual) {
al = stdimpl_strlen(actual);
} else {
al = 4;
actual = "null";
}
if (el > exp_act_limit) {
if (al > exp_act_limit) {
al = exp_act_limit;
el = exp_act_limit;
} else {
int w = exp_act_limit + (exp_act_limit - al);
if (el > w) {
el = w;
}
}
} else {
int w = exp_act_limit + (exp_act_limit - el);
if (al > w) {
al = w;
}
}
stdimpl_strcpy(buffer, "exp \"");
stdimpl_strncat(buffer, expected, el);
stdimpl_strcat(buffer, "\" was \"");
stdimpl_strncat(buffer, actual, al);
stdimpl_strcat(buffer, "\"");

addFailure(buffer, line, file);
addFailure(buffer, line, file);
}
24 changes: 12 additions & 12 deletions tests/unittests/embunit/embUnit/AssertImpl.h
Expand Up @@ -32,40 +32,40 @@
*
* $Id: AssertImpl.h,v 1.6 2003/09/16 11:09:53 arms22 Exp $
*/
#ifndef __ASSERTIMPL_H__
#define __ASSERTIMPL_H__
#ifndef __ASSERTIMPL_H__
#define __ASSERTIMPL_H__

#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
#endif

void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/
void addFailure(const char *msg, long line, const char *file); /*TestCase.c*/

void assertImplementationInt(int expected,int actual, long line, const char *file);
void assertImplementationCStr(const char *expected,const char *actual, long line, const char *file);

#define TEST_ASSERT_EQUAL_STRING(expected,actual)\
if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;}
if (expected && actual && (stdimpl_strcmp(expected,actual)==0)) {} else {assertImplementationCStr(expected,actual,__LINE__,__FILE__);return;}

#define TEST_ASSERT_EQUAL_INT(expected,actual)\
if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;}
if (expected == actual) {} else {assertImplementationInt(expected,actual,__LINE__,__FILE__);return;}

#define TEST_ASSERT_NULL(pointer)\
TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.")
TEST_ASSERT_MESSAGE(pointer == NULL,#pointer " was not null.")

#define TEST_ASSERT_NOT_NULL(pointer)\
TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.")
TEST_ASSERT_MESSAGE(pointer != NULL,#pointer " was null.")

#define TEST_ASSERT_MESSAGE(condition, message)\
if (condition) {} else {TEST_FAIL(message);}
if (condition) {} else {TEST_FAIL(message);}

#define TEST_ASSERT(condition)\
if (condition) {} else {TEST_FAIL(#condition);}
if (condition) {} else {TEST_FAIL(#condition);}

#define TEST_FAIL(message)\
if (0) {} else {addFailure(message,__LINE__,__FILE__);return;}
if (0) {} else {addFailure(message,__LINE__,__FILE__);return;}

#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

Expand Down
18 changes: 9 additions & 9 deletions tests/unittests/embunit/embUnit/HelperMacro.h
Expand Up @@ -32,28 +32,28 @@
*
* $Id: HelperMacro.h,v 1.3 2004/02/10 16:19:29 arms22 Exp $
*/
#ifndef __HELPERMACRO_H__
#define __HELPERMACRO_H__
#ifndef __HELPERMACRO_H__
#define __HELPERMACRO_H__

#define EMB_UNIT_TESTCASE(ca,sup,tdw,run) \
static const TestCase ca = new_TestCase(#ca,sup,tdw,run)
static const TestCase ca = new_TestCase(#ca,sup,tdw,run)

#define EMB_UNIT_TESTSUITE(su,array) \
static const TestSuite su = new_TestSuite(#su,(Test**)array,sizeof(array)/sizeof(array[0]))
static const TestSuite su = new_TestSuite(#su,(Test**)array,sizeof(array)/sizeof(array[0]))

#define EMB_UNIT_TESTREFS(tests) \
static Test* const tests[] =
static Test* const tests[] =

#define EMB_UNIT_ADD_TESTREF(testref) \
(Test*) testref
(Test*) testref

#define EMB_UNIT_TESTCALLER(caller,sup,tdw,fixtures) \
static const TestCaller caller = new_TestCaller(#caller,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures)
static const TestCaller caller = new_TestCaller(#caller,sup,tdw,sizeof(fixtures)/sizeof(fixtures[0]),(TestFixture*)fixtures)

#define EMB_UNIT_TESTFIXTURES(fixtures) \
static const TestFixture fixtures[] =
static const TestFixture fixtures[] =

#define EMB_UNIT_REPEATEDTEST(repeater,test,tmrp) \
static const RepeatedTest repeater = new_RepeatedTest(test,tmrp)
static const RepeatedTest repeater = new_RepeatedTest(test,tmrp)

#endif/*__HELPERMACRO_H__*/
20 changes: 10 additions & 10 deletions tests/unittests/embunit/embUnit/RepeatedTest.c
Expand Up @@ -37,25 +37,25 @@

char* RepeatedTest_name(RepeatedTest* self)
{
return Test_name(self->test);
return Test_name(self->test);
}

void RepeatedTest_run(RepeatedTest* self,TestResult* result)
{
int i;
Test* test = self->test;
for (i=0; i<self->timesRepeat; i++) {
Test_run(test, result);
}
int i;
Test* test = self->test;
for (i=0; i<self->timesRepeat; i++) {
Test_run(test, result);
}
}

int RepeatedTest_countTestCases(RepeatedTest* self)
{
return Test_countTestCases(self->test) * self->timesRepeat;
return Test_countTestCases(self->test) * self->timesRepeat;
}

const TestImplement RepeatedTestImplement = {
(TestNameFunction) RepeatedTest_name,
(TestRunFunction) RepeatedTest_run,
(TestCountTestCasesFunction)RepeatedTest_countTestCases,
(TestNameFunction) RepeatedTest_name,
(TestRunFunction) RepeatedTest_run,
(TestCountTestCasesFunction)RepeatedTest_countTestCases,
};
26 changes: 13 additions & 13 deletions tests/unittests/embunit/embUnit/RepeatedTest.h
Expand Up @@ -32,25 +32,25 @@
*
* $Id: RepeatedTest.h,v 1.7 2004/02/10 16:19:29 arms22 Exp $
*/
#ifndef __REPEATEDTEST_H__
#define __REPEATEDTEST_H__
#ifndef __REPEATEDTEST_H__
#define __REPEATEDTEST_H__

typedef struct __RepeatedTest RepeatedTest;
typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/
typedef struct __RepeatedTest RepeatedTest;
typedef struct __RepeatedTest* RepeatedTestRef; /*downward compatible*/

struct __RepeatedTest {
TestImplement* isa;
Test* test;
int timesRepeat;
TestImplement* isa;
Test* test;
int timesRepeat;
};

extern const TestImplement RepeatedTestImplement;

#define new_RepeatedTest(test,tmrp)\
{\
(TestImplement*)&RepeatedTestImplement,\
(Test*)test,\
tmrp,\
}
#define new_RepeatedTest(test,tmrp)\
{\
(TestImplement*)&RepeatedTestImplement,\
(Test*)test,\
tmrp,\
}

#endif/*__REPEATEDTEST_H__*/
30 changes: 15 additions & 15 deletions tests/unittests/embunit/embUnit/Test.h
Expand Up @@ -32,34 +32,34 @@
*
* $Id: Test.h,v 1.4 2004/02/10 16:19:29 arms22 Exp $
*/
#ifndef __TEST_H__
#define __TEST_H__
#ifndef __TEST_H__
#define __TEST_H__

typedef struct __TestResult TestResult;
typedef struct __TestResult* TestResultRef;/*downward compatible*/
typedef struct __TestResult TestResult;
typedef struct __TestResult* TestResultRef;/*downward compatible*/

typedef struct __TestImplement TestImplement;
typedef struct __TestImplement* TestImplementRef;/*downward compatible*/
typedef struct __TestImplement TestImplement;
typedef struct __TestImplement* TestImplementRef;/*downward compatible*/

typedef char*(*TestNameFunction)(void*);
typedef void(*TestRunFunction)(void*,TestResult*);
typedef int(*TestCountTestCasesFunction)(void*);

struct __TestImplement {
TestNameFunction name;
TestRunFunction run;
TestCountTestCasesFunction countTestCases;
TestNameFunction name;
TestRunFunction run;
TestCountTestCasesFunction countTestCases;
};

typedef struct __Test Test;
typedef struct __Test* TestRef;/*downward compatible*/
typedef struct __Test Test;
typedef struct __Test* TestRef;/*downward compatible*/

struct __Test {
TestImplement* isa;
TestImplement* isa;
};

#define Test_name(s) ((Test*)s)->isa->name(s)
#define Test_run(s,r) ((Test*)s)->isa->run(s,r)
#define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s)
#define Test_name(s) ((Test*)s)->isa->name(s)
#define Test_run(s,r) ((Test*)s)->isa->run(s,r)
#define Test_countTestCases(s) ((Test*)s)->isa->countTestCases(s)

#endif/*__TEST_H__*/
30 changes: 15 additions & 15 deletions tests/unittests/embunit/embUnit/TestCaller.c
Expand Up @@ -38,30 +38,30 @@

char* TestCaller_name(TestCaller* self)
{
return self->name;
return self->name;
}

void TestCaller_run(TestCaller* self,TestResult* result)
{
TestCase cs = new_TestCase(0,0,0,0);
int i;
cs.setUp= self->setUp;
cs.tearDown = self->tearDown;
for (i=0; i<self->numberOfFixtuers; i++) {
cs.name = self->fixtuers[i].name;
cs.runTest = self->fixtuers[i].test;
/*run test*/
Test_run(&cs,result);
}
TestCase cs = new_TestCase(0,0,0,0);
int i;
cs.setUp= self->setUp;
cs.tearDown = self->tearDown;
for (i=0; i<self->numberOfFixtuers; i++) {
cs.name = self->fixtuers[i].name;
cs.runTest = self->fixtuers[i].test;
/*run test*/
Test_run(&cs,result);
}
}

int TestCaller_countTestCases(TestCaller* self)
{
return self->numberOfFixtuers;
return self->numberOfFixtuers;
}

const TestImplement TestCallerImplement = {
(TestNameFunction) TestCaller_name,
(TestRunFunction) TestCaller_run,
(TestCountTestCasesFunction)TestCaller_countTestCases,
(TestNameFunction) TestCaller_name,
(TestRunFunction) TestCaller_run,
(TestCountTestCasesFunction)TestCaller_countTestCases,
};

0 comments on commit db2cf8d

Please sign in to comment.