2026-09-06 20:46:08 -07:00
|
|
|
/*
|
|
|
|
|
streamer-tools OBS Camera Plugin - core library tests
|
|
|
|
|
Copyright (C) 2026 CyberCoveLLC <jknapp85@gmail.com>
|
|
|
|
|
|
2026-09-07 04:44:16 -07:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2026-09-06 20:46:08 -07:00
|
|
|
*/
|
|
|
|
|
|
2026-09-06 22:13:28 -07:00
|
|
|
// NOTE on why this file uses ST_ASSERT and not assert(): CI builds Release,
|
|
|
|
|
// which defines NDEBUG, which compiles every bare assert() out entirely. This
|
|
|
|
|
// suite previously passed unconditionally for exactly that reason. The
|
|
|
|
|
// ST_ASSERT macros in test_util.h are always live and report a pass/fail
|
|
|
|
|
// count.
|
2026-09-06 20:46:08 -07:00
|
|
|
|
|
|
|
|
#include <cstring>
|
2026-09-06 22:13:28 -07:00
|
|
|
#include <string>
|
2026-09-06 20:46:08 -07:00
|
|
|
|
|
|
|
|
#include "stplugin/core.h"
|
|
|
|
|
#include "stplugin/core_c.h"
|
2026-09-06 22:13:28 -07:00
|
|
|
#include "test_util.h"
|
2026-09-06 20:46:08 -07:00
|
|
|
|
2026-09-06 22:13:28 -07:00
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
// The version string comes through both the C++ API and the C ABI
|
|
|
|
|
// wrapper, and the two must agree.
|
2026-09-06 20:46:08 -07:00
|
|
|
const char *cpp_version = stplugin::core_version();
|
2026-09-06 22:13:28 -07:00
|
|
|
ST_ASSERT(cpp_version != nullptr);
|
|
|
|
|
ST_ASSERT(cpp_version != nullptr && std::strlen(cpp_version) > 0);
|
2026-09-06 20:46:08 -07:00
|
|
|
|
|
|
|
|
const char *c_version = stplugin_core_version();
|
2026-09-06 22:13:28 -07:00
|
|
|
ST_ASSERT(c_version != nullptr);
|
|
|
|
|
ST_ASSERT_EQ(std::string(cpp_version ? cpp_version : ""), std::string(c_version ? c_version : ""));
|
|
|
|
|
|
|
|
|
|
// It is the version CMake injected, not a hand-maintained literal.
|
|
|
|
|
ST_ASSERT_EQ(std::string(cpp_version ? cpp_version : ""), std::string(STPLUGIN_EXPECTED_CORE_VERSION));
|
|
|
|
|
|
|
|
|
|
// ConnectionConfig::is_valid(): all three fields are required. Named
|
|
|
|
|
// locals rather than braced temporaries inline, because the commas inside
|
|
|
|
|
// a braced initialiser would be read as macro argument separators.
|
|
|
|
|
const stplugin::ConnectionConfig complete{"https://streamers.example.com", "main-room", "readkey123"};
|
|
|
|
|
const stplugin::ConnectionConfig no_url{"", "main-room", "readkey123"};
|
|
|
|
|
const stplugin::ConnectionConfig no_slug{"https://streamers.example.com", "", "readkey123"};
|
|
|
|
|
const stplugin::ConnectionConfig no_key{"https://streamers.example.com", "main-room", ""};
|
|
|
|
|
const stplugin::ConnectionConfig empty;
|
|
|
|
|
|
|
|
|
|
ST_ASSERT(complete.is_valid());
|
|
|
|
|
ST_ASSERT(!no_url.is_valid());
|
|
|
|
|
ST_ASSERT(!no_slug.is_valid());
|
|
|
|
|
ST_ASSERT(!no_key.is_valid());
|
|
|
|
|
ST_ASSERT(!empty.is_valid());
|
|
|
|
|
|
|
|
|
|
return st_test_report("core");
|
2026-09-06 20:46:08 -07:00
|
|
|
}
|