优化位掩码工具的输出格式
- 十六进制不再输出无意义的前导0符号 - 修正部分测试单元检测逻辑
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
ComponentRegistry,
|
||||
ComponentStorage,
|
||||
ComponentStorageManager,
|
||||
ComponentType
|
||||
} from '../../../src/ECS/Core/ComponentStorage';
|
||||
import { ComponentRegistry, ComponentStorage, ComponentStorageManager } from '../../../src/ECS/Core/ComponentStorage';
|
||||
import { Component } from '../../../src/ECS/Component';
|
||||
import { BitMask64Utils } from '../../../src/ECS/Utils/BigIntCompatibility';
|
||||
|
||||
@@ -104,8 +99,8 @@ describe('ComponentRegistry - 组件注册表测试', () => {
|
||||
const mask1 = ComponentRegistry.getBitMask(TestComponent);
|
||||
const mask2 = ComponentRegistry.getBitMask(PositionComponent);
|
||||
|
||||
expect(mask1.lo).toBe(1); // 2^0
|
||||
expect(mask2.lo).toBe(2); // 2^1
|
||||
expect(BitMask64Utils.getBit(mask1,0)).toBe(true); // 2^0
|
||||
expect(BitMask64Utils.getBit(mask2,1)).toBe(true); // 2^1
|
||||
});
|
||||
|
||||
test('应该能够获取组件的位索引', () => {
|
||||
@@ -471,7 +466,7 @@ describe('ComponentStorageManager - 组件存储管理器测试', () => {
|
||||
const mask = manager.getComponentMask(1);
|
||||
|
||||
// 应该包含TestComponent(位0)和PositionComponent(位1)的掩码
|
||||
expect(mask.lo).toBe(3); // 1 | 2 = 3
|
||||
expect(BitMask64Utils.getBit(mask,0) && BitMask64Utils.getBit(mask,1)).toBe(true);
|
||||
});
|
||||
|
||||
test('没有组件的实体应该有零掩码', () => {
|
||||
@@ -485,15 +480,15 @@ describe('ComponentStorageManager - 组件存储管理器测试', () => {
|
||||
|
||||
manager.addComponent(1, new TestComponent(100));
|
||||
let mask = manager.getComponentMask(1);
|
||||
expect(mask.lo).toBe(1);
|
||||
expect(BitMask64Utils.getBit(mask,0)).toBe(true);
|
||||
|
||||
manager.addComponent(1, new PositionComponent(10, 20));
|
||||
mask = manager.getComponentMask(1);
|
||||
expect(mask.lo).toBe(3); // 0b11
|
||||
expect(BitMask64Utils.getBit(mask,1)).toBe(true); // 0b11
|
||||
|
||||
manager.removeComponent(1, TestComponent);
|
||||
mask = manager.getComponentMask(1);
|
||||
expect(mask.lo).toBe(2); // 0b10
|
||||
expect(BitMask64Utils.getBit(mask,0)).toBe(false); // 0b10
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user