def test_writeAlignedElements(self): f = lambda x: bdeformatutil.writeAlignedElements( bdeformatutil.alignElementParts( [bdeformatutil.parseElement(e) for e in x])) A = self.assertEqual l = ["int a;", "char character = 0;", "unsigned char x = 'c';", "void *d;"] A(f(l), ([(x, "") for x in l], 15)) l = ["a,", "bcd,", "**eg,", "&h)"] A(f(l), ([(x, "") for x in l], 0))
def test_alignElementParts(self): # 'f' takes a list of strings, replaces '|' with some spaces in # each, calls 'parseElement' on each to build a list suitable for # 'alignElementParts', and then joins each element of the returned # list back with "|" f = lambda x: ["|".join(a) for a in bdeformatutil.alignElementParts( [bdeformatutil.parseElement( e.replace("|", " ")) for e in x])] A = self.assertEqual l = ["int | |a||,|", "char | |b||,|", "void |*|c||,|", "another type| |x|= 2|,|"] A(f(l), l) l = ["int | |abc|= 123|,|", "char | |b |= 2345|,|", "void |***|c||,|", "void ***& |***|c||,|", "another type| |x |= 2|,|"] A(f(l), l)