1 parent
a7ffe73a6c
commit
c1a11ffe29
29 files changed
+433
-123
No files matched your search
@@ -1,12 +1,12 @@
|
||||
# Unit tests for EchoionProtocol. Uses a tiny header-only harness (check.hpp),
|
||||
# Unit tests for VoidTeamspeak. Uses a tiny header-only harness (check.hpp),
|
||||
# no external test framework required.
|
||||
|
||||
file(GLOB ECHOIONPROTOCOL_TEST_SOURCES CONFIGURE_DEPENDS
|
||||
file(GLOB VOID_TEAMSPEAK_TEST_SOURCES CONFIGURE_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/test_*.cpp")
|
||||
|
||||
add_executable(echoion_protocol_tests ${ECHOIONPROTOCOL_TEST_SOURCES})
|
||||
target_link_libraries(echoion_protocol_tests PRIVATE Void::TeamSpeak)
|
||||
target_include_directories(echoion_protocol_tests PRIVATE
|
||||
add_executable(void_teamspeak_tests ${VOID_TEAMSPEAK_TEST_SOURCES})
|
||||
target_link_libraries(void_teamspeak_tests PRIVATE Void::TeamSpeak)
|
||||
target_include_directories(void_teamspeak_tests PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
add_test(NAME echoion_protocol_tests COMMAND echoion_protocol_tests)
|
||||
add_test(NAME void_teamspeak_tests COMMAND void_teamspeak_tests)
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "check.hpp"
|
||||
#include "echoion/protocol/Command.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Command.hpp"
|
||||
|
||||
using namespace Echoion::Protocol;
|
||||
using namespace Void::TeamSpeak::Protocol;
|
||||
|
||||
TEST_CASE(escape_roundtrip)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "check.hpp"
|
||||
#include "echoion/protocol/Crypto.hpp"
|
||||
#include "echoion/protocol/Util.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Crypto.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Util.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace Echoion::Protocol;
|
||||
using namespace Void::TeamSpeak::Protocol;
|
||||
using Crypto::ByteView;
|
||||
|
||||
namespace
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "check.hpp"
|
||||
#include "echoion/protocol/Crypto.hpp"
|
||||
#include "echoion/protocol/Identity.hpp"
|
||||
#include "echoion/protocol/Util.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Crypto.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Identity.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/Util.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
using namespace Echoion::Protocol;
|
||||
using namespace Void::TeamSpeak::Protocol;
|
||||
|
||||
TEST_CASE(identity_generate_uid_and_level)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ TEST_CASE(identity_sign_verifiable_length)
|
||||
TEST_CASE(identity_save_load_roundtrip)
|
||||
{
|
||||
auto id = Identity::generate(0);
|
||||
std::string path = "/tmp/echoion_identity_test.txt";
|
||||
std::string path = "/tmp/void_teamspeak_identity_test.txt";
|
||||
id.save(path);
|
||||
auto loaded = Identity::load(path);
|
||||
CHECK_EQ(loaded.publicKeyString(), id.publicKeyString());
|
||||
@@ -84,8 +84,8 @@ namespace
|
||||
|
||||
TEST_CASE(identity_import_teamspeak_ini)
|
||||
{
|
||||
const std::string exportPath = "/tmp/echoion_ts_identity.ini";
|
||||
const std::string nativePath = "/tmp/echoion_imported_identity.txt";
|
||||
const std::string exportPath = "/tmp/void_teamspeak_identity.ini";
|
||||
const std::string nativePath = "/tmp/void_teamspeak_imported_identity.txt";
|
||||
{
|
||||
std::ofstream output(exportPath);
|
||||
output << "[Identity]\nidentity=\"" << teamSpeakExportForScalarOne(42)
|
||||
@@ -109,7 +109,7 @@ TEST_CASE(identity_import_teamspeak_ini)
|
||||
|
||||
TEST_CASE(identity_import_rejects_malformed_export)
|
||||
{
|
||||
const std::string path = "/tmp/echoion_bad_identity.ini";
|
||||
const std::string path = "/tmp/void_teamspeak_bad_identity.ini";
|
||||
{
|
||||
std::ofstream output(path);
|
||||
output << "[Identity]\nidentity=not-a-private-key\n";
|
||||
|
||||
+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);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "check.hpp"
|
||||
#include "echoion/protocol/QuickLz.hpp"
|
||||
#include "Void/TeamSpeak/Protocol/QuickLz.hpp"
|
||||
|
||||
using namespace Echoion::Protocol;
|
||||
using namespace Void::TeamSpeak::Protocol;
|
||||
|
||||
// QuickLZ level-1 "stored" (uncompressed) block: header byte with level=1
|
||||
// (bits 2-3 = 01 -> 0x04), compressed bit (bit0) = 0, short size form
|
||||
|
||||
Reference in new issue
Block a user