| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/google_url_tracker.h" | 5 #include "chrome/browser/google_url_tracker.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
| 7 | 7 |
| 8 TEST(GoogleURLTrackerTest, CheckAndConvertURL) { | 8 TEST(GoogleURLTrackerTest, CheckAndConvertURL) { |
| 9 static const struct { | 9 static const struct { |
| 10 const char* const source_url; | 10 const char* const source_url; |
| 11 const bool can_convert; | 11 const bool can_convert; |
| 12 const char* const base_url; | 12 const char* const base_url; |
| 13 } data[] = { | 13 } data[] = { |
| 14 { "http://www.google.com/", true, "http://www.google.com/", }, | 14 { "http://www.google.com/", true, "http://www.google.com/", }, |
| 15 { "http://google.fr/", true, "http://google.fr/", }, | 15 { "http://google.fr/", true, "http://google.fr/", }, |
| 16 { "http://google.co.uk/", true, "http://google.co.uk/", }, | 16 { "http://google.co.uk/", true, "http://google.co.uk/", }, |
| 17 { "http://www.google.com.by/", true, "http://www.google.com.by/", }, | 17 { "http://www.google.com.by/", true, "http://www.google.com.by/", }, |
| 18 { "http://www.google.com/ig", true, "http://www.google.com/", }, | 18 { "http://www.google.com/ig", true, "http://www.google.com/", }, |
| 19 { "http://www.google.com/intl/xx", true, "http://www.google.com/intl/xx", }, | 19 { "http://www.google.com/intl/xx", true, "http://www.google.com/intl/xx", }, |
| 20 { "http://a.b.c.google.com/", true, "http://a.b.c.google.com/", }, | 20 { "http://a.b.c.google.com/", true, "http://a.b.c.google.com/", }, |
| 21 { "http://www.yahoo.com/", false, "", }, | 21 { "http://www.yahoo.com/", false, "", }, |
| 22 { "http://google.evil.com/", false, "", }, | 22 { "http://google.evil.com/", false, "", }, |
| 23 { "http://google.com.com.com/", false, "", }, | 23 { "http://google.com.com.com/", false, "", }, |
| 24 { "http://google/", false, "", }, | 24 { "http://google/", false, "", }, |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 for (size_t i = 0; i < arraysize(data); ++i) { | 27 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
| 28 GURL base_url; | 28 GURL base_url; |
| 29 const bool can_convert = GoogleURLTracker::CheckAndConvertToGoogleBaseURL( | 29 const bool can_convert = GoogleURLTracker::CheckAndConvertToGoogleBaseURL( |
| 30 GURL(data[i].source_url), &base_url); | 30 GURL(data[i].source_url), &base_url); |
| 31 EXPECT_EQ(data[i].can_convert, can_convert); | 31 EXPECT_EQ(data[i].can_convert, can_convert); |
| 32 EXPECT_STREQ(data[i].base_url, base_url.spec().c_str()); | 32 EXPECT_STREQ(data[i].base_url, base_url.spec().c_str()); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| OLD | NEW |