diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-11-06 22:14:16 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-11-06 22:14:16 +0200 |
commit | 24dd76ee0bca1a593781d366a41017f5b1d9ec07 (patch) | |
tree | a8ef42603c3834e8c0489dc01180a0902296e4a2 /tests/events.cc | |
parent | Adjust appveyor configuration (diff) | |
download | nheko-24dd76ee0bca1a593781d366a41017f5b1d9ec07.tar.xz |
Parse unsigned key
Diffstat (limited to '')
-rw-r--r-- | tests/events.cc | 246 |
1 files changed, 129 insertions, 117 deletions
diff --git a/tests/events.cc b/tests/events.cc index ee1f9560..a4f6fedf 100644 --- a/tests/events.cc +++ b/tests/events.cc @@ -22,8 +22,8 @@ using namespace matrix::events; TEST(BaseEvent, Deserialization) { // NameEventContent - auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Room Name" } } }, - { "type", "m.room.name" } }; + auto data = + QJsonObject{{"content", QJsonObject{{"name", "Room Name"}}}, {"type", "m.room.name"}}; Event<NameEventContent> name_event; name_event.deserialize(data); @@ -31,47 +31,57 @@ TEST(BaseEvent, Deserialization) EXPECT_EQ(name_event.serialize(), data); // TopicEventContent - data = QJsonObject{ { "content", QJsonObject{ { "topic", "Room Topic" } } }, - { "type", "m.room.topic" } }; + data = QJsonObject{{"content", QJsonObject{{"topic", "Room Topic"}}}, + {"unsigned", QJsonObject{{"age", 22}, {"transaction_id", "randomid"}}}, + {"type", "m.room.topic"}}; Event<TopicEventContent> topic_event; topic_event.deserialize(data); EXPECT_EQ(topic_event.content().topic(), "Room Topic"); + EXPECT_EQ(topic_event.unsignedData().age(), 22); + EXPECT_EQ(topic_event.unsignedData().transactionId(), "randomid"); EXPECT_EQ(topic_event.serialize(), data); // AvatarEventContent - data = QJsonObject{ { "content", QJsonObject{ { "url", "https://matrix.org" } } }, - { "type", "m.room.avatar" } }; + data = QJsonObject{ + {"content", QJsonObject{{"url", "https://matrix.org"}}}, + {"unsigned", QJsonObject{{"age", 1343434343}, {"transaction_id", "m33434.33"}}}, + {"type", "m.room.avatar"}}; Event<AvatarEventContent> avatar_event; avatar_event.deserialize(data); EXPECT_EQ(avatar_event.content().url().toString(), "https://matrix.org"); + EXPECT_EQ(avatar_event.unsignedData().age(), 1343434343); + EXPECT_EQ(avatar_event.unsignedData().transactionId(), "m33434.33"); EXPECT_EQ(avatar_event.serialize(), data); // AliasesEventContent - data = - QJsonObject{ { "content", - QJsonObject{ - { "aliases", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } } }, - { "type", "m.room.aliases" } }; + data = QJsonObject{ + {"content", + QJsonObject{{"aliases", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}}}, + {"unsigned", QJsonObject{{"transaction_id", "m33434.33"}}}, + {"type", "m.room.aliases"}}; Event<AliasesEventContent> aliases_event; aliases_event.deserialize(data); EXPECT_EQ(aliases_event.content().aliases().size(), 2); + EXPECT_EQ(aliases_event.unsignedData().transactionId(), "m33434.33"); EXPECT_EQ(aliases_event.serialize(), data); // CreateEventContent - data = QJsonObject{ { "content", QJsonObject{ { "creator", "@alice:matrix.org" } } }, - { "type", "m.room.create" } }; + data = QJsonObject{{"content", QJsonObject{{"creator", "@alice:matrix.org"}}}, + {"unsigned", QJsonObject{{"age", 2233}}}, + {"type", "m.room.create"}}; Event<CreateEventContent> create_event; create_event.deserialize(data); EXPECT_EQ(create_event.content().creator(), "@alice:matrix.org"); + EXPECT_EQ(create_event.unsignedData().age(), 2233); EXPECT_EQ(create_event.serialize(), data); // JoinRulesEventContent - data = QJsonObject{ { "content", QJsonObject{ { "join_rule", "private" } } }, - { "type", "m.room.join_rules" } }; + data = QJsonObject{{"content", QJsonObject{{"join_rule", "private"}}}, + {"type", "m.room.join_rules"}}; Event<JoinRulesEventContent> join_rules_event; join_rules_event.deserialize(data); @@ -81,27 +91,34 @@ TEST(BaseEvent, Deserialization) TEST(BaseEvent, DeserializationException) { - auto data = QJsonObject{ { "content", QJsonObject{ { "rule", "private" } } }, - { "type", "m.room.join_rules" } }; + auto data = + QJsonObject{{"content", QJsonObject{{"rule", "private"}}}, {"type", "m.room.join_rules"}}; Event<JoinRulesEventContent> event1; ASSERT_THROW(event1.deserialize(data), DeserializationException); - data = QJsonObject{ { "contents", QJsonObject{ { "join_rule", "private" } } }, - { "type", "m.room.join_rules" } }; + data = QJsonObject{{"contents", QJsonObject{{"join_rule", "private"}}}, + {"type", "m.room.join_rules"}}; Event<JoinRulesEventContent> event2; ASSERT_THROW(event2.deserialize(data), DeserializationException); + + data = QJsonObject{{"contents", QJsonObject{{"join_rule", "private"}}}, + {"unsigned", QJsonObject{{"age", "222"}}}, + {"type", "m.room.join_rules"}}; + + Event<JoinRulesEventContent> event3; + ASSERT_THROW(event3.deserialize(data), DeserializationException); } TEST(RoomEvent, Deserialization) { - auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } }, - { "event_id", "$asdfafdf8af:matrix.org" }, - { "room_id", "!aasdfaeae23r9:matrix.org" }, - { "sender", "@alice:matrix.org" }, - { "origin_server_ts", 1323238293289323LL }, - { "type", "m.room.name" } }; + auto data = QJsonObject{{"content", QJsonObject{{"name", "Name"}}}, + {"event_id", "$asdfafdf8af:matrix.org"}, + {"room_id", "!aasdfaeae23r9:matrix.org"}, + {"sender", "@alice:matrix.org"}, + {"origin_server_ts", 1323238293289323LL}, + {"type", "m.room.name"}}; RoomEvent<NameEventContent> event; event.deserialize(data); @@ -116,11 +133,11 @@ TEST(RoomEvent, Deserialization) TEST(RoomEvent, DeserializationException) { - auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } }, - { "event_id", "$asdfafdf8af:matrix.org" }, - { "room_id", "!aasdfaeae23r9:matrix.org" }, - { "origin_server_ts", 1323238293289323LL }, - { "type", "m.room.name" } }; + auto data = QJsonObject{{"content", QJsonObject{{"name", "Name"}}}, + {"event_id", "$asdfafdf8af:matrix.org"}, + {"room_id", "!aasdfaeae23r9:matrix.org"}, + {"origin_server_ts", 1323238293289323LL}, + {"type", "m.room.name"}}; RoomEvent<NameEventContent> event; @@ -133,14 +150,14 @@ TEST(RoomEvent, DeserializationException) TEST(StateEvent, Deserialization) { - auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } }, - { "event_id", "$asdfafdf8af:matrix.org" }, - { "state_key", "some_state_key" }, - { "prev_content", QJsonObject{ { "name", "Previous Name" } } }, - { "room_id", "!aasdfaeae23r9:matrix.org" }, - { "sender", "@alice:matrix.org" }, - { "origin_server_ts", 1323238293289323LL }, - { "type", "m.room.name" } }; + auto data = QJsonObject{{"content", QJsonObject{{"name", "Name"}}}, + {"event_id", "$asdfafdf8af:matrix.org"}, + {"state_key", "some_state_key"}, + {"prev_content", QJsonObject{{"name", "Previous Name"}}}, + {"room_id", "!aasdfaeae23r9:matrix.org"}, + {"sender", "@alice:matrix.org"}, + {"origin_server_ts", 1323238293289323LL}, + {"type", "m.room.name"}}; StateEvent<NameEventContent> event; event.deserialize(data); @@ -157,13 +174,13 @@ TEST(StateEvent, Deserialization) TEST(StateEvent, DeserializationException) { - auto data = QJsonObject{ { "content", QJsonObject{ { "name", "Name" } } }, - { "event_id", "$asdfafdf8af:matrix.org" }, - { "prev_content", QJsonObject{ { "name", "Previous Name" } } }, - { "room_id", "!aasdfaeae23r9:matrix.org" }, - { "sender", "@alice:matrix.org" }, - { "origin_server_ts", 1323238293289323LL }, - { "type", "m.room.name" } }; + auto data = QJsonObject{{"content", QJsonObject{{"name", "Name"}}}, + {"event_id", "$asdfafdf8af:matrix.org"}, + {"prev_content", QJsonObject{{"name", "Previous Name"}}}, + {"room_id", "!aasdfaeae23r9:matrix.org"}, + {"sender", "@alice:matrix.org"}, + {"origin_server_ts", 1323238293289323LL}, + {"type", "m.room.name"}}; StateEvent<NameEventContent> event; @@ -176,35 +193,30 @@ TEST(StateEvent, DeserializationException) TEST(EventType, Mapping) { - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.aliases" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.aliases"}}), EventType::RoomAliases); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.avatar" } }), - EventType::RoomAvatar); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.canonical_alias" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.avatar"}}), EventType::RoomAvatar); + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.canonical_alias"}}), EventType::RoomCanonicalAlias); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.create" } }), - EventType::RoomCreate); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.history_visibility" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.create"}}), EventType::RoomCreate); + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.history_visibility"}}), EventType::RoomHistoryVisibility); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.join_rules" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.join_rules"}}), EventType::RoomJoinRules); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.member" } }), - EventType::RoomMember); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.message" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.member"}}), EventType::RoomMember); + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.message"}}), EventType::RoomMessage); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.name" } }), EventType::RoomName); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.power_levels" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.name"}}), EventType::RoomName); + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.power_levels"}}), EventType::RoomPowerLevels); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.topic" } }), - EventType::RoomTopic); - EXPECT_EQ(extractEventType(QJsonObject{ { "type", "m.room.unknown" } }), + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.topic"}}), EventType::RoomTopic); + EXPECT_EQ(extractEventType(QJsonObject{{"type", "m.room.unknown"}}), EventType::Unsupported); } TEST(AliasesEventContent, Deserialization) { - auto data = - QJsonObject{ { "aliases", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } }; + auto data = QJsonObject{{"aliases", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}}; AliasesEventContent content; content.deserialize(data); @@ -215,7 +227,7 @@ TEST(AliasesEventContent, Deserialization) TEST(AliasesEventContent, NotAnObject) { - auto data = QJsonArray{ "#test:matrix.org", "#test2:matrix.org" }; + auto data = QJsonArray{"#test:matrix.org", "#test2:matrix.org"}; AliasesEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -223,7 +235,7 @@ TEST(AliasesEventContent, NotAnObject) TEST(AliasesEventContent, MissingKey) { - auto data = QJsonObject{ { "key", QJsonArray{ "#test:matrix.org", "#test2:matrix.org" } } }; + auto data = QJsonObject{{"key", QJsonArray{"#test:matrix.org", "#test2:matrix.org"}}}; AliasesEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -237,7 +249,7 @@ TEST(AliasesEventContent, MissingKey) TEST(AvatarEventContent, Deserialization) { - auto data = QJsonObject{ { "url", "https://matrix.org/avatar.png" } }; + auto data = QJsonObject{{"url", "https://matrix.org/avatar.png"}}; AvatarEventContent content; content.deserialize(data); @@ -248,7 +260,7 @@ TEST(AvatarEventContent, Deserialization) TEST(AvatarEventContent, NotAnObject) { - auto data = QJsonArray{ "key", "url" }; + auto data = QJsonArray{"key", "url"}; AvatarEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -256,7 +268,7 @@ TEST(AvatarEventContent, NotAnObject) TEST(AvatarEventContent, MissingKey) { - auto data = QJsonObject{ { "key", "https://matrix.org" } }; + auto data = QJsonObject{{"key", "https://matrix.org"}}; AvatarEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -270,7 +282,7 @@ TEST(AvatarEventContent, MissingKey) TEST(CreateEventContent, Deserialization) { - auto data = QJsonObject{ { "creator", "@alice:matrix.org" } }; + auto data = QJsonObject{{"creator", "@alice:matrix.org"}}; CreateEventContent content; content.deserialize(data); @@ -281,7 +293,7 @@ TEST(CreateEventContent, Deserialization) TEST(CreateEventContent, NotAnObject) { - auto data = QJsonArray{ "creator", "alice" }; + auto data = QJsonArray{"creator", "alice"}; CreateEventContent content; @@ -290,7 +302,7 @@ TEST(CreateEventContent, NotAnObject) TEST(CreateEventContent, MissingKey) { - auto data = QJsonObject{ { "key", "@alice:matrix.org" } }; + auto data = QJsonObject{{"key", "@alice:matrix.org"}}; CreateEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -304,23 +316,23 @@ TEST(CreateEventContent, MissingKey) TEST(HistoryVisibilityEventContent, Deserialization) { - auto data = QJsonObject{ { "history_visibility", "invited" } }; + auto data = QJsonObject{{"history_visibility", "invited"}}; HistoryVisibilityEventContent content; content.deserialize(data); EXPECT_EQ(content.historyVisibility(), HistoryVisibility::Invited); - data = QJsonObject{ { "history_visibility", "joined" } }; + data = QJsonObject{{"history_visibility", "joined"}}; content.deserialize(data); EXPECT_EQ(content.historyVisibility(), HistoryVisibility::Joined); - data = QJsonObject{ { "history_visibility", "shared" } }; + data = QJsonObject{{"history_visibility", "shared"}}; content.deserialize(data); EXPECT_EQ(content.historyVisibility(), HistoryVisibility::Shared); - data = QJsonObject{ { "history_visibility", "world_readable" } }; + data = QJsonObject{{"history_visibility", "world_readable"}}; content.deserialize(data); EXPECT_EQ(content.historyVisibility(), HistoryVisibility::WorldReadable); @@ -328,7 +340,7 @@ TEST(HistoryVisibilityEventContent, Deserialization) TEST(HistoryVisibilityEventContent, NotAnObject) { - auto data = QJsonArray{ "history_visibility", "alice" }; + auto data = QJsonArray{"history_visibility", "alice"}; HistoryVisibilityEventContent content; @@ -337,7 +349,7 @@ TEST(HistoryVisibilityEventContent, NotAnObject) TEST(HistoryVisibilityEventContent, InvalidHistoryVisibility) { - auto data = QJsonObject{ { "history_visibility", "wrong" } }; + auto data = QJsonObject{{"history_visibility", "wrong"}}; HistoryVisibilityEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -351,7 +363,7 @@ TEST(HistoryVisibilityEventContent, InvalidHistoryVisibility) TEST(HistoryVisibilityEventContent, MissingKey) { - auto data = QJsonObject{ { "key", "joined" } }; + auto data = QJsonObject{{"key", "joined"}}; HistoryVisibilityEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -365,23 +377,23 @@ TEST(HistoryVisibilityEventContent, MissingKey) TEST(JoinRulesEventContent, Deserialization) { - auto data = QJsonObject{ { "join_rule", "invite" } }; + auto data = QJsonObject{{"join_rule", "invite"}}; JoinRulesEventContent content; content.deserialize(data); EXPECT_EQ(content.joinRule(), JoinRule::Invite); - data = QJsonObject{ { "join_rule", "knock" } }; + data = QJsonObject{{"join_rule", "knock"}}; content.deserialize(data); EXPECT_EQ(content.joinRule(), JoinRule::Knock); - data = QJsonObject{ { "join_rule", "private" } }; + data = QJsonObject{{"join_rule", "private"}}; content.deserialize(data); EXPECT_EQ(content.joinRule(), JoinRule::Private); - data = QJsonObject{ { "join_rule", "public" } }; + data = QJsonObject{{"join_rule", "public"}}; content.deserialize(data); EXPECT_EQ(content.joinRule(), JoinRule::Public); @@ -389,7 +401,7 @@ TEST(JoinRulesEventContent, Deserialization) TEST(JoinRulesEventContent, NotAnObject) { - auto data = QJsonArray{ "rule", "alice" }; + auto data = QJsonArray{"rule", "alice"}; JoinRulesEventContent content; @@ -398,7 +410,7 @@ TEST(JoinRulesEventContent, NotAnObject) TEST(JoinRulesEventContent, InvalidHistoryVisibility) { - auto data = QJsonObject{ { "join_rule", "wrong" } }; + auto data = QJsonObject{{"join_rule", "wrong"}}; JoinRulesEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -412,7 +424,7 @@ TEST(JoinRulesEventContent, InvalidHistoryVisibility) TEST(JoinRulesEventContent, MissingKey) { - auto data = QJsonObject{ { "key", "invite" } }; + auto data = QJsonObject{{"key", "invite"}}; JoinRulesEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -426,7 +438,7 @@ TEST(JoinRulesEventContent, MissingKey) TEST(CanonicalAliasEventContent, Deserialization) { - auto data = QJsonObject{ { "alias", "Room Alias" } }; + auto data = QJsonObject{{"alias", "Room Alias"}}; CanonicalAliasEventContent content; content.deserialize(data); @@ -437,7 +449,7 @@ TEST(CanonicalAliasEventContent, Deserialization) TEST(CanonicalAliasEventContent, NotAnObject) { - auto data = QJsonArray{ "alias", "Room Alias" }; + auto data = QJsonArray{"alias", "Room Alias"}; CanonicalAliasEventContent content; @@ -446,7 +458,7 @@ TEST(CanonicalAliasEventContent, NotAnObject) TEST(CanonicalAliasEventContent, MissingKey) { - auto data = QJsonObject{ { "key", "alias" } }; + auto data = QJsonObject{{"key", "alias"}}; CanonicalAliasEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -462,29 +474,29 @@ TEST(MemberEventContent, Deserialization) { MemberEventContent content; - auto data = QJsonObject{ { "membership", "join" } }; + auto data = QJsonObject{{"membership", "join"}}; content.deserialize(data); EXPECT_EQ(content.membershipState(), Membership::Join); - data = QJsonObject{ { "membership", "invite" }, { "displayname", "Username" } }; + data = QJsonObject{{"membership", "invite"}, {"displayname", "Username"}}; content.deserialize(data); EXPECT_EQ(content.membershipState(), Membership::Invite); EXPECT_EQ(content.displayName(), "Username"); - data = QJsonObject{ { "membership", "leave" }, { "avatar_url", "https://matrix.org" } }; + data = QJsonObject{{"membership", "leave"}, {"avatar_url", "https://matrix.org"}}; content.deserialize(data); EXPECT_EQ(content.membershipState(), Membership::Leave); EXPECT_EQ(content.avatarUrl().toString(), "https://matrix.org"); - data = QJsonObject{ { "membership", "ban" } }; + data = QJsonObject{{"membership", "ban"}}; content.deserialize(data); EXPECT_EQ(content.membershipState(), Membership::Ban); - data = QJsonObject{ { "membership", "knock" } }; + data = QJsonObject{{"membership", "knock"}}; content.deserialize(data); EXPECT_EQ(content.membershipState(), Membership::Knock); @@ -492,7 +504,7 @@ TEST(MemberEventContent, Deserialization) TEST(MemberEventContent, InvalidMembership) { - auto data = QJsonObject{ { "membership", "wrong" } }; + auto data = QJsonObject{{"membership", "wrong"}}; MemberEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -506,7 +518,7 @@ TEST(MemberEventContent, InvalidMembership) TEST(MemberEventContent, NotAnObject) { - auto data = QJsonArray{ "name", "join" }; + auto data = QJsonArray{"name", "join"}; MemberEventContent content; @@ -515,7 +527,7 @@ TEST(MemberEventContent, NotAnObject) TEST(MemberEventContent, MissingName) { - auto data = QJsonObject{ { "key", "random" } }; + auto data = QJsonObject{{"key", "random"}}; MemberEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -529,7 +541,7 @@ TEST(MemberEventContent, MissingName) TEST(NameEventContent, Deserialization) { - auto data = QJsonObject{ { "name", "Room Name" } }; + auto data = QJsonObject{{"name", "Room Name"}}; NameEventContent content; content.deserialize(data); @@ -540,7 +552,7 @@ TEST(NameEventContent, Deserialization) TEST(NameEventContent, NotAnObject) { - auto data = QJsonArray{ "name", "Room Name" }; + auto data = QJsonArray{"name", "Room Name"}; NameEventContent content; @@ -549,7 +561,7 @@ TEST(NameEventContent, NotAnObject) TEST(NameEventContent, MissingName) { - auto data = QJsonObject{ { "key", "Room Name" } }; + auto data = QJsonObject{{"key", "Room Name"}}; NameEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); @@ -582,17 +594,17 @@ TEST(PowerLevelsEventContent, DefaultValues) TEST(PowerLevelsEventContent, FullDeserialization) { auto data = QJsonObject{ - { "ban", 1 }, - { "invite", 2 }, - { "kick", 3 }, - { "redact", 4 }, + {"ban", 1}, + {"invite", 2}, + {"kick", 3}, + {"redact", 4}, - { "events_default", 5 }, - { "state_default", 6 }, - { "users_default", 7 }, + {"events_default", 5}, + {"state_default", 6}, + {"users_default", 7}, - { "events", QJsonObject{ { "m.message.text", 8 }, { "m.message.image", 9 } } }, - { "users", QJsonObject{ { "@alice:matrix.org", 10 }, { "@bob:matrix.org", 11 } } }, + {"events", QJsonObject{{"m.message.text", 8}, {"m.message.image", 9}}}, + {"users", QJsonObject{{"@alice:matrix.org", 10}, {"@bob:matrix.org", 11}}}, }; PowerLevelsEventContent power_levels; @@ -621,13 +633,13 @@ TEST(PowerLevelsEventContent, FullDeserialization) TEST(PowerLevelsEventContent, PartialDeserialization) { auto data = QJsonObject{ - { "ban", 1 }, - { "invite", 2 }, + {"ban", 1}, + {"invite", 2}, - { "events_default", 5 }, - { "users_default", 7 }, + {"events_default", 5}, + {"users_default", 7}, - { "users", QJsonObject{ { "@alice:matrix.org", 10 }, { "@bob:matrix.org", 11 } } }, + {"users", QJsonObject{{"@alice:matrix.org", 10}, {"@bob:matrix.org", 11}}}, }; PowerLevelsEventContent power_levels; @@ -653,7 +665,7 @@ TEST(PowerLevelsEventContent, PartialDeserialization) TEST(PowerLevelsEventContent, NotAnObject) { - auto data = QJsonArray{ "test", "test2" }; + auto data = QJsonArray{"test", "test2"}; PowerLevelsEventContent power_levels; @@ -662,7 +674,7 @@ TEST(PowerLevelsEventContent, NotAnObject) TEST(TopicEventContent, Deserialization) { - auto data = QJsonObject{ { "topic", "Room Topic" } }; + auto data = QJsonObject{{"topic", "Room Topic"}}; TopicEventContent content; content.deserialize(data); @@ -673,7 +685,7 @@ TEST(TopicEventContent, Deserialization) TEST(TopicEventContent, NotAnObject) { - auto data = QJsonArray{ "topic", "Room Topic" }; + auto data = QJsonArray{"topic", "Room Topic"}; TopicEventContent content; @@ -682,7 +694,7 @@ TEST(TopicEventContent, NotAnObject) TEST(TopicEventContent, MissingName) { - auto data = QJsonObject{ { "key", "Room Name" } }; + auto data = QJsonObject{{"key", "Room Name"}}; TopicEventContent content; ASSERT_THROW(content.deserialize(data), DeserializationException); |