Automatically provide program input and check output?

I need a tool to grade student programs. These are going to be simple CLI programs that just request some user input, processes it and prints an output.
The challenge is: code to be tested will be purely imperative (no OOP) by beginner programming students, where they are free to use functions and logic as they want (as long as it makes sense), so there is no way to know exactly what functions they will create. Programs are just a bunch of functions calling each other and struct definitions (with only member variables, no methods). Students are required to use the right data structures, flow control, logic, low-level and high-level containers (data is saved to ram only, no DB o file writing).
An example of program to be coded by students might be: "write a program to manage the stock and sales of a store, knowing that from each sale we must store date, product codes and total amount; allowing the user to: store as many sales as they want, know the total amount earned in a specific year, know the product code that has been sold the most (printing each product code only once)".
Any ideas on how I could approach writing such a tool? Thanks.
Last edited on
closed account (oy0Gy60M)
The challenge is: code to be tested will be purely imperative (no OOP) by beginner programming students, where they are free to use functions and logic as they want (as long as it makes sense), so there is no way to know exactly what functions they will create.

What do you mean by "there is no way to know exactly what functions they will create"?
Last edited on
Well, since these are beginners, sometimes they don't add all necessary functions.

In the example problem I provided, when they have to print the product code that has been sold the most, some might create a function that takes the container with all the sales and returns a set with unique product codes, then print that set contents; while others might do a void function that creates the set as well as prints its contents in the same function.

Also, there is no way to know the names, parameter list and return value of their functions. Also, some might use a vector to store the sales, while others might use a linked list or a static array (usually we tell them what to use but sometimes we leave it to them to see how they use containers).
Topic archived. No new replies allowed.