Files
panda3d/tests/pgraph/test_materialattrib.py
rdb a01711148b tests: add an assorted variety of unit tests
I'm mostly trying to make sure we have over-coverage for a couple of places that are being hit intermittently by our current unit tests, generating noisy codecov reports.  If we make sure these places are hit always, we hopefully won't have codecov misreport lost/gained coverage for unrelated changes.
2020-04-02 13:45:09 +02:00

35 lines
1.1 KiB
Python

from panda3d import core
def test_materialattrib_compare():
mat1 = core.Material()
mat2 = core.Material()
# Two empty attribs
mattr1 = core.MaterialAttrib.make_off()
mattr2 = core.MaterialAttrib.make_off()
assert mattr1.compare_to(mattr2) == 0
assert mattr2.compare_to(mattr1) == 0
# One empty attrib, one with a material
mattr1 = core.MaterialAttrib.make_off()
mattr2 = core.MaterialAttrib.make(mat1)
assert mattr1 != mattr2
assert mattr1.compare_to(mattr2) != 0
assert mattr2.compare_to(mattr1) != 0
assert mattr1.compare_to(mattr2) == -mattr2.compare_to(mattr1)
# Two attribs with same material
mattr1 = core.MaterialAttrib.make(mat1)
mattr2 = core.MaterialAttrib.make(mat1)
assert mattr1.compare_to(mattr2) == 0
assert mattr2.compare_to(mattr1) == 0
# Two different materials
mattr1 = core.MaterialAttrib.make(mat1)
mattr2 = core.MaterialAttrib.make(mat2)
assert mattr1 != mattr2
assert mattr1.compare_to(mattr2) != 0
assert mattr2.compare_to(mattr1) != 0
assert mattr1.compare_to(mattr2) == -mattr2.compare_to(mattr1)