Fixed code smells
Some checks failed
Run tests / test (1.25) (push) Failing after 15s
Run tests / test (stable) (push) Failing after 17s

This commit is contained in:
2026-02-22 21:14:58 +01:00
parent 3bcbaf2135
commit 32f6c38c13
17 changed files with 1593 additions and 22 deletions

View File

@@ -0,0 +1,52 @@
package fields
import "testing"
func TestGillhamToAltitude(t *testing.T) {
tests := []struct {
Test string
Want int32
}{
{"00000000010", -1000},
{"00000001010", -500},
{"00000011010", 0},
{"00000011110", 100},
{"00000010011", 600},
{"00000110010", 1000},
{"00001001001", 5800},
{"00011100100", 10300},
{"01100011010", 32000},
{"01110000100", 46300},
{"10000000011", 126600},
{"10000000001", 126700},
}
for _, test := range tests {
t.Run(test.Test, func(t *testing.T) {
alt, err := GillhamToAltitude(testString2Bits(test.Test))
if err != nil {
t.Fatalf("%v", err)
}
if alt != test.Want {
t.Errorf("expected altitude %d, got %d", test.Want, alt)
}
})
}
}
func testString2Bits(s string) (bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool) {
d2 := s[0] == '1'
d4 := s[1] == '1'
a1 := s[2] == '1'
a2 := s[3] == '1'
a4 := s[4] == '1'
b1 := s[5] == '1'
b2 := s[6] == '1'
b4 := s[7] == '1'
c1 := s[8] == '1'
c2 := s[9] == '1'
c4 := s[10] == '1'
return false, d2, d4, a1, a2, a4, b1, b2, b4, c1, c2, c4
}