From ad296492f839ecc3d236a8bd8b749e760795e954 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 25 Apr 2020 10:36:23 +0200 Subject: [PATCH] tests: add more TextureAttrib comparison tests This will hopefully cover all the lines that are hit non-deterministically by codecov. --- tests/pgraph/test_textureattrib.py | 45 +++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/pgraph/test_textureattrib.py b/tests/pgraph/test_textureattrib.py index 868f3f4b07..85c2aa8311 100644 --- a/tests/pgraph/test_textureattrib.py +++ b/tests/pgraph/test_textureattrib.py @@ -88,7 +88,50 @@ def test_textureattrib_compare(): assert tattr2.compare_to(tattr1) != 0 assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) - # If both have the same texture, they are equal + # Empty stage is not the same as a single off stage + tattr1 = core.TextureAttrib.make() + tattr2 = core.TextureAttrib.make() + tattr2 = tattr2.add_off_stage(stage1) + assert tattr1.compare_to(tattr2) != 0 + assert tattr2.compare_to(tattr1) != 0 + assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) + + # All-off stage is not the same as a single off stage + tattr1 = core.TextureAttrib.make_all_off() + tattr2 = core.TextureAttrib.make() + tattr2 = tattr2.add_off_stage(stage1) + assert tattr1.compare_to(tattr2) != 0 + assert tattr2.compare_to(tattr1) != 0 + assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) + + # Different off stages are non-equal + tattr1 = core.TextureAttrib.make_all_off() + tattr1 = tattr2.add_off_stage(stage1) + tattr2 = core.TextureAttrib.make() + tattr2 = tattr2.add_off_stage(stage2) + assert tattr1.compare_to(tattr2) != 0 + assert tattr2.compare_to(tattr1) != 0 + assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) + + # If both have a different texture, but same stage, they are not equal + tattr1 = core.TextureAttrib.make() + tattr1 = tattr1.add_on_stage(stage1, tex1) + tattr2 = core.TextureAttrib.make() + tattr2 = tattr2.add_on_stage(stage1, tex2) + assert tattr1.compare_to(tattr2) != 0 + assert tattr2.compare_to(tattr1) != 0 + assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) + + # If both have the same texture, but different stage, they are not equal + tattr1 = core.TextureAttrib.make() + tattr1 = tattr1.add_on_stage(stage1, tex1) + tattr2 = core.TextureAttrib.make() + tattr2 = tattr2.add_on_stage(stage2, tex2) + assert tattr1.compare_to(tattr2) != 0 + assert tattr2.compare_to(tattr1) != 0 + assert tattr2.compare_to(tattr1) == -tattr1.compare_to(tattr2) + + # If both have the same texture and stage, they are equal tattr1 = core.TextureAttrib.make() tattr1 = tattr1.add_on_stage(stage1, tex1) tattr2 = core.TextureAttrib.make()