1 parent
5c036d91fb
commit
01362d2e51
14 files changed
+1324
-51
No files matched your search
@@ -0,0 +1,41 @@
|
||||
#include "echoion/core/state/StateSerializer.hpp"
|
||||
#include "echoion/core/ListeningRoomName.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
const auto normalized = Echoion::Core::validateListeningRoomName(" Focus Room ");
|
||||
if (!normalized || *normalized != "Focus Room" ||
|
||||
Echoion::Core::canonicalListeningRoomName(*normalized) != "focus room" ||
|
||||
Echoion::Core::validateListeningRoomName("\n\t") ||
|
||||
Echoion::Core::validateListeningRoomName(std::string(49, 'x'))) {
|
||||
std::cerr << "listening-room name validation failed\n";
|
||||
return 1;
|
||||
}
|
||||
Echoion::Core::StateV1 state;
|
||||
Echoion::Core::StateV1::ListeningRoomState room;
|
||||
room.name = "focus";
|
||||
room.ownerId = 17;
|
||||
room.members = {17, 23};
|
||||
room.playback.isPlaying = true;
|
||||
room.playback.position = std::chrono::milliseconds{42000};
|
||||
room.playbackPositionMs = 42000;
|
||||
room.autoplay = true;
|
||||
state.listeningRooms.push_back(std::move(room));
|
||||
|
||||
const auto blob = Echoion::Core::StateSerializer::serialize(state);
|
||||
const auto restored = Echoion::Core::StateSerializer::deserialize(blob);
|
||||
if (!restored || restored->listeningRooms.size() != 1) {
|
||||
std::cerr << "listening-room state did not round-trip\n";
|
||||
return 1;
|
||||
}
|
||||
const auto& actual = restored->listeningRooms.front();
|
||||
if (actual.name != "focus" || actual.ownerId != 17 ||
|
||||
actual.members != std::vector<uint64_t>({17, 23}) ||
|
||||
actual.playbackPositionMs != 42000 || !actual.autoplay) {
|
||||
std::cerr << "restored listening-room fields differ\n";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user