1818#include < cstdint>
1919#include < cstring>
2020#include < limits>
21+ #include < numeric>
2122#include < vector>
2223
2324#include " gmock/gmock.h"
2425#include " gtest/gtest.h"
2526#include " absl/container/flat_hash_set.h"
2627#include " ./centipede/execution_metadata.h"
2728#include " ./centipede/knobs.h"
28- #include " ./centipede/mutation_input .h"
29+ #include " ./centipede/mutation_data .h"
2930#include " ./centipede/runner_cmp_trace.h"
3031#include " ./common/defs.h"
3132
@@ -93,8 +94,9 @@ TEST(ByteArrayMutator, RoundDownToRemoveCorrectly) {
9394namespace {
9495
9596TEST (DictEntry, DictEntry) {
96- uint8_t bytes[17 ] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ,
97- 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 };
97+ uint8_t bytes[129 ];
98+ std::iota (bytes, bytes + 129 , 0 );
99+
98100 DictEntry a_0_10 ({bytes + 0 , 10 });
99101 DictEntry a_0_4 ({bytes + 0 , 4 });
100102 DictEntry a_1_8 ({bytes + 1 , 8 });
@@ -103,7 +105,7 @@ TEST(DictEntry, DictEntry) {
103105 EXPECT_LT (a_0_10, a_1_8);
104106 EXPECT_EQ (memcmp (a_0_10.begin (), bytes, a_0_10.end () - a_0_10.begin ()), 0 );
105107
106- EXPECT_DEATH ({ DictEntry a_0_10 ({bytes, 17 }); }, " " );
108+ EXPECT_DEATH ({ DictEntry a_0_10 ({bytes, 129 }); }, " " );
107109}
108110
109111TEST (CmpDictionary, CmpDictionary) {
@@ -158,11 +160,11 @@ TEST(CmpDictionary, CmpDictionary) {
158160}
159161
160162TEST (CmpDictionary, CmpDictionaryIsCompatibleWithCmpTrace) {
161- CmpTrace<0 , 13 > traceN;
163+ CmpTrace<0 , 13 > traceN = {} ;
162164 traceN.Clear ();
163165 constexpr uint8_t long_array[20 ] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ,
164166 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 };
165- traceN.Capture (20 , long_array, long_array); // will be trimmed to 16.
167+ traceN.Capture (20 , long_array, long_array);
166168
167169 ExecutionMetadata metadata;
168170 bool append_failed = false ;
@@ -928,12 +930,12 @@ TEST(ByteArrayMutator, MutateManyWithAlignedInputs) {
928930 {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 },
929931 {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 },
930932 };
931- const std::vector<ByteArray > mutants =
933+ const std::vector<Mutant > mutants =
932934 mutator.MutateMany (GetMutationInputRefsFromDataInputs (aligned_inputs),
933935 kNumMutantsToGenerate );
934936 EXPECT_EQ (mutants.size (), kNumMutantsToGenerate );
935- for (const ByteArray & mutant : mutants) {
936- EXPECT_EQ (mutant.size () % kSizeAlignment , 0 );
937+ for (const Mutant& mutant : mutants) {
938+ EXPECT_EQ (mutant.data . size () % kSizeAlignment , 0 );
937939 }
938940}
939941
@@ -958,13 +960,13 @@ TEST(ByteArrayMutator, MutateManyWithUnalignedInputs) {
958960 {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 },
959961 {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 },
960962 };
961- const std::vector<ByteArray > mutants =
963+ const std::vector<Mutant > mutants =
962964 mutator.MutateMany (GetMutationInputRefsFromDataInputs (unaligned_inputs),
963965 kNumMutantsToGenerate );
964966 EXPECT_EQ (mutants.size (), kNumMutantsToGenerate );
965- for (const ByteArray & mutant : mutants) {
966- if (mutant.size () % kSizeAlignment != 0 ) {
967- EXPECT_LE (mutant.size (), 11 );
967+ for (const Mutant& mutant : mutants) {
968+ if (mutant.data . size () % kSizeAlignment != 0 ) {
969+ EXPECT_LE (mutant.data . size (), 11 );
968970 }
969971 }
970972}
@@ -982,12 +984,12 @@ TEST(ByteArrayMutator, MutateManyWithMaxLen) {
982984 {0 , 1 , 2 },
983985 {0 , 1 , 2 , 3 },
984986 };
985- const std::vector<ByteArray > mutants = mutator.MutateMany (
987+ const std::vector<Mutant > mutants = mutator.MutateMany (
986988 GetMutationInputRefsFromDataInputs (inputs), kNumMutantsToGenerate );
987989 EXPECT_EQ (mutants.size (), kNumMutantsToGenerate );
988990
989- for (const ByteArray & mutant : mutants) {
990- EXPECT_LE (mutant.size (), kMaxLen );
991+ for (const Mutant& mutant : mutants) {
992+ EXPECT_LE (mutant.data . size (), kMaxLen );
991993 }
992994}
993995
@@ -1001,16 +1003,16 @@ TEST(ByteArrayMutator, MutateManyWithMaxLenWithStartingLargeInput) {
10011003 const std::vector<ByteArray> large_input = {
10021004 {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 }, {0 }, {0 , 1 }, {0 , 1 , 2 }, {0 , 1 , 2 , 3 },
10031005 };
1004- const std::vector<ByteArray > mutants = mutator.MutateMany (
1006+ const std::vector<Mutant > mutants = mutator.MutateMany (
10051007 GetMutationInputRefsFromDataInputs (large_input), kNumMutantsToGenerate );
10061008 EXPECT_EQ (mutants.size (), kNumMutantsToGenerate );
10071009
1008- for (const ByteArray & mutant : mutants) {
1009- if (mutant.size () > kMaxLen ) {
1010+ for (const Mutant& mutant : mutants) {
1011+ if (mutant.data . size () > kMaxLen ) {
10101012 // The only mutant larger than max length should be the same large input
10111013 // that mutation originally started with. All other mutants should be
10121014 // within the maximum length specified.
1013- EXPECT_EQ (mutant, large_input[0 ]);
1015+ EXPECT_EQ (mutant. data , large_input[0 ]);
10141016 }
10151017 }
10161018}
0 commit comments