123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <#/*THIS IS A T4 FILE - see t4_text_templating.md for what it is and how to run codegen*/#>
- <#@ template debug="True" #>
- <#@ output extension=".gen.cs" #>
- <#@ assembly name="System.Core" #>
- using System;
- using NUnit.Framework;
- using Unity.Collections;
- using Unity.Collections.LowLevel.Unsafe;
- using Unity.Collections.Tests;
-
- internal class NativeHashSetTestsGenerated : CollectionsTestFixture
- {
- <#
- {
- foreach (var ContainerType in new[] {
- ( "NativeHashSet" ),
- ( "UnsafeHashSet" ),
- }) {
- #>
- static void ExpectedCount<T>(ref <#=ContainerType#><T> container, int expected)
- where T : unmanaged, IEquatable<T>
- {
- Assert.AreEqual(expected == 0, container.IsEmpty);
- Assert.AreEqual(expected, container.Count);
- }
-
- <#
- foreach (var OtherContainerType in new[] {
- ( "NativeHashSet" ),
- ( "UnsafeHashSet" ),
- ( "NativeParallelHashSet" ),
- ( "UnsafeParallelHashSet" ),
- ( "NativeList" ),
- ( "UnsafeList" ),
- }) {
- #>
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- container.ExceptWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- other.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_AxB()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
- container.ExceptWith(other);
-
- ExpectedCount(ref container, 3);
- Assert.True(container.Contains(0));
- Assert.True(container.Contains(1));
- Assert.True(container.Contains(2));
-
- container.Dispose();
- other.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- container.IntersectWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- other.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
- container.IntersectWith(other);
-
- ExpectedCount(ref container, 3);
- Assert.True(container.Contains(3));
- Assert.True(container.Contains(4));
- Assert.True(container.Contains(5));
-
- container.Dispose();
- other.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- container.UnionWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- other.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>(8, CommonRwdAllocator.Handle) { 3, 4, 5, 6, 7, 8 };
- container.UnionWith(other);
-
- ExpectedCount(ref container, 9);
- Assert.True(container.Contains(0));
- Assert.True(container.Contains(1));
- Assert.True(container.Contains(2));
- Assert.True(container.Contains(3));
- Assert.True(container.Contains(4));
- Assert.True(container.Contains(5));
- Assert.True(container.Contains(6));
- Assert.True(container.Contains(7));
- Assert.True(container.Contains(8));
-
- container.Dispose();
- other.Dispose();
- }
-
- <#}#>
-
- <#
- foreach (var OtherContainerType in new[] {
- ( "FixedList32Bytes" ),
- ( "FixedList64Bytes" ),
- ( "FixedList128Bytes" ),
- ( "FixedList512Bytes" ),
- ( "FixedList4096Bytes" ),
- }) {
- #>
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>() { };
- container.ExceptWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_ExceptWith_AxB()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
- container.ExceptWith(other);
-
- ExpectedCount(ref container, 3);
- Assert.True(container.Contains(0));
- Assert.True(container.Contains(1));
- Assert.True(container.Contains(2));
-
- container.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>() { };
- container.IntersectWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_IntersectWith()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
- container.IntersectWith(other);
-
- ExpectedCount(ref container, 3);
- Assert.True(container.Contains(3));
- Assert.True(container.Contains(4));
- Assert.True(container.Contains(5));
-
- container.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith_Empty()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { };
- var other = new <#=OtherContainerType#><int>() { };
- container.UnionWith(other);
-
- ExpectedCount(ref container, 0);
-
- container.Dispose();
- }
-
- [Test]
- public void <#=ContainerType#>_<#=OtherContainerType#>_EIU_UnionWith()
- {
- var container = new <#=ContainerType#><int>(8, CommonRwdAllocator.Handle) { 0, 1, 2, 3, 4, 5 };
- var other = new <#=OtherContainerType#><int>() { 3, 4, 5, 6, 7, 8 };
- container.UnionWith(other);
-
- ExpectedCount(ref container, 9);
- Assert.True(container.Contains(0));
- Assert.True(container.Contains(1));
- Assert.True(container.Contains(2));
- Assert.True(container.Contains(3));
- Assert.True(container.Contains(4));
- Assert.True(container.Contains(5));
- Assert.True(container.Contains(6));
- Assert.True(container.Contains(7));
- Assert.True(container.Contains(8));
-
- container.Dispose();
- }
- <#}}}#>
- }
|