Skip to content

Commit

Permalink
(agrf) finish the layout test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Dec 24, 2024
1 parent c4cd98f commit 2f53302
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions agrf/lib/building/layout_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,45 @@
temperate_1012 = np.array(Image.open("agrf/third_party/opengfx2/temperate/1012.png"))


gs1012 = ADefaultGroundSprite(1012)
dgs1012 = ADefaultGroundSprite(1012)
gs1012 = AGroundSprite(image_sprite("agrf/third_party/opengfx2/temperate/1012.png"))
l1012 = ALayout(dgs1012, [], True)


def test_default_groundsprite():
assert (temperate_1012 == gs1012.graphics(4, 32).to_image()).all()
assert (temperate_1012 == dgs1012.graphics(4, 32).to_image()).all()


def test_default_groundsprite_M():
assert (temperate_1011 == gs1012.M.graphics(4, 32).to_image()).all()
assert (temperate_1011 == dgs1012.M.graphics(4, 32).to_image()).all()


def test_default_groundsprite_R():
assert (temperate_1012 == gs1012.R.graphics(4, 32).to_image()).all()
assert (temperate_1012 == dgs1012.R.graphics(4, 32).to_image()).all()


def test_default_groundsprite_T():
assert (temperate_1012 == gs1012.T.graphics(4, 32).to_image()).all()
assert (temperate_1012 == dgs1012.T.graphics(4, 32).to_image()).all()


def test_groundsprite():
gs1012 = AGroundSprite(image_sprite("agrf/third_party/opengfx2/temperate/1012.png"))
graphics = gs1012.graphics(4, 32).to_image()
assert graphics.shape == (127, 256, 4)
assert graphics[64, 128, 1] == 67
assert (temperate_1012 == gs1012.graphics(4, 32).to_image()).all()


def test_layout():
l = ALayout(gs1012, [], True)
assert (temperate_1012 == l1012.graphics(4, 32).to_image()).all()


def test_layout_M():
assert (temperate_1011 == l1012.M.graphics(4, 32).to_image()).all()

graphics = l.graphics(4, 32).to_image()
assert graphics.shape == (127, 256, 4)
assert graphics[64, 128, 1] == 67

m_graphics = l.M.graphics(4, 32).to_image()
assert m_graphics.shape == (127, 256, 4)
assert m_graphics[64, 128, 1] == 72
def test_layout_R():
assert (temperate_1012 == l1012.R.graphics(4, 32).to_image()).all()

r_graphics = l.R.graphics(4, 32).to_image()
assert r_graphics.shape == (127, 256, 4)
assert r_graphics[64, 128, 1] == 67

t_graphics = l.T.graphics(4, 32).to_image()
assert t_graphics.shape == (127, 256, 4)
assert t_graphics[64, 128, 1] == 67
def test_layout_T():
assert (temperate_1012 == l1012.T.graphics(4, 32).to_image()).all()


def test_symmetry():
Expand Down

0 comments on commit 2f53302

Please sign in to comment.