OLD | NEW |
(Empty) | |
| 1 // Copyright 2011 Facebook, Inc. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 // not use this file except in compliance with the License. You may obtain |
| 5 // a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 // License for the specific language governing permissions and limitations |
| 13 // under the License. |
| 14 // |
| 15 // Author: Ben Gertzfield |
| 16 |
| 17 #include <gtest/gtest.h> |
| 18 |
| 19 #include "unicodetext.h" |
| 20 |
| 21 namespace i18n { |
| 22 namespace unicodetext { |
| 23 |
| 24 TEST(UnicodeTextTest, Iterator) { |
| 25 struct value { |
| 26 const char* utf8; |
| 27 char32 code_point; |
| 28 } values[] = { |
| 29 { "\x31", 0x31 }, // U+0031 DIGIT ONE |
| 30 { "\xC2\xBD", 0x00BD }, // U+00BD VULGAR FRACTION ONE HALF |
| 31 { "\xEF\xBC\x91", 0xFF11 }, // U+FF11 FULLWIDTH DIGIT ONE |
| 32 { "\xF0\x9F\x80\x80", 0x1F000 }, // U+1F000 MAHJONG TILE EAST WIND |
| 33 }; |
| 34 |
| 35 for (size_t i = 0; i < sizeof values / sizeof values[0]; i++) { |
| 36 string number(values[i].utf8); |
| 37 UnicodeText number_as_unicode; |
| 38 number_as_unicode.PointToUTF8(number.data(), number.size()); |
| 39 UnicodeText::const_iterator it = number_as_unicode.begin(); |
| 40 EXPECT_EQ(values[i].code_point, *it); |
| 41 } |
| 42 } |
| 43 |
| 44 } // namespace unicodetext |
| 45 } // namespace i18n |
OLD | NEW |