1import fontTools.varLib.iup as iup 2import sys 3import pytest 4 5 6class IupTest: 7 8# ----- 9# Tests 10# ----- 11 12 @pytest.mark.parametrize( 13 "delta, coords, forced", 14 [ 15 ( 16 [(0, 0)], 17 [(1, 2)], 18 set() 19 ), 20 ( 21 [(0, 0), (0, 0), (0, 0)], 22 [(1, 2), (3, 2), (2, 3)], 23 set() 24 ), 25 ( 26 [(1, 1), (-1, 1), (-1, -1), (1, -1)], 27 [(0, 0), (2, 0), (2, 2), (0, 2)], 28 set() 29 ), 30 ( 31 [(-1, 0), (-1, 0), (-1, 0), (-1, 0), (-1, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (0, 0), (-1, 0)], 32 [(-35, -152), (-86, -101), (-50, -65), (0, -116), (51, -65), (86, -99), (35, -151), (87, -202), (51, -238), (-1, -187), (-53, -239), (-88, -205)], 33 {11} 34 ), 35 ( 36 [(0, 0), (1, 0), (2, 0), (2, 0), (0, 0), (1, 0), (3, 0), (3, 0), (2, 0), (2, 0), (0, 0), (0, 0), (-1, 0), (-1, 0), (-1, 0), (-3, 0), (-1, 0), (0, 0), (0, 0), (-2, 0), (-2, 0), (-1, 0), (-1, 0), (-1, 0), (-4, 0)], 37 [(330, 65), (401, 65), (499, 117), (549, 225), (549, 308), (549, 422), (549, 500), (497, 600), (397, 648), (324, 648), (271, 648), (200, 620), (165, 570), (165, 536), (165, 473), (252, 407), (355, 407), (396, 407), (396, 333), (354, 333), (249, 333), (141, 268), (141, 203), (141, 131), (247, 65)], 38 {5, 15, 24} 39 ), 40 ] 41 ) 42 def test_forced_set(self, delta, coords, forced): 43 f = iup._iup_contour_bound_forced_set(delta, coords) 44 assert forced == f 45 46 chain1, costs1 = iup._iup_contour_optimize_dp(delta, coords, f) 47 chain2, costs2 = iup._iup_contour_optimize_dp(delta, coords, set()) 48 49 assert chain1 == chain2, f 50 assert costs1 == costs2, f 51 52if __name__ == "__main__": 53 sys.exit(pytest.main(sys.argv)) 54