开发:增加测试用例

pull/1906/MERGE
ChenX 2 years ago
parent 12f34053ed
commit 8ff9d6b0e1

@ -0,0 +1,30 @@
import { RoomWallBase } from "../../src/DatabaseServices/Room/Entity/Wall/RoomWallBase";
import { RoomWallRemoveDuplicate } from "../../src/DatabaseServices/Room/ParseService/RoomWallRemoveDuplicate";
import "../Utils/jest.util";
import { LoadEntityFromFileData } from "../Utils/LoadEntity.util";
test('简单的墙体删除重复', () =>
{
let d1 =
{ "file": [4, "RoomWallLine", 1, 3, 8, 2, 116, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 0, 2000, 0, 0, 0, 0, "RoomWallLine", 1, 3, 8, 2, 117, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 0, 0, 0, 2000, 0, 0, "RoomWallLine", 1, 3, 8, 2, 118, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 2000, 0, 0, 2000, 2000, 0, "RoomWallLine", 1, 3, 8, 2, 119, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 2000, 2000, 0, 0, 2000, 0], "basePt": { "x": -60, "y": -60, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let d2 =
{ "file": [4, "RoomWallLine", 1, 3, 8, 2, 126, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 1300, 0, 0, 1300, 1000, 0, "RoomWallLine", 1, 3, 8, 2, 127, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 1300, 1000, 0, 300, 1000, 0, "RoomWallLine", 1, 3, 8, 2, 124, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 300, 1000, 0, 300, 0, 0, "RoomWallLine", 1, 3, 8, 2, 125, false, 1, 7, 0, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 0, true, [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], 0, 120, 0, 2700, 300, 0, 0, 1300, 0, 0], "basePt": { "x": 240, "y": -60, "z": 0 }, "ucs": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1] };
let walls1 = LoadEntityFromFileData<RoomWallBase>(d1);
let walls2 = LoadEntityFromFileData<RoomWallBase>(d2);
let rrd = new RoomWallRemoveDuplicate(walls1, walls2);
expect(rrd.SplitWalls.length).toMatchSnapshot();
for (let w of rrd.SplitWalls)
expect(w.Length).toMatchNumberSnapshot();
walls1 = LoadEntityFromFileData<RoomWallBase>(d1);
walls2 = LoadEntityFromFileData<RoomWallBase>(d2);
let rrd2 = new RoomWallRemoveDuplicate(walls2, walls1);
expect(rrd2.SplitWalls.length).toMatchSnapshot();
for (let w of rrd2.SplitWalls)
expect(w.Length).toMatchNumberSnapshot();
});

@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`简单的墙体删除重复 1`] = `5`;
exports[`简单的墙体删除重复 2`] = `"300.00000"`;
exports[`简单的墙体删除重复 3`] = `"700.00000"`;
exports[`简单的墙体删除重复 4`] = `"2000.00000"`;
exports[`简单的墙体删除重复 5`] = `"2000.00000"`;
exports[`简单的墙体删除重复 6`] = `"2000.00000"`;
exports[`简单的墙体删除重复 7`] = `3`;
exports[`简单的墙体删除重复 8`] = `"1000.00000"`;
exports[`简单的墙体删除重复 9`] = `"1000.00000"`;
exports[`简单的墙体删除重复 10`] = `"1000.00000"`;

@ -5,7 +5,7 @@ import { Log } from "../../Common/Log";
import { RoomWallBase } from "../../DatabaseServices/Room/Entity/Wall/RoomWallBase";
import { RoomWallLine } from "../../DatabaseServices/Room/Entity/Wall/RoomWallLine";
import { WallSnapMode } from "../../DatabaseServices/Room/Entity/Wall/WallSnapMode";
import { RoomParse } from "../../DatabaseServices/Room/ParseService/RoomParseUtil";
import { GetAllWalls, RoomParse } from "../../DatabaseServices/Room/ParseService/RoomParseUtil";
import { RoomWallParse } from "../../DatabaseServices/Room/ParseService/RoomWallParse";
import { RoomWallRemoveDuplicate } from "../../DatabaseServices/Room/ParseService/RoomWallRemoveDuplicate";
import { Command } from "../../Editor/CommandMachine";
@ -107,7 +107,7 @@ export class Command_DrawRectWall implements Command
{
UpdateDraw(rectRes.Point1UCS, rectRes.Point2UCS, false);
let rrd = new RoomWallRemoveDuplicate(walls);//删除重复
let rrd = new RoomWallRemoveDuplicate(walls, GetAllWalls());//删除重复
for (let wall of rrd.SplitWalls)
{

@ -10,7 +10,6 @@ import { RoomWallLine } from "../Entity/Wall/RoomWallLine";
import { CreateCurveTrim, CurveTrim } from "./CurveTrim";
import { CreateGetCurveParam, GetCurveParam } from './GetCurveParam';
import { Intersection } from './RangeUtils';
import { GetAllWalls } from "./RoomParseUtil";
/**
@ -24,7 +23,7 @@ export class RoomWallRemoveDuplicate
* @param diffWalls
* @param [walls=GetAllWalls()]
*/
constructor(diffWalls: RoomWallBase[], walls: RoomWallBase[] = GetAllWalls())
constructor(diffWalls: RoomWallBase[], walls: RoomWallBase[])
{
let diffSet = new Set(diffWalls);
walls = walls.filter(w => !diffSet.has(w));

Loading…
Cancel
Save