mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-27 06:19:23 +01:00
aa8579b6e8
* Fix #679 (borked reply to `JOIN #chan,\r\n`) * Replace invalid error parameters with *'s in various places * Fix PART with no message sending an empty trailing parameter to the channel * Fix some error responses not getting labeled
33 lines
834 B
Go
33 lines
834 B
Go
// Copyright (c) 2019 Shivaram Lingamneni <slingamn@cs.stanford.edu>
|
|
// released under the MIT license
|
|
|
|
package utils
|
|
|
|
import "testing"
|
|
|
|
func TestStringToBool(t *testing.T) {
|
|
val, err := StringToBool("on")
|
|
assertEqual(val, true, t)
|
|
assertEqual(err, nil, t)
|
|
|
|
val, err = StringToBool("n")
|
|
assertEqual(val, false, t)
|
|
assertEqual(err, nil, t)
|
|
|
|
val, err = StringToBool("OFF")
|
|
assertEqual(val, false, t)
|
|
assertEqual(err, nil, t)
|
|
|
|
val, err = StringToBool("default")
|
|
assertEqual(err, ErrInvalidParams, t)
|
|
}
|
|
|
|
func TestSafeErrorParam(t *testing.T) {
|
|
assertEqual(SafeErrorParam("hi"), "hi", t)
|
|
assertEqual(SafeErrorParam("#hi"), "#hi", t)
|
|
assertEqual(SafeErrorParam("#hi there"), "*", t)
|
|
assertEqual(SafeErrorParam(":"), "*", t)
|
|
assertEqual(SafeErrorParam("#hi:there"), "#hi:there", t)
|
|
assertEqual(SafeErrorParam(""), "*", t)
|
|
}
|