Home > Net >  Test for a program that receives input from keyboard
Test for a program that receives input from keyboard

Time:11-28

i have done a program that receives input from the terminal with the readline function in c (https://eli.thegreenplace.net/2016/basics-of-using-the-readline-library/), that saves keyboard input from the terminal (basically a read for the stdin), and i wanted to do a test (In python, c or bash) to do some tests, do anyone knows a way to do it?

CodePudding user response:

Here is an initial bash script that randomizes input with some properties:

for i in {1..5}; do
    input=$(echo {A..Z} {a..z} | tr ' ' "\n" | shuf | xargs | tr -d ' ' | cut -b 1-18)
    echo ${input}
    /path/to/your_program < ${input}
done

You can add characters, make the input shorter etc.

CodePudding user response:

I think what you want is to grab the input in python (I suggest you use the input() function), store it in a variable, then print it out in the terminal using print()

  • Related