1// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7generate_empty_element!(
8 /// Stream:feature sent by the server to advertise it supports CSI.
9 Feature, "csi", CSI
10);
11
12generate_empty_element!(
13 /// Client indicates it is inactive.
14 Inactive, "inactive", CSI
15);
16
17generate_empty_element!(
18 /// Client indicates it is active again.
19 Active, "active", CSI
20);
21
22#[cfg(test)]
23mod tests {
24 use super::*;
25 use crate::Element;
26 use std::convert::TryFrom;
27 use crate::ns;
28
29 #[test]
30 fn test_size() {
31 assert_size!(Feature, 0);
32 assert_size!(Inactive, 0);
33 assert_size!(Active, 0);
34 }
35
36 #[test]
37 fn parsing() {
38 let elem: Element = "<csi xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
39 Feature::try_from(elem).unwrap();
40
41 let elem: Element = "<inactive xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
42 Inactive::try_from(elem).unwrap();
43
44 let elem: Element = "<active xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
45 Active::try_from(elem).unwrap();
46 }
47
48 #[test]
49 fn serialising() {
50 let elem: Element = Feature.into();
51 assert!(elem.is("csi", ns::CSI));
52
53 let elem: Element = Inactive.into();
54 assert!(elem.is("inactive", ns::CSI));
55
56 let elem: Element = Active.into();
57 assert!(elem.is("active", ns::CSI));
58 }
59}