X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gamma_expansion_effect_test.cpp;fp=gamma_expansion_effect_test.cpp;h=0fd9a71dd57518e8b28fba15268a7690fa2754b6;hp=0000000000000000000000000000000000000000;hb=b76bbc2fce2c56aa65bb8827a3e488c5726a4a9f;hpb=62504944698295c8c48d88df124855af6874fdfe diff --git a/gamma_expansion_effect_test.cpp b/gamma_expansion_effect_test.cpp new file mode 100644 index 0000000..0fd9a71 --- /dev/null +++ b/gamma_expansion_effect_test.cpp @@ -0,0 +1,35 @@ +// Unit tests for GammaExpansionEffect. + +#include "test_util.h" +#include "gtest/gtest.h" +#include "gamma_expansion_effect.h" + +TEST(GammaExpansionEffectTest, sRGB_KeyValues) { + float data[] = { + 0.0f, 1.0f, + 0.040f, 0.041f, // On either side of the discontinuity. + }; + float expected_data[] = { + 0.0f, 1.0f, + 0.00309f, 0.00317f, + }; + float out_data[4]; + EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_sRGB); + tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(expected_data, out_data, 2, 2); +} + +TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) { + float data[256], out_data[256]; + for (unsigned i = 0; i < 256; ++i) { + data[i] = i / 255.0f; + } + EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_sRGB); + tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + + for (unsigned i = 1; i < 256; ++i) { + EXPECT_GT(out_data[i], out_data[i - 1]) + << "No increase between " << i-1 << " and " << i; + } +}