Skip to content

Commit eb2e862

Browse files
committed
fix: avoid endless loop
close #392
1 parent d1386a1 commit eb2e862

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

Assets/Tests/Editor/NewTestScript.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
using System.Collections;
2+
using Coffee.UIParticleInternal;
23
using NUnit.Framework;
4+
using UnityEngine;
35
using UnityEngine.TestTools;
46

57
namespace Coffee.UIParticle.Editor.Tests
68
{
79
public class NewTestScript
810
{
9-
// A Test behaves as an ordinary method
10-
[Test]
11-
public void NewTestScriptSimplePasses()
11+
[TestCase(-1)]
12+
[TestCase(0)]
13+
[TestCase(2048)]
14+
[TestCase(3000)]
15+
public void GetParticleArray(int requiredSize)
1216
{
13-
// Use the Assert class to test conditions
17+
var array = ParticleSystemExtensions.GetParticleArray(requiredSize);
18+
Debug.Log($"requiredSize: {requiredSize}, array.Length: {array.Length}");
1419
}
1520

1621
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use

Packages/src/Runtime/UIParticle.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Random = UnityEngine.Random;
1010

1111
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor")]
12+
[assembly: InternalsVisibleTo("Coffee.UIParticle.Editor.Tests")]
1213
[assembly: InternalsVisibleTo("Coffee.UIParticle.PerformanceDemo")]
1314
[assembly: InternalsVisibleTo("Coffee.UIParticle.Demo")]
1415

Packages/src/Runtime/Utilities/ParticleSystemExtensions.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ public static ParticleSystem.Particle[] GetParticleArray(int size)
1313
{
1414
if (s_TmpParticles.Length < size)
1515
{
16-
while (s_TmpParticles.Length < size)
17-
{
18-
size = Mathf.NextPowerOfTwo(size);
19-
}
20-
16+
size = Mathf.NextPowerOfTwo(size);
2117
s_TmpParticles = new ParticleSystem.Particle[size];
2218
}
2319

0 commit comments

Comments
 (0)