Files
obs-streamer-tools-plugin/core/tests/test_core.cpp
T

60 lines
2.3 KiB
C++
Raw Normal View History

/*
streamer-tools OBS Camera Plugin - core library tests
Copyright (C) 2026 CyberCoveLLC <jknapp85@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
// Deliberately dependency-free (no gtest/catch2 etc.) so this test target
// has no network fetch or package-manager step in CI -- proving the
// "core library builds and tests headlessly, no OBS required" claim
// without adding another moving part to this scaffolding pass.
#include <cassert>
#include <cstdio>
#include <cstring>
#include "stplugin/core.h"
#include "stplugin/core_c.h"
int main() {
// core_version() should return a non-empty string, via both the
// C++ API and the C ABI wrapper the OBS adapter will actually call.
const char *cpp_version = stplugin::core_version();
assert(cpp_version != nullptr);
assert(std::strlen(cpp_version) > 0);
const char *c_version = stplugin_core_version();
assert(c_version != nullptr);
assert(std::strcmp(cpp_version, c_version) == 0);
// ConnectionConfig::is_valid() -- trivial non-empty checks, but
// exercised through all four combinations to prove the core library
// is genuinely testable in isolation.
stplugin::ConnectionConfig valid{"https://streamers.example.com", "main-room", "readkey123"};
assert(valid.is_valid());
stplugin::ConnectionConfig missing_url{"", "main-room", "readkey123"};
assert(!missing_url.is_valid());
stplugin::ConnectionConfig missing_slug{"https://streamers.example.com", "", "readkey123"};
assert(!missing_slug.is_valid());
stplugin::ConnectionConfig missing_key{"https://streamers.example.com", "main-room", ""};
assert(!missing_key.is_valid());
std::printf("core: all tests passed\n");
return 0;
}