2017-09-07 01:26:16 +02:00
|
|
|
// Copyright (c) 2017 Daniel Oaks
|
|
|
|
// released under the MIT license
|
|
|
|
|
|
|
|
package irc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2018-02-03 11:28:02 +01:00
|
|
|
|
|
|
|
"github.com/oragono/oragono/irc/modes"
|
2017-09-07 01:26:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseDefaultChannelModes(t *testing.T) {
|
|
|
|
nt := "+nt"
|
|
|
|
n := "+n"
|
|
|
|
empty := ""
|
|
|
|
tminusi := "+t -i"
|
|
|
|
|
|
|
|
var parseTests = []struct {
|
|
|
|
raw *string
|
2018-02-03 11:28:02 +01:00
|
|
|
expected modes.Modes
|
2017-09-07 01:26:16 +02:00
|
|
|
}{
|
2018-02-03 11:28:02 +01:00
|
|
|
{&nt, modes.Modes{modes.NoOutside, modes.OpOnlyTopic}},
|
|
|
|
{&n, modes.Modes{modes.NoOutside}},
|
|
|
|
{&empty, modes.Modes{}},
|
|
|
|
{&tminusi, modes.Modes{modes.OpOnlyTopic}},
|
|
|
|
{nil, modes.Modes{modes.NoOutside, modes.OpOnlyTopic}},
|
2017-09-07 01:26:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var config Config
|
|
|
|
for _, testcase := range parseTests {
|
|
|
|
config.Channels.DefaultModes = testcase.raw
|
|
|
|
result := ParseDefaultChannelModes(&config)
|
|
|
|
if !reflect.DeepEqual(result, testcase.expected) {
|
|
|
|
t.Errorf("expected modes %s, got %s", testcase.expected, result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|