|
| 1 | +#include <CSFML/Graphics/BlendMode.h> |
| 2 | + |
| 3 | +#include <SFML/Graphics/BlendMode.hpp> |
| 4 | + |
| 5 | +#include <catch2/catch_test_macros.hpp> |
| 6 | + |
| 7 | +TEST_CASE("[Graphics] sfBlendMode") |
| 8 | +{ |
| 9 | + SECTION("sfBlendFactor") |
| 10 | + { |
| 11 | + STATIC_CHECK(sfBlendFactorZero == static_cast<int>(sf::BlendMode::Factor::Zero)); |
| 12 | + STATIC_CHECK(sfBlendFactorOne == static_cast<int>(sf::BlendMode::Factor::One)); |
| 13 | + STATIC_CHECK(sfBlendFactorSrcColor == static_cast<int>(sf::BlendMode::Factor::SrcColor)); |
| 14 | + STATIC_CHECK(sfBlendFactorOneMinusSrcColor == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcColor)); |
| 15 | + STATIC_CHECK(sfBlendFactorDstColor == static_cast<int>(sf::BlendMode::Factor::DstColor)); |
| 16 | + STATIC_CHECK(sfBlendFactorOneMinusDstColor == static_cast<int>(sf::BlendMode::Factor::OneMinusDstColor)); |
| 17 | + STATIC_CHECK(sfBlendFactorSrcAlpha == static_cast<int>(sf::BlendMode::Factor::SrcAlpha)); |
| 18 | + STATIC_CHECK(sfBlendFactorOneMinusSrcAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusSrcAlpha)); |
| 19 | + STATIC_CHECK(sfBlendFactorDstAlpha == static_cast<int>(sf::BlendMode::Factor::DstAlpha)); |
| 20 | + STATIC_CHECK(sfBlendFactorOneMinusDstAlpha == static_cast<int>(sf::BlendMode::Factor::OneMinusDstAlpha)); |
| 21 | + } |
| 22 | + |
| 23 | + SECTION("sfBlendEquation") |
| 24 | + { |
| 25 | + STATIC_CHECK(sfBlendEquationAdd == static_cast<int>(sf::BlendMode::Equation::Add)); |
| 26 | + STATIC_CHECK(sfBlendEquationSubtract == static_cast<int>(sf::BlendMode::Equation::Subtract)); |
| 27 | + STATIC_CHECK(sfBlendEquationReverseSubtract == static_cast<int>(sf::BlendMode::Equation::ReverseSubtract)); |
| 28 | + STATIC_CHECK(sfBlendEquationMin == static_cast<int>(sf::BlendMode::Equation::Min)); |
| 29 | + STATIC_CHECK(sfBlendEquationMax == static_cast<int>(sf::BlendMode::Equation::Max)); |
| 30 | + } |
| 31 | + |
| 32 | + SECTION("Construction") |
| 33 | + { |
| 34 | + // sfBlendFactor colorSrcFactor; ///< Source blending factor for the color channels |
| 35 | + // sfBlendFactor colorDstFactor; ///< Destination blending factor for the color channels |
| 36 | + // sfBlendEquation colorEquation; ///< Blending equation for the color channels |
| 37 | + // sfBlendFactor alphaSrcFactor; ///< Source blending factor for the alpha channel |
| 38 | + // sfBlendFactor alphaDstFactor; ///< Destination blending factor for the alpha channel |
| 39 | + // sfBlendEquation alphaEquation; ///< Blending equation for the alpha channel |
| 40 | + |
| 41 | + constexpr sfBlendMode blendMode{}; |
| 42 | + STATIC_CHECK(blendMode.colorSrcFactor == sfBlendFactorZero); |
| 43 | + STATIC_CHECK(blendMode.colorDstFactor == sfBlendFactorZero); |
| 44 | + STATIC_CHECK(blendMode.colorEquation == sfBlendEquationAdd); |
| 45 | + STATIC_CHECK(blendMode.alphaSrcFactor == sfBlendFactorZero); |
| 46 | + STATIC_CHECK(blendMode.alphaDstFactor == sfBlendFactorZero); |
| 47 | + STATIC_CHECK(blendMode.alphaEquation == sfBlendEquationAdd); |
| 48 | + } |
| 49 | + |
| 50 | + SECTION("Constants") |
| 51 | + { |
| 52 | + SECTION("sfBlendAlpha") |
| 53 | + { |
| 54 | + CHECK(sfBlendAlpha.colorSrcFactor == sfBlendFactorSrcAlpha); |
| 55 | + CHECK(sfBlendAlpha.colorDstFactor == sfBlendFactorOneMinusSrcAlpha); |
| 56 | + CHECK(sfBlendAlpha.colorEquation == sfBlendEquationAdd); |
| 57 | + CHECK(sfBlendAlpha.alphaSrcFactor == sfBlendFactorOne); |
| 58 | + CHECK(sfBlendAlpha.alphaDstFactor == sfBlendFactorOneMinusSrcAlpha); |
| 59 | + CHECK(sfBlendAlpha.alphaEquation == sfBlendEquationAdd); |
| 60 | + } |
| 61 | + |
| 62 | + SECTION("sfBlendAdd") |
| 63 | + { |
| 64 | + CHECK(sfBlendAdd.colorSrcFactor == sfBlendFactorSrcAlpha); |
| 65 | + CHECK(sfBlendAdd.colorDstFactor == sfBlendFactorOne); |
| 66 | + CHECK(sfBlendAdd.colorEquation == sfBlendEquationAdd); |
| 67 | + CHECK(sfBlendAdd.alphaSrcFactor == sfBlendFactorOne); |
| 68 | + CHECK(sfBlendAdd.alphaDstFactor == sfBlendFactorOne); |
| 69 | + CHECK(sfBlendAdd.alphaEquation == sfBlendEquationAdd); |
| 70 | + } |
| 71 | + |
| 72 | + SECTION("sfBlendMultiply") |
| 73 | + { |
| 74 | + CHECK(sfBlendMultiply.colorSrcFactor == sfBlendFactorDstColor); |
| 75 | + CHECK(sfBlendMultiply.colorDstFactor == sfBlendFactorZero); |
| 76 | + CHECK(sfBlendMultiply.colorEquation == sfBlendEquationAdd); |
| 77 | + CHECK(sfBlendMultiply.alphaSrcFactor == sfBlendFactorDstColor); |
| 78 | + CHECK(sfBlendMultiply.alphaDstFactor == sfBlendFactorZero); |
| 79 | + CHECK(sfBlendMultiply.alphaEquation == sfBlendEquationAdd); |
| 80 | + } |
| 81 | + |
| 82 | + SECTION("sfBlendMin") |
| 83 | + { |
| 84 | + CHECK(sfBlendMin.colorSrcFactor == sfBlendFactorOne); |
| 85 | + CHECK(sfBlendMin.colorDstFactor == sfBlendFactorOne); |
| 86 | + CHECK(sfBlendMin.colorEquation == sfBlendEquationMin); |
| 87 | + CHECK(sfBlendMin.alphaSrcFactor == sfBlendFactorOne); |
| 88 | + CHECK(sfBlendMin.alphaDstFactor == sfBlendFactorOne); |
| 89 | + CHECK(sfBlendMin.alphaEquation == sfBlendEquationMin); |
| 90 | + } |
| 91 | + |
| 92 | + SECTION("sfBlendMax") |
| 93 | + { |
| 94 | + CHECK(sfBlendMax.colorSrcFactor == sfBlendFactorOne); |
| 95 | + CHECK(sfBlendMax.colorDstFactor == sfBlendFactorOne); |
| 96 | + CHECK(sfBlendMax.colorEquation == sfBlendEquationMax); |
| 97 | + CHECK(sfBlendMax.alphaSrcFactor == sfBlendFactorOne); |
| 98 | + CHECK(sfBlendMax.alphaDstFactor == sfBlendFactorOne); |
| 99 | + CHECK(sfBlendMax.alphaEquation == sfBlendEquationMax); |
| 100 | + } |
| 101 | + |
| 102 | + SECTION("sfBlendNone") |
| 103 | + { |
| 104 | + CHECK(sfBlendNone.colorSrcFactor == sfBlendFactorOne); |
| 105 | + CHECK(sfBlendNone.colorDstFactor == sfBlendFactorZero); |
| 106 | + CHECK(sfBlendNone.colorEquation == sfBlendEquationAdd); |
| 107 | + CHECK(sfBlendNone.alphaSrcFactor == sfBlendFactorOne); |
| 108 | + CHECK(sfBlendNone.alphaDstFactor == sfBlendFactorZero); |
| 109 | + CHECK(sfBlendNone.alphaEquation == sfBlendEquationAdd); |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments