-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTest_ManagedString.h
More file actions
56 lines (38 loc) · 1.15 KB
/
Test_ManagedString.h
File metadata and controls
56 lines (38 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#pragma once
#include "Common.h"
namespace Test_ManagedString
{
bool Run(dotnet_runtime::Library& a_lib)
{
bool ret = true;
typedef void* (CORECLR_DELEGATE_CALLTYPE* custom_entry_point_fn)();
{ // Ansi
// begin-snippet: Test_ManagedString_Ansi_CPP
auto fpTest_ManagedString_Ansi = (custom_entry_point_fn)a_lib.GetCustomEntrypoint(
STR("LibNamespace.Test_ManagedString"),
STR("Test_ManagedString_Ansi")
);
char* str = (char*)fpTest_ManagedString_Ansi();
// Compare the ASCII strings
bool success = cmp(str, (char*)"Hello Ansi");
LogTest(success, L"Test_ManagedString_Ansi");
// end-snippet
ret &= success;
}
{ // Wide
// begin-snippet: Test_ManagedString_Wide_CPP
auto fpTest_ManagedString_Wide = (custom_entry_point_fn)a_lib.GetCustomEntrypoint(
STR("LibNamespace.Test_ManagedString"),
STR("Test_ManagedString_Wide")
);
wchar_t* str = (wchar_t*)fpTest_ManagedString_Wide();
// Compare the wide strings
bool success = cmp(str, (wchar_t*)L"Hello ❤");
LogTest(success, L"Test_ManagedString_Wide");
// end-snippet
ret &= success;
}
return ret;
}
}