about summary refs log blame commit diff
path: root/IrcTokens/Tests/Data/msg-join.yaml
blob: d1d7429055f77d54a02ab0b9d7e009d6fdc6923d (plain) (tree)




























































































































































































































                                                                                                              
# 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"