def test_standard(): l1 = gj2ascii.array2ascii([['*', '*', '*', '*', '*'], [' ', ' ', '*', ' ', ' '], ['*', '*', ' ', ' ', ' ']]) l2 = gj2ascii.array2ascii([[' ', ' ', ' ', '+', '+'], [' ', '+', ' ', ' ', ' '], [' ', ' ', '+', '+', '+']]) eo = gj2ascii.array2ascii([['*', '*', '*', '+', '+'], ['.', '+', '*', '.', '.'], ['*', '*', '+', '+', '+']]) assert gj2ascii.stack([l1, l2], fill='.').strip(os.linesep), eo.strip(os.linesep)
def test_standard(self): l1 = gj2ascii.array2ascii([['*', '*', '*', '*', '*'], [' ', ' ', '*', ' ', ' '], ['*', '*', ' ', ' ', ' ']]) l2 = gj2ascii.array2ascii([[' ', ' ', ' ', '+', '+'], [' ', '+', ' ', ' ', ' '], [' ', ' ', '+', '+', '+']]) eo = gj2ascii.array2ascii([['*', '*', '*', '+', '+'], ['.', '+', '*', '.', '.'], ['*', '*', '+', '+', '+']]) self.assertEqual(gj2ascii.stack( [l1, l2], fill='.').strip(os.linesep), eo.strip(os.linesep))
def test_style(): array = [['0', '0', '0', '1', '0'], [' ', ' ', '2', '0', '1'], ['1', '1', '2', '1', '3']] colormap = { ' ': 'black', '0': 'blue', '1': 'yellow', '2': 'white', '3': 'red' } expected = [] for row in array: o_row = [] for char in row: color = gj2ascii.ANSI_COLORMAP[colormap[char]] o_row.append(color + char + ' ' + gj2ascii.core._ANSI_RESET) expected.append(''.join(o_row)) expected = os.linesep.join(expected) assert expected == gj2ascii.style(gj2ascii.array2ascii(array), stylemap=colormap)
def test_style(self): array = [['0', '0', '0', '1', '0'], [' ', ' ', '2', '0', '1'], ['1', '1', '2', '1', '3']] colormap = { ' ': 'black', '0': 'blue', '1': 'yellow', '2': 'white', '3': 'red' } expected = [] for row in array: o_row = [] for char in row: color = gj2ascii.ANSI_COLORMAP[colormap[char]] o_row.append(color + char + ' ' + gj2ascii.core._ANSI_RESET) expected.append(''.join(o_row)) expected = os.linesep.join(expected) self.assertEqual( expected, gj2ascii.style(gj2ascii.array2ascii(array), stylemap=colormap))
def test_roundhouse(ascii, array): assert ascii == gj2ascii.array2ascii(gj2ascii.ascii2array(ascii)) assert array == gj2ascii.ascii2array(gj2ascii.array2ascii(array))
def test_array2ascii(ascii, array): assert ascii == gj2ascii.array2ascii(array) assert ascii == gj2ascii.array2ascii(array)
def test_single_layer(compare_ascii): l1 = gj2ascii.array2ascii([['*', '*', '*', '*', '*'], [' ', ' ', '*', ' ', ' '], ['*', '*', ' ', ' ', ' ']]) assert compare_ascii(l1, gj2ascii.stack([l1]))
def test_roundhouse(self): self.assertEqual(self.ascii, gj2ascii.array2ascii(gj2ascii.ascii2array(self.ascii))) self.assertEqual(self.array, gj2ascii.ascii2array(gj2ascii.array2ascii(self.array)))
def test_array2ascii(self): self.assertEqual(self.ascii, gj2ascii.array2ascii(self.array)) self.assertEqual(self.ascii, gj2ascii.array2ascii(self.np_array))
def test_single_layer(self): l1 = gj2ascii.array2ascii([['*', '*', '*', '*', '*'], [' ', ' ', '*', ' ', ' '], ['*', '*', ' ', ' ', ' ']]) self.assertTrue(compare_ascii(l1, gj2ascii.stack([l1])))