OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ |
| 17 #include <gtest/gtest.h> |
| 18 #include "../../src/plugin/PluginUtil.h" |
| 19 |
| 20 namespace |
| 21 { |
| 22 template<class CharT, size_t M, size_t N> |
| 23 bool BeginsWithForTesting(const CharT(&s)[M], const CharT(&beginning)[N]) |
| 24 { |
| 25 return BeginsWith(std::basic_string<CharT>(s), beginning); |
| 26 } |
| 27 } |
| 28 |
| 29 TEST(BeginsWith, EmptyIsEmpty) |
| 30 { |
| 31 ASSERT_TRUE(BeginsWithForTesting(L"", L"")); |
| 32 } |
| 33 |
| 34 TEST(BeginsWith, EmptyAlwaysBegins) |
| 35 { |
| 36 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"")); |
| 37 } |
| 38 |
| 39 TEST(BeginsWith, EmptyNeverHasABeginning) |
| 40 { |
| 41 ASSERT_FALSE(BeginsWithForTesting(L"", L"foo")); |
| 42 } |
| 43 |
| 44 TEST(BeginsWith, PartGood) |
| 45 { |
| 46 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"f")); |
| 47 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"fo")); |
| 48 } |
| 49 |
| 50 TEST(BeginsWith, AllGood) |
| 51 { |
| 52 ASSERT_TRUE(BeginsWithForTesting(L"foo", L"foo")); |
| 53 } |
| 54 |
| 55 TEST(BeginsWith, PartBad) |
| 56 { |
| 57 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"b")); |
| 58 } |
| 59 |
| 60 TEST(BeginsWith, AllBad) |
| 61 { |
| 62 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"bar")); |
| 63 } |
| 64 |
| 65 TEST(BeginsWith, ExtraBad) |
| 66 { |
| 67 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"foobar")); |
| 68 } |
| 69 |
| 70 TEST(BeginsWith, LongerBad) |
| 71 { |
| 72 ASSERT_FALSE(BeginsWithForTesting(L"foo", L"barfoo")); |
| 73 } |
OLD | NEW |