OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/omnibox/browser/in_memory_url_index_types.h" | 5 #include "components/omnibox/browser/in_memory_url_index_types.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <algorithm> | 9 #include <algorithm> |
8 | 10 |
| 11 #include "base/macros.h" |
9 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
12 | 15 |
13 using base::UTF8ToUTF16; | 16 using base::UTF8ToUTF16; |
14 | 17 |
15 // Helper function for verifying that the contents of a C++ iterable container | 18 // Helper function for verifying that the contents of a C++ iterable container |
16 // of ints matches a C array ints. | 19 // of ints matches a C array ints. |
17 template <typename T> | 20 template <typename T> |
18 bool IntArraysEqual(const size_t* expected, | 21 bool IntArraysEqual(const size_t* expected, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EXPECT_EQ(expected_offsets_a[i], offsets[i]); | 140 EXPECT_EQ(expected_offsets_a[i], offsets[i]); |
138 | 141 |
139 // Test ReplaceOffsetsInTermMatches | 142 // Test ReplaceOffsetsInTermMatches |
140 offsets[4] = base::string16::npos; // offset of third term | 143 offsets[4] = base::string16::npos; // offset of third term |
141 TermMatches matches_b = ReplaceOffsetsInTermMatches(matches_a, offsets); | 144 TermMatches matches_b = ReplaceOffsetsInTermMatches(matches_a, offsets); |
142 const size_t expected_offsets_b[] = {1, 4, 10, 14}; | 145 const size_t expected_offsets_b[] = {1, 4, 10, 14}; |
143 ASSERT_EQ(arraysize(expected_offsets_b), matches_b.size()); | 146 ASSERT_EQ(arraysize(expected_offsets_b), matches_b.size()); |
144 for (size_t i = 0; i < matches_b.size(); ++i) | 147 for (size_t i = 0; i < matches_b.size(); ++i) |
145 EXPECT_EQ(expected_offsets_b[i], matches_b[i].offset); | 148 EXPECT_EQ(expected_offsets_b[i], matches_b[i].offset); |
146 } | 149 } |
OLD | NEW |