aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-01-23 11:57:22 +0000
committerbloodstalker <thabogre@gmail.com>2017-01-23 11:57:22 +0000
commitbbe45e2ebb912752a6bd64438973eca73a8406d2 (patch)
tree04ddef62e2ed7e9fb654f4056b33a68a4d0fe51f
parentadded an option to run automatic refactorings (diff)
downloadmutator-bbe45e2ebb912752a6bd64438973eca73a8406d2.tar.gz
mutator-bbe45e2ebb912752a6bd64438973eca73a8406d2.zip
added tdd tests for automatic refactoring
-rw-r--r--test/auto-refac-tdd/auto-refac-tdd01.c49
-rw-r--r--test/auto-refac-tdd/auto-refac-tdd01.h17
-rw-r--r--test/auto-refac-tdd/mut.c0
-rw-r--r--test/testFuncs1.c715
-rw-r--r--test/testFuncs2.c201
-rw-r--r--test/testFuncs3.c58
6 files changed, 457 insertions, 583 deletions
diff --git a/test/auto-refac-tdd/auto-refac-tdd01.c b/test/auto-refac-tdd/auto-refac-tdd01.c
new file mode 100644
index 0000000..40e60d1
--- /dev/null
+++ b/test/auto-refac-tdd/auto-refac-tdd01.c
@@ -0,0 +1,49 @@
+
+/*first line's intentionally left blank.*/
+/**********************************************************************************************************************/
+/*inclusion directives*/
+#include "auto-refac-tdd01.h"
+/**********************************************************************************************************************/
+/**************************************************MACROS & DEFS*******************************************************/
+#define MACRO1 100U
+
+/**********************************************************************************************************************/
+/******************************************************Globals*********************************************************/
+
+
+/**********************************************************************************************************************/
+/***********************************************Function Definitions***************************************************/
+void tdd_forfixer(void)
+{
+ int loopcounter;
+ int counter;
+
+ for (loopcounter = 0; loopcounter < 10; ++loopcounter)
+ counter;
+
+ for (loopcounter = 0; loopcounter < 10; ++loopcounter)
+ counter-- ;
+}
+
+void tdd_ifconstswapper(void)
+{
+ int a;
+
+ if (a = 10)
+ {
+ /*blah blah*/
+ }
+
+ if (a == MACRO1)
+ {
+
+ }
+
+ if (MACRO1 == a)
+ {
+
+ }
+}
+/**********************************************************************************************************************/
+/**********************************************************************************************************************/
+/*last line's intntionally left blank.*/
diff --git a/test/auto-refac-tdd/auto-refac-tdd01.h b/test/auto-refac-tdd/auto-refac-tdd01.h
new file mode 100644
index 0000000..7acdb65
--- /dev/null
+++ b/test/auto-refac-tdd/auto-refac-tdd01.h
@@ -0,0 +1,17 @@
+
+/*first line's been intentionally left blank.*/
+#ifndef AUTO_REFAC_TDD_01_H
+#define AUTO_REFAC_TDD_01_H
+/*********************************************************************************************************************/
+/**************************************************MACROS & DEFS*******************************************************/
+
+/*********************************************************************************************************************/
+/***************************************************Globals***********************************************************/
+
+/*********************************************************************************************************************/
+/********************************************Function Declarations****************************************************/
+
+
+/*********************************************************************************************************************/
+#endif
+/*last line's intentionally lefg blank.*/
diff --git a/test/auto-refac-tdd/mut.c b/test/auto-refac-tdd/mut.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/auto-refac-tdd/mut.c
diff --git a/test/testFuncs1.c b/test/testFuncs1.c
index fc1c25d..e0d35f1 100644
--- a/test/testFuncs1.c
+++ b/test/testFuncs1.c
@@ -7,7 +7,8 @@
#if 0
#include <string.h>
#endif
-/**************************************************MACROS & DEFS*******************************************************/
+/**************************************************MACROS &
+ * DEFS*******************************************************/
/**********************************************************************************************************************/
#define LUPO 1U
#define LOCO 2U
@@ -25,18 +26,16 @@ const unsigned int shift = 10U;
/******************************************************Globals*********************************************************/
/**********************************************************************************************************************/
-void test (void);
-void test2 (void);
-void test11 (void);
+void test(void);
+void test2(void);
+void test11(void);
double badboy = 0.0;
-
/**********************************************************************************************************************/
/*testing for simple statement coverage*/
-void testFuncStatementsinmple (void)
-{
+void testFuncStatementsinmple(void) {
int int1 = 1U;
int int2 = 2U;
int int3 = 3U;
@@ -50,102 +49,84 @@ void testFuncStatementsinmple (void)
}
/*testing for complex statement coverage*/
-void testFuncStatementComplexIf (void)
-{
+void testFuncStatementComplexIf(void) {
int int1 = 1U;
int int2 = 2U;
int int3 = 3U;
int int4 = 4U;
- if ( int4 > int3 )
- if ( int3 > int2 )
- if ( int2 > int1 )
- if ( int2 > int1 )
+ if (int4 > int3)
+ if (int3 > int2)
+ if (int2 > int1)
+ if (int2 > int1)
im_a_minion_02();
}
/*testing to see whether the tool recognizes not covering statements*/
-void testFuncStatementNotCoverage (void)
-{
+void testFuncStatementNotCoverage(void) {
int int1 = 1U;
int int2 = 2U;
int int3 = 3U;
int int4 = 4U;
- if (int4 < int3)
- {
+ if (int4 < int3) {
int4 = int3;
}
/*do note that your compiler might optimize this by completely erasing this*/
- if (int2 > int1)
- {
- if (int1 > int2)
- {
+ if (int2 > int1) {
+ if (int1 > int2) {
im_a_minion_01();
}
}
- if (int2 > int1)
- {
- if (int3 < int2)
- {
+ if (int2 > int1) {
+ if (int3 < int2) {
im_a_minion_02();
}
}
-
}
/*verifying for loops*/
-void testFuncLoopFor (void)
-{
+void testFuncLoopFor(void) {
int i = 1U;
- for (i = 1; i < 10; i++)
- {
+ for (i = 1; i < 10; i++) {
im_a_minion_01();
}
i = 1U;
- for (i = 1; i < 10; i++)
- {
- if (1U == (i % 2U) )
- {
+ for (i = 1; i < 10; i++) {
+ if (1U == (i % 2U)) {
im_a_minion_01();
}
}
}
/*verifying while loops*/
-void testFuncLoopWhile (void)
-{
+void testFuncLoopWhile(void) {
int i = 20U;
- while (i > 10U)
- {
+ while (i > 10U) {
i = i - 1U;
}
i = 20;
#if (TRUE == INF_LOOP)
- while (20U == i)
- {
+ while (20U == i) {
im_a_minion_03();
}
#endif
}
/*verifying the correct handling of continue*/
-void testFuncContinue (void)
-{
+void testFuncContinue(void) {
int i = 1U;
- for (i = 1U; i < 20U; i++)
- {
- if (i < 19U)
- {
+ for (i = 1U; i < 20U; i++) {
+ if (i < 19U) {
continue;
}
im_a_minion_01();
@@ -153,14 +134,11 @@ void testFuncContinue (void)
}
/*verifying the correct handling of break*/
-void testFuncBreak (void)
-{
+void testFuncBreak(void) {
int i = 1U;
- for (i = 1U; i < 10U ; i++)
- {
- if (i > 0U)
- {
+ for (i = 1U; i < 10U; i++) {
+ if (i > 0U) {
break;
}
im_a_minion_03();
@@ -168,8 +146,7 @@ void testFuncBreak (void)
}
/*checking whether goto is handled correctly*/
-void testFuncGoto (void)
-{
+void testFuncGoto(void) {
im_a_minion_01();
goto jumpy;
im_a_minion_02();
@@ -177,19 +154,16 @@ jumpy:
im_a_minion_03();
}
-/*checking whether the basic blocks do not complete execution due to return statements*/
-int testFuncNotReturn (int a, int b)
-{
+/*checking whether the basic blocks do not complete execution due to return
+ * statements*/
+int testFuncNotReturn(int a, int b) {
int sum = 0U;
sum = a + b;
- if (10U == sum)
- {
+ if (10U == sum) {
return (sum);
- }
- else
- {
+ } else {
im_a_dummy();
}
@@ -199,67 +173,66 @@ int testFuncNotReturn (int a, int b)
}
/*checking whether the tool handles multi-line statements correctly*/
-void testFuncMultiLineStatement (void)
-{
- im_a_minion_01();
-}
+void testFuncMultiLineStatement(void) { im_a_minion_01(); }
/*checking how the tool handles multiple statements on the same line*/
-void testFuncMultipleStatement (void)
-{
+void testFuncMultipleStatement(void) {
int a = 1U;
int b = 2U;
int c = 3U;
int d = 4U;
- a = a + b; b = b + c; c = c + d; d = d + a;
+ a = a + b;
+ b = b + c;
+ c = c + d;
+ d = d + a;
}
/*checking whether multiple statements are handled correctly on the same line*/
-void testFuncMultipleStatementNot (void)
-{
+void testFuncMultipleStatementNot(void) {
int a = 10U;
- if (a < 10U) {im_a_minion_01();} else {im_a_minion_02();}
+ if (a < 10U) {
+ im_a_minion_01();
+ } else {
+ im_a_minion_02();
+ }
testFuncMultipleStatementNot();
}
-/*checking how compiler optimizations may affect the coverage reported-killed assignment elimination*/
-void testFuncCompOpti1 (void)
-{
+/*checking how compiler optimizations may affect the coverage reported-killed
+ * assignment elimination*/
+void testFuncCompOpti1(void) {
int a = 1U;
int b = 2U;
}
-/*checking how compiler optimizations may affect the coverage reported-common subexpression optimization*/
-void testFuncCompOpti2 (void)
-{
+/*checking how compiler optimizations may affect the coverage reported-common
+ * subexpression optimization*/
+void testFuncCompOpti2(void) {
int a = 1U;
int b = 1U;
- if ( 0U == (((a * b) + (a / b) - a) - b) )
- {
+ if (0U == (((a * b) + (a / b) - a) - b)) {
im_a_benign_func();
}
- if ( 0U == (((a * b) + (a / b) - a) - b) )
- {
+ if (0U == (((a * b) + (a / b) - a) - b)) {
im_a_mlaign_func();
}
}
-/*checking how compiler optimizations may affect the coverage reported-loop invariant optimization*/
-void testFuncCompOpti3 (void)
-{
+/*checking how compiler optimizations may affect the coverage reported-loop
+ * invariant optimization*/
+void testFuncCompOpti3(void) {
int i = 1U;
int counter = 0U;
int a = 0U;
int b = 10U;
int sum = 0U;
- for (i = 1U; i < 100U ; i++)
- {
+ for (i = 1U; i < 100U; i++) {
counter = counter + 1U;
sum = a + b;
}
@@ -267,99 +240,91 @@ void testFuncCompOpti3 (void)
sum = sum * 2U;
}
-/*checking how compiler optimizations may affect the coverage reported-dead code optimization*/
-void testFuncCompOpti4 (void)
-{
+/*checking how compiler optimizations may affect the coverage reported-dead code
+ * optimization*/
+void testFuncCompOpti4(void) {
im_a_minion_01();
im_a_minion_02();
im_a_minion_03();
}
-/*testing if declarative statements that have a run-time footprint are covered by statement coverage.*/
-void testFuncStatementDecl1 (void)
-{
+/*testing if declarative statements that have a run-time footprint are covered
+ * by statement coverage.*/
+void testFuncStatementDecl1(void) {
int declaration1 = 1001U;
int declaration2 = 666U;
}
-
/*testing to see whether statement coverage covers the return.*/
-int testFuncStatementInt1 (int int1, int int2)
-{
+int testFuncStatementInt1(int int1, int int2) {
int sum = 0U;
sum = int1 + int2;
return (sum);
}
-
/* to test this one we need two test cases:*/
/* bool1 = FALSE and bool2 = whatever*/
/* bool1 = TRUE and bool2 = whatever*/
-/* obviously if you get a full coverage with just the first test case, your tool didnt understand*/
-/* the short-circuit. if you need both test cases for a full coverage, then your tool is doing decision coverage,*/
+/* obviously if you get a full coverage with just the first test case, your tool
+ * didnt understand*/
+/* the short-circuit. if you need both test cases for a full coverage, then your
+ * tool is doing decision coverage,*/
/* not branch coverage so good for you!*/
-blreplacement testFuncStatementbool1 (blreplacement bool1 , blreplacement bool2)
-{
+blreplacement testFuncStatementbool1(blreplacement bool1, blreplacement bool2) {
return (bool1 && bool2);
}
-
/*same as above but with these test cases*/
/*bool1 = TRUE and bool2 = whatever*/
/*bool1 = FALSE and bool2 = whatever*/
-/* obviously if you get a full coverage with just the first test case, your tool didnt understand*/
-/* the short-circuit. if you need both test cases for a full coverage, then your tool is doing decision coverage,*/
+/* obviously if you get a full coverage with just the first test case, your tool
+ * didnt understand*/
+/* the short-circuit. if you need both test cases for a full coverage, then your
+ * tool is doing decision coverage,*/
/* not branch coverage so good for you!*/
-blreplacement testFuncStatementbool2 (blreplacement bool1, blreplacement bool2)
-{
+blreplacement testFuncStatementbool2(blreplacement bool1, blreplacement bool2) {
return (bool1 || bool2);
}
-
-/*the fault will only be generated only if decision1 is FALSE. if we get a full coverage by running*/
-/* d1 = d2 = FALSE and d1 = FALSE and d2 = TRUE, then we dont have decision coverage. for a decision*/
-/* coverage we need to have an extra test case, wehre d1 = TRUE and d2 = whatever.*/
-void testFuncStatementDecision1 (blreplacement decision1 , blreplacement decision2)
-{
- if ( decision1 || decision2 )
- {
+/*the fault will only be generated only if decision1 is FALSE. if we get a full
+ * coverage by running*/
+/* d1 = d2 = FALSE and d1 = FALSE and d2 = TRUE, then we dont have decision
+ * coverage. for a decision*/
+/* coverage we need to have an extra test case, wehre d1 = TRUE and d2 =
+ * whatever.*/
+void testFuncStatementDecision1(blreplacement decision1,
+ blreplacement decision2) {
+ if (decision1 || decision2) {
/*this function will supposedly casue a bug if decision1 is true*/
im_a_mlaign_func();
- }
- else
- {
+ } else {
im_a_benign_func();
}
}
-
/* short-circuit!*/
-/* the compiler could go for short-cuircuit for both conditions.if it does, then we can see if we still get*/
-/* a full coverage. if the compiler doesnt go for a short-circuit, then all this dont apply.*/
-void testFuncShortCircuit (blreplacement bool1, blreplacement bool2)
-{
- if (FALSE == bool1 && TRUE == bool2)
- {
- im_a_dummy ();
+/* the compiler could go for short-cuircuit for both conditions.if it does, then
+ * we can see if we still get*/
+/* a full coverage. if the compiler doesnt go for a short-circuit, then all this
+ * dont apply.*/
+void testFuncShortCircuit(blreplacement bool1, blreplacement bool2) {
+ if (FALSE == bool1 && TRUE == bool2) {
+ im_a_dummy();
}
- if (TRUE == bool2 || FALSE == bool1)
- {
+ if (TRUE == bool2 || FALSE == bool1) {
im_a_dummy();
}
}
-
/*checking MCDC coverage behavior of the tool for multiply occuring conditions*/
-void testFuncMCDC1 (blreplacement decision1, blreplacement decision2)
-{
- if (decision1 && (( decision2 || decision1) || (!decision1 || decision2)) )
- {
+void testFuncMCDC1(blreplacement decision1, blreplacement decision2) {
+ if (decision1 && ((decision2 || decision1) || (!decision1 || decision2))) {
im_a_dummy();
}
}
-
-/* this one is to test how the tool handles inline functions.do all instances get covered separately or they get*/
+/* this one is to test how the tool handles inline functions.do all instances
+ * get covered separately or they get*/
/* covered accumulatively*/
#if 0
void testFuncMultiInstantiation (int level)
@@ -401,84 +366,56 @@ void testFuncMultiInstantiation (int level)
#endif
/* this function will check how the tool handles the "?" operator*/
-void testFuncQMark (int int1, int int2)
-{
+void testFuncQMark(int int1, int int2) {
(int1 > int2) ? im_a_minion_01() : im_a_minion_02();
}
-
/* checking how the tool handles calling a function that returns boolean*/
-void testFuncCallBool (void)
-{
+void testFuncCallBool(void) {
int local1 = 0U;
int local2 = 0U;
- local1 = testFuncStatementbool1(1U , 0U);
- local2 = testFuncStatementbool2(1U , 0U);
+ local1 = testFuncStatementbool1(1U, 0U);
+ local2 = testFuncStatementbool2(1U, 0U);
}
-
/**********************************************************************************************************************/
/* where all the fakes go.*/
-
/*the function that is *supposedly* carrying a bug*/
-static void im_a_mlaign_func (void)
-{
- /* KATSU!*/
+static void im_a_mlaign_func(void) { /* KATSU!*/
}
-
/*the function that is *supposedly* the good guy here*/
-static void im_a_benign_func (void)
-{
- /* see the light ring?!*/
+static void im_a_benign_func(void) { /* see the light ring?!*/
}
-
/*the dummy function.*/
-void im_a_dummy (void)
-{
- /* dumb dumb*/
+void im_a_dummy(void) { /* dumb dumb*/
}
-
/* minion function number #01*/
-void im_a_minion_01 (void)
-{
- /* minion1*/
+void im_a_minion_01(void) { /* minion1*/
}
-
/* minion function number #02*/
-void im_a_minion_02 (void)
-{
- /* minion1*/
+void im_a_minion_02(void) { /* minion1*/
}
-
/* minion function number #03*/
-static void im_a_minion_03 (void)
-{
- /* minion1*/
+static void im_a_minion_03(void) { /* minion1*/
}
-
/* the only thing special about this one is that it has been inlined.*/
-/*since different compilers have different methods of inlining a function, this function has multiple versions.*/
+/*since different compilers have different methods of inlining a function, this
+ * function has multiple versions.*/
#if (TRUE == INLINE)
#if (MPC == COMPILER)
-inline void babeFunk (int entry)
-{
- if (10U > entry)
- {
+inline void babeFunk(int entry) {
+ if (10U > entry) {
im_a_minion_01();
- }
- else if (10U == entry)
- {
+ } else if (10U == entry) {
im_a_minion_02();
- }
- else
- {
+ } else {
im_a_minion_03();
}
}
@@ -486,53 +423,44 @@ inline void babeFunk (int entry)
#if (HCS12 == COMPILER)
#pragma INLINE
-void babeFunk (int entry)
-{
- if (10U > entry)
- {
+void babeFunk(int entry) {
+ if (10U > entry) {
im_a_minion_01();
- }
- else if (10U == entry)
- {
+ } else if (10U == entry) {
im_a_minion_02();
- }
- else
- {
+ } else {
im_a_minion_03();
}
}
#endif
#endif
-/*RL78s dont have inline for all functions, so no use trying to test the functionality*/
+/*RL78s dont have inline for all functions, so no use trying to test the
+ * functionality*/
-void test (void)
-{
+void test(void) {
int i = 0U;
int j = 0U;
int a, b;
int c, d;
- for (;;)
- {
+ for (;;) {
a = b;
}
for (i = 1; i < 100U; i++)
- b++ ;
+ b++;
while (a > 10U)
- im_a_minion_01() ;
+ im_a_minion_01();
- while (a == 90U)
- {
+ while (a == 90U) {
b++;
}
if (a == d)
b = c;
- if (a == d)
- {
+ if (a == d) {
a = d;
}
@@ -546,42 +474,32 @@ void test (void)
c++;
else if (a > d)
d++;
-
-
}
-void test2 (void)
-{
+void test2(void) {
int a = 0U;
int b = 10U;
int c, d;
- if (a == b)
- {
+ if (a == b) {
/*do something*/
- }
- else
+ } else
b = a;
- if (20U == a)
- {
+ if (20U == a) {
/*kill all mutants.*/
}
- if (20U == a)
- {
+ if (20U == a) {
/*do somethin good*/
a = b;
- }
- else if (30U == a)
- {
+ } else if (30U == a) {
/*do something else*/
b = a;
}
- if (10U == a)
- {/*die*/}
- else if (15U == a)
+ if (10U == a) { /*die*/
+ } else if (15U == a)
a = b;
else if (17U == a)
a = 10000000U;
@@ -589,79 +507,74 @@ void test2 (void)
a = 50U;
if (b == a) {
- if (10U == b)
- {}
- else
- {}
+ if (10U == b) {
+ } else {
+ }
}
-
-
if (a > b) {
- if (a > d)
- {}
- else
+ if (a > d) {
+ } else
a++;
}
- if (a > b)
- {a++;}
- else if (b > a)
- {b++;}
- else if (a == b)
- {a++;}
+ if (a > b) {
+ a++;
+ } else if (b > a) {
+ b++;
+ } else if (a == b) {
+ a++;
+ }
int level = 10U;
- switch (level)
- {
- case 10U:
- { level++;
+ switch (level) {
+ case 10U: {
+ level++;
test();
break;
}
- case 20U:
- { level = 10000U;
+ case 20U: {
+ level = 10000U;
break;
}
- case 30U:
- { level++;
+ case 30U: {
+ level++;
break;
}
- case 40U:
- { level++;
+ case 40U: {
+ level++;
break;
}
- case 50U:
- { level++;
+ case 50U: {
+ level++;
break;
}
- case 60U:
- { level = 1000U;
+ case 60U: {
+ level = 1000U;
break;
}
- case 70U:
- { level++;
+ case 70U: {
+ level++;
break;
}
- case 80U:
- { level++;
+ case 80U: {
+ level++;
break;
}
- case 90U:
- { level++;
+ case 90U: {
+ level++;
break;
}
- default:
- { level++;
+ default: {
+ level++;
break;
}
}
- switch (level)
- {
- case 1:
- { level++;
+ switch (level) {
+ case 1: {
+ level++;
break;
}
case 2:
@@ -675,8 +588,7 @@ void test2 (void)
}
}
- switch (level)
- {
+ switch (level) {
case 1:
level++;
case 2:
@@ -687,10 +599,7 @@ void test2 (void)
level++;
}
- switch (level)
- {}
-
-
+ switch (level) {}
}
#if 0
@@ -700,41 +609,32 @@ void test3 (int a, int, ...)
}
#endif
-test3()
-{
+test3() {
int a;
int b;
}
-double test4 (int a, int b, double c)
-{
- return a + b + c;
-}
+double test4(int a, int b, double c) { return a + b + c; }
-void test5(void)
-{
+void test5(void) {
int i = 0;
- if (test4)
- {
+ if (test4) {
i++;
}
}
-void test6 (void)
-{
+void test6(void) {
int a[100];
int *p = a;
int i = 0;
- for (i = 0; i < 100; ++i)
- {
+ for (i = 0; i < 100; ++i) {
a[i] = i;
}
}
-void test7(void)
-{
+void test7(void) {
double a[100];
double b[100];
@@ -743,9 +643,9 @@ void test7(void)
double *pointer;
- double* pointerb;
+ double *pointerb;
- char* pointerc;
+ char *pointerc;
pointerb = b;
@@ -753,51 +653,43 @@ void test7(void)
pointerc = c;
- if (a - b >= a)
- {}
- else if (b - a < a)
- {}
+ if (a - b >= a) {
+ } else if (b - a < a) {
+ }
- if (a < b)
- {}
+ if (a < b) {
+ }
- if (pointer < pointerb)
- {}
+ if (pointer < pointerb) {
+ }
- if (pointer > pointerb)
- {}
+ if (pointer > pointerb) {
+ }
- if (pointerb <= pointer)
- {}
+ if (pointerb <= pointer) {
+ }
- if (pointer >= pointerb)
- {}
+ if (pointer >= pointerb) {
+ }
- if (pointer < pointerc)
- {}
+ if (pointer < pointerc) {
+ }
int i = 0;
- for (i = 0; i < 50; i++)
- {
+ for (i = 0; i < 50; i++) {
*(a + i) = i;
}
-
}
-void test8 (void)
-{
- union uni uni2;
-}
+void test8(void) { union uni uni2; }
-void test9 (void)
-{
+void test9(void) {
/*im a comment*/
- //im also a comment
+ // im also a comment
}
-void test10 (void)
-{
+void test10(void) {
struct {
unsigned int r1 : 1;
unsigned int r2 : 2;
@@ -817,26 +709,19 @@ void test10 (void)
} reg3;
}
-void test11 (void)
-{
- /*empty*/
+void test11(void) { /*empty*/
}
-double test12(double a)
-{
- return a * 2;
-}
+double test12(double a) { return a * 2; }
-int test13(void)
-{
+int test13(void) {
static int a;
int b;
return (a * b);
}
-void test14 (void)
-{
+void test14(void) {
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
int arr2[4][4] = {0};
@@ -851,21 +736,19 @@ void test14 (void)
#endif
}
-void test15(void)
-{
- enum colour {red = 3, blue, yellow, green = 5};
+void test15(void) {
+ enum colour { red = 3, blue, yellow, green = 5 };
- enum anotherset {black, grey, white};
+ enum anotherset { black, grey, white };
- enum yetanotherset {pink = 7, purple, magenta, maroon};
+ enum yetanotherset { pink = 7, purple, magenta, maroon };
- enum loco {verrueckt, crazy = 3, divune};
+ enum loco { verrueckt, crazy = 3, divune };
- enum primeevil {diablo = 2, mephisto = 3, baal = 4};
+ enum primeevil { diablo = 2, mephisto = 3, baal = 4 };
}
-short int test16(int a, int b)
-{
+short int test16(int a, int b) {
short int sum;
short unsigned int sumus;
sum = a + b;
@@ -874,41 +757,33 @@ short int test16(int a, int b)
return sum;
}
-void test17(void)
-{
+void test17(void) {
int a = 100;
int b = 1000;
long int longa;
- a = sizeof (b = 2000U);
+ a = sizeof(b = 2000U);
}
-void test18(void)
-{
+void test18(void) {
int a;
int b;
int c;
unsigned char d;
- if (c && (a = b))
- {
+ if (c && (a = b)) {
/*yada /*yada*/
}
- if ((c = a) || a)
- {
+ if ((c = a) || a) {
/*yada*/
}
- if (c && (a || c))
- {
-
+ if (c && (a || c)) {
}
d = c && (a = c);
-
}
-void test19(void)
-{
+void test19(void) {
const int a = 100;
unsigned char flag = 1;
@@ -917,29 +792,27 @@ void test19(void)
unsigned char flag3;
- //char *str = "loco\0";
+ // char *str = "loco\0";
const double pi = 3.54;
- if ((flag) && pi)
- {}
-
- if (flag || flag2 && flag3)
- {}
+ if ((flag) && pi) {
+ }
- if (a == 0 && flag)
- {}
+ if (flag || flag2 && flag3) {
+ }
- if (flag || (a == 0))
- {}
+ if (a == 0 && flag) {
+ }
- if (!flag || flag2)
- {}
+ if (flag || (a == 0)) {
+ }
+ if (!flag || flag2) {
+ }
}
-void test20(void)
-{
+void test20(void) {
signed int a;
unsigned int b;
signed char c;
@@ -956,8 +829,7 @@ void test20(void)
f = f << 4U;
}
-void test21(void)
-{
+void test21(void) {
unsigned int a;
a = a >> 44U;
a = a >> shift;
@@ -965,8 +837,7 @@ void test21(void)
a << 45U;
}
-void test22(void)
-{
+void test22(void) {
unsigned int a;
int b;
t_int c;
@@ -977,15 +848,13 @@ void test22(void)
b = -d;
}
-void test23 (void)
-{
+void test23(void) {
int a, b, c;
a = b, c = a;
}
-void test24(void)
-{
+void test24(void) {
int a;
int b;
int c;
@@ -996,117 +865,100 @@ void test24(void)
--a;
}
-void test25(void)
-{
+void test25(void) {
int a;
int b;
int c;
- if (a - b)
- {
+ if (a - b) {
/*i dont care.*/
}
}
-void test26 (void)
-{
+void test26(void) {
double a;
double b;
double c;
unsigned char d;
- if (a == b)
- {}
+ if (a == b) {
+ }
- if (a < b)
- {}
+ if (a < b) {
+ }
- if (c >= a)
- {}
+ if (c >= a) {
+ }
d = (a <= c);
}
-void test27(void)
-{
+void test27(void) {
double a;
- for (a = 0.0; a < 10.0; ++a)
- {}
+ for (a = 0.0; a < 10.0; ++a) {
+ }
}
-void test28(void)
-{
+void test28(void) {
int i;
int j;
int k;
int flag = 0;
int counter = 0;
- for (i = 0; i < 10; i++)
- {
+ for (i = 0; i < 10; i++) {
i = i + 3;
}
- for (j = 0; j < 20; ++j)
- {
+ for (j = 0; j < 20; ++j) {
j++;
}
- for (k = 0; k < 10; ++k)
- {
+ for (k = 0; k < 10; ++k) {
k = i + j;
--j;
i = j - k;
}
- for (i = 0; flag == 1; i++)
- {
- if (i > 10)
- {
+ for (i = 0; flag == 1; i++) {
+ if (i > 10) {
flag = 1;
}
}
- for (i = 0; flag == 1, counter++; i++)
- {
- if (i > 10)
- {
+ for (i = 0; flag == 1, counter++; i++) {
+ if (i > 10) {
flag = 1;
}
}
- for (k = 0, i = 0; i < 10, k < 10; ++i, k++)
- {
+ for (k = 0, i = 0; i < 10, k < 10; ++i, k++) {
k = i + j;
--j;
i = j - k;
}
- for (i = 0, k = 0; i < 10, k < 10; ++i, k++)
- {
+ for (i = 0, k = 0; i < 10, k < 10; ++i, k++) {
k = i + j;
--j;
i = j - k;
}
}
-int test29(int a)
-{
+int test29(int a) {
goto loco;
loco:
return a;
}
-void test30(void)
-{
+void test30(void) {
int a;
int b;
int c;
- for (a = 0; a < 10; ++a)
- {
+ for (a = 0; a < 10; ++a) {
a++;
if (a == 5)
@@ -1115,15 +967,13 @@ void test30(void)
break;
}
- for (a = 0; a < 10; a++)
- {
+ for (a = 0; a < 10; a++) {
a++;
if (a == 6)
break;
}
- while (a < 10)
- {
+ while (a < 10) {
if (b == 1)
break;
if (c == 1)
@@ -1139,29 +989,24 @@ void test30(void)
break;
} while (a < 10);
- for (a = 0; a < 100; a++)
- {
- for (b = 0; b < 100; b++)
- {
+ for (a = 0; a < 100; a++) {
+ for (b = 0; b < 100; b++) {
c++;
if (a == 1)
break;
}
- for (c = 0; c < 100; c++)
- {
+ for (c = 0; c < 100; c++) {
b++;
if (a == 10)
break;
}
}
- for (a = 0; a < 100; a++)
- {
+ for (a = 0; a < 100; a++) {
if (a == 1)
break;
- while (a < 10)
- {
+ while (a < 10) {
b++;
if (c == 10)
break;
@@ -1169,8 +1014,7 @@ void test30(void)
}
}
-int test31(void)
-{
+int test31(void) {
int a;
if (a == 1)
@@ -1181,12 +1025,10 @@ int test31(void)
return 1;
}
-void test32(void)
-{
+void test32(void) {
int a;
- switch (a == 1)
- {
+ switch (a == 1) {
case 1:
a++;
case 0:
@@ -1194,29 +1036,27 @@ void test32(void)
}
}
-void test33(void)
-{
+void test33(void) {
short int a;
long int b;
b = (int)a;
}
-void test34(void)
-{
+void test34(void) {
int i, a;
i >= 3;
- for (;; i++)
- {
+ for (;; i++) {
a++;
}
; /*yadayada*/
- ;/*:P*/
+ ; /*:P*/
- ; int b;
+ ;
+ int b;
int ut_int = 0;
@@ -1230,6 +1070,5 @@ void malloc (void)
}
#endif
-
/**********************************************************************************************************************/
/*the last line's been intentionally left blank.*/
diff --git a/test/testFuncs2.c b/test/testFuncs2.c
index f6dadb6..f8c9bd2 100644
--- a/test/testFuncs2.c
+++ b/test/testFuncs2.c
@@ -4,15 +4,15 @@
/*inclusion directives*/
#include "testFuncs2.h"
#if 0
-#include <stdlib.h>
-#include <stdio.h>
-#include <stddef.h>
#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <time.h>
#endif
/*********************************************************************************************************************/
/*macro and definitions*/
-typedef const* INTPTR;
+typedef const *INTPTR;
/*clang wont let it through*/
#if 0
typedef int dummytypedef;
@@ -29,12 +29,12 @@ typedef gaga incompletearr1;
#define ABSOLUTE(X) (((X) >= 0) ? (X) : -(X))
#define ABSOLUTE2(X) ((X >= 0) ? X : -X)
#define ABSOLUTE3(XMACRO) (((XMACRO) <= 0) ? (XMACRO) : -(XMACRO))
-#define MINUS(X,Y) ((X) - (Y))
+#define MINUS(X, Y) ((X) - (Y))
#define PRINT(bubba) printf(#bubba "%d\n", bubba)
#define LOCO i##nt
#define LOCO2 #LOCO2
#define LOCO3(bubba) printf(#bubba "%d\n", bu##bba)
-#define DEFINEVAR(X,Y) int X##Y
+#define DEFINEVAR(X, Y) int X##Y
#define PI 3.14
#define PI2 (a)
#define charchar char
@@ -72,7 +72,6 @@ typedef gaga incompletearr1;
#if defined LOCOLUPO || LOCO
#endif
-
#define LOCOLUPO
#if 1
#undef LOCOLUPO
@@ -112,14 +111,12 @@ int incompletearr1[10];
union u3;
union u4;
-union u3
-{
+union u3 {
int ua;
char ub;
};
-union yizzy
-{
+union yizzy {
int ua;
char ub;
};
@@ -134,8 +131,7 @@ int s10;
struct s10;
struct s11;
-struct s10
-{
+struct s10 {
int sa[10];
char sb;
int sc;
@@ -145,8 +141,7 @@ const unsigned int cint = 0xFFFFFFFF;
/*********************************************************************************************************************/
/*functions go here.*/
-static void test33(void)
-{
+static void test33(void) {
short int a;
long int b;
@@ -157,21 +152,19 @@ static void test33(void)
sum = dudu + bubu + fufu;
MINUS(a, b);
- //MINUS(a);
+ // MINUS(a);
b = (int)a;
/* contrast the above START + LEN with the following */
- if ((START + LEN) > END)
- {
- //error ("Buffer overrun");
+ if ((START + LEN) > END) {
+ // error ("Buffer overrun");
/* Not OK: START + LEN wraps around to 0x0000
due to unsigned int arithmetic */
}
}
-void testfunc1(void)
-{
+void testfunc1(void) {
unsigned char a;
unsigned char b;
char c;
@@ -180,7 +173,7 @@ void testfunc1(void)
sum = sum + dudu + fufu;
- b = a;
+ b = a;
c = 123;
d = 123;
c = 'c';
@@ -190,8 +183,11 @@ void testfunc1(void)
a = 123;
c = '\n';
- ;;;;
- ;/*comment*/
+ ;
+ ;
+ ;
+ ;
+ ; /*comment*/
; /*comment*/
c = '5';
@@ -200,8 +196,7 @@ void testfunc1(void)
#if CRAZYMACRO < 0
#endif
-testfunc2(void)
-{
+testfunc2(void) {
int a;
int b;
int sum;
@@ -209,8 +204,7 @@ testfunc2(void)
sum = a + b + dudu;
}
-void testfunc3()
-{
+void testfunc3() {
int a;
int b;
int c;
@@ -225,26 +219,23 @@ void testfunc3()
/*do stuff*/
}
-int testfunc6(void)
-{
+int testfunc6(void) {
int a;
int b;
- //return ();
+ // return ();
}
-int testfunc7(void)
-{
+int testfunc7(void) {
int a;
int b;
- //return;
+ // return;
}
-int testfunc8(void)
-{
+int testfunc8(void) {
int a[10];
int b[10];
- int* p;
+ int *p;
p = &a[0];
@@ -256,82 +247,74 @@ int testfunc8(void)
int garbage;
int garbage2;
- for (i = 0; i < 10; ++i)
- {
+ for (i = 0; i < 10; ++i) {
sum += *(a + i);
sum2 += *(p + i);
- //garbage = *(a - b);
+ // garbage = *(a - b);
}
- for (i = 10; i < 1; i++)
- {
+ for (i = 10; i < 1; i++) {
sum += *(a - i);
sum2 += *(p - i);
- //garbage2 = *(p - a);
+ // garbage2 = *(p - a);
}
}
-void testfunc9(void)
-{
- int** p1;
- int*** p2;
+void testfunc9(void) {
+ int **p1;
+ int ***p2;
- int* pointer1;
+ int *pointer1;
double d2;
pointer1 = &d2;
- struct
- {
- int* sp1;
- int** sp2;
- int*** sp3;
+ struct {
+ int *sp1;
+ int **sp2;
+ int ***sp3;
};
- struct s* ps1;
- /*these two should not be tagged by 18.1 since they are pointers(to pointers) to an incomplete type. the pointer itself is a complete type.*/
- struct s** ps2;
- struct s*** ps3;
+ struct s *ps1;
+ /*these two should not be tagged by 18.1 since they are pointers(to pointers)
+ * to an incomplete type. the pointer itself is a complete type.*/
+ struct s **ps2;
+ struct s ***ps3;
- INTPTR *const* const fedupp1;
+ INTPTR *const *const fedupp1;
- int ** (*pfunc1)();
+ int **(*pfunc1)();
int crazycast1 = (int)pfunc1;
int crazycast2;
- pfunc1 = (int ** (*)())crazycast2;
- int ** (**pfunc2)();
+ pfunc1 = (int **(*)())crazycast2;
+ int **(**pfunc2)();
pfunc2 = pfunc1;
- pfunc2 = (int ** (*)())pfunc1;
- int ** (***pfunc3)();
- int *** (**pfunc4)();
- int ** (**pfunc5)(int**, int**);
- int ** (**pfunc6)(int**, int***);
+ pfunc2 = (int **(*)())pfunc1;
+ int **(***pfunc3)();
+ int ***(**pfunc4)();
+ int **(**pfunc5)(int **, int **);
+ int **(**pfunc6)(int **, int ***);
}
-void testfunc10 (int ** (**p5)(int**, int**), int ** (**p6)(int**, int***))
-{
-
-}
+void testfunc10(int **(**p5)(int **, int **), int **(**p6)(int **, int ***)) {}
-void testfunc11(void)
-{
+void testfunc11(void) {
long int a;
double dd;
short unsigned int b;
- short int* p1;
- long int* p2;
+ short int *p1;
+ long int *p2;
int normalint;
- p2 = (long int*)p1;
- p1 = (short int*)p2;
+ p2 = (long int *)p1;
+ p1 = (short int *)p2;
b = a;
dd = b;
normalint = a;
}
-void testfunc12(void)
-{
- const char* stringlit = "date should be in the form ??-??-??";
+void testfunc12(void) {
+ const char *stringlit = "date should be in the form ??-??-??";
short unsigned int port = 0x005aU;
unsigned char portchar = 0x005aU;
@@ -356,26 +339,24 @@ void testfunc12(void)
}
/*the test are from the misrac doc for 11.5*/
-void testfunc13(void)
-{
+void testfunc13(void) {
int x;
- int * const cpi = &x; /* const pointer */
- int * const * pcpi; /* pointer to const pointer */
- const int * * ppci; /* pointer to pointer to const */
- int * * ppi;
- const int * pci; /* pointer to const */
- volatile int * pvi; /* pointer to volatile */
- int * pi;
- pi = cpi; /* Compliant - no conversion
-no cast required */
- pi = (int *)pci; /* Not compliant */
- pi = (int *)pvi; /* Not compliant */
- ppi = (int * *)pcpi; /* Not compliant */
- ppi = (int * *)ppci; /* Not compliant */
+ int *const cpi = &x; /* const pointer */
+ int *const *pcpi; /* pointer to const pointer */
+ const int **ppci; /* pointer to pointer to const */
+ int **ppi;
+ const int *pci; /* pointer to const */
+ volatile int *pvi; /* pointer to volatile */
+ int *pi;
+ pi = cpi; /* Compliant - no conversion
+ no cast required */
+ pi = (int *)pci; /* Not compliant */
+ pi = (int *)pvi; /* Not compliant */
+ ppi = (int **)pcpi; /* Not compliant */
+ ppi = (int **)ppci; /* Not compliant */
}
-void testfunc14(void)
-{
+void testfunc14(void) {
char a;
long int b;
long int b2;
@@ -386,8 +367,7 @@ void testfunc14(void)
a = (int)(b + b2);
a = b + b2;
a = b++;
- if ((int)(b + b2))
- {
+ if ((int)(b + b2)) {
/*somethi/*ng*/
}
@@ -397,23 +377,19 @@ void testfunc14(void)
d = e;
}
-void testfunc15 (void)
-{
+void testfunc15(void) {
int a[10];
a[1] = 041;
a[2] = 052;
}
-void testfunc16(int* p1, int* p2, int* const p3, const int* p4, int* p5)
-{
- if (*p1 > 100)
- {
+void testfunc16(int *p1, int *p2, int *const p3, const int *p4, int *p5) {
+ if (*p1 > 100) {
/*do something*/
}
- if (*p5 > 100)
- {
+ if (*p5 > 100) {
/*do something*/
}
@@ -423,21 +399,18 @@ void testfunc16(int* p1, int* p2, int* const p3, const int* p4, int* p5)
*p2++;
*p2 = *p2 + 100;
- if (*p3 > 1000)
- {
+ if (*p3 > 1000) {
/*do something else*/
}
- if (*p4 < 100)
- {
+ if (*p4 < 100) {
/*yet another task*/
}
-}
-
-void externfunc (void)
-{
+ asm("add %al, (%rax)");
}
+void externfunc(void) {}
+
/*********************************************************************************************************************/
/*last line intentionally left blank.*/
diff --git a/test/testFuncs3.c b/test/testFuncs3.c
index baf3f37..24b7ac6 100644
--- a/test/testFuncs3.c
+++ b/test/testFuncs3.c
@@ -15,10 +15,8 @@ int intarray4[3][2] = MACRO2;
int answer = ANSWER;
float floatbitaccess;
-
/*********************************************************************************************************************/
-void tddfunc1 (void)
-{
+void tddfunc1(void) {
double complex z1 = 10.0 + 10.0 * I;
double complex z2 = 1.0 - 4.0 * I;
@@ -43,19 +41,17 @@ void tddfunc1 (void)
n1 = n2;
}
-void tddfunc2(void)
-{
+void tddfunc2(void) {
static int staticint1;
unsigned short int port = 0x5aU;
unsigned short int result_8;
- //uint16_t result_16;
- //uint16_t mode;
+ // uint16_t result_16;
+ // uint16_t mode;
result_8 = (~port) >> 4;
}
-void tddfunc3(void)
-{
+void tddfunc3(void) {
int a = 1;
READ_TIME_32();
@@ -63,14 +59,12 @@ void tddfunc3(void)
READ_TIME_34();
}
-int* tddfunc4(void)
-{
+int *tddfunc4(void) {
int localauto;
return (&localauto);
}
-void tddfunc5(void)
-{
+void tddfunc5(void) {
int arrint[4];
arrint[0] = 052;
arrint[1] = 067;
@@ -79,27 +73,29 @@ void tddfunc5(void)
}
/*12.12 tdd*/
-void tddfunc6(void)
-{
+void tddfunc6(void) {
float floatbitaccess;
- int* pointertofloat;
+ int *pointertofloat;
int apartoffloat;
- /*@DEVI-you cannot get away with this since c90 and c99 both specify that operands to & need to both be of integral types.*/
- /*embedded compilers might not necessarily be ISO-C-complete so apparently this might be actually viable in some cases but
- if the clang parser won't let this through, i can't analyze it so we can't check for this.*/
+ /*@DEVI-you cannot get away with this since c90 and c99 both specify that
+ * operands to & need to both be of integral types.*/
+ /*embedded compilers might not necessarily be ISO-C-complete so apparently this
+ might be actually viable in some cases but
+ if the clang parser won't let this through, i can't analyze it so we can't check
+ for this.*/
#if 0
apartoffloat = floatbitaccess & 0x000000FF;
#endif
- /*this results in a bticast castexpr which we are already tagging,clang does too, so im not overly concerned with this one
+ /*this results in a bticast castexpr which we are already tagging,clang does
+ too, so im not overly concerned with this one
though its fairly east to implement.*/
pointertofloat = &floatbitaccess;
- /*we could literally just tag all unions having float members as possible violations.*/
- union aunion
- {
+ /*we could literally just tag all unions having float members as possible
+ * violations.*/
+ union aunion {
float member1;
- union member2
- {
+ union member2 {
unsigned char member3;
unsigned char member4;
unsigned char member5;
@@ -111,13 +107,9 @@ void tddfunc6(void)
apartoffloat = aunionproto.member22.member5 & 0x000000FF;
}
-int externfunc(int arg)
-{
- return arg;
-}
+int externfunc(int arg) { return arg; }
-void testfunc7(void)
-{
+void testfunc7(void) {
unsigned char chararroct[7U];
chararroct[0U] = '\100';
@@ -127,5 +119,9 @@ void testfunc7(void)
chararroct[4U] = 125;
chararroct[5U] = '\x12';
}
+
+void tddfunc8(void) {
+ // asm("add %al, (%rax)");
+}
/*********************************************************************************************************************/
/*last line intnetionally left blank.*/