Initial commit

This commit is contained in:
2026-03-03 00:39:30 +05:00
commit fc01f07d9b
29933 changed files with 5353098 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
<#/*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" encoding="utf-8" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Globalization" #>
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// TextTransform Samples/Packages/com.unity.collections/Unity.Collections.Tests.Playmode/FixedListPlayModeTests.tt
//
// These tests require UNITY_DOTS_DEBUG to be enabled.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Collections;
using NUnit.Framework;
using UnityEngine.TestTools;
using System;
using Unity.Collections;
[TestFixture]
internal class FixedListPlaymodeTests
{
[UnityTest]
#if UNITY_EDITOR // standalone only
[Ignore("Test is for standalone builds only")]
#endif
public IEnumerator FixedListPlaymode_AreCollectionsChecksEnabled()
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
Assert.IsTrue(false, "Collections checks should not be enabled in standalone playmode tests");
#endif
#if !UNITY_DOTS_DEBUG
Assert.IsTrue(false, "UNITY_DOTS_DEBUG should be defined in standalone playmode tests");
#endif
yield break;
}
<#
{
var TYPES = new string[] {"byte", "int", "float"};
var TYPESIZES = new int[] {1, 4, 4};
var SIZES = new int[] {32, 64, 128};
for (var type = 0; type < 3; ++type)
{
for (var size = 0; size < 3; ++size)
{
var BYTES = SIZES[size];
var TYPE = TYPES[type];
var TYPESIZE = TYPESIZES[type];
var MAXLENGTH = BYTES - 2;
var TYPENAME = String.Format("FixedList{0}Bytes", BYTES);
var TYPENAME_IDENTIFIER = String.Format("FixedList{0}{1}Playmode_", BYTES, new CultureInfo("en-US").TextInfo.ToTitleCase(TYPE));
var EXPECTEDCAPACITY = (BYTES - 2) / TYPESIZE;
var BUFFERTYPE = String.Format("FixedBytes{0}", MAXLENGTH);
#>
[UnityTest]
public IEnumerator <#=TYPENAME_IDENTIFIER #>GenericHasExpectedCapacity()
{
var list = new <#=TYPENAME #><<#=TYPE#>>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((<#=TYPE #>)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((<#=TYPE #>)expectedCapacity); });
yield break;
}
<#
}
for (var size = 0; size < 3; ++size)
{
var BYTES = SIZES[size];
var TYPE = TYPES[type];
var TYPESIZE = TYPESIZES[type];
var MAXLENGTH = BYTES - 2;
var TYPENAME = String.Format("FixedList{0}Bytes<{1}>", BYTES, TYPE);
var TYPENAME_IDENTIFIER = String.Format("FixedList{0}{1}Playmode_", BYTES, new CultureInfo("en-US").TextInfo.ToTitleCase(TYPE));
var EXPECTEDCAPACITY = (BYTES - 2) / TYPESIZE;
#>
[UnityTest]
public IEnumerator <#=TYPENAME_IDENTIFIER #>HasExpectedCapacity()
{
var list = new <#=TYPENAME #>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((<#=TYPE #>)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((<#=TYPE #>)expectedCapacity); });
yield break;
}
<#
foreach (var OTHERBYTES in SIZES)
{
if (OTHERBYTES != BYTES)
{
var OTHERCAPACITY = (OTHERBYTES - 2) / TYPESIZE;
var OTHERTYPENAME = String.Format("FixedList{0}Bytes<{1}>", OTHERBYTES, TYPE);
var OTHERTYPENAME_IDENTIFIER = String.Format("_FixedList{0}{1}", OTHERBYTES, new CultureInfo("en-US").TextInfo.ToTitleCase(TYPE));
if (EXPECTEDCAPACITY > OTHERCAPACITY)
{
#>
[UnityTest]
public IEnumerator <#=TYPENAME_IDENTIFIER #>To<#=OTHERTYPENAME_IDENTIFIER #>()
{
var a = new <#=TYPENAME #>();
for(var i = 0; i < <#=EXPECTEDCAPACITY #>; ++i)
a.Add((<#=TYPE #>)i);
<#
WriteLine(
" Assert.Throws<IndexOutOfRangeException> (() => {{ var b = new {0}(a); }} );",
OTHERTYPENAME);
#>
yield break;
}
<#
}
}
}
}
}
}
#>
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6a88e2cd1798bb445bc5517141684031
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,345 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// TextTransform Samples/Packages/com.unity.collections/Unity.Collections.Tests.Playmode/FixedListPlayModeTests.tt
//
// These tests require UNITY_DOTS_DEBUG to be enabled.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System.Collections;
using NUnit.Framework;
using UnityEngine.TestTools;
using System;
using Unity.Collections;
[TestFixture]
internal class FixedListPlaymodeTests
{
[UnityTest]
#if UNITY_EDITOR // standalone only
[Ignore("Test is for standalone builds only")]
#endif
public IEnumerator FixedListPlaymode_AreCollectionsChecksEnabled()
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
Assert.IsTrue(false, "Collections checks should not be enabled in standalone playmode tests");
#endif
#if !UNITY_DOTS_DEBUG
Assert.IsTrue(false, "UNITY_DOTS_DEBUG should be defined in standalone playmode tests");
#endif
yield break;
}
[UnityTest]
public IEnumerator FixedList32BytePlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList32Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64BytePlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList64Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128BytePlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList128Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList32BytePlaymode_HasExpectedCapacity()
{
var list = new FixedList32Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64BytePlaymode_HasExpectedCapacity()
{
var list = new FixedList64Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64BytePlaymode_To_FixedList32Byte()
{
var a = new FixedList64Bytes<byte>();
for(var i = 0; i < 62; ++i)
a.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<byte>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128BytePlaymode_HasExpectedCapacity()
{
var list = new FixedList128Bytes<byte>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((byte)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128BytePlaymode_To_FixedList32Byte()
{
var a = new FixedList128Bytes<byte>();
for(var i = 0; i < 126; ++i)
a.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<byte>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128BytePlaymode_To_FixedList64Byte()
{
var a = new FixedList128Bytes<byte>();
for(var i = 0; i < 126; ++i)
a.Add((byte)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList64Bytes<byte>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList32IntPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList32Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64IntPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList64Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128IntPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList128Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList32IntPlaymode_HasExpectedCapacity()
{
var list = new FixedList32Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64IntPlaymode_HasExpectedCapacity()
{
var list = new FixedList64Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64IntPlaymode_To_FixedList32Int()
{
var a = new FixedList64Bytes<int>();
for(var i = 0; i < 15; ++i)
a.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<int>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128IntPlaymode_HasExpectedCapacity()
{
var list = new FixedList128Bytes<int>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((int)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128IntPlaymode_To_FixedList32Int()
{
var a = new FixedList128Bytes<int>();
for(var i = 0; i < 31; ++i)
a.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<int>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128IntPlaymode_To_FixedList64Int()
{
var a = new FixedList128Bytes<int>();
for(var i = 0; i < 31; ++i)
a.Add((int)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList64Bytes<int>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList32FloatPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList32Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64FloatPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList64Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128FloatPlaymode_GenericHasExpectedCapacity()
{
var list = new FixedList128Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList32FloatPlaymode_HasExpectedCapacity()
{
var list = new FixedList32Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64FloatPlaymode_HasExpectedCapacity()
{
var list = new FixedList64Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList64FloatPlaymode_To_FixedList32Float()
{
var a = new FixedList64Bytes<float>();
for(var i = 0; i < 15; ++i)
a.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<float>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128FloatPlaymode_HasExpectedCapacity()
{
var list = new FixedList128Bytes<float>();
var expectedCapacity = list.Capacity;
for(int i = 0; i < expectedCapacity; ++i)
list.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { list.Add((float)expectedCapacity); });
yield break;
}
[UnityTest]
public IEnumerator FixedList128FloatPlaymode_To_FixedList32Float()
{
var a = new FixedList128Bytes<float>();
for(var i = 0; i < 31; ++i)
a.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList32Bytes<float>(a); } );
yield break;
}
[UnityTest]
public IEnumerator FixedList128FloatPlaymode_To_FixedList64Float()
{
var a = new FixedList128Bytes<float>();
for(var i = 0; i < 31; ++i)
a.Add((float)i);
Assert.Throws<IndexOutOfRangeException> (() => { var b = new FixedList64Bytes<float>(a); } );
yield break;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4af3af31f23c85b4287da4d2acf87301
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
{
"name": "Unity.Collections.Tests.Playmode",
"references": [
"Unity.Entities",
"Unity.Entities.Hybrid",
"Unity.Entities.Tests",
"Unity.Collections",
"Unity.Burst",
"Unity.Jobs",
"Unity.Mathematics",
"Unity.Collections.BurstCompatibilityGen"
],
"optionalUnityReferences": [
"TestAssemblies"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [
"UNITY_DOTS_DEBUG"
],
"versionDefines": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5e96082520aa86a458e400b89afe93a4
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: