'Make sure the ANSIString is always constructed correctly.'

def test_instance(self):

    clean = u'This    isA|r    testTest'
    encoded = u'\x1b[1m\x1b[32mThis    is\x1b[1m\x1b[31mA|r    test\x1b[0mTest\x1b[0m'
    target = ANSIString('|gThis    is|rA||r    test|nTest|n')
    char_table = [9, 10, 11, 12, 13, 14, 15, 25, 26, 27, 28, 29, 30, 31, 32, 37, 38, 39, 40]
    code_table = [0, 1, 2, 3, 4, 5, 6, 7, 8, 16, 17, 18, 19, 20, 21, 22, 23, 24, 33, 34, 35, 36, 41, 42, 43, 44]
    self.checker(target, encoded, clean)
    self.table_check(target, char_table, code_table)
    self.checker(ANSIString(target), encoded, clean)
    self.table_check(ANSIString(target), char_table, code_table)
    self.checker(ANSIString(encoded, decoded=True), encoded, clean)
    self.table_check(ANSIString(encoded, decoded=True), char_table, code_table)
    self.checker(ANSIString('Test'), u'Test', u'Test')
    self.table_check(ANSIString('Test'), [0, 1, 2, 3], [])
    self.checker(ANSIString(''), u'', u'')
