about summary refs log tree commit diff
path: root/IrcTokens/Tests/Data/msg-join.yaml
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2020-04-19 20:52:41 -0400
committerBen Harris <ben@tilde.team>2020-04-19 23:14:41 -0400
commit616abc70303990fbf8096fc6ada5fac100a6c66a (patch)
tree08df1ec5e896be6a18e6a39630ffc2fec8118297 /IrcTokens/Tests/Data/msg-join.yaml
init
Diffstat (limited to 'IrcTokens/Tests/Data/msg-join.yaml')
-rw-r--r--IrcTokens/Tests/Data/msg-join.yaml221
1 files changed, 221 insertions, 0 deletions
diff --git a/IrcTokens/Tests/Data/msg-join.yaml b/IrcTokens/Tests/Data/msg-join.yaml
new file mode 100644
index 0000000..d1d7429
--- /dev/null
+++ b/IrcTokens/Tests/Data/msg-join.yaml
@@ -0,0 +1,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"