vendredi 25 novembre 2016

compare program results on cpp and python

I would like to test cpp code using Python.

I have next code and a.exe file, which I get after complilation:

int main() {
    std::istream& input_stream = std::cin;
    std::ostream& output_stream = std::cout;
    Data input_data = ReadData(input_stream);
    Data output_data = DoSomethingWithData(input_data);
    OutputData(output_data, output_stream);
    return 0;
}

And I have py code:

input_data = ''
for line in sys.stdin:
    input_data += line
output_data = do_something_with_data(input_data)
print(output_data)

I would like to make py script, which can give equal input to cpp programm and py programm and compare outputs. Is there an easy way to do it?

Aucun commentaire:

Enregistrer un commentaire