Bug 1885489 - Part 5: Add SnapshotIterator::readInt32(). r=iain
[gecko.git] / xpcom / tests / TestUnicodeArguments.cpp
bloba44f8a2f2e6b4bd261a24dcf0e043cf897beecc9
1 /**
2 * On Windows, a Unicode argument is passed as UTF-16 using ShellExecuteExW.
3 * On other platforms, it is passed as UTF-8
4 */
6 static const int args_length = 4;
7 #if defined(XP_WIN) && defined(_MSC_VER)
8 # define _UNICODE
9 # include <tchar.h>
10 # include <stdio.h>
12 static const _TCHAR* expected_utf16[args_length] = {
13 // Latin-1
14 L"M\xF8z\xEEll\xE5",
15 // Cyrillic
16 L"\x41C\x43E\x437\x438\x43B\x43B\x430",
17 // Bengali
18 L"\x9AE\x9CB\x99C\x9BF\x9B2\x9BE",
19 // Cuneiform
20 L"\xD808\xDE2C\xD808\xDF63\xD808\xDDB7"};
22 int wmain(int argc, _TCHAR* argv[]) {
23 printf("argc = %d\n", argc);
25 if (argc != args_length + 1) return -1;
27 for (int i = 1; i < argc; ++i) {
28 printf("expected[%d]: ", i - 1);
29 for (size_t j = 0; j < _tcslen(expected_utf16[i - 1]); ++j) {
30 printf("%x ", *(expected_utf16[i - 1] + j));
32 printf("\n");
34 printf("argv[%d]: ", i);
35 for (size_t j = 0; j < _tcslen(argv[i]); ++j) {
36 printf("%x ", *(argv[i] + j));
38 printf("\n");
40 if (_tcscmp(expected_utf16[i - 1], argv[i])) {
41 return i;
45 return 0;
47 #else
48 # include <string.h>
49 # include <stdio.h>
51 static const char* expected_utf8[args_length] = {
52 // Latin-1
53 "M\xC3\xB8z\xC3\xAEll\xC3\xA5",
54 // Cyrillic
55 "\xD0\x9C\xD0\xBE\xD0\xB7\xD0\xB8\xD0\xBB\xD0\xBB\xD0\xB0",
56 // Bengali
57 "\xE0\xA6\xAE\xE0\xA7\x8B\xE0\xA6\x9C\xE0\xA6\xBF\xE0\xA6\xB2\xE0\xA6\xBE",
58 // Cuneiform
59 "\xF0\x92\x88\xAC\xF0\x92\x8D\xA3\xF0\x92\x86\xB7"};
61 int main(int argc, char* argv[]) {
62 if (argc != args_length + 1) return -1;
64 for (int i = 1; i < argc; ++i) {
65 printf("argv[%d] = %s; expected = %s\n", i, argv[i], expected_utf8[i - 1]);
66 if (strcmp(expected_utf8[i - 1], argv[i])) {
67 return i;
71 return 0;
73 #endif