def test_a_5(self): with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: tmp_file.write('struct test_t {} test;\n') iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual(variant, ' test\n')
def test_a_4(self): with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: tmp_file.write( 'namespace {Some more content} which is not interesting!\n') iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual(variant, ' which is not interesting\n')
def test_a_2(self): with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: tmp_file.write( "{That's a small test} whether the transformation works!\n") iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual(variant, ' whether the transformation works\n')
def test_success_a(self): with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: tmp_file.write('struct test_t {int a;} foo = {1};\n') state = self.pass_.new(tmp_file.name) (result, state) = self.pass_.transform(tmp_file.name, state, None) iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual(variant, ' foo \n')
def test_infinite_loop(self): with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp_file: tmp_file.write(',0,') state = self.pass_.new(tmp_file.name) (result, state) = self.pass_.transform(tmp_file.name, state, None) iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual(variant, ',,')
def test_a(self): with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp_file: tmp_file.write( '// Useless comment\ntransparent_crc(g_376.f0, "g_376.f0", print_hash_value);\ntransparent_crc(g_1194[i].f0, "g_1194[i].f0", print_hash_value);\nint a = 9;' ) iterate_pass(self.pass_, tmp_file.name) with open(tmp_file.name) as variant_file: variant = variant_file.read() os.unlink(tmp_file.name) self.assertEqual( variant, '// Useless comment\nprintf("%d\\n", (int)g_376.f0);\nprintf("%d\\n", (int)g_1194[i].f0);\nint a = 9;' )