Commit 61a48fdd authored by Rennarde's avatar Rennarde
Browse files

Add a test to cover 27%

parent 27dbbc4f
......@@ -34,7 +34,7 @@ func UpdateCycle(Part Particle) (Particle) {
if config.General.LifeOpt[i] == "fade" {
Part.Opacity = (float64(Part.Life)/float64(config.General.NumCycle))
}
if config.General.LifeOpt[i] == "grow" && Part.Life != 0 {
if config.General.LifeOpt[i] == "grow" && Part.Life > 0 {
Part.PositionX += -0.0125
Part.ScaleX += 0.025
Part.PositionY += -0.0125
......
......@@ -3,6 +3,7 @@ package particles
import (
"testing"
"project-particles/config"
// "fmt"
)
func TestVitesseNull(t *testing.T){
......@@ -124,38 +125,28 @@ func Test_UpdateCycle_Fade(t *testing.T) {
}
}
// NOT WORKING ATM
// func Test_UpdateCycle_Grow(t *testing.T) {
// config.Get("../Extension/TestConfig.json")
// config.General.InitNumParticles = 10
// config.General.NumCycle = 5
// config.General.LifeOpt = []string {"grow"}
// config.General.ScaleX = 1
// config.General.ScaleY = 1
// config.General.WindowSizeX = 400
// config.General.WindowSizeY = 400
// config.General.SpawnX = 200
// config.General.SpawnY = 200
// config.General.RandomSpawn = false
// config.General.SpeedLimit = []float64 {0,0,0,0}
// Sys := NewSystem()
// var OldPosX,OldPosY float64
// // var OldScaleX,OldScaleY float64
// for i:=0; i < 7; i++ {
// for j:=0; j < len(Sys.Content); j++ {
// OldPosX = Sys.Content[j].PositionX
// OldPosY = Sys.Content[j].PositionY
// // OldScaleX = Sys.Content[j].ScaleX
// // OldScaleY = Sys.Content[j].ScaleY
// Sys.Content[j] = UpdateCycle(Sys.Content[j])
// if OldPosX-0.0125 != Sys.Content[j].PositionX || OldPosY-0.0125 != Sys.Content[j].PositionY {
// fmt.Println(OldPosX-0.0125,Sys.Content[j].PositionX)
// t.Fail()
// }
// // if OldScaleX+0.025 != Sys.Content[j].ScaleX || OldScaleY+0.025 != Sys.Content[j].ScaleY {
// // t.Fail()
// // }
// }
// }
// }
func Test_UpdateCycle_Grow(t *testing.T) {
config.Get("../Extension/TestConfig.json")
config.General.InitNumParticles = 1
config.General.NumCycle = 5
config.General.LifeOpt = []string {"grow"}
Sys := NewSystem()
var InvalidPos,InvalidScale,Alive bool
var OldPosX,OldPosY float64
var OldScaleX,OldScaleY float64
for i:=0; i < 7; i++ {
OldPosX,OldPosY = Sys.Content[0].PositionX,Sys.Content[0].PositionY
OldScaleX,OldScaleY = Sys.Content[0].ScaleX,Sys.Content[0].ScaleY
Sys.Content[0] = UpdateCycle(Sys.Content[0])
InvalidPos = OldPosX-0.0125 != Sys.Content[0].PositionX || OldPosY-0.0125 != Sys.Content[0].PositionY
InvalidScale = OldScaleX + 0.025 != Sys.Content[0].ScaleX || OldScaleY + 0.025 != Sys.Content[0].ScaleY
Alive = Sys.Content[0].Life > 0
if (Alive && (InvalidPos || InvalidScale)) && (!(Alive) && !(InvalidPos || InvalidScale)) {
t.Fail()
}
}
}
// func Test_Gravite(t *testing.T) {
// }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment