This commit is contained in:
2026-03-30 12:47:29 +09:00
parent 04dd7222d9
commit 8231d6df60
45 changed files with 2497 additions and 707 deletions

View File

@@ -49,7 +49,7 @@ public class TestConcurrentSlotMap
{
var slotIndex = _slotMap.Add(200, out var generation);
Assert.IsTrue(_slotMap.Contains(slotIndex, generation));
var removed = _slotMap.Remove(slotIndex, generation + 1); // Wrong generation
var removed = _slotMap.Remove(slotIndex, generation + 1); // Wrong Generation
Assert.IsFalse(removed);
Assert.IsTrue(_slotMap.Contains(slotIndex, generation));
}
@@ -71,11 +71,11 @@ public class TestConcurrentSlotMap
const int itemsPerThread = 1000;
var tasks = new List<Task>();
for (int t = 0; t < threadCount; t++)
for (var t = 0; t < threadCount; t++)
{
tasks.Add(Task.Run(() =>
{
for (int i = 0; i < itemsPerThread; i++)
for (var i = 0; i < itemsPerThread; i++)
{
_slotMap.Add(i, out _);
}
@@ -98,11 +98,11 @@ public class TestConcurrentSlotMap
var count = 0;
for (int t = 0; t < threadCount; t++)
for (var t = 0; t < threadCount; t++)
{
tasks.Add(Task.Run(() =>
{
for (int i = 0; i < operationsPerThread; i++)
for (var i = 0; i < operationsPerThread; i++)
{
if (rand.NextDouble() < 0.5)
{

View File

@@ -1,5 +1,4 @@
using Misaki.HighPerformance.Collections;
using System.Collections.Concurrent;
namespace Misaki.HighPerformance.Test.UnitTest.Collections;
@@ -43,7 +42,7 @@ public class TestSlotMap
{
var slotIndex = _slotMap.Add(200, out var generation);
Assert.IsTrue(_slotMap.Contains(slotIndex, generation));
var removed = _slotMap.Remove(slotIndex, generation + 1); // Wrong generation
var removed = _slotMap.Remove(slotIndex, generation + 1); // Wrong Generation
Assert.IsFalse(removed);
Assert.IsTrue(_slotMap.Contains(slotIndex, generation));
}

View File

@@ -29,12 +29,12 @@ public class TestUnsafeArray
[TestMethod]
public void TestIndexAccess()
{
for (int i = 0; i < _arr.Count; i++)
for (var i = 0; i < _arr.Count; i++)
{
_arr[i] = i * 10;
}
for (int i = 0; i < _arr.Count; i++)
for (var i = 0; i < _arr.Count; i++)
{
Assert.AreEqual(i * 10, _arr[i]);
}
@@ -45,7 +45,7 @@ public class TestUnsafeArray
{
_arr.Clear();
int expectedValue = 0;
var expectedValue = 0;
foreach (var item in _arr)
{
Assert.AreEqual(expectedValue, item);

View File

@@ -23,14 +23,14 @@ public class TestUnsafeStack
[TestMethod]
public void TestPushPop()
{
for (int i = 0; i < 10; i++)
for (var i = 0; i < 10; i++)
{
_stack.Push(i);
}
Assert.AreEqual(10, _stack.Count);
for (int i = 9; i >= 0; i--)
for (var i = 9; i >= 0; i--)
{
int value = _stack.Pop();
var value = _stack.Pop();
Assert.AreEqual(i, value);
}
Assert.AreEqual(0, _stack.Count);
@@ -40,7 +40,7 @@ public class TestUnsafeStack
public void TestPeek()
{
_stack.Push(42);
int value = _stack.Peek();
var value = _stack.Peek();
Assert.AreEqual(42, value);
Assert.AreEqual(1, _stack.Count);
}
@@ -48,12 +48,12 @@ public class TestUnsafeStack
[TestMethod]
public void TestEnumeration()
{
for (int i = 0; i < 5; i++)
for (var i = 0; i < 5; i++)
{
_stack.Push(i);
}
int expected = 4;
var expected = 4;
foreach (var item in _stack)
{
Assert.AreEqual(expected, item);