Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / jsapi-tests / testUTF8.cpp
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * vim: set ts=8 sw=4 et tw=99:
3  */
4
5 #include "tests.h"
6
7 BEGIN_TEST(testUTF8_bug589917)
8 {
9     const jschar surrogate_pair[] = { 0xd800, 0xdc00 };
10     char output_buffer[10];
11     size_t utf8_len = sizeof(output_buffer);
12
13     CHECK(JS_EncodeCharacters(cx, surrogate_pair, 2, output_buffer, &utf8_len));
14     CHECK(utf8_len == 4);
15
16     CHECK(JS_EncodeCharacters(cx, surrogate_pair, 2, NULL, &utf8_len));
17     CHECK(utf8_len == 4);
18
19     return true;
20 }
21 END_TEST(testUTF8_bug589917)