OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ios/web/public/string_util.h" | 5 #include "ios/web/public/string_util.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
9 | 11 |
10 namespace web { | 12 namespace web { |
11 | 13 |
12 // Tests that a regular sentence is clipped correctly. | 14 // Tests that a regular sentence is clipped correctly. |
13 TEST(StringByClippingLastWordTest, ClipRegularSentence) { | 15 TEST(StringByClippingLastWordTest, ClipRegularSentence) { |
14 const base::string16 kInput = | 16 const base::string16 kInput = |
15 base::UTF8ToUTF16("\nSome text here and there."); | 17 base::UTF8ToUTF16("\nSome text here and there."); |
16 EXPECT_EQ(kInput, GetStringByClippingLastWord(kInput, 100)); | 18 EXPECT_EQ(kInput, GetStringByClippingLastWord(kInput, 100)); |
(...skipping 19 matching lines...) Expand all Loading... |
36 // A string slightly longer than |kLongStringLength|. | 38 // A string slightly longer than |kLongStringLength|. |
37 base::string16 long_string(kLongStringLength + 10, 'a'); | 39 base::string16 long_string(kLongStringLength + 10, 'a'); |
38 // Block of text with no space should be truncated to kLongStringLength. | 40 // Block of text with no space should be truncated to kLongStringLength. |
39 base::string16 result = | 41 base::string16 result = |
40 GetStringByClippingLastWord(long_string, kLongStringLength); | 42 GetStringByClippingLastWord(long_string, kLongStringLength); |
41 EXPECT_EQ(kLongStringLength, result.size()); | 43 EXPECT_EQ(kLongStringLength, result.size()); |
42 EXPECT_EQ(0u, long_string.find_first_of(result)); | 44 EXPECT_EQ(0u, long_string.find_first_of(result)); |
43 } | 45 } |
44 | 46 |
45 } // namespace web | 47 } // namespace web |
OLD | NEW |