Add more tests
This commit is contained in:
parent
8da21ec110
commit
170ee14db8
|
|
@ -12,8 +12,8 @@ internal final class EntityIdentifierGenerator {
|
|||
stack.count
|
||||
}
|
||||
|
||||
init() {
|
||||
stack = [0]
|
||||
convenience init() {
|
||||
self.init([EntityIdentifier(0)])
|
||||
}
|
||||
|
||||
init(_ entityIds: [EntityIdentifier]) {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ class EntityTests: XCTestCase {
|
|||
|
||||
let entity = nexus.createEntity()
|
||||
entity.assign(pos)
|
||||
entity.assign(name)
|
||||
entity.assign(vel)
|
||||
entity.assign(name, vel)
|
||||
|
||||
let expectedComponents: [Component] = [pos, name, vel]
|
||||
let allComponents = entity.allComponents()
|
||||
|
|
@ -40,6 +39,25 @@ class EntityTests: XCTestCase {
|
|||
XCTAssertTrue(allComponents.elementsEqualUnordered(expectedComponents) { $0 === $1 })
|
||||
}
|
||||
|
||||
func testEntityEquality() {
|
||||
let nexus = Nexus()
|
||||
|
||||
let entityA = nexus.createEntity()
|
||||
let entityB = nexus.createEntity()
|
||||
|
||||
XCTAssertEqual(entityA, entityA)
|
||||
XCTAssertNotEqual(entityA, entityB)
|
||||
}
|
||||
|
||||
func testRemoveAllComponentsFromEntity() {
|
||||
let nexus = Nexus()
|
||||
|
||||
let entity = nexus.createEntity(with: Position(x: 1, y: 2), Name(name: "MyEntity"))
|
||||
XCTAssertEqual(entity.numComponents, 2)
|
||||
entity.removeAll()
|
||||
XCTAssertEqual(entity.numComponents, 0)
|
||||
}
|
||||
|
||||
func testEntityIdGenerator() {
|
||||
let generator = EntityIdentifierGenerator()
|
||||
|
||||
|
|
|
|||
|
|
@ -26,8 +26,10 @@ extension EntityTests {
|
|||
// to regenerate.
|
||||
static let __allTests__EntityTests = [
|
||||
("testAllComponentsOfEntity", testAllComponentsOfEntity),
|
||||
("testEntityEquality", testEntityEquality),
|
||||
("testEntityIdentifierAndIndex", testEntityIdentifierAndIndex),
|
||||
("testEntityIdGenerator", testEntityIdGenerator)
|
||||
("testEntityIdGenerator", testEntityIdGenerator),
|
||||
("testRemoveAllComponentsFromEntity", testRemoveAllComponentsFromEntity)
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue