forked from dotnet/coreclr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLPTStrTestNative.cpp
More file actions
50 lines (39 loc) · 1.66 KB
/
LPTStrTestNative.cpp
File metadata and controls
50 lines (39 loc) · 1.66 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#include "../Native/StringMarshalingNative.h"
using StringType = LPWSTR;
using Tests = StringMarshalingTests<StringType, TP_slen>;
#define FUNCTION_NAME __FUNCTIONW__
#include "../Native/StringTestEntrypoints.inl"
// Verify that we append extra null terminators to our StringBuilder native buffers.
// Although this is a hidden implementation detail, it would be breaking behavior to stop doing this
// so we have a test for it. In particular, this detail prevents us from optimizing marshalling StringBuilders by pinning.
extern "C" DLL_EXPORT BOOL STDMETHODCALLTYPE Verify_NullTerminators_PastEnd(LPCWSTR buffer, int length)
{
return buffer[length+1] == W('\0');
}
struct ByValStringInStructAnsi
{
char str[20];
};
struct ByValStringInStructUnicode
{
WCHAR str[20];
};
extern "C" DLL_EXPORT BOOL STDMETHODCALLTYPE MatchFuncNameAnsi(ByValStringInStructAnsi str)
{
return StringMarshalingTests<char*, strlen>::Compare(__func__, str.str);
}
extern "C" DLL_EXPORT BOOL STDMETHODCALLTYPE MatchFuncNameUni(ByValStringInStructUnicode str)
{
return StringMarshalingTests<LPWSTR, TP_slen>::Compare(__FUNCTIONW__, str.str);
}
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ReverseByValStringAnsi(ByValStringInStructAnsi* str)
{
StringMarshalingTests<char*, strlen>::ReverseInplace(str->str);
}
extern "C" DLL_EXPORT void STDMETHODCALLTYPE ReverseByValStringUni(ByValStringInStructUnicode* str)
{
StringMarshalingTests<LPWSTR, TP_slen>::ReverseInplace(str->str);
}