Nantes Université

Skip to content
Extraits de code Groupes Projets
Decrease_Opacity_test.go 1,49 ko
Newer Older
  • Learn to ignore specific revisions
  • Clovis_Leport's avatar
    Clovis_Leport a validé
    package particles
    
    import (
    	"project-particles/config"
    	"testing"
    )
    
    // Test fonction decrease de 1 par 1
    func Test_Decrease_by_1(t *testing.T) {
    	config.General.Opacity_Increment = 1
    	p1 := Particle{
    		PositionX: 0,
    		PositionY: 0,
    
    		SpeedX: 1,
    		SpeedY: 1,
    
    		ScaleX: 1, ScaleY: 1,
    		ColorRed: 1, ColorGreen: 1, ColorBlue: 1,
    		Opacity: 1,
    	}
    	previous_opacity := p1.Opacity
    	Decrease_Opacity(&p1)
    	if p1.Opacity != previous_opacity-1 {
    		t.Error("L'opacité n'est pas correctement mise à jour, différence :", previous_opacity-p1.Opacity)
    	}
    }
    
    // Test fonction decrease de 5 par 5
    func Test_Decrease_by_5(t *testing.T) {
    	config.General.Opacity_Increment = 5
    	p1 := Particle{
    		PositionX: 0,
    		PositionY: 0,
    
    		SpeedX: 1,
    		SpeedY: 1,
    
    		ScaleX: 1, ScaleY: 1,
    		ColorRed: 1, ColorGreen: 1, ColorBlue: 1,
    		Opacity: 1,
    	}
    	previous_opacity := p1.Opacity
    	Decrease_Opacity(&p1)
    	if p1.Opacity != previous_opacity-5 {
    		t.Error("L'opacité n'est pas correctement mise à jour, différence :", previous_opacity-p1.Opacity)
    	}
    }
    
    // Test fonction decrease de -1 par -1
    func Test_Decrease_by_Negative_1(t *testing.T) {
    	config.General.Opacity_Increment = -1
    	p1 := Particle{
    		PositionX: 0,
    		PositionY: 0,
    
    		SpeedX: 1,
    		SpeedY: 1,
    
    		ScaleX: 1, ScaleY: 1,
    		ColorRed: 1, ColorGreen: 1, ColorBlue: 1,
    		Opacity: 1,
    	}
    	previous_opacity := p1.Opacity
    	Decrease_Opacity(&p1)
    	if p1.Opacity != previous_opacity+1 {
    		t.Error("L'opacité n'est pas correctement mise à jour, différence :", previous_opacity-p1.Opacity)
    	}
    }