OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
| 5 #include "vm/unicode.h" |
5 #include "vm/globals.h" | 6 #include "vm/globals.h" |
6 #include "vm/unicode.h" | |
7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
8 | 8 |
9 namespace dart { | 9 namespace dart { |
10 | 10 |
11 TEST_CASE(Utf8Decode) { | 11 TEST_CASE(Utf8Decode) { |
12 // Examples from the Unicode specification, chapter 3 | 12 // Examples from the Unicode specification, chapter 3 |
13 { | 13 { |
14 const char* src = "\x41\xC3\xB1\x42"; | 14 const char* src = "\x41\xC3\xB1\x42"; |
15 int32_t expected[] = {0x41, 0xF1, 0x42}; | 15 int32_t expected[] = {0x41, 0xF1, 0x42}; |
16 int32_t dst[ARRAY_SIZE(expected)]; | 16 int32_t dst[ARRAY_SIZE(expected)]; |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 int32_t expected[] = {0xFFFF}; | 1031 int32_t expected[] = {0xFFFF}; |
1032 int32_t dst[ARRAY_SIZE(expected)]; | 1032 int32_t dst[ARRAY_SIZE(expected)]; |
1033 memset(dst, 0, sizeof(dst)); | 1033 memset(dst, 0, sizeof(dst)); |
1034 bool is_valid = Utf8::DecodeCStringToUTF32(src, dst, ARRAY_SIZE(dst)); | 1034 bool is_valid = Utf8::DecodeCStringToUTF32(src, dst, ARRAY_SIZE(dst)); |
1035 EXPECT(is_valid); | 1035 EXPECT(is_valid); |
1036 EXPECT(!memcmp(expected, dst, sizeof(expected))); | 1036 EXPECT(!memcmp(expected, dst, sizeof(expected))); |
1037 } | 1037 } |
1038 } | 1038 } |
1039 | 1039 |
1040 } // namespace dart | 1040 } // namespace dart |
OLD | NEW |