37 lines
1.2 KiB
Ruby
37 lines
1.2 KiB
Ruby
require "pry"
|
|
require "minitest"
|
|
require "logger"
|
|
require_relative "../lib/imap_server"
|
|
|
|
class ImapServer
|
|
class ClientMessageTest < Minitest::Test
|
|
|
|
def test_parser_simple
|
|
simple_response = ClientMessage.parse("tag1 command1 arg1 arg2")
|
|
assert_equal "tag1", simple_response.tag
|
|
assert_equal "command1", simple_response.command
|
|
assert_equal "arg1", simple_response.args[0]
|
|
assert_equal "arg2", simple_response.args[1]
|
|
end
|
|
|
|
def test_parser_quote
|
|
simple_response = ClientMessage.parse("tag1 command1 \"arg1 arg1\" arg2")
|
|
assert_equal "tag1", simple_response.tag
|
|
assert_equal "command1", simple_response.command
|
|
assert_equal "arg1 arg1", simple_response.args[0]
|
|
assert_equal "arg2", simple_response.args[1]
|
|
end
|
|
|
|
def test_parser_quote_and_escape
|
|
simple_response = ClientMessage.parse('tag1 command1 "arg1 arg1" arg2 \\"arg3 "\\"\\"arg4 arg4\\"\\""')
|
|
assert_equal "tag1", simple_response.tag
|
|
assert_equal "command1", simple_response.command
|
|
assert_equal "arg1 arg1", simple_response.args[0]
|
|
assert_equal "arg2", simple_response.args[1]
|
|
assert_equal '"arg3', simple_response.args[2]
|
|
assert_equal '""arg4 arg4""', simple_response.args[3]
|
|
end
|
|
|
|
end
|
|
end
|