style: Apply code formatting with go fmt

- Run 'make format' to ensure all Go code follows standard formatting
- Maintains consistent code style across the entire codebase
- No functional changes, only whitespace and formatting improvements
This commit is contained in:
Ole-Morten Duesund 2025-09-01 10:05:29 +02:00
commit 2bffa2c418
19 changed files with 543 additions and 527 deletions

View file

@ -9,7 +9,7 @@ func TestNewDatabase(t *testing.T) {
if db == nil {
t.Fatal("NewDatabase() returned nil")
}
if len(db.codes) == 0 {
t.Error("Database should contain pre-loaded codes")
}
@ -17,20 +17,20 @@ func TestNewDatabase(t *testing.T) {
func TestEmergencyCodes(t *testing.T) {
db := NewDatabase()
emergencyCodes := []string{"7500", "7600", "7700"}
for _, code := range emergencyCodes {
info := db.Lookup(code)
if info == nil {
t.Errorf("Emergency code %s not found", code)
continue
}
if info.Type != Emergency {
t.Errorf("Code %s should be Emergency type, got %s", code, info.Type)
}
if !db.IsEmergencyCode(code) {
t.Errorf("IsEmergencyCode(%s) should return true", code)
}
@ -39,7 +39,7 @@ func TestEmergencyCodes(t *testing.T) {
func TestStandardCodes(t *testing.T) {
db := NewDatabase()
testCases := []struct {
code string
description string
@ -48,16 +48,16 @@ func TestStandardCodes(t *testing.T) {
{"7000", "VFR - Visual Flight Rules"},
{"1000", "Mode A/C Not Assigned"},
}
for _, tc := range testCases {
info := db.Lookup(tc.code)
if info == nil {
t.Errorf("Standard code %s not found", tc.code)
continue
}
if info.Description != tc.description {
t.Errorf("Code %s: expected description %q, got %q",
t.Errorf("Code %s: expected description %q, got %q",
tc.code, tc.description, info.Description)
}
}
@ -65,17 +65,17 @@ func TestStandardCodes(t *testing.T) {
func TestLookupInt(t *testing.T) {
db := NewDatabase()
// Test integer lookup
info := db.LookupInt(7700)
if info == nil {
t.Fatal("LookupInt(7700) returned nil")
}
if info.Code != "7700" {
t.Errorf("Expected code '7700', got '%s'", info.Code)
}
if info.Type != Emergency {
t.Errorf("Code 7700 should be Emergency type, got %s", info.Type)
}
@ -83,11 +83,11 @@ func TestLookupInt(t *testing.T) {
func TestLookupHex(t *testing.T) {
db := NewDatabase()
// 7700 in octal is 3840 in decimal, which is F00 in hex
// However, squawk codes are transmitted differently in different formats
// For now, test with a simple hex conversion
// Test invalid hex
info := db.LookupHex("INVALID")
if info != nil {
@ -97,7 +97,7 @@ func TestLookupHex(t *testing.T) {
func TestFormatSquawkWithDescription(t *testing.T) {
db := NewDatabase()
testCases := []struct {
code string
expected string
@ -108,7 +108,7 @@ func TestFormatSquawkWithDescription(t *testing.T) {
{"0000", "0000 (🔰 No Transponder/Military)"},
{"9999", "9999"}, // Unknown code should return just the code
}
for _, tc := range testCases {
result := db.FormatSquawkWithDescription(tc.code)
if result != tc.expected {
@ -120,12 +120,12 @@ func TestFormatSquawkWithDescription(t *testing.T) {
func TestGetEmergencyCodes(t *testing.T) {
db := NewDatabase()
emergencyCodes := db.GetEmergencyCodes()
if len(emergencyCodes) != 3 {
t.Errorf("Expected 3 emergency codes, got %d", len(emergencyCodes))
}
// Check that they're sorted by priority (highest first)
for i := 1; i < len(emergencyCodes); i++ {
if emergencyCodes[i-1].Priority < emergencyCodes[i].Priority {
@ -136,7 +136,7 @@ func TestGetEmergencyCodes(t *testing.T) {
func TestAddCustomCode(t *testing.T) {
db := NewDatabase()
customCode := &CodeInfo{
Code: "1234",
Description: "Test Custom Code",
@ -145,14 +145,14 @@ func TestAddCustomCode(t *testing.T) {
Priority: 50,
Notes: "This is a test custom code",
}
db.AddCustomCode(customCode)
info := db.Lookup("1234")
if info == nil {
t.Fatal("Custom code not found after adding")
}
if info.Description != "Test Custom Code" {
t.Errorf("Custom code description mismatch: expected %q, got %q",
"Test Custom Code", info.Description)
@ -170,7 +170,7 @@ func TestCodeTypeString(t *testing.T) {
{Military, "Military"},
{Special, "Special"},
}
for _, tc := range testCases {
result := tc.codeType.String()
if result != tc.expected {
@ -181,16 +181,16 @@ func TestCodeTypeString(t *testing.T) {
func TestGetAllCodes(t *testing.T) {
db := NewDatabase()
allCodes := db.GetAllCodes()
if len(allCodes) == 0 {
t.Error("GetAllCodes() should return non-empty slice")
}
// Verify we can find known codes in the result
found7700 := false
found1200 := false
for _, code := range allCodes {
if code.Code == "7700" {
found7700 = true
@ -199,11 +199,11 @@ func TestGetAllCodes(t *testing.T) {
found1200 = true
}
}
if !found7700 {
t.Error("Emergency code 7700 not found in GetAllCodes() result")
}
if !found1200 {
t.Error("Standard code 1200 not found in GetAllCodes() result")
}
}
}