17 w.Printf(
"{ \"%s\" : %d",
"length", 175);
18 EXPECT_STREQ(
"{ \"length\" : 175",
w.buffer());
19 w.Printf(
", \"%s\" : \"%s\" }",
"command",
"stopIt");
20 EXPECT_STREQ(
"{ \"length\" : 175, \"command\" : \"stopIt\" }",
w.buffer());
29 EXPECT_STREQ(
"{}",
js.ToCString());
36 EXPECT_STREQ(
"[]",
js.ToCString());
44 EXPECT_STREQ(
"[true]",
js.ToCString());
52 EXPECT_STREQ(
"[false]",
js.ToCString());
58 jsarr.
AddValue(
static_cast<intptr_t
>(4));
60 EXPECT_STREQ(
"[4]",
js.ToCString());
68 EXPECT_STREQ(
"[1.0]",
js.ToCString());
76 EXPECT_STREQ(
"[\"hello\"]",
js.ToCString());
84 EXPECT_STREQ(
"[\"helo\"]",
js.ToCString());
95 EXPECT_STREQ(
"[true,false]",
js.ToCString());
102 jsonBase64String.
AppendBytes(
reinterpret_cast<const uint8_t*
>(
"Hello"), 5);
103 jsonBase64String.
AppendBytes(
reinterpret_cast<const uint8_t*
>(
", "), 2);
104 jsonBase64String.
AppendBytes(
reinterpret_cast<const uint8_t*
>(
"world!"), 6);
106 EXPECT_STREQ(
"\"SGVsbG8sIHdvcmxkIQ==\"",
js.ToCString());
116 EXPECT_STREQ(
"{\"key1\":\"a\",\"key2\":\"b\"}",
js.ToCString());
126 EXPECT_STREQ(
"{\"key\":{\"key1\":\"d\"}}",
js.ToCString());
142 EXPECT_STREQ(
"[{\"key\":\"e\"},{\"yek\":\"f\"}]",
js.ToCString());
151 jsarr1.
AddValue(
static_cast<intptr_t
>(4));
158 EXPECT_STREQ(
"[[4],[false]]",
js.ToCString());
167 EXPECT_STREQ(
"[\"2 hello\"]",
js.ToCString());
176 EXPECT_STREQ(
"{\"key\":\"2 hello\"}",
js.ToCString());
190 const char* json_str =
js.ToCString();
200 "[{\"type\":\"@Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@"
201 "Class\",\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{"
202 "\"type\":\"SourceLocation\",\"script\":{\"type\":\"@Script\","
203 "\"fixedId\":true,\"id\":\"\",\"uri\":\"dart:core\\/null.dart\","
204 "\"_kind\":\"kernel\"}},\"library\":{"
205 "\"type\":\"@Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart."
206 "core\",\"uri\":\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true,"
207 "\"id\":\"\",\"valueAsString\":\"null\"},{\"object_key\":{\"type\":\"@"
208 "Instance\",\"_vmType\":\"null\",\"class\":{\"type\":\"@Class\","
209 "\"fixedId\":true,\"id\":\"\",\"name\":\"Null\",\"location\":{\"type\":"
210 "\"SourceLocation\",\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
211 "\"id\":\"\",\"uri\":\"dart:core\\/null.dart\",\"_kind\":\"kernel\"}},"
212 "\"library\":{\"type\":\"@"
213 "Library\",\"fixedId\":true,\"id\":\"\",\"name\":\"dart.core\",\"uri\":"
214 "\"dart:core\"}},\"kind\":\"Null\",\"fixedId\":true,\"id\":\"\","
215 "\"valueAsString\":\"null\"}}]",
225 EXPECT_STREQ(
"[\"Hel\\\"\\\"lo\\r\\n\\t\"]",
js.ToCString());
229 const char* kScriptChars =
230 "var ascii = 'Hello, World!';\n"
231 "var unicode = '\\u00CE\\u00F1\\u0163\\u00E9r\\u00F1\\u00E5\\u0163"
232 "\\u00EE\\u00F6\\u00F1\\u00E5\\u013C\\u00EE\\u017E\\u00E5\\u0163"
233 "\\u00EE\\u1EDD\\u00F1';\n"
234 "var surrogates = '\\u{1D11E}\\u{1D11E}\\u{1D11E}"
235 "\\u{1D11E}\\u{1D11E}';\n"
236 "var wrongEncoding = '\\u{1D11E}' + surrogates[0] + '\\u{1D11E}';"
237 "var nullInMiddle = 'This has\\u0000 four words.';";
246 auto do_test = [&](
const char* field_name,
const char* expected) {
261 EXPECT_STREQ(expected,
js.ToCString());
279 EXPECT_STREQ(
"{\"subrange\":\"ello\"}",
js.ToCString());
282 do_test(
"ascii",
"{\"ascii\":\"Hello, World!\"}");
283 do_test(
"unicode",
"{\"unicode\":\"Îñţérñåţîöñåļîžåţîờñ\"}");
284 do_test(
"surrogates",
"{\"surrogates\":\"𝄞𝄞𝄞𝄞𝄞\"}");
285 do_test(
"wrongEncoding",
"{\"wrongEncoding\":\"𝄞\\uD834𝄞\"}");
286 do_test(
"nullInMiddle",
"{\"nullInMiddle\":\"This has\\u0000 four words.\"}");
290 const char* param_keys[] = {
"dog",
"cat"};
291 const char* param_values[] = {
"apple",
"banana"};
295 js.SetParams(¶m_keys[0], ¶m_values[0], 2);
300 EXPECT(
js.ParamIs(
"cat",
"banana"));
301 EXPECT(!
js.ParamIs(
"dog",
"banana"));
static const size_t kBufferSize
static ObjectPtr UnwrapHandle(Dart_Handle object)
void AddValue(bool b) const
void AddValueF(const char *format,...) const PRINTF_ATTRIBUTE(2
void AppendBytes(const uint8_t *bytes, intptr_t length)
void AddProperty(const char *name, bool b) const
bool AddPropertyStr(const char *name, const String &s, intptr_t offset=0, intptr_t count=-1) const
void AddPropertyF(const char *name, const char *format,...) const PRINTF_ATTRIBUTE(3
static Dart_Handle LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true, bool allow_compile_errors=false)
struct _Dart_Handle * Dart_Handle
void ElideJSONSubstring(const char *prefix, const char *in, char *out, const char *postfix)
DART_EXPORT Dart_Handle Dart_GetField(Dart_Handle container, Dart_Handle name)
ISOLATE_UNIT_TEST_CASE(StackAllocatedDestruction)
TEST_CASE(DirectoryCurrent)
Dart_Handle NewString(const char *str)
void StripTokenPositions(char *buffer)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
#define EXPECT_VALID(handle)