I'm currently trying to automate the testing of a C++ program which takes input from the terminal and outputs the result onto the terminal. For example my C++ file would do something like below:
#include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
std::cout << a + b;
}
And my Python file used for testing would be like:
as = [1, 2, 3, 4, 5]
bs = [2, 3, 1, 4, 5]
results = []
for i in range(5):
# input a[i] and b[i] into the C++ program
# append answer from C++ program into results
Although it is possible to input and output from C++ through file I/O, I'd rather leave the C++ program untouched.
What can I do instead of the commented out lines in the Python program?
Aucun commentaire:
Enregistrer un commentaire