Tanoda
SlidingMaxTest.cs
Go to the documentation of this file.
1
/******************************************************************************
2
* Copyright (C) Ultraleap, Inc. 2011-2020. *
3
* *
4
* Use subject to the terms of the Apache License 2.0 available at *
5
* http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6
* between Ultraleap and you, your company or other organization. *
7
******************************************************************************/
8
9
using
UnityEngine
;
10
using
NUnit.Framework;
11
using
System.Collections.Generic;
12
13
namespace
Leap.Unity.Tests
{
14
15
public
class
SlidingMaxTest
{
16
public
const
int
MAX_HISTORY
= 64;
17
18
private
SlidingMax
_slidingMax;
19
20
[SetUp]
21
public
void
Setup
() {
22
_slidingMax =
new
SlidingMax
(
MAX_HISTORY
);
23
}
24
25
[TearDown]
26
public
void
Teardown
() {
27
_slidingMax =
null
;
28
}
29
30
[Test]
31
public
void
IsFunctional
() {
32
List<float> list =
new
List<float>();
33
34
for
(
int
i = 0; i < 1000; i++) {
35
float
newValue =
Random
.value;
36
37
_slidingMax.
AddValue
(newValue);
38
39
list.Add(newValue);
40
while
(list.Count >
MAX_HISTORY
) {
41
list.RemoveAt(0);
42
}
43
44
float
max = list[0];
45
for
(
int
j = 1; j < list.Count; j++) {
46
max = Mathf.Max(max, list[j]);
47
}
48
49
Assert.That(max, Is.EqualTo(_slidingMax.
Max
));
50
}
51
}
52
}
53
}
Random
UnityEngine.Random Random
Definition:
RealToolAction.cs:9
Leap.Unity.SlidingMax
Definition:
SlidingMax.cs:11
Leap.Unity.SlidingMax.Max
float Max
Definition:
SlidingMax.cs:45
Leap.Unity.SlidingMax.AddValue
void AddValue(float value)
Definition:
SlidingMax.cs:32
Leap.Unity.Tests.SlidingMaxTest
Definition:
SlidingMaxTest.cs:15
Leap.Unity.Tests.SlidingMaxTest.Setup
void Setup()
Definition:
SlidingMaxTest.cs:21
Leap.Unity.Tests.SlidingMaxTest.Teardown
void Teardown()
Definition:
SlidingMaxTest.cs:26
Leap.Unity.Tests.SlidingMaxTest.MAX_HISTORY
const int MAX_HISTORY
Definition:
SlidingMaxTest.cs:16
Leap.Unity.Tests.SlidingMaxTest.IsFunctional
void IsFunctional()
Definition:
SlidingMaxTest.cs:31
Leap.Unity.Tests
Definition:
BitConverterNonAllocTests.cs:13
UnityEngine
Definition:
HSVPicker/UtilityScripts/BoxSlider.cs:7
Source
Assets
Plugins
LeapMotion
Core
Tests
Editor
SlidingMaxTest.cs
Generated by
1.9.3