imap_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package goimap
  2. import (
  3. "reflect"
  4. "testing"
  5. )
  6. func Test_paramsErr(t *testing.T) {
  7. }
  8. func Test_getCommand(t *testing.T) {
  9. type args struct {
  10. line string
  11. }
  12. tests := []struct {
  13. name string
  14. args args
  15. want string
  16. want1 string
  17. want2 string
  18. }{
  19. {
  20. "STATUS命令测试",
  21. args{`15.64 STATUS "Deleted Messages" (MESSAGES UIDNEXT UIDVALIDITY UNSEEN)`},
  22. "15.64",
  23. "STATUS",
  24. `"Deleted Messages" (MESSAGES UIDNEXT UIDVALIDITY UNSEEN)`,
  25. },
  26. {
  27. "SELECT命令测试",
  28. args{`9.79 SELECT INBOX`},
  29. "9.79",
  30. "SELECT",
  31. `INBOX`,
  32. },
  33. {
  34. "CAPABILITY命令测试",
  35. args{`1.81 CAPABILITY`},
  36. "1.81",
  37. "CAPABILITY",
  38. ``,
  39. },
  40. {
  41. "异常命令测试",
  42. args{`GET/HTTP/1.0`},
  43. "",
  44. "",
  45. ``,
  46. },
  47. }
  48. for _, tt := range tests {
  49. t.Run(tt.name, func(t *testing.T) {
  50. got, got1, got2 := getCommand(tt.args.line)
  51. if got != tt.want {
  52. t.Errorf("getCommand() got = %v, want %v", got, tt.want)
  53. }
  54. if got1 != tt.want1 {
  55. t.Errorf("getCommand() got1 = %v, want %v", got1, tt.want1)
  56. }
  57. if !reflect.DeepEqual(got2, tt.want2) {
  58. t.Errorf("getCommand() got2 = %v, want %v", got2, tt.want2)
  59. }
  60. })
  61. }
  62. }