Files
VoidTeamspeak/tests/test_modern_api.cpp
T
faumaray df7fefa85c Update
Signed-off-by: faumaray <faumaray@gmail.com>
2026-07-12 17:55:24 +03:00

51 lines
1.6 KiB
C++

#include "check.hpp"
#include <Void/TeamSpeak/TeamSpeak.hpp>
#include <type_traits>
#include <utility>
using namespace Void::TeamSpeak;
static_assert(!std::is_copy_constructible_v<Client>);
static_assert(std::is_move_constructible_v<Client>);
static_assert(std::is_same_v<decltype(Client{}.id()), ClientId>);
static_assert(std::is_same_v<decltype(ChannelGroup{}.id), ChannelGroupId>);
static_assert(std::is_same_v<decltype(Permission{}.id), PermissionId>);
static_assert(std::is_same_v<decltype(Events{}.clientUpdated),
std::function<void(const ClientUpdated&)>>);
static_assert(std::is_same_v<decltype(Events{}.talkStatusChanged),
std::function<void(const TalkStatusChanged&)>>);
static_assert(std::is_same_v<decltype(Events{}.serverUpdated),
std::function<void(const ServerUpdated&)>>);
static_assert(std::is_same_v<decltype(Events{}.fileTransferStatus),
std::function<void(const FileTransferStatus&)>>);
static_assert(std::is_same_v<decltype(std::declval<Client&>().deleteFile("x")),
Void::Result::Result<void, Error>>);
TEST_CASE(modern_build_command_escapes_fields)
{
const auto command = buildCommand("sendtextmessage", {
{"msg", "hello world|all"}, {"target", "7"}});
CHECK_EQ(command,
std::string("sendtextmessage msg=hello\\sworld\\pall target=7"));
}
TEST_CASE(strong_ids_do_not_implicitly_convert)
{
const ClientId client{42};
const ChannelId channel{42};
CHECK(client.value == 42);
CHECK(channel.value == 42);
CHECK(static_cast<bool>(client));
CHECK(static_cast<bool>(channel));
}
TEST_CASE(whisper_targets_report_empty_state)
{
WhisperTargets targets;
CHECK(targets.empty());
targets.clients.push_back(ClientId{7});
CHECK(!targets.empty());
}