2
0

order_action_test.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package sentio
  2. import "testing"
  3. func TestParseOrderAction(t *testing.T) {
  4. tests := []struct {
  5. arg string
  6. want OrderAction
  7. wantErr bool
  8. }{
  9. {
  10. arg: "SELL",
  11. want: OrderSell,
  12. wantErr: false,
  13. },
  14. {
  15. arg: "S",
  16. want: OrderSell,
  17. wantErr: false,
  18. },
  19. {
  20. arg: "s",
  21. want: OrderSell,
  22. wantErr: false,
  23. },
  24. {
  25. arg: "sELL",
  26. want: OrderSell,
  27. wantErr: false,
  28. },
  29. {
  30. arg: "b",
  31. want: OrderBuy,
  32. wantErr: false,
  33. },
  34. {
  35. arg: "bUy",
  36. want: OrderBuy,
  37. wantErr: false,
  38. },
  39. {
  40. arg: "B",
  41. want: OrderBuy,
  42. wantErr: false,
  43. },
  44. {
  45. arg: "BUY",
  46. want: OrderBuy,
  47. wantErr: false,
  48. },
  49. }
  50. for _, tt := range tests {
  51. t.Run("TestParseOrderAction", func(t *testing.T) {
  52. got, err := ParseOrderAction(tt.arg)
  53. if (err != nil) != tt.wantErr {
  54. t.Errorf("ParseOrderAction() error = %v, wantErr %v", err, tt.wantErr)
  55. return
  56. }
  57. if got != tt.want {
  58. t.Errorf("ParseOrderAction() got = %v, want %v", got, tt.want)
  59. }
  60. })
  61. }
  62. }