@@ -2,7 +2,6 @@ package volt
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/stretchr/testify/assert"
6
5
"testing"
7
6
)
8
7
@@ -17,10 +16,15 @@ func TestWorld_CreateEntity(t *testing.T) {
17
16
}
18
17
19
18
// Check if the entities all exist in the world
20
- assert .True (t , len (world .Entities ) == TEST_ENTITY_NUMBER )
19
+ if len (world .Entities ) != TEST_ENTITY_NUMBER {
20
+ t .Errorf ("Number of entities created invalid" )
21
+ }
21
22
for i := 0 ; i < TEST_ENTITY_NUMBER ; i ++ {
22
23
_ , ok := world.Entities [entities [i ]]
23
- assert .True (t , ok )
24
+
25
+ if ! ok {
26
+ t .Errorf ("Entity %d was not created properly" , entities [i ])
27
+ }
24
28
}
25
29
}
26
30
@@ -36,11 +40,17 @@ func TestWorld_RemoveEntity(t *testing.T) {
36
40
world .RemoveEntity (entities [TEST_ENTITY_NUMBER / 2 ])
37
41
world .RemoveEntity (entities [TEST_ENTITY_NUMBER - 1 ])
38
42
39
- // Check if the entities all exist in the world
40
- assert .True (t , len (world .Entities ) == (TEST_ENTITY_NUMBER - 3 ))
41
- assert .True (t , world .SearchEntity (fmt .Sprint (0 )) == 0 )
42
- assert .True (t , world .SearchEntity (fmt .Sprint (TEST_ENTITY_NUMBER / 2 )) == 0 )
43
- assert .True (t , world .SearchEntity (fmt .Sprint (TEST_ENTITY_NUMBER - 1 )) == 0 )
43
+ // Check the expected world size
44
+ if len (world .Entities ) != (TEST_ENTITY_NUMBER - 3 ) {
45
+ t .Errorf ("World size not valid after removal of entities" )
46
+ }
47
+
48
+ // Check if the entities are correctly removed of the world
49
+ for _ , id := range []EntityId {0 , TEST_ENTITY_NUMBER / 2 , TEST_ENTITY_NUMBER - 1 } {
50
+ if world .SearchEntity (fmt .Sprint (0 )) != 0 {
51
+ t .Errorf ("Entity %d was not removed" , entities [id ])
52
+ }
53
+ }
44
54
}
45
55
46
56
func TestWorld_SearchEntity (t * testing.T ) {
@@ -53,11 +63,15 @@ func TestWorld_SearchEntity(t *testing.T) {
53
63
54
64
// Test searching for existing entities
55
65
for entityName , entityId := range entities {
56
- assert .Equal (t , entityId , world .SearchEntity (fmt .Sprint (entityName )))
66
+ if entityId != world .SearchEntity (fmt .Sprint (entityName )) {
67
+ t .Errorf ("SearchEntity does not return correct entityId for %s" , fmt .Sprint (entityName ))
68
+ }
57
69
}
58
70
59
71
// Test searching for a non-existing entity
60
- assert .Zero (t , world .SearchEntity ("nonexistent" ))
72
+ if id := world .SearchEntity ("nonexistent" ); id != 0 {
73
+ t .Errorf ("world.SearchEntity returned id %d for a non existent entity" , id )
74
+ }
61
75
}
62
76
63
77
func TestWorld_GetEntityName (t * testing.T ) {
@@ -70,9 +84,13 @@ func TestWorld_GetEntityName(t *testing.T) {
70
84
71
85
// Test the names for each entity
72
86
for entityName , entityId := range entities {
73
- assert .Equal (t , fmt .Sprint (entityName ), world .GetEntityName (entityId ))
87
+ if fmt .Sprint (entityName ) != world .GetEntityName (entityId ) {
88
+ t .Errorf ("world.GetEntityName does not return correct value for id %d" , entityId )
89
+ }
74
90
}
75
91
76
92
// Test if none entity return an empty name
77
- assert .Empty (t , world .GetEntityName (0 ))
93
+ if world .GetEntityName (0 ) != "" {
94
+ t .Errorf ("world.GetEntityName does not return empty string for entityId 0" )
95
+ }
78
96
}
0 commit comments