mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
* refactor(workflows): Improve GitHub Action workflows * bump go version to 1.24 * set coverage report baseline to correct workflow * nit: keep same * require older go version * let semantic-prs write to PR * let semantic-prs write to PR * bump go version to 1.24 * bump dependencies --------- Co-authored-by: Cedric Kienzler <cedric@specht-labs.de>
36 lines
735 B
Go
36 lines
735 B
Go
//go:build !tinygo
|
|
|
|
package smartfanunit
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestFloat32ToAndFrom24Bit(t *testing.T) {
|
|
tests := []struct {
|
|
input float32
|
|
expected float32
|
|
}{
|
|
{0.0, 0.0},
|
|
{1.0, 1.0},
|
|
{0.123, 0.1},
|
|
{10.0, 10.0},
|
|
{100.0, 100.0},
|
|
{1677721.5, 1677721.5},
|
|
{2000000.0, 1677721.5}, // Should be capped at 0xFFFFFF
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(fmt.Sprintf("Input: %f", test.input), func(t *testing.T) {
|
|
data := float32To24Bit(test.input)
|
|
result := float32From24Bit(data)
|
|
|
|
// Check if the result is approximately equal within a small delta
|
|
if result < test.expected-0.01 || result > test.expected+0.01 {
|
|
t.Errorf("Expected %f, but got %f", test.expected, result)
|
|
}
|
|
})
|
|
}
|
|
}
|