OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 110 |
111 int diff_parameter = 0; | 111 int diff_parameter = 0; |
112 | 112 |
113 for (DiffChunkStruct* chunk = first_chunk; | 113 for (DiffChunkStruct* chunk = first_chunk; |
114 chunk != NULL; | 114 chunk != NULL; |
115 chunk = chunk->next) { | 115 chunk = chunk->next) { |
116 int diff_pos1 = chunk->pos1; | 116 int diff_pos1 = chunk->pos1; |
117 int similar_part_length = diff_pos1 - pos1; | 117 int similar_part_length = diff_pos1 - pos1; |
118 int diff_pos2 = pos2 + similar_part_length; | 118 int diff_pos2 = pos2 + similar_part_length; |
119 | 119 |
120 ASSERT_EQ(diff_pos2, chunk->pos2); | 120 DCHECK_EQ(diff_pos2, chunk->pos2); |
121 | 121 |
122 for (int j = 0; j < similar_part_length; j++) { | 122 for (int j = 0; j < similar_part_length; j++) { |
123 ASSERT(pos1 + j < len1); | 123 DCHECK(pos1 + j < len1); |
124 ASSERT(pos2 + j < len2); | 124 DCHECK(pos2 + j < len2); |
125 ASSERT_EQ(s1[pos1 + j], s2[pos2 + j]); | 125 DCHECK_EQ(s1[pos1 + j], s2[pos2 + j]); |
126 } | 126 } |
127 diff_parameter += chunk->len1 + chunk->len2; | 127 diff_parameter += chunk->len1 + chunk->len2; |
128 pos1 = diff_pos1 + chunk->len1; | 128 pos1 = diff_pos1 + chunk->len1; |
129 pos2 = diff_pos2 + chunk->len2; | 129 pos2 = diff_pos2 + chunk->len2; |
130 } | 130 } |
131 { | 131 { |
132 // After last chunk. | 132 // After last chunk. |
133 int similar_part_length = len1 - pos1; | 133 int similar_part_length = len1 - pos1; |
134 ASSERT_EQ(similar_part_length, len2 - pos2); | 134 DCHECK_EQ(similar_part_length, len2 - pos2); |
135 USE(len2); | 135 USE(len2); |
136 for (int j = 0; j < similar_part_length; j++) { | 136 for (int j = 0; j < similar_part_length; j++) { |
137 ASSERT(pos1 + j < len1); | 137 DCHECK(pos1 + j < len1); |
138 ASSERT(pos2 + j < len2); | 138 DCHECK(pos2 + j < len2); |
139 ASSERT_EQ(s1[pos1 + j], s2[pos2 + j]); | 139 DCHECK_EQ(s1[pos1 + j], s2[pos2 + j]); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 if (expected_diff_parameter != -1) { | 143 if (expected_diff_parameter != -1) { |
144 ASSERT_EQ(expected_diff_parameter, diff_parameter); | 144 DCHECK_EQ(expected_diff_parameter, diff_parameter); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 | 148 |
149 void CompareStrings(const char* s1, const char* s2, | 149 void CompareStrings(const char* s1, const char* s2, |
150 int expected_diff_parameter = -1) { | 150 int expected_diff_parameter = -1) { |
151 CompareStringsOneWay(s1, s2, expected_diff_parameter); | 151 CompareStringsOneWay(s1, s2, expected_diff_parameter); |
152 CompareStringsOneWay(s2, s1, expected_diff_parameter); | 152 CompareStringsOneWay(s2, s1, expected_diff_parameter); |
153 } | 153 } |
154 | 154 |
(...skipping 13 matching lines...) Expand all Loading... |
168 CompareStrings("cat", "cut", 2); | 168 CompareStrings("cat", "cut", 2); |
169 CompareStrings("ct", "cut", 1); | 169 CompareStrings("ct", "cut", 1); |
170 CompareStrings("cat", "ct", 1); | 170 CompareStrings("cat", "ct", 1); |
171 CompareStrings("cat", "cat", 0); | 171 CompareStrings("cat", "cat", 0); |
172 CompareStrings("", "", 0); | 172 CompareStrings("", "", 0); |
173 CompareStrings("cat", "", 3); | 173 CompareStrings("cat", "", 3); |
174 CompareStrings("a cat", "a capybara", 7); | 174 CompareStrings("a cat", "a capybara", 7); |
175 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", | 175 CompareStrings("abbabababababaaabbabababababbabbbbbbbababa", |
176 "bbbbabababbbabababbbabababababbabbababa"); | 176 "bbbbabababbbabababbbabababababbabbababa"); |
177 } | 177 } |
OLD | NEW |