-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdamage_to_hero_armor_test.go
63 lines (56 loc) · 1.48 KB
/
damage_to_hero_armor_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"testing"
)
func TestDamageToArmor(t *testing.T) {
hero := Hero{
maxHealth: 100,
health: 40,
damage: 20,
armor: 47,
}
hero2 := Hero{
maxHealth: 100,
health: 40,
damage: 20,
armor: 2,
}
hero3 := Hero{
maxHealth: 100,
health: 40,
damage: 20,
armor: 0,
}
dragon := Dragon{
health: 1000,
damage: 5,
missChance: 0,
}
hero.armor, hero.health = damageToArmor(hero, dragon)
wantHeroHealth := 40
wantHeroArmor := 42
if hero.armor != wantHeroArmor {
t.Fatalf("ERROR!!! hero armor must be equal %d, but equal %d", wantHeroArmor, hero.armor)
}
if hero.health != wantHeroHealth {
t.Fatalf("ERROR!!! hero health must be equal %d, but equal %d", wantHeroHealth, hero.health)
}
hero2.armor, hero2.health = damageToArmor(hero2, dragon)
wantHeroHealth = 37
wantHeroArmor = 0
if hero2.armor != wantHeroArmor {
t.Fatalf("ERROR!!! hero armor must be equal %d, but equal %d", wantHeroArmor, hero2.armor)
}
if hero2.health != wantHeroHealth {
t.Fatalf("ERROR!!! hero health must be equal %d, but equal %d", wantHeroHealth, hero2.health)
}
hero3.armor, hero3.health = damageToArmor(hero3, dragon)
wantHeroHealth = 35
wantHeroArmor = 0
if hero3.armor != wantHeroArmor {
t.Fatalf("ERROR!!! hero armor must be equal %d, but equal %d", wantHeroArmor, hero3.armor)
}
if hero3.health != wantHeroHealth {
t.Fatalf("ERROR!!! hero health must be equal %d, but equal %d", wantHeroHealth, hero3.health)
}
}