2 * test-mono-string.c: Unit test for runtime MonoString* manipulation.
7 #include "metadata/object-internals.h"
14 MonoString
*s
= mono_string_new_checked (mono_domain_get (), "abcd", error
);
15 static const gunichar2 u16s
[] = { 0x61, 0x62, 0x63, 0x64, 0 }; /* u16 "abcd" */
16 mono_error_assert_ok (error
);
17 gunichar2
* c
= mono_string_chars_internal (s
);
19 g_assert (c
!= NULL
&& !memcmp (&u16s
, c
, sizeof (u16s
)));
24 new_string_utf8 (void)
27 const gunichar2 snowman
= 0x2603;
28 static const unsigned char bytes
[] = { 0xE2, 0x98, 0x83, 0x00 }; /* U+2603 NUL */
29 MonoString
*s
= mono_string_new_checked (mono_domain_get (), (const char*)bytes
, error
);
30 mono_error_assert_ok (error
);
31 gunichar2
* c
= mono_string_chars_internal (s
);
32 g_assert (c
!= NULL
&&
39 new_string_conv_err (void)
42 static const unsigned char bytes
[] = { 'a', 0xFC, 'b', 'c', 0 };
43 MonoString G_GNUC_UNUSED
*s
= mono_string_new_checked (mono_domain_get (), (const char*)bytes
, error
);
44 g_assert (!mono_error_ok (error
));
45 const char *msg
= mono_error_get_message (error
);
46 g_assert (msg
!= NULL
);
47 fprintf (stderr
, "(expected) error message was: \"%s\"", msg
);
48 mono_error_cleanup (error
);
56 test_mono_string_main (void);
59 test_mono_string_main (void)
62 mono_jit_init_version ("test-mono-string", "v4.0.30319");
66 res
+= new_string_ok ();
67 res
+= new_string_utf8 ();
68 res
+= new_string_conv_err ();