1 parent
a7ffe73a6c
commit
c1a11ffe29
29 files changed
+433
-123
No files matched your search
+30
-25
@@ -2,36 +2,41 @@
|
||||
|
||||
#include <Void/TeamSpeak/TeamSpeak.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
using namespace Void::TeamSpeak;
|
||||
|
||||
TEST_CASE(modern_library_creates_independent_clients)
|
||||
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(std::declval<Client&>().deleteFile("x")),
|
||||
Void::Result::Result<void, Error>>);
|
||||
|
||||
TEST_CASE(modern_build_command_escapes_fields)
|
||||
{
|
||||
ClientLibrary library;
|
||||
auto first = library.createClient();
|
||||
auto second = library.createClient();
|
||||
CHECK(first != nullptr);
|
||||
CHECK(second != nullptr);
|
||||
CHECK(first.get() != second.get());
|
||||
CHECK_EQ(first->state(), ConnectionState::Disconnected);
|
||||
CHECK_EQ(second->state(), ConnectionState::Disconnected);
|
||||
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_erase_target_types)
|
||||
TEST_CASE(strong_ids_do_not_implicitly_convert)
|
||||
{
|
||||
WhisperTargets targets{
|
||||
.channels = {ChannelId{42}},
|
||||
.clients = {ClientId{7}, ClientId{8}},
|
||||
};
|
||||
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());
|
||||
CHECK_EQ(targets.channels.front().value, std::uint64_t{42});
|
||||
CHECK_EQ(targets.clients.size(), std::size_t{2});
|
||||
CHECK(ClientId{7} != ClientId{8});
|
||||
}
|
||||
|
||||
TEST_CASE(connect_options_are_validated_before_network_io)
|
||||
{
|
||||
Client client;
|
||||
auto result = client.connect({});
|
||||
CHECK(!result.has_value());
|
||||
CHECK_EQ(result.error().code, Error::Code::InvalidArgument);
|
||||
}
|
||||
Reference in new issue
Block a user