A game about forced loneliness, made by TACStudios
1<#/*THIS IS A T4 FILE - see t4_text_templating.md for what it is and how to run codegen*/#>
2<#@ template debug="True" #>
3<#@ output extension=".gen.cs" #>
4<#@ assembly name="System.Core" #>
5using System;
6using NUnit.Framework;
7using Unity.Collections;
8using Unity.Collections.LowLevel.Unsafe;
9using Unity.Collections.Tests;
10
11internal class NativeHashSetTestsGenerated : CollectionsTestFixture
12{
13<#
14{
15 foreach (var ContainerType in new[] {
16 ( "NativeHashSet" ),
17 ( "UnsafeHashSet" ),
18 }) {
19#>
20 static void ExpectedCount<T>(ref <#=ContainerType#><T> container, int expected)
21 where T : unmanaged, IEquatable<T>
22 {
23 Assert.AreEqual(expected == 0, container.IsEmpty);
24 Assert.AreEqual(expected, container.Count);
25 }
26
27<#
28 foreach (var OtherContainerType in new[] {
29 ( "NativeHashSet" ),
30 ( "UnsafeHashSet" ),
31 ( "NativeParallelHashSet" ),
32 ( "UnsafeParallelHashSet" ),
33 ( "NativeList" ),
34 ( "UnsafeList" ),
35 }) {
36#>
37
38 [Test]
39 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_Empty()
40 {
41 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
42 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
43 container.ExceptWith(other);
44
45 ExpectedCount(ref container, 0);
46
47 container.Dispose();
48 other.Dispose();
49 }
50
51 [Test]
52 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_AxB()
53 {
54 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
55 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
56 container.ExceptWith(other);
57
58 ExpectedCount(ref container, 3);
59 Assert.True(container.Contains(0));
60 Assert.True(container.Contains(1));
61 Assert.True(container.Contains(2));
62
63 container.Dispose();
64 other.Dispose();
65 }
66
67 [Test]
68 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith_Empty()
69 {
70 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
71 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
72 container.IntersectWith(other);
73
74 ExpectedCount(ref container, 0);
75
76 container.Dispose();
77 other.Dispose();
78 }
79
80 [Test]
81 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith()
82 {
83 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
84 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
85 container.IntersectWith(other);
86
87 ExpectedCount(ref container, 3);
88 Assert.True(container.Contains(3));
89 Assert.True(container.Contains(4));
90 Assert.True(container.Contains(5));
91
92 container.Dispose();
93 other.Dispose();
94 }
95
96 [Test]
97 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith_Empty()
98 {
99 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
100 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
101 container.UnionWith(other);
102
103 ExpectedCount(ref container, 0);
104
105 container.Dispose();
106 other.Dispose();
107 }
108
109 [Test]
110 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith()
111 {
112 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
113 var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
114 container.UnionWith(other);
115
116 ExpectedCount(ref container, 9);
117 Assert.True(container.Contains(0));
118 Assert.True(container.Contains(1));
119 Assert.True(container.Contains(2));
120 Assert.True(container.Contains(3));
121 Assert.True(container.Contains(4));
122 Assert.True(container.Contains(5));
123 Assert.True(container.Contains(6));
124 Assert.True(container.Contains(7));
125 Assert.True(container.Contains(8));
126
127 container.Dispose();
128 other.Dispose();
129 }
130
131<#}#>
132
133<#
134 foreach (var OtherContainerType in new[] {
135 ( "FixedList32Bytes" ),
136 ( "FixedList64Bytes" ),
137 ( "FixedList128Bytes" ),
138 ( "FixedList512Bytes" ),
139 ( "FixedList4096Bytes" ),
140 }) {
141#>
142 [Test]
143 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_Empty()
144 {
145 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
146 var other = new <#=OtherContainerType#><int>() { };
147 container.ExceptWith(other);
148
149 ExpectedCount(ref container, 0);
150
151 container.Dispose();
152 }
153
154 [Test]
155 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_AxB()
156 {
157 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
158 var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
159 container.ExceptWith(other);
160
161 ExpectedCount(ref container, 3);
162 Assert.True(container.Contains(0));
163 Assert.True(container.Contains(1));
164 Assert.True(container.Contains(2));
165
166 container.Dispose();
167 }
168
169 [Test]
170 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith_Empty()
171 {
172 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
173 var other = new <#=OtherContainerType#><int>() { };
174 container.IntersectWith(other);
175
176 ExpectedCount(ref container, 0);
177
178 container.Dispose();
179 }
180
181 [Test]
182 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith()
183 {
184 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
185 var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
186 container.IntersectWith(other);
187
188 ExpectedCount(ref container, 3);
189 Assert.True(container.Contains(3));
190 Assert.True(container.Contains(4));
191 Assert.True(container.Contains(5));
192
193 container.Dispose();
194 }
195
196 [Test]
197 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith_Empty()
198 {
199 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
200 var other = new <#=OtherContainerType#><int>() { };
201 container.UnionWith(other);
202
203 ExpectedCount(ref container, 0);
204
205 container.Dispose();
206 }
207
208 [Test]
209 public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith()
210 {
211 var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
212 var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
213 container.UnionWith(other);
214
215 ExpectedCount(ref container, 9);
216 Assert.True(container.Contains(0));
217 Assert.True(container.Contains(1));
218 Assert.True(container.Contains(2));
219 Assert.True(container.Contains(3));
220 Assert.True(container.Contains(4));
221 Assert.True(container.Contains(5));
222 Assert.True(container.Contains(6));
223 Assert.True(container.Contains(7));
224 Assert.True(container.Contains(8));
225
226 container.Dispose();
227 }
228<#}}}#>
229}