// Copyright 2021 The Mellium Contributors. // Use of this source code is governed by the BSD 2-clause // license that can be found in the LICENSE file. package muc_test import ( "encoding/xml" "testing" "mellium.im/xmlstream" "mellium.im/xmpp/internal/xmpptest" "mellium.im/xmpp/jid" "mellium.im/xmpp/muc" ) var ( _ xml.Marshaler = muc.Invitation{} _ xml.Unmarshaler = (*muc.Invitation)(nil) _ xmlstream.Marshaler = muc.Invitation{} _ xmlstream.WriterTo = muc.Invitation{} ) var inviteEncodingTestCases = []xmpptest.EncodingTestCase{ 0: { Value: &muc.Invitation{}, XML: ``, NoUnmarshal: true, }, 1: { Value: &muc.Invitation{XMLName: xml.Name{Space: muc.NSUser, Local: "x"}}, XML: ``, }, 2: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSUser, Local: "x"}, Continue: true, Thread: "123", JID: jid.MustParse("bridgecrew@muc.localhost"), Password: "NCC-1701-D", Reason: "Senior officers to the bridge.", }, XML: `Senior officers to the bridge.NCC-1701-D`, }, 3: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSUser, Local: "x"}, Thread: "123", JID: jid.MustParse("bridgecrew@muc.localhost"), Password: "NCC-1701-D", Reason: "Senior officers to the bridge.", }, XML: `Senior officers to the bridge.NCC-1701-D`, NoUnmarshal: true, }, 4: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSUser, Local: "x"}, JID: jid.MustParse("bridgecrew@muc.localhost"), Continue: true, }, XML: ``, }, 5: { Value: &muc.Invitation{XMLName: xml.Name{Space: muc.NSConf, Local: "x"}}, XML: ``, }, 6: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSConf, Local: "x"}, Continue: true, Thread: "123", JID: jid.MustParse("bridgecrew@muc.localhost"), Password: "NCC-1701-D", Reason: "Senior officers to the bridge.", }, XML: ``, }, 7: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSConf, Local: "x"}, Thread: "123", JID: jid.MustParse("bridgecrew@muc.localhost"), Password: "NCC-1701-D", Reason: "Senior officers to the bridge.", }, XML: ``, NoUnmarshal: true, }, 8: { Value: &muc.Invitation{ XMLName: xml.Name{Space: muc.NSConf, Local: "x"}, Continue: true, JID: jid.MustParse("bridgecrew@muc.localhost"), }, XML: ``, }, } func TestActions(t *testing.T) { xmpptest.RunEncodingTests(t, inviteEncodingTestCases) }