diff options
| author | Ioannis Tzavaras <tzavaras.jannis@gmail.com> | 2026-03-28 23:41:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-28 21:41:14 +0000 |
| commit | ef2e8dfd5f7e6ee55fa7bc48e44974e64938d14a (patch) | |
| tree | ecc0c3f5d2d2d76c1e14b26c88ca28335d598932 /tests/helpers/TransferFunction.cpp | |
| parent | fdf0e7a305592668e1b01ea4830d239e5151152c (diff) | |
tests: add unit tests for TransferFunction helpers (#13889)
Diffstat (limited to 'tests/helpers/TransferFunction.cpp')
| -rw-r--r-- | tests/helpers/TransferFunction.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/helpers/TransferFunction.cpp b/tests/helpers/TransferFunction.cpp new file mode 100644 index 00000000..8d5c21e3 --- /dev/null +++ b/tests/helpers/TransferFunction.cpp @@ -0,0 +1,43 @@ +#include <helpers/TransferFunction.hpp> + +#include <gtest/gtest.h> + +using namespace NTransferFunction; + +TEST(Helpers, transferFunctionFromStringNamed) { + EXPECT_EQ(fromString("default"), TF_DEFAULT); + EXPECT_EQ(fromString("auto"), TF_AUTO); + EXPECT_EQ(fromString("srgb"), TF_SRGB); + EXPECT_EQ(fromString("gamma22"), TF_GAMMA22); + EXPECT_EQ(fromString("gamma22force"), TF_FORCED_GAMMA22); +} + +TEST(Helpers, transferFunctionFromStringNumeric) { + EXPECT_EQ(fromString("0"), TF_DEFAULT); + EXPECT_EQ(fromString("1"), TF_GAMMA22); + EXPECT_EQ(fromString("2"), TF_FORCED_GAMMA22); + EXPECT_EQ(fromString("3"), TF_SRGB); +} + +TEST(Helpers, transferFunctionFromStringInvalid) { + EXPECT_EQ(fromString(""), TF_DEFAULT); + EXPECT_EQ(fromString("invalid"), TF_DEFAULT); + EXPECT_EQ(fromString("SRGB"), TF_DEFAULT); + EXPECT_EQ(fromString("Gamma22"), TF_DEFAULT); +} + +TEST(Helpers, transferFunctionToString) { + EXPECT_FALSE(toString(TF_DEFAULT).empty()); + EXPECT_FALSE(toString(TF_AUTO).empty()); + EXPECT_FALSE(toString(TF_SRGB).empty()); + EXPECT_FALSE(toString(TF_GAMMA22).empty()); + EXPECT_FALSE(toString(TF_FORCED_GAMMA22).empty()); +} + +TEST(Helpers, transferFunctionRoundTrip) { + EXPECT_EQ(fromString(toString(TF_DEFAULT)), TF_DEFAULT); + EXPECT_EQ(fromString(toString(TF_AUTO)), TF_AUTO); + EXPECT_EQ(fromString(toString(TF_SRGB)), TF_SRGB); + EXPECT_EQ(fromString(toString(TF_GAMMA22)), TF_GAMMA22); + EXPECT_EQ(fromString(toString(TF_FORCED_GAMMA22)), TF_FORCED_GAMMA22); +} |
