tif_test.go 860 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package sentio
  2. import "testing"
  3. func TestParseTimeInForce(t *testing.T) {
  4. tests := []struct {
  5. name string
  6. arg string
  7. want TimeInForce
  8. wantErr bool
  9. }{
  10. {
  11. name: "DAY",
  12. arg: "day",
  13. want: TIFDay,
  14. wantErr: false,
  15. },
  16. {
  17. name: "DAY",
  18. arg: "Day",
  19. want: TIFDay,
  20. wantErr: false,
  21. },
  22. {
  23. name: "DAY",
  24. arg: " day",
  25. want: TIFDay,
  26. wantErr: false,
  27. },
  28. {
  29. name: "Unknown",
  30. arg: "D ay",
  31. want: -1,
  32. wantErr: true,
  33. },
  34. }
  35. for _, tt := range tests {
  36. t.Run(tt.name, func(t *testing.T) {
  37. got, err := ParseTimeInForce(tt.arg)
  38. if (err != nil) != tt.wantErr {
  39. t.Errorf("ParseTimeInForce() error = %v, wantErr %v", err, tt.wantErr)
  40. return
  41. }
  42. if got != tt.want {
  43. t.Errorf("ParseTimeInForce() got = %v, want %v", got, tt.want)
  44. }
  45. })
  46. }
  47. }