Add tests for scene graph implementation
This commit is contained in:
parent
f312f9335e
commit
f99f171a15
|
|
@ -65,7 +65,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = entity
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -81,7 +81,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
.forEach { (position: Position) in
|
||||
_ = position
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, numEntities * 10)
|
||||
|
|
@ -103,7 +103,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = position
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -127,7 +127,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = position
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -150,7 +150,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = velocity
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -175,7 +175,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = velocity
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -199,7 +199,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = name
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -225,7 +225,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = name
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -250,7 +250,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = color
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -277,7 +277,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = color
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
@ -330,7 +330,7 @@ class TypedFamilyPerformanceTests: XCTestCase {
|
|||
_ = empty
|
||||
|
||||
loopCount += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(loopCount, family.count * 10)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class ColorSystem {
|
|||
color.r = 1
|
||||
color.g = 2
|
||||
color.b = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,6 +106,6 @@ class PositionSystem {
|
|||
|
||||
pos.x = x
|
||||
pos.y = y
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class EntityTests: XCTestCase {
|
|||
XCTAssertEqual(max, EntityIdentifier.invalid)
|
||||
XCTAssertEqual(max.index, Int(UInt32.max))
|
||||
}
|
||||
|
||||
|
||||
func testEntityIdentifierComparison() {
|
||||
XCTAssertTrue(EntityIdentifier(1) < EntityIdentifier(2))
|
||||
XCTAssertTrue(EntityIdentifier(23) > EntityIdentifier(4))
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class FamilyTests: XCTestCase {
|
|||
.forEach { (entity: Entity, _: Position) in
|
||||
entity.assign(Velocity(a: 3.14))
|
||||
entity.remove(Position.self)
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(familyA.count, 0)
|
||||
XCTAssertEqual(familyB.count, 10)
|
||||
|
|
@ -130,7 +130,7 @@ class FamilyTests: XCTestCase {
|
|||
.forEach { (entity: Entity, velocity: Velocity) in
|
||||
entity.assign(Position(x: 1, y: 2))
|
||||
entity.remove(velocity)
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(familyA.count, 10)
|
||||
XCTAssertEqual(familyB.count, 0)
|
||||
|
|
@ -175,7 +175,7 @@ class FamilyTests: XCTestCase {
|
|||
.prefix(currentCount)
|
||||
.forEach { (entity: Entity) in
|
||||
entity.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
XCTAssertEqual(family.memberIds.count, (count / 2))
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import FirebladeECS
|
|||
class SceneGraphTests: XCTestCase {
|
||||
|
||||
var nexus: Nexus!
|
||||
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
nexus = Nexus()
|
||||
|
|
@ -22,35 +22,57 @@ class SceneGraphTests: XCTestCase {
|
|||
nexus = nil
|
||||
}
|
||||
|
||||
func testParent() {
|
||||
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 testDescendRelatives() {
|
||||
let nttParrent = nexus.createEntity(with: Position(x: 1, y: 1))
|
||||
|
||||
let nttChild1 = nexus.createEntity(with: Position(x: 2, y: 2))
|
||||
let nttChild2 = nexus.createEntity(with: Position(x: 3, y: 3))
|
||||
|
||||
|
||||
nttParrent.addChild(nttChild1)
|
||||
nttParrent.removeChild(nttChild1)
|
||||
nttParrent.addChild(nttChild1)
|
||||
|
||||
|
||||
let family = nexus.family(requires: Position.self)
|
||||
|
||||
|
||||
|
||||
family
|
||||
.descendRelatives.forEach { (parent: Position, child: Position) in
|
||||
|
||||
.descendRelatives.forEach { (_: Position, _: Position) in
|
||||
// TODO:
|
||||
}
|
||||
|
||||
let family2 = nexus.family(requiresAll: Position.self, Name.self)
|
||||
|
||||
family2
|
||||
.descendRelatives
|
||||
.forEach { (parent, child) in
|
||||
let (pPos, pName) = parent
|
||||
let (cPos, cName) = child
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,6 @@ class SystemsTests: XCTestCase {
|
|||
.prefix(count)
|
||||
.forEach { (entity: Entity) in
|
||||
entity.destroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ extension EntityTests {
|
|||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__EntityTests = [
|
||||
("testEntityIdentifierAndIndex", testEntityIdentifierAndIndex)
|
||||
("testEntityIdentifierAndIndex", testEntityIdentifierAndIndex),
|
||||
("testEntityIdentifierComparison", testEntityIdentifierComparison)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +68,18 @@ extension NexusTests {
|
|||
]
|
||||
}
|
||||
|
||||
extension SceneGraphTests {
|
||||
// DO NOT MODIFY: This is autogenerated, use:
|
||||
// `swift test --generate-linuxmain`
|
||||
// to regenerate.
|
||||
static let __allTests__SceneGraphTests = [
|
||||
("testAddChild", testAddChild),
|
||||
("testDescendRelatives", testDescendRelatives),
|
||||
("testRemoveAllChildren", testRemoveAllChildren),
|
||||
("testRemoveChild", testRemoveChild)
|
||||
]
|
||||
}
|
||||
|
||||
extension SingleTests {
|
||||
// DO NOT MODIFY: This is autogenerated, use:
|
||||
// `swift test --generate-linuxmain`
|
||||
|
|
@ -116,6 +129,7 @@ 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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue