package async_smtp

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file mail_from_lexer_tests.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
open! Core

let%test_module _ =
  (module struct
    let test_lexing str = Mail_from_lexer.parse_mail_from (Lexing.from_string str)

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "foo@bar.com")
        ~expect:
          { prefix = None
          ; sender = `Email { local_part = "foo"; domain = Some "bar.com" }
          ; suffix = ""
          }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "foo@bar.com suffix")
        ~expect:
          { prefix = None
          ; sender = `Email { local_part = "foo"; domain = Some "bar.com" }
          ; suffix = " suffix"
          }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "<foo@bar.com> suffix")
        ~expect:
          { prefix = Some ""
          ; sender = `Email { local_part = "foo"; domain = Some "bar.com" }
          ; suffix = " suffix"
          }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "Foo Bar <foo@bar.com> suffix")
        ~expect:
          { prefix = Some "Foo Bar "
          ; sender = `Email { local_part = "foo"; domain = Some "bar.com" }
          ; suffix = " suffix"
          }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "<>")
        ~expect:{ prefix = Some ""; sender = `Null; suffix = "" }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "prefix <>")
        ~expect:{ prefix = Some "prefix "; sender = `Null; suffix = "" }
    ;;

    let%test_unit _ =
      [%test_result: Mail_from_lexer_types.email_with_suffix]
        (test_lexing "\"Mailer Daemon\" <> AUTH=<>")
        ~expect:
          { prefix = Some "\"Mailer Daemon\" "; sender = `Null; suffix = " AUTH=<>" }
    ;;
  end)
;;