def test_merge_03(self): sj = StringJoiner(prefix="[", suffix="]") sj.merge([1, 2, 3, "str", 4.0, ","]) self.assertEqual("[1,2,3,str,4.0,,]", str(sj)) expected__repr__ = '{"separator": ",", "prefix": "[", "suffix": "]", ' \ '"nelem": 6, "str_length": 17, "elements": ["1", "2", "3", "str", "4.0", ","]}' self.assertEqual(expected__repr__, sj.__repr__())
def test_merge_02(self): sj1 = StringJoiner(prefix="[", suffix="]") sj1.add("e1").add("e2").add(3) sj2 = StringJoiner(prefix="(", suffix=")") sj2.add("o1").add("o2") sj2.merge(sj1, 1) self.assertEqual("(o1,e1,e2,3,o2)", str(sj2)) expected__repr__ = '{"separator": ",", "prefix": "(", "suffix": ")", ' \ '"nelem": 5, "str_length": 15, "elements": ["o1", "e1", "e2", "3", "o2"]}' self.assertEqual(expected__repr__, sj2.__repr__())