Upgraded target framework to .NET 10 across all projects to leverage new features and improve performance. Refactored `JobScheduler` to fix method naming inconsistencies and ensure proper resource disposal. Enhanced `AllocationManager` with safer memory operations and better performance handling. Simplified `ReadOnlyUnsafeCollection` enumerator logic for efficiency. Overhauled `UnsafeBitSet` with new properties, improved bitwise operations, and optimized memory management. Updated `UnsafeSlotMap` and `ConcurrentSlotMap` for better validation and naming consistency. Revised `MemoryLeakException` to use `ReadOnlySpan` for improved performance. Simplified `MathematicsBenchmark` logic and integrated `BenchmarkDotNet` for testing. Added AOT compatibility settings for `Debug` and `Release` configurations. Introduced unit tests for `UnsafeBitSet` to validate functionality. Cleaned up unused code, improved readability, and ensured consistent naming conventions. Updated project references and metadata for consistency. Enabled inline methods for `NET10_0_OR_GREATER` in `VectorGenerator`.
78 lines
1.7 KiB
C#
78 lines
1.7 KiB
C#
using Misaki.HighPerformance.LowLevel.Buffer;
|
|
using Misaki.HighPerformance.LowLevel.Collections;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace Misaki.HighPerformance.Test.UnitTest.Collections;
|
|
|
|
[TestClass]
|
|
public class TestUnsafeBitSet
|
|
{
|
|
private UnsafeBitSet _set1;
|
|
private UnsafeBitSet _set2;
|
|
|
|
[TestInitialize]
|
|
public void Initialize()
|
|
{
|
|
_set1 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
|
|
_set2 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
|
|
}
|
|
|
|
[TestCleanup]
|
|
public void Cleanup()
|
|
{
|
|
_set1.Dispose();
|
|
_set2.Dispose();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestBitCount()
|
|
{
|
|
Assert.AreEqual(256, _set1.BitCount);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestSetAndGet()
|
|
{
|
|
Assert.IsFalse(_set1.IsSet(0));
|
|
_set1.SetBit(0);
|
|
Assert.IsTrue(_set1.IsSet(0));
|
|
_set1.ClearBit(0);
|
|
Assert.IsFalse(_set1.IsSet(0));
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestClearAll()
|
|
{
|
|
for (int i = 0; i < _set1.BitCount; i++)
|
|
{
|
|
_set1.SetBit(i);
|
|
}
|
|
|
|
_set1.ClearAll();
|
|
for (int i = 0; i < _set1.BitCount; i++)
|
|
{
|
|
Assert.IsFalse(_set1.IsSet(i));
|
|
}
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestAndOperation()
|
|
{
|
|
_set1.SetBit(0);
|
|
_set1.SetBit(1);
|
|
|
|
_set2.SetBit(1);
|
|
_set2.SetBit(2);
|
|
|
|
_set1.And(_set2);
|
|
|
|
Assert.IsFalse(_set1.IsSet(0));
|
|
Assert.IsTrue(_set1.IsSet(1));
|
|
Assert.IsFalse(_set1.IsSet(2));
|
|
}
|
|
} |