Skip to content

Commit

Permalink
Add execute tests for unsigned relational operators
Browse files Browse the repository at this point in the history
These tests validate that relational operator mutations are working as
expected when the optimisations from Just and Schweiggert 2014 are
applied.

Resolves #285.
  • Loading branch information
afd authored Jul 16, 2024
1 parent 542f1fd commit 1c853fd
Show file tree
Hide file tree
Showing 48 changed files with 424 additions and 78 deletions.
7 changes: 7 additions & 0 deletions test/execute/unsigned_comparison_eq_0_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void doit(unsigned zero,
unsigned ten);

int main() {
doit(0, 10);
return 0;
}
5 changes: 5 additions & 0 deletions test/execute/unsigned_comparison_eq_0_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1_1_1_0_
1_1_0_1_
1_0_1_1_
0_1_1_1_
1_1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_eq_0_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_1_
24 changes: 24 additions & 0 deletions test/execute/unsigned_comparison_eq_0_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void doit(unsigned zero, unsigned ten) {
if(zero == 0) {
printf("1_");
} else {
printf("0_");
}
if(0 == zero) {
printf("1_");
} else {
printf("0_");
}
if (ten == 0) {
printf("0_");
} else {
printf("1_");
}
if (0 == ten) {
printf("0_");
} else {
printf("1_");
}
}
21 changes: 8 additions & 13 deletions test/execute/unsigned_comparison_eq_c/harness.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include <stdio.h>

unsigned EQ(unsigned, unsigned);

void comparison(unsigned x, unsigned y) {
printf("EQ_%u_%u_%u_",
x,
y,
EQ(x, y));
}
void doit(unsigned zero,
unsigned one,
unsigned two_a,
unsigned two_b,
unsigned ten,
unsigned onehundred);

int main() {
comparison(2, 2);
comparison(1, 10);
comparison(100, 0);
doit(0, 1, 2, 2, 10, 100);
return 0;
}
26 changes: 4 additions & 22 deletions test/execute/unsigned_comparison_eq_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
EQ_2_2_0_EQ_1_10_1_EQ_100_0_1_ ; replace == with !=
EQ_2_2_1_EQ_1_10_0_EQ_100_0_1_ ; replace == with >=
EQ_2_2_0_EQ_1_10_0_EQ_100_0_1_ ; replace == with >
EQ_2_2_1_EQ_1_10_1_EQ_100_0_0_ ; replace == with <=
EQ_2_2_0_EQ_1_10_1_EQ_100_0_0_ ; replace == with <
EQ_2_2_0_EQ_1_10_0_EQ_100_0_1_ ; replace LHS with 0
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace LHS with 1
EQ_2_2_0_EQ_1_10_0_EQ_100_0_1_ ; replace LHS with !LHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace LHS with ~LHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace LHS with --LHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace LHS with ++LHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace RHS with 0
EQ_2_2_0_EQ_1_10_1_EQ_100_0_0_ ; replace RHS with 1
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace RHS with !RHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace RHS with ~RHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace RHS with --RHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace RHS with ++RHS
EQ_2_2_0_EQ_1_10_0_EQ_100_0_0_ ; replace expression with 0
EQ_2_2_1_EQ_1_10_1_EQ_100_0_1_ ; replace expression with 1
EQ_2_2_0_EQ_1_10_1_EQ_100_0_1_ ; insert ! above expression
EQ_2_2_4294967294_EQ_1_10_4294967295_EQ_100_0_4294967295_ ; insert ~ above expression
EQ_2_2_3_EQ_1_10_3_EQ_100_0_3_ ; remove statement (so that default return of 3 is hit)
1_1_0_
1_0_1_
0_1_1_
1_1_
2 changes: 1 addition & 1 deletion test/execute/unsigned_comparison_eq_c/original.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
EQ_2_2_1_EQ_1_10_0_EQ_100_0_0_
1_1_1_
21 changes: 18 additions & 3 deletions test/execute/unsigned_comparison_eq_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
unsigned EQ(unsigned x, unsigned y) {
return x == y;
return 3; // This return statement guards against an undefined returned value
#include <stdio.h>

void doit(unsigned zero, unsigned one, unsigned two_a, unsigned two_b, unsigned ten, unsigned onehundred) {
if(two_a == two_b) {
printf("1_");
} else {
printf("0_");
}
if (one == ten) {
printf("0_");
} else {
printf("1_");
}
if (onehundred == zero) {
printf("0_");
} else {
printf("1_");
}
}
7 changes: 7 additions & 0 deletions test/execute/unsigned_comparison_ge_0_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void doit(unsigned zero,
unsigned ten);

int main() {
doit(0, 10);
return 0;
}
5 changes: 5 additions & 0 deletions test/execute/unsigned_comparison_ge_0_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1_1_1_0_
1_1_0_1_
1_0_1_1_
0_1_1_1_
1_1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_ge_0_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_1_
24 changes: 24 additions & 0 deletions test/execute/unsigned_comparison_ge_0_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void doit(unsigned zero, unsigned ten) {
if(zero >= 0) {
printf("1_");
} else {
printf("0_");
}
if(0 >= zero) {
printf("1_");
} else {
printf("0_");
}
if (ten >= 0) {
printf("1_");
} else {
printf("0_");
}
if (0 >= ten) {
printf("0_");
} else {
printf("1_");
}
}
11 changes: 11 additions & 0 deletions test/execute/unsigned_comparison_ge_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void doit(unsigned zero,
unsigned one,
unsigned two_a,
unsigned two_b,
unsigned ten,
unsigned onehundred);

int main() {
doit(0, 1, 2, 2, 10, 100);
return 0;
}
4 changes: 4 additions & 0 deletions test/execute/unsigned_comparison_ge_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1_1_0_
1_0_1_
0_1_1_
1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_ge_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_
19 changes: 19 additions & 0 deletions test/execute/unsigned_comparison_ge_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

void doit(unsigned zero, unsigned one, unsigned two_a, unsigned two_b, unsigned ten, unsigned onehundred) {
if(two_a >= two_b) {
printf("1_");
} else {
printf("0_");
}
if (one >= ten) {
printf("0_");
} else {
printf("1_");
}
if (onehundred >= zero) {
printf("1_");
} else {
printf("0_");
}
}
7 changes: 7 additions & 0 deletions test/execute/unsigned_comparison_gt_0_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void doit(unsigned zero,
unsigned ten);

int main() {
doit(0, 10);
return 0;
}
5 changes: 5 additions & 0 deletions test/execute/unsigned_comparison_gt_0_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1_1_1_0_
1_1_0_1_
1_0_1_1_
0_1_1_1_
1_1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_gt_0_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_1_
24 changes: 24 additions & 0 deletions test/execute/unsigned_comparison_gt_0_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void doit(unsigned zero, unsigned ten) {
if(zero > 0) {
printf("0_");
} else {
printf("1_");
}
if(0 > zero) {
printf("0_");
} else {
printf("1_");
}
if (ten > 0) {
printf("1_");
} else {
printf("0_");
}
if (0 > ten) {
printf("0_");
} else {
printf("1_");
}
}
11 changes: 11 additions & 0 deletions test/execute/unsigned_comparison_gt_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void doit(unsigned zero,
unsigned one,
unsigned two_a,
unsigned two_b,
unsigned ten,
unsigned onehundred);

int main() {
doit(0, 1, 2, 2, 10, 100);
return 0;
}
4 changes: 4 additions & 0 deletions test/execute/unsigned_comparison_gt_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1_1_0_
1_0_1_
0_1_1_
1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_gt_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_
19 changes: 19 additions & 0 deletions test/execute/unsigned_comparison_gt_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

void doit(unsigned zero, unsigned one, unsigned two_a, unsigned two_b, unsigned ten, unsigned onehundred) {
if(two_a > two_b) {
printf("0_");
} else {
printf("1_");
}
if (one > ten) {
printf("0_");
} else {
printf("1_");
}
if (onehundred > zero) {
printf("1_");
} else {
printf("0_");
}
}
7 changes: 7 additions & 0 deletions test/execute/unsigned_comparison_le_0_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void doit(unsigned zero,
unsigned ten);

int main() {
doit(0, 10);
return 0;
}
5 changes: 5 additions & 0 deletions test/execute/unsigned_comparison_le_0_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1_1_1_0_
1_1_0_1_
1_0_1_1_
0_1_1_1_
1_1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_le_0_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_1_
24 changes: 24 additions & 0 deletions test/execute/unsigned_comparison_le_0_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void doit(unsigned zero, unsigned ten) {
if(zero <= 0) {
printf("1_");
} else {
printf("0_");
}
if(0 <= zero) {
printf("1_");
} else {
printf("0_");
}
if (ten <= 0) {
printf("0_");
} else {
printf("1_");
}
if (0 <= ten) {
printf("1_");
} else {
printf("0_");
}
}
11 changes: 11 additions & 0 deletions test/execute/unsigned_comparison_le_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
void doit(unsigned zero,
unsigned one,
unsigned two_a,
unsigned two_b,
unsigned ten,
unsigned onehundred);

int main() {
doit(0, 1, 2, 2, 10, 100);
return 0;
}
4 changes: 4 additions & 0 deletions test/execute/unsigned_comparison_le_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1_1_0_
1_0_1_
0_1_1_
1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_le_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_
19 changes: 19 additions & 0 deletions test/execute/unsigned_comparison_le_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <stdio.h>

void doit(unsigned zero, unsigned one, unsigned two_a, unsigned two_b, unsigned ten, unsigned onehundred) {
if(two_a <= two_b) {
printf("1_");
} else {
printf("0_");
}
if (one <= ten) {
printf("1_");
} else {
printf("0_");
}
if (onehundred <= zero) {
printf("0_");
} else {
printf("1_");
}
}
7 changes: 7 additions & 0 deletions test/execute/unsigned_comparison_lt_0_c/harness.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void doit(unsigned zero,
unsigned ten);

int main() {
doit(0, 10);
return 0;
}
5 changes: 5 additions & 0 deletions test/execute/unsigned_comparison_lt_0_c/mutants.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1_1_1_0_
1_1_0_1_
1_0_1_1_
0_1_1_1_
1_1_1_
1 change: 1 addition & 0 deletions test/execute/unsigned_comparison_lt_0_c/original.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1_1_1_1_
24 changes: 24 additions & 0 deletions test/execute/unsigned_comparison_lt_0_c/tomutate.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <stdio.h>

void doit(unsigned zero, unsigned ten) {
if(zero < 0) {
printf("0_");
} else {
printf("1_");
}
if(0 < zero) {
printf("0_");
} else {
printf("1_");
}
if (ten < 0) {
printf("0_");
} else {
printf("1_");
}
if (0 < ten) {
printf("1_");
} else {
printf("0_");
}
}
Loading

0 comments on commit 1c853fd

Please sign in to comment.