cg85-v2/Tests/Np85SnakeTests/VertexTests.swift

61 lines
1.1 KiB
Swift

import Testing
@testable import Np85Snake
struct VertexTest {
@Test func initTest() async throws {
let vertex = Vertex(1, 2)
#expect(vertex.x == 1)
#expect(vertex.y == 2)
}
@Test func addTest() async throws {
let vertex: Vertex = Vertex(1, 2)
let add = vertex + vertex
#expect(add.x == 2)
#expect(add.y == 4)
}
@Test func subTest() async throws {
let vertex: Vertex = Vertex(1, 2)
let sub = vertex - Vertex(2, 1)
#expect(sub.x == -1)
#expect(sub.y == 1)
}
@Test func mulTest() async throws {
let vertex = Vertex(1, 2)
let mul = vertex * 4
#expect(mul.x == 4)
#expect(mul.y == 8)
}
@Test func divTest() async throws {
let vertex = Vertex(2, 4)
let mul = vertex / 2
#expect(mul.x == 1)
#expect(mul.y == 2)
}
@Test func modTest() async throws {
let vertex = Vertex(4, 8)
let mod = vertex % Vertex(2, 3)
#expect(mod.x == 0)
#expect(mod.y == 2)
}
@Test func negModTest() async throws {
let vertex = Vertex(-1, -1)
let mod = vertex % Vertex(2, 3)
#expect(mod.x == 1)
#expect(mod.y == 2)
}
}