Files
video-shader-toys/tests/NdiInputFormatTests.cpp
2026-05-22 16:34:20 +10:00

63 lines
1.7 KiB
C++

#include "video/ndi/NdiInputFormat.h"
#include <iostream>
#include <string>
namespace
{
int gFailures = 0;
void Expect(bool condition, const std::string& message)
{
if (condition)
return;
++gFailures;
std::cerr << "FAILED: " << message << "\n";
}
void TestNdiFourCcMapping()
{
using namespace RenderCadenceCompositor;
VideoIOPixelFormat format = VideoIOPixelFormat::Uyvy8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_BGRA, format), "BGRA maps successfully");
Expect(format == VideoIOPixelFormat::Bgra8, "BGRA maps to Bgra8");
format = VideoIOPixelFormat::Uyvy8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_BGRX, format), "BGRX maps successfully");
Expect(format == VideoIOPixelFormat::Bgra8, "BGRX maps to Bgra8");
format = VideoIOPixelFormat::Bgra8;
Expect(MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_UYVY, format), "UYVY maps successfully");
Expect(format == VideoIOPixelFormat::Uyvy8, "UYVY maps to Uyvy8");
format = VideoIOPixelFormat::Bgra8;
Expect(!MapNdiFourCcToVideoIOPixelFormat(NDIlib_FourCC_video_type_RGBA, format), "RGBA is unsupported until conversion is implemented");
Expect(format == VideoIOPixelFormat::Bgra8, "unsupported mapping leaves output untouched");
}
void TestNdiFourCcNames()
{
using namespace RenderCadenceCompositor;
Expect(std::string(NdiFourCcName(NDIlib_FourCC_video_type_BGRA)) == "BGRA", "BGRA name is readable");
Expect(std::string(NdiFourCcName(NDIlib_FourCC_video_type_UYVY)) == "UYVY", "UYVY name is readable");
}
}
int main()
{
TestNdiFourCcMapping();
TestNdiFourCcNames();
if (gFailures != 0)
{
std::cerr << gFailures << " NdiInputFormat test failure(s).\n";
return 1;
}
std::cout << "NdiInputFormat tests passed.\n";
return 0;
}