decred.org/dcrdex@v1.0.5/dex/order/status_test.go (about) 1 package order 2 3 import ( 4 "testing" 5 ) 6 7 func TestOrderStatus_String(t *testing.T) { 8 // spot check a valid status 9 bookedStatusStr := OrderStatusBooked.String() 10 if bookedStatusStr != "booked" { 11 t.Errorf(`OrderStatusBooked.String() = %s (!= "booked")`, bookedStatusStr) 12 } 13 14 unknownStatusStr := OrderStatusUnknown.String() 15 if unknownStatusStr != "unknown" { 16 t.Errorf(`OrderStatusBooked.String() = %s (!= "unknown")`, unknownStatusStr) 17 } 18 19 // Check a fake and invalid status. 20 os := OrderStatus(12345) 21 defer func() { 22 if recover() == nil { 23 t.Fatalf("OrderStatus.String() should panic for invalid status") 24 } 25 }() 26 _ = os.String() 27 }