def test_add_text_with_groups(self): txt = "TEXT TAIL1 TAIL2" result = encode_whitespaces(txt) self.assertEqual(result[0], "TEXT ") self.assertEqual(result[2], "TAIL1 ") self.assertEqual(result[4], "TAIL2") self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_with_brk(self): txt = "TEXT\nTAIL" result = encode_whitespaces(txt) self.assertEqual(result[0], "TEXT") self.assertEqual(result[1].TAG, CN('text:line-break')) self.assertEqual(result[2], "TAIL") self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_with_tab(self): txt = "TEXT\tTAIL" result = encode_whitespaces(txt) self.assertEqual(result[0], "TEXT") self.assertEqual(result[1].TAG, CN('text:tab')) self.assertEqual(result[2], "TAIL") self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_ends_with_5_spc(self): txt = "TEXT " result = encode_whitespaces(txt) self.assertEqual(result[0], "TEXT ") self.assertEqual(result[1].TAG, CN('text:s')) self.assertEqual(result[1].count, 4) self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_start_with_spc_tab(self): txt = " \tTEXT" result = encode_whitespaces(txt) self.assertEqual(result[0], " ") self.assertEqual(result[1].TAG, CN('text:s')) self.assertEqual(result[2].TAG, CN('text:tab')) self.assertEqual(result[3], "TEXT") self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_with_brk_after_spc(self): txt = "TEXT\nTAIL \n" result = encode_whitespaces(txt) self.assertEqual(result[0], "TEXT") self.assertEqual(result[1].TAG, CN('text:line-break')) self.assertEqual(result[2], "TAIL ") self.assertEqual(result[3].TAG, CN('text:s')) self.assertEqual(result[3].count, 4) self.assertEqual(result[4].TAG, CN('text:line-break')) self.assertEqual(decode_whitespaces(result), txt)
def test_add_text_with_1_spc(self): txt = "TEXT TAIL" result = encode_whitespaces(txt) self.assertEqual(result[0], txt) self.assertEqual(decode_whitespaces(result), txt)
def test_add_simple_text(self): result = encode_whitespaces("TEXT") self.assertEqual(result[0], "TEXT") self.assertEqual(decode_whitespaces(result), "TEXT")