forked from bit/DotRecastNetSim
added DtNodePool all tests
This commit is contained in:
parent
8ae375ef4c
commit
88059fcdcf
|
@ -7,13 +7,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
## [Unreleased] - yyyy-mm-dd
|
## [Unreleased] - yyyy-mm-dd
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added DtNodePool.GetNode, FindNode, FindNodes tests
|
- Added DtNodePool tests
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fixed SOH issue in dtNavMeshQuery.Raycast
|
- Fixed SOH issue in DtNavMeshQuery.Raycast
|
||||||
- Fixed SOH issue in DtProximityGrid.QueryItems
|
- Fixed SOH issue in DtProximityGrid.QueryItems
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
- Upgrade NUnit.Analyzers 4.0.1
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DotRecast.Detour.Test;
|
namespace DotRecast.Detour.Test;
|
||||||
|
@ -37,6 +38,20 @@ public class DtNodePoolTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sum = counts.Sum();
|
||||||
|
Assert.That(sum, Is.EqualTo(10));
|
||||||
|
|
||||||
|
// check GetNodeIdx GetNodeAtIdx
|
||||||
|
for (int i = 0; i < sum; ++i)
|
||||||
|
{
|
||||||
|
var node = pool.GetNodeAtIdx(i);
|
||||||
|
var nodeIdx = pool.GetNodeIdx(node);
|
||||||
|
var nodeByIdx = pool.GetNodeAtIdx(nodeIdx);
|
||||||
|
|
||||||
|
Assert.That(node, Is.SameAs(nodeByIdx));
|
||||||
|
Assert.That(nodeIdx, Is.EqualTo(i));
|
||||||
|
}
|
||||||
|
|
||||||
// check count
|
// check count
|
||||||
for (int i = 0; i < counts.Length; ++i)
|
for (int i = 0; i < counts.Length; ++i)
|
||||||
{
|
{
|
||||||
|
@ -58,5 +73,12 @@ public class DtNodePoolTest
|
||||||
Assert.That(n, Is.EqualTo(0));
|
Assert.That(n, Is.EqualTo(0));
|
||||||
Assert.That(nodes, Is.Null);
|
Assert.That(nodes, Is.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var totalCount = pool.GetNodeMap().Sum(x => x.Value.Count);
|
||||||
|
Assert.That(totalCount, Is.EqualTo(sum));
|
||||||
|
|
||||||
|
pool.Clear();
|
||||||
|
totalCount = pool.GetNodeMap().Sum(x => x.Value.Count);
|
||||||
|
Assert.That(totalCount, Is.EqualTo(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue