Skip to content

Commit d9f6145

Browse files
committed
Fixed a memory leak in tests
1 parent fc17e03 commit d9f6145

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Assets/AdncAnimatorHelpers/Editor/Testing/AnimatorStub/TestAnimatorStub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public void Teardown () {
2020
}
2121

2222
[Test]
23-
public void FailsCreationIfNoGameObject () {
23+
public void DoesNotFailCreationIfNoGameObject () {
2424
var stub = new AnimatorStub(null);
2525

26-
Assert.IsFalse(stub.IsValid);
26+
Assert.IsTrue(stub.IsValid);
2727
}
2828

2929
[Test]

Assets/AdncAnimatorHelpers/Editor/Testing/HasParameter/TestHasParametersExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void Teardown () {
4141
Object.DestroyImmediate(_stub.Animator.gameObject);
4242
_stub = null;
4343

44+
Object.DestroyImmediate(_runtime.gameObject);
4445
AnimatorHelperRuntime.ClearSingleton();
4546
_runtime = null;
4647
}
@@ -79,6 +80,8 @@ public void HasParameterGetsTheSameParameterCacheAcrossAnimatorControllers () {
7980
Assert.IsTrue(AnimatorHelperRuntime.Instance.parameters.HasParameters(id));
8081

8182
Assert.IsTrue(clone.HasParameter("bool"));
83+
84+
Object.DestroyImmediate(clone.gameObject);
8285
}
8386

8487
[Test]

Assets/AdncAnimatorHelpers/Editor/Testing/HasParameter/TestHasParametersExtensionsStressTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public void Teardown () {
2121
Object.DestroyImmediate(_stub.Animator.gameObject);
2222
_stub = null;
2323

24+
Object.DestroyImmediate(_runtime.gameObject);
2425
AnimatorHelperRuntime.ClearSingleton();
2526
_runtime = null;
2627
}
@@ -39,7 +40,7 @@ public void CallWithSingleParameter () {
3940

4041
[Test]
4142
public void CallWithHundredParameters () {
42-
for (int i = 0; i < 100; i++) {
43+
for (var i = 0; i < 100; i++) {
4344
_stub.AnimatorCtrl.AddParameter(new AnimatorControllerParameter {
4445
name = "bool" + i,
4546
type = AnimatorControllerParameterType.Bool
@@ -53,7 +54,7 @@ public void CallWithHundredParameters () {
5354

5455
[Test]
5556
public void CallWithThosandParameters () {
56-
for (int i = 0; i < 1000; i++) {
57+
for (var i = 0; i < 1000; i++) {
5758
_stub.AnimatorCtrl.AddParameter(new AnimatorControllerParameter {
5859
name = "bool" + i,
5960
type = AnimatorControllerParameterType.Bool

0 commit comments

Comments
 (0)