-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathListMethodsExtraTest.cs
More file actions
51 lines (43 loc) · 1.25 KB
/
Copy pathListMethodsExtraTest.cs
File metadata and controls
51 lines (43 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine.Profiling;
using UnityEngine.TestTools.Constraints;
using Is = UnityEngine.TestTools.Constraints.Is;
namespace MH.GCTests
{
public class ListMethodsExtra
{
const int ELEM_COUNT = 1000;
const int LOOP_COUNT = 1000; //don't know why, but if the mem allocation is too small, the profiler.GetMonoUsedSizeLong cannot detect it
List<DummyObjA> _cache = new List<DummyObjA>();
[OneTimeSetUp]
public void Init()
{
GC.Collect();
Profiler.enabled = true;
for(int i=0; i<ELEM_COUNT; ++i)
_cache.Add(new DummyObjA(i));
}
[OneTimeTearDown]
public void Fini()
{
Profiler.enabled = false;
_cache.Clear();
}
[Test]
public void OK_Reverse()
{
var cont = new List<DummyObjA>();
for(int i=0; i<ELEM_COUNT; ++i)
cont.Add(_cache[i]);
//------------------//
Assert.That(
() => cont.Reverse(),
Is.Not.AllocatingGCMemory()
);
}
}
}