OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/i18n/char_iterator.h" | 5 #include "base/i18n/char_iterator.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace base { | 10 namespace base { |
11 namespace i18n { | 11 namespace i18n { |
12 | 12 |
13 TEST(CharIteratorsTest, TestUTF8) { | 13 TEST(CharIteratorsTest, TestUTF8) { |
14 std::string empty(""); | 14 std::string empty; |
15 UTF8CharIterator empty_iter(&empty); | 15 UTF8CharIterator empty_iter(&empty); |
16 ASSERT_TRUE(empty_iter.end()); | 16 ASSERT_TRUE(empty_iter.end()); |
17 ASSERT_EQ(0, empty_iter.array_pos()); | 17 ASSERT_EQ(0, empty_iter.array_pos()); |
18 ASSERT_EQ(0, empty_iter.char_pos()); | 18 ASSERT_EQ(0, empty_iter.char_pos()); |
19 ASSERT_FALSE(empty_iter.Advance()); | 19 ASSERT_FALSE(empty_iter.Advance()); |
20 | 20 |
21 std::string str("s\303\273r"); // [u with circumflex] | 21 std::string str("s\303\273r"); // [u with circumflex] |
22 UTF8CharIterator iter(&str); | 22 UTF8CharIterator iter(&str); |
23 ASSERT_FALSE(iter.end()); | 23 ASSERT_FALSE(iter.end()); |
24 ASSERT_EQ(0, iter.array_pos()); | 24 ASSERT_EQ(0, iter.array_pos()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 ASSERT_EQ(4, iter.char_pos()); | 92 ASSERT_EQ(4, iter.char_pos()); |
93 | 93 |
94 // Don't care what it returns, but this shouldn't crash | 94 // Don't care what it returns, but this shouldn't crash |
95 iter.get(); | 95 iter.get(); |
96 | 96 |
97 ASSERT_FALSE(iter.Advance()); | 97 ASSERT_FALSE(iter.Advance()); |
98 } | 98 } |
99 | 99 |
100 } // namespace i18n | 100 } // namespace i18n |
101 } // namespace base | 101 } // namespace base |
OLD | NEW |