about summary refs log tree commit diff
path: root/IrcTokens/Tests/Data/msg-join.yaml
blob: d1d7429055f77d54a02ab0b9d7e009d6fdc6923d (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# IRC parser tests
# joining atoms into sendable messages

# Written in 2015 by Daniel Oaks <daniel@danieloaks.net>
#
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software. If not, see
# <http://creativecommons.org/publicdomain/zero/1.0/>.

# some of the tests here originate from grawity's test vectors, which is WTFPL v2 licensed
#   https://github.com/grawity/code/tree/master/lib/tests
# some of the tests here originate from Mozilla's test vectors, which is public domain
#   https://dxr.mozilla.org/comm-central/source/chat/protocols/irc/test/test_ircMessage.js
# some of the tests here originate from SaberUK's test vectors, which he's indicated I am free to include here
#   https://github.com/SaberUK/ircparser/tree/master/test

tests:
  # the desc string holds a description of the test, if it exists

  # the atoms dict has the keys:
  #   * tags: tags dict
  #       tags with no value are an empty string
  #   * source: source string, without single leading colon
  #   * verb: verb string
  #   * params: params split up as a list
  # if the params key does not exist, assume it is empty
  # if any other keys do no exist, assume they are null
  # a key that is null does not exist or is not specified with the
  #   given input string

  # matches is a list of messages that match

  # simple tests
  - desc: Simple test with verb and params.
    atoms:
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "asdf"
    matches:
      - "foo bar baz asdf"
      - "foo bar baz :asdf"

  # with no regular params
  - desc: Simple test with source and no params.
    atoms:
      source: "src"
      verb: "AWAY"
    matches:
      - ":src AWAY"

  - desc: Simple test with source and empty trailing param.
    atoms:
      source: "src"
      verb: "AWAY"
      params:
        - ""
    matches:
      - ":src AWAY :"

  # with source
  - desc: Simple test with source.
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "asdf"
    matches:
      - ":coolguy foo bar baz asdf"
      - ":coolguy foo bar baz :asdf"

  # with trailing param
  - desc: Simple test with trailing param.
    atoms:
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "asdf quux"
    matches:
      - "foo bar baz :asdf quux"

  - desc: Simple test with empty trailing param.
    atoms:
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - ""
    matches:
      - "foo bar baz :"

  - desc: Simple test with trailing param containing colon.
    atoms:
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - ":asdf"
    matches:
      - "foo bar baz ::asdf"

  # with source and trailing param
  - desc: Test with source and trailing param.
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "asdf quux"
    matches:
      - ":coolguy foo bar baz :asdf quux"

  - desc: Test with trailing containing beginning+end whitespace.
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "  asdf quux "
    matches:
      - ":coolguy foo bar baz :  asdf quux "

  - desc: Test with trailing containing what looks like another trailing param.
    atoms:
      source: "coolguy"
      verb: "PRIVMSG"
      params:
        - "bar"
        - "lol :) "
    matches:
      - ":coolguy PRIVMSG bar :lol :) "

  - desc: Simple test with source and empty trailing.
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - ""
    matches:
      - ":coolguy foo bar baz :"

  - desc: Trailing contains only spaces.
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "  "
    matches:
      - ":coolguy foo bar baz :  "

  - desc: Param containing tab (tab is not considered SPACE for message splitting).
    atoms:
      source: "coolguy"
      verb: "foo"
      params:
        - "b\tar"
        - "baz"
    matches:
      - ":coolguy foo b\tar baz"
      - ":coolguy foo b\tar :baz"

  # with tags
  - desc: Tag with no value and space-filled trailing.
    atoms:
      tags:
        "asd": ""
      source: "coolguy"
      verb: "foo"
      params:
        - "bar"
        - "baz"
        - "  "
    matches:
      - "@asd :coolguy foo bar baz :  "

  - desc: Tags with escaped values.
    atoms:
      verb: "foo"
      tags:
        "a": "b\\and\nk"
        "d": "gh;764"
    matches:
      - "@a=b\\\\and\\nk;d=gh\\:764 foo"
      - "@d=gh\\:764;a=b\\\\and\\nk foo"

  - desc: Tags with escaped values and params.
    atoms:
      verb: "foo"
      tags:
        "a": "b\\and\nk"
        "d": "gh;764"
      params:
        - "par1"
        - "par2"
    matches:
      - "@a=b\\\\and\\nk;d=gh\\:764 foo par1 par2"
      - "@a=b\\\\and\\nk;d=gh\\:764 foo par1 :par2"
      - "@d=gh\\:764;a=b\\\\and\\nk foo par1 par2"
      - "@d=gh\\:764;a=b\\\\and\\nk foo par1 :par2"

  - desc: Tag with long, strange values (including LF and newline).
    atoms:
      tags:
        foo: "\\\\;\\s \r\n"
      verb: "COMMAND"
    matches:
      - "@foo=\\\\\\\\\\:\\\\s\\s\\r\\n COMMAND"