Commit a7e447a2 authored by Rennarde's avatar Rennarde
Browse files

Remake test tree

parent f9e8e9e2
{
"WindowTitle": "Default",
"WindowTitle": "test",
"WindowSizeX": 800,
"WindowSizeY": 600,
"WindowSizeY": 800,
"ParticleImage": "assets/particle.png",
"Debug": true,
"InitNumParticles": 100000,
"RandomSpawn": true,
"InitNumParticles": 0,
"RandomSpawn": false,
"SpawnX": 400,
"SpawnY": 400,
"SpawnRate": 0,
"SpeedLimit": [0,0,0,0],
"Colors": [0,1,0,1,0,1]
}
"Colors": [1,1,1,1,1,1],
"Gravity": false,
"GravityCenter": false,
"NumCycle": 0,
"LifeOpt": [""]
}
\ No newline at end of file
package particles
import (
"testing"
"project-particles/config"
"testing"
"project-particles/config"
)
func TestVitesseNull(t *testing.T){
config.Get("../config.json")
config.General.SpawnRate = 0
tab := []float64{0,0,0,0}
config.General.SpeedLimit = tab
var SystemTest System = NewSystem()
for i:=0; i<len(SystemTest.Content)-1;i++{
PosX1 := SystemTest.Content[i].PositionX
PosY1 := SystemTest.Content[i].PositionY
SystemTest.Update()
if SystemTest.Content[i].PositionX != PosX1 || SystemTest.Content[i].PositionY != PosY1{
t.Fail()
}
}
func TestVide(t *testing.T) {
config.Get("../Extension/TestConfig.json")
config.General.InitNumParticles = 0
Systemtest := NewSystem()
if Systemtest.Content != nil{
t.Fail()
}
}
func TestNombre(t *testing.T) {
config.Get("../Extension/TestConfig.json")
config.General.InitNumParticles = 10
Systemtest := NewSystem()
if len(Systemtest.Content) != 10 {
t.Fail()
}
}
func TestVitesse(t *testing.T){
config.Get("../config.json")
config.General.SpawnRate = 0
var SystemTest System = NewSystem()
for i:=0; i<len(SystemTest.Content)-1;i++{
PosX1 := SystemTest.Content[i].PositionX
PosY1 := SystemTest.Content[i].PositionY
SystemTest.Update()
if SystemTest.Content[i].PositionX != PosX1 + SystemTest.Content[i].SpeedX || SystemTest.Content[i].PositionY != PosY1 + SystemTest.Content[i].SpeedY{
t.Fail()
}
}
func TestPositionNonAleatoire(t *testing.T){
config.Get("../Extension/TestConfig.json")
config.General.InitNumParticles = 10
config.General.SpawnX = 400
config.General.SpawnY = 400
config.General.RandomSpawn = false
S := NewSystem()
for i:= 0; i< len(S.Content); i++{
if S.Content[i].PositionX != 400 || S.Content[i].PositionY != 400 {
t.Fail()
}
}
}
func TestPositionAleatoireOOB(t *testing.T){
config.Get("../Extension/TestConfig.json")
config.General.RandomSpawn = true
for i:=0 ; i <len(NewSystem().Content);i++{
if NewSystem().Content[i].PositionX > float64(config.General.WindowSizeX) || NewSystem().Content[i].PositionX < 0 || NewSystem().Content[i].PositionY > float64(config.General.WindowSizeY) || NewSystem().Content[i].PositionY <0{
t.Fail()
}
}
}
func Test_Postition_Aléatoire_Plausibilite(t *testing.T) {
config.Get("../Extension/TestConfig.json")
}
\ 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