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

Side by Side Diff: chrome/browser/autocomplete/history_url_provider_unittest.cc

Issue 16972007: Fix test case table in HistoryURLProviderTest for C++11 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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 | « no previous file | 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 (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 "chrome/browser/autocomplete/history_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 } 793 }
794 794
795 TEST_F(HistoryURLProviderTest, SuggestExactInput) { 795 TEST_F(HistoryURLProviderTest, SuggestExactInput) {
796 struct TestCase { 796 struct TestCase {
797 // Inputs: 797 // Inputs:
798 const char* input; 798 const char* input;
799 bool trim_http; 799 bool trim_http;
800 // Expected Outputs: 800 // Expected Outputs:
801 const char* contents; 801 const char* contents;
802 // Offsets of the ACMatchClassifications, terminated by -1s. 802 // Offsets of the ACMatchClassifications, terminated by -1s.
803 size_t offsets[3]; 803 ssize_t offsets[3];
Peter Kasting 2013/06/17 18:43:43 Do not use ssize_t, use size_t. To avoid having t
cmarcelo 2013/06/17 18:48:52 Would be OK to (re-)use std::string::npos?
Peter Kasting 2013/06/17 18:53:12 Yes, in fact, that's what _should_ be used, since
804 // The index of the ACMatchClassification that should have the MATCH bit 804 // The index of the ACMatchClassification that should have the MATCH bit
805 // set, -1 if there no ACMatchClassification should have the MATCH bit set. 805 // set, -1 if there no ACMatchClassification should have the MATCH bit set.
806 size_t match_classification_index; 806 ssize_t match_classification_index;
807 } test_cases[] = { 807 } test_cases[] = {
808 { "http://www.somesite.com", false, 808 { "http://www.somesite.com", false,
809 "http://www.somesite.com", {0, -1, -1}, 0 }, 809 "http://www.somesite.com", {0, -1, -1}, 0 },
810 { "www.somesite.com", true, 810 { "www.somesite.com", true,
811 "www.somesite.com", {0, -1, -1}, 0 }, 811 "www.somesite.com", {0, -1, -1}, 0 },
812 { "www.somesite.com", false, 812 { "www.somesite.com", false,
813 "http://www.somesite.com", {0, 7, -1}, 1 }, 813 "http://www.somesite.com", {0, 7, -1}, 1 },
814 { "somesite.com", true, 814 { "somesite.com", true,
815 "somesite.com", {0, -1, -1}, 0 }, 815 "somesite.com", {0, -1, -1}, 0 },
816 { "somesite.com", false, 816 { "somesite.com", false,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 << test_cases[i].input << ", trim_http: " 851 << test_cases[i].input << ", trim_http: "
852 << test_cases[i].trim_http); 852 << test_cases[i].trim_http);
853 853
854 AutocompleteInput input(ASCIIToUTF16(test_cases[i].input), string16::npos, 854 AutocompleteInput input(ASCIIToUTF16(test_cases[i].input), string16::npos,
855 string16(), GURL("about:blank"), 855 string16(), GURL("about:blank"),
856 false, false, true, AutocompleteInput::ALL_MATCHES); 856 false, false, true, AutocompleteInput::ALL_MATCHES);
857 AutocompleteMatch match = 857 AutocompleteMatch match =
858 HistoryURLProvider::SuggestExactInput(autocomplete_, input, 858 HistoryURLProvider::SuggestExactInput(autocomplete_, input,
859 test_cases[i].trim_http); 859 test_cases[i].trim_http);
860 EXPECT_EQ(ASCIIToUTF16(test_cases[i].contents), match.contents); 860 EXPECT_EQ(ASCIIToUTF16(test_cases[i].contents), match.contents);
861 ssize_t match_classification_index =
862 test_cases[i].match_classification_index;
861 for (size_t match_index = 0; match_index < match.contents_class.size(); 863 for (size_t match_index = 0; match_index < match.contents_class.size();
862 ++match_index) { 864 ++match_index) {
863 EXPECT_EQ(test_cases[i].offsets[match_index], 865 ssize_t offset = test_cases[i].offsets[match_index];
864 match.contents_class[match_index].offset); 866 EXPECT_NE(-1, offset);
867 EXPECT_EQ(size_t(offset), match.contents_class[match_index].offset);
868 bool should_match = match_classification_index >= 0 &&
869 match_index == size_t(match_classification_index);
865 EXPECT_EQ(ACMatchClassification::URL | 870 EXPECT_EQ(ACMatchClassification::URL |
866 (match_index == test_cases[i].match_classification_index ? 871 (should_match ? ACMatchClassification::MATCH : 0),
867 ACMatchClassification::MATCH : 0),
868 match.contents_class[match_index].style); 872 match.contents_class[match_index].style);
869 } 873 }
870 EXPECT_EQ(std::string::npos, 874 EXPECT_EQ(-1, test_cases[i].offsets[match.contents_class.size()]);
871 test_cases[i].offsets[match.contents_class.size()]);
872 } 875 }
873 } 876 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698