go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/experiments/huectl/pkg/hue/color_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2023 - Present. Will Charczuk. All rights reserved.
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository.
     5  
     6  */
     7  
     8  package hue
     9  
    10  import (
    11  	"fmt"
    12  	"math"
    13  	"testing"
    14  
    15  	"go.charczuk.com/sdk/assert"
    16  )
    17  
    18  func Test_Color_XY_blue(t *testing.T) {
    19  	c := Color{B: 255, A: 255}
    20  
    21  	x := c.XY(GamutC)
    22  
    23  	expectedX, expectedY := 0.135, 0.048
    24  
    25  	assert.ItsEqual(t, 2, len(x))
    26  	assert.ItsEqual(t, true, math.Abs(expectedX-float64(x[0])) < 0.001, fmt.Sprintf("%v vs. %v", expectedX, x[0]))
    27  	assert.ItsEqual(t, true, math.Abs(expectedY-float64(x[1])) < 0.001, fmt.Sprintf("%v vs. %v", expectedY, x[1]))
    28  }