Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: courgette/third_party/qsufsort_unittest.cc

Issue 1288703002: [Courgette] Optimize QSufSort to speed up courgette-gen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments and spacing. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « courgette/third_party/qsufsort.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/third_party/qsufsort.h" 5 #include "courgette/third_party/qsufsort.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 for (size_t idx = 0; idx < arraysize(test_cases); ++idx) { 110 for (size_t idx = 0; idx < arraysize(test_cases); ++idx) {
111 const auto& test_case = test_cases[idx]; 111 const auto& test_case = test_cases[idx];
112 int new_size = static_cast<int>(::strlen(test_case.query_str)); 112 int new_size = static_cast<int>(::strlen(test_case.query_str));
113 const unsigned char* new_buf = 113 const unsigned char* new_buf =
114 reinterpret_cast<const unsigned char*>(test_case.query_str); 114 reinterpret_cast<const unsigned char*>(test_case.query_str);
115 115
116 // Perform the search. 116 // Perform the search.
117 int pos = 0; 117 int pos = 0;
118 int match_len = courgette::qsuf::search( 118 int match_len = courgette::qsuf::search(
119 &I[0], old_buf, old_size, new_buf, new_size, 0, old_size, &pos); 119 &I[0], old_buf, old_size, new_buf, new_size, &pos);
120 120
121 // Check basic properties and match with expected values. 121 // Check basic properties and match with expected values.
122 EXPECT_GE(match_len, 0) << "test_case[" << idx << "]"; 122 EXPECT_GE(match_len, 0) << "test_case[" << idx << "]";
123 EXPECT_LE(match_len, new_size) << "test_case[" << idx << "]"; 123 EXPECT_LE(match_len, new_size) << "test_case[" << idx << "]";
124 if (match_len > 0) { 124 if (match_len > 0) {
125 EXPECT_GE(pos, 0) << "test_case[" << idx << "]"; 125 EXPECT_GE(pos, 0) << "test_case[" << idx << "]";
126 EXPECT_LE(pos, old_size - match_len) << "test_case[" << idx << "]"; 126 EXPECT_LE(pos, old_size - match_len) << "test_case[" << idx << "]";
127 EXPECT_EQ(0, ::memcmp(old_buf + pos, new_buf, match_len)) 127 EXPECT_EQ(0, ::memcmp(old_buf + pos, new_buf, match_len))
128 << "test_case[" << idx << "]"; 128 << "test_case[" << idx << "]";
129 } 129 }
130 if (test_case.exp_pos >= 0) { 130 if (test_case.exp_pos >= 0) {
131 EXPECT_EQ(test_case.exp_pos, pos) << "test_case[" << idx << "]"; 131 EXPECT_EQ(test_case.exp_pos, pos) << "test_case[" << idx << "]";
132 } 132 }
133 EXPECT_EQ(test_case.exp_match_len, match_len) << "test_case[" << idx << "]"; 133 EXPECT_EQ(test_case.exp_match_len, match_len) << "test_case[" << idx << "]";
134 } 134 }
135 } 135 }
OLDNEW
« no previous file with comments | « courgette/third_party/qsufsort.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698