| 48 | struct_({field("insert", boolean()), field("run_length", int64())}); |
| 49 | |
| 50 | Status ValidateEditScript(const Array& edits, const Array& base, const Array& target) { |
| 51 | // beginning (in base) of the run before the current hunk |
| 52 | int64_t base_run_begin = 0; |
| 53 | return VisitEditScript(edits, [&](int64_t delete_begin, int64_t delete_end, |
| 54 | int64_t insert_begin, int64_t insert_end) { |
| 55 | auto target_run_begin = insert_begin - (delete_begin - base_run_begin); |
| 56 | if (!base.RangeEquals(base_run_begin, delete_begin, target_run_begin, target)) { |
| 57 | return Status::Invalid("base and target were unequal in a run"); |
| 58 | } |
| 59 | |
| 60 | base_run_begin = delete_end; |
| 61 | for (int64_t i = insert_begin; i < insert_end; ++i) { |
| 62 | for (int64_t d = delete_begin; d < delete_end; ++d) { |
| 63 | if (target.RangeEquals(i, i + 1, d, base)) { |
| 64 | return Status::Invalid("a deleted element was simultaneously inserted"); |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return Status::OK(); |
| 70 | }); |
| 71 | } |
| 72 | |
| 73 | class DiffTest : public ::testing::Test { |
| 74 | protected: |
no test coverage detected