Skip to content

Commit

Permalink
Update and correct needles test for U01 and TBF
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarize committed Oct 27, 2023
1 parent 21cf9da commit 0e95ff6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/test_convert_tbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,27 +186,28 @@ def test_convert_tbf_to_xxx(self):
self.addCleanup(os.remove, file1)
self.addCleanup(os.remove, file2)

def test_convert_tbf_to_u01_needles(self):
def test_needles_convert_tbf_to_u01(self):
file1 = "convert_u01.tbf"
file2 = "converted_tbf.u01"
write_tbf(get_shift_pattern_needles(), file1)
f_pattern = read_tbf(file1)

t = 7
t = 8
for x, y, cmd in f_pattern.stitches:
if cmd & COMMAND_MASK == COLOR_CHANGE:
if cmd & COMMAND_MASK == NEEDLE_SET:
flag, thread, needle, order = decode_embroidery_command(cmd)
self.assertEqual(needle, t)
t -= 1
if t <= 0:
t = 8

write_u01(f_pattern, file2)
t_pattern = read_u01(file2)

self.assertIsNotNone(t_pattern)
self.assertEqual(f_pattern.count_stitch_commands(NEEDLE_SET), 15)
self.assertEqual(t_pattern.count_stitch_commands(NEEDLE_SET), 15)
self.assertEqual(t_pattern.count_stitch_commands(STITCH), 8 * 5)
self.position_equals(t_pattern.stitches, 0, -1)
self.assertEqual(f_pattern.count_stitch_commands(NEEDLE_SET), 16)
self.assertEqual(t_pattern.count_stitch_commands(NEEDLE_SET), 16)
self.assertEqual(t_pattern.count_stitch_commands(STITCH), 16 * 5)
print("tbf->u01: ", t_pattern.stitches)
self.addCleanup(os.remove, file1)
self.addCleanup(os.remove, file2)

0 comments on commit 0e95ff6

Please sign in to comment.