Remove obsolete relatives tests

This commit is contained in:
Christian Treffs 2020-08-06 15:53:27 +02:00
parent ae283feab4
commit aeab748362
No known key found for this signature in database
GPG Key ID: 49A4B4B460BE3ED4
2 changed files with 0 additions and 146 deletions

View File

@ -1,132 +0,0 @@
//
// SceneGraphTests.swift
// FirebladeECSTests
//
// Created by Christian Treffs on 30.09.19.
//
import FirebladeECS
import XCTest
@available(*, deprecated, message: "This will be removed in the next minor update.")
class SceneGraphTests: XCTestCase {
var nexus: Nexus!
override func setUp() {
super.setUp()
nexus = Nexus()
}
override func tearDown() {
super.tearDown()
nexus = nil
}
func testAddChild() {
let nttParrent = nexus.createEntity()
let nttChild1 = nexus.createEntity()
XCTAssertEqual(nttParrent.numChildren, 0)
XCTAssertTrue(nttParrent.addChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 1)
XCTAssertFalse(nttParrent.addChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 1)
}
func testRemoveChild() {
let nttParrent = nexus.createEntity()
let nttChild1 = nexus.createEntity()
XCTAssertEqual(nttParrent.numChildren, 0)
XCTAssertTrue(nttParrent.addChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 1)
XCTAssertTrue(nttParrent.removeChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 0)
XCTAssertFalse(nttParrent.removeChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 0)
XCTAssertTrue(nttParrent.addChild(nttChild1))
XCTAssertEqual(nttParrent.numChildren, 1)
}
func testRemoveAllChildren() {
let nttParrent = nexus.createEntity()
let nttChild1 = nexus.createEntity()
let nttChild2 = nexus.createEntity()
XCTAssertEqual(nttParrent.numChildren, 0)
nttParrent.addChild(nttChild1)
nttParrent.addChild(nttChild2)
XCTAssertEqual(nttParrent.numChildren, 2)
nttParrent.removeAllChildren()
XCTAssertEqual(nttParrent.numChildren, 0)
}
func testDescendRelativesSimple() {
let nttParrent = nexus.createEntity(with: Position(x: 1, y: 1))
let child1Pos = Position(x: 2, y: 2)
let nttChild1 = nexus.createEntity(with: child1Pos)
nttParrent.addChild(nttChild1)
let family = nexus.family(requires: Position.self)
var counter: Int = 0
XCTAssertEqual(child1Pos.x, 2)
XCTAssertEqual(child1Pos.y, 2)
family
.descendRelatives(from: nttParrent)
.forEach { (parent: Position, child: Position) in
defer { counter += 1 }
child.x += parent.x
child.y += parent.y
}
XCTAssertEqual(counter, 1)
XCTAssertEqual(child1Pos.x, 3)
XCTAssertEqual(child1Pos.y, 3)
}
func testDescendRelativesOnlyFamilyMembers() {
let otherComponents: [Component] = [Position(x: 0, y: 0), Velocity(a: 0), Party(partying: true), Color(), Name(name: "")]
func addChild(to parent: Entity, index: Int) -> Entity {
let randComp = otherComponents.randomElement()!
let badChild = nexus.createEntity(with: randComp)
let child = nexus.createEntity(with: Index(index: index))
parent.addChild(child)
parent.addChild(badChild)
return child
}
let root = nexus.createEntity(with: Index(index: 0))
var parent: Entity = root
for i in 1..<10 {
parent = addChild(to: parent, index: i)
}
XCTAssertEqual(nexus.numEntities, 19)
var parentSum: Int = 0
var childSum: Int = 0
var lastIndex: Int = -1
nexus
.family(requires: Index.self)
.descendRelatives(from: root)
.forEach { (parent: Index, child: Index) in
XCTAssertEqual(parent.index + 1, child.index)
XCTAssertGreaterThan(parent.index, lastIndex)
lastIndex = parent.index
parentSum += parent.index
childSum += child.index
}
XCTAssertEqual(parentSum, 36)
XCTAssertEqual(childSum, 45)
}
}

View File

@ -235,19 +235,6 @@ extension NexusTests {
]
}
extension SceneGraphTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
// to regenerate.
static let __allTests__SceneGraphTests = [
("testAddChild", testAddChild),
("testDescendRelativesOnlyFamilyMembers", testDescendRelativesOnlyFamilyMembers),
("testDescendRelativesSimple", testDescendRelativesSimple),
("testRemoveAllChildren", testRemoveAllChildren),
("testRemoveChild", testRemoveChild)
]
}
extension SingleTests {
// DO NOT MODIFY: This is autogenerated, use:
// `swift test --generate-linuxmain`
@ -310,7 +297,6 @@ public func __allTests() -> [XCTestCaseEntry] {
testCase(FamilyTraitsTests.__allTests__FamilyTraitsTests),
testCase(HashingTests.__allTests__HashingTests),
testCase(NexusTests.__allTests__NexusTests),
testCase(SceneGraphTests.__allTests__SceneGraphTests),
testCase(SingleTests.__allTests__SingleTests),
testCase(SparseSetTests.__allTests__SparseSetTests),
testCase(SystemsTests.__allTests__SystemsTests)