Added new numeric types for unsigned integers, including uint2, uint3, and uint4, along with their matrix types. Added a new `quaternion` struct with constructors and methods for creating and manipulating quaternions. Added methods for projecting and reflecting vectors, enhancing geometric operations. Added utility functions for generating orthonormal bases and changing vector signs. Added comprehensive unit tests for new mathematical functions and quaternion operations. Added a high-performance job scheduling system with job management features and worker thread management. Added new structs for job execution, allowing efficient job scheduling and execution. Added utility functions for job execution, including methods for obtaining unique job IDs. Changed access modifiers and property definitions in several files for improved clarity and maintainability. Changed property definitions and method implementations in `ImageInfo.cs`, `ImageResult.cs`, and `ImageResultFloat.cs` for better readability. Changed memory management functions in `CRuntime.cs` and improved memory allocation tracking in `MemoryStats.cs`. Changed the project file to include references to necessary projects and enable unsafe code blocks. Removed the `WorkerThreadPool.cs` file, integrating worker thread management directly into the `JobScheduler`. Removed the `float4` struct and its associated methods and properties, transitioning to a new code generation strategy. Removed the `float4.tt` template and other related files, indicating a shift in code generation approach. Removed the `Vectorize.cs` file, indicating a change in how vector operations are handled. Updated the `.gitignore` file to include IDE-specific settings. Updated various XML files to define project components and structure. Updated the `AllocationManager.cs` to improve memory allocation management and introduce new strategies. Updated the `UnsafeArray.cs`, `UnsafeHashMap.cs`, and `UnsafeList.cs` to enhance performance and safety in unsafe contexts. Updated error handling and function pointer management in `MemoryLeakException.cs` and `FunctionPointer.cs`. Updated the `AssemblyInfo.cs` file to include global using directives for better code organization.
95 lines
2.3 KiB
C#
95 lines
2.3 KiB
C#
using Misaki.HighPerformance.Mathematics;
|
|
|
|
namespace Misaki.HighPerformance.Test.UnitTest.Mathematics;
|
|
|
|
[TestClass]
|
|
public class TestBool2
|
|
{
|
|
[TestMethod]
|
|
public void TestConstructors()
|
|
{
|
|
// Default constructor
|
|
var v1 = new bool2();
|
|
Assert.IsFalse(v1.x);
|
|
Assert.IsFalse(v1.y);
|
|
|
|
// Single value constructor
|
|
var v2 = new bool2(true);
|
|
Assert.IsTrue(v2.x);
|
|
Assert.IsTrue(v2.y);
|
|
|
|
// Component constructor
|
|
var v3 = new bool2(true, false);
|
|
Assert.IsTrue(v3.x);
|
|
Assert.IsFalse(v3.y);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestLogicalOperators()
|
|
{
|
|
var a = new bool2(true, false);
|
|
var b = new bool2(false, true);
|
|
|
|
// Note: bool types don't typically have bitwise operators in this implementation
|
|
// They are primarily used for conditional operations with math functions
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestComparisonOperators()
|
|
{
|
|
var a = new bool2(true, false);
|
|
var b = new bool2(true, false);
|
|
var c = new bool2(false, true);
|
|
|
|
// For bool vectors, we typically use math.all for equality comparison
|
|
var isEqual = math.all(a == b);
|
|
Assert.IsTrue(isEqual);
|
|
|
|
var isNotEqual = math.any(a != c);
|
|
Assert.IsTrue(isNotEqual);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestSwizzleProperties()
|
|
{
|
|
var v = new bool2(true, false);
|
|
|
|
Assert.IsTrue(v.x);
|
|
Assert.IsFalse(v.y);
|
|
|
|
var xy = v.xy;
|
|
Assert.IsTrue(xy.x);
|
|
Assert.IsFalse(xy.y);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestMathFunctions()
|
|
{
|
|
var v = new bool2(true, false);
|
|
|
|
// Test any function
|
|
var anyResult = math.any(v);
|
|
Assert.IsTrue(anyResult);
|
|
|
|
var allFalse = new bool2(false, false);
|
|
var anyFalse = math.any(allFalse);
|
|
Assert.IsFalse(anyFalse);
|
|
|
|
// Test all function
|
|
var allResult = math.all(v);
|
|
Assert.IsFalse(allResult);
|
|
|
|
var allTrue = new bool2(true, true);
|
|
var allTrueResult = math.all(allTrue);
|
|
Assert.IsTrue(allTrueResult);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestIndexer()
|
|
{
|
|
var v = new bool2(true, false);
|
|
|
|
Assert.IsTrue(v[0]);
|
|
Assert.IsFalse(v[1]);
|
|
}
|
|
} |