diff options
Diffstat (limited to 'MapTests/MapParserStrategyTests.swift')
| -rw-r--r-- | MapTests/MapParserStrategyTests.swift | 163 |
1 files changed, 0 insertions, 163 deletions
diff --git a/MapTests/MapParserStrategyTests.swift b/MapTests/MapParserStrategyTests.swift deleted file mode 100644 index 7061d4d..0000000 --- a/MapTests/MapParserStrategyTests.swift +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2024 Rubén Beltrán del Río - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -import CoreGraphics -// You should have received a copy of the GNU General Public License -// along with this program. If not, see https://map.tranquil.systems. -import Testing - -@testable import Map - -struct MapParserStrategyTests { - - @Test func testVertexParserStrategyCanHandle() async throws { - let strategy = VertexParserStrategy() - - #expect(strategy.canHandle(line: "Node (10, 20)")) - #expect(strategy.canHandle(line: "NodeWithDecimals (30.5, 40.2)")) - #expect(strategy.canHandle(line: "Multi Word Node (0, 100)")) - #expect(strategy.canHandle(line: "Node C (50, 60) [square]")) - - #expect(!strategy.canHandle(line: "Node A -> Node B")) - #expect(!strategy.canHandle(line: "[Note] (10, 20) Test")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testVertexParserStrategyHandle() async throws { - let strategy = VertexParserStrategy() - let vertices: [String: Vertex] = [:] - - let (type, object) = strategy.handle(index: 0, line: "Test Node (25, 75)", vertices: vertices) - - #expect(String(describing: type) == String(describing: Vertex.self)) - let vertex = object as! Vertex - #expect(vertex.id == 0) - #expect(vertex.label == "Test Node") - #expect(vertex.position.x == 25.0) - #expect(vertex.position.y == 75.0) - #expect(vertex.shape == .circle) - } - - @Test func testVertexParserStrategyHandleWithShape() async throws { - let strategy = VertexParserStrategy() - let vertices: [String: Vertex] = [:] - - let (type, object) = strategy.handle( - index: 1, line: "Shaped Node (10, 20) [triangle]", vertices: vertices) - - #expect(String(describing: type) == String(describing: Vertex.self)) - let vertex = object as! Vertex - #expect(vertex.shape == .triangle) - } - - @Test func testEdgeParserStrategyCanHandle() async throws { - let strategy = EdgeParserStrategy() - - #expect(strategy.canHandle(line: "Node A -- Node B")) - #expect(strategy.canHandle(line: "Node A -> Node B")) - #expect(strategy.canHandle(line: "Multi Word A -> Multi Word B")) - - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "[Note] (10, 20) Test")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testEdgeParserStrategyHandle() async throws { - let strategy = EdgeParserStrategy() - let vertices: [String: Vertex] = [ - "Node A": Vertex(id: 0, label: "Node A", position: CGPoint(x: 10, y: 20)), - "Node B": Vertex(id: 1, label: "Node B", position: CGPoint(x: 30, y: 40)), - ] - - let (type, object) = strategy.handle(index: 2, line: "Node A -> Node B", vertices: vertices) - - #expect(String(describing: type) == String(describing: MapEdge.self)) - let edge = object as! MapEdge - #expect(edge.id == 2) - #expect(edge.origin.x == 10.0) - #expect(edge.origin.y == 20.0) - #expect(edge.destination.x == 30.0) - #expect(edge.destination.y == 40.0) - #expect(edge.arrowhead == true) - } - - @Test func testEdgeParserStrategyHandleWithMissingVertex() async throws { - let strategy = EdgeParserStrategy() - let vertices: [String: Vertex] = [ - "Node A": Vertex(id: 0, label: "Node A", position: CGPoint(x: 10, y: 20)) - ] - - let (type, object) = strategy.handle(index: 2, line: "Node A -> Node B", vertices: vertices) - - #expect(String(describing: type) == String(describing: NSObject.self)) - #expect(object is NSObject) - } - - @Test func testNoteParserStrategyCanHandle() async throws { - let strategy = NoteParserStrategy() - - #expect(strategy.canHandle(line: "[Note] (10, 20) Test note")) - #expect(strategy.canHandle(line: "[Note] (50.5, 60.2) Multi word note")) - - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "Node A -> Node B")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testInertiaParserStrategyCanHandle() async throws { - let strategy = InertiaParserStrategy() - - #expect(strategy.canHandle(line: "[Indertia] Node A")) - #expect(strategy.canHandle(line: "[Inertia] Multi Word Node")) - - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "[Note] (10, 20) Test")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testOpportunityParserStrategyCanHandle() async throws { - let strategy = OpportunityParserStrategy() - - #expect(strategy.canHandle(line: "[Evolution] Node A +15")) - #expect(strategy.canHandle(line: "[Evolution] Node B -10")) - #expect(strategy.canHandle(line: "[Evolution] Multi Word Node +5.5")) - - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "[Inertia] Node A")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testStageParserStrategyCanHandle() async throws { - let strategy = StageParserStrategy() - - #expect(strategy.canHandle(line: "[I] 25")) - #expect(strategy.canHandle(line: "[II] 50.5")) - #expect(strategy.canHandle(line: "[III] 75")) - - #expect(!strategy.canHandle(line: "[IV] 100")) - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - - @Test func testGroupParserStrategyCanHandle() async throws { - let strategy = GroupParserStrategy() - - #expect(strategy.canHandle(line: "[Group] Node A, Node B")) - #expect(strategy.canHandle(line: "[Group] Node A, Node B, Node C")) - #expect(strategy.canHandle(line: "[Group] Multi Word A, Multi Word B")) - - #expect(!strategy.canHandle(line: "Node A (10, 20)")) - #expect(!strategy.canHandle(line: "[Note] (10, 20) Test")) - #expect(!strategy.canHandle(line: "Invalid line")) - } - -} |