-
Notifications
You must be signed in to change notification settings - Fork 269
Expand file tree
/
Copy pathtest.cs
More file actions
167 lines (139 loc) · 4.07 KB
/
test.cs
File metadata and controls
167 lines (139 loc) · 4.07 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Text;
namespace TestWorld.wit.Exports.test.lists
{
public class ToTestExportsImpl : IToTestExports
{
public static uint AllocatedBytes()
{
return 0;
}
public static void EmptyListParam(byte[] a)
{
Debug.Assert(a.Length == 0);
}
public static void EmptyStringParam(string a)
{
Debug.Assert(a.Length == 0);
}
public static byte[] EmptyListResult()
{
return new byte[0];
}
public static string EmptyStringResult()
{
return "";
}
public static void ListParam(byte[] a)
{
Debug.Assert(a.Length == 4);
Debug.Assert(a[0] == 1);
Debug.Assert(a[1] == 2);
Debug.Assert(a[2] == 3);
Debug.Assert(a[3] == 4);
}
public static void ListParam2(string a)
{
Debug.Assert(a.Equals("foo"));
}
public static void ListParam3(List<String> a)
{
Debug.Assert(a.Count() == 3);
Debug.Assert(a[0].Equals("foo"));
Debug.Assert(a[1].Equals("bar"));
Debug.Assert(a[2].Equals("baz"));
}
public static void ListParam4(List<List<String>> a)
{
Debug.Assert(a.Count() == 2);
Debug.Assert(a[0].Count() == 2);
Debug.Assert(a[1].Count() == 1);
Debug.Assert(a[0][0].Equals("foo"));
Debug.Assert(a[0][1].Equals("bar"));
Debug.Assert(a[1][0].Equals("baz"));
}
public static void ListParam5(List<(byte, uint, byte)> a)
{
Debug.Assert(a.Count() == 2);
Debug.Assert(a[0].Item1 == 1);
Debug.Assert(a[0].Item2 == 2);
Debug.Assert(a[0].Item3 == 3);
Debug.Assert(a[1].Item1 == 4);
Debug.Assert(a[1].Item2 == 5);
Debug.Assert(a[1].Item3 == 6);
}
public static void ListParamLarge(List<String> a)
{
Debug.Assert(a.Count() == 1000);
}
public static byte[] ListResult()
{
return new byte[] { (byte)1, (byte)2, (byte)3, (byte)4, (byte)5 };
}
public static string ListResult2()
{
return "hello!";
}
public static List<string> ListResult3()
{
return new List<string>() {
"hello,",
"world!"
};
}
public static byte[] ListRoundtrip(byte[] a)
{
return a;
}
public static string stringRoundtrip(string a)
{
return a;
}
public static (byte[], byte[]) ListMinmax8(byte[] a, byte[] b)
{
return new(a, b);
}
public static (short[], short[]) ListMinmax16(short[] a, short[] b)
{
return new(a, b);
}
public static (int[], int[]) ListMinmax32(int[] a, int[] b)
{
return new(a, b);
}
public static (long[], long[]) ListMinmax64(long[] a, long[] b)
{
return new(a, b);
}
public static (float[], double[]) ListMinmaxFloat(float[] a, double[] b)
{
return new(a, b);
}
public static (byte[], sbyte[]) ListMinmax8(byte[] a, sbyte[] b)
{
return (a, b);
}
public static (ushort[], short[]) ListMinmax16(ushort[] a, short[] b)
{
return (a, b);
}
public static (uint[], int[]) ListMinmax32(uint[] a, int[] b)
{
return (a, b);
}
public static (ulong[], long[]) ListMinmax64(ulong[] a, long[] b)
{
return (a, b);
}
public static string StringRoundtrip(string a)
{
return a;
}
public static List<(string, byte[])> WasiHttpHeadersRoundtrip(List<(string, byte[])> a)
{
return a;
}
}
}