Блог пользователя accidentallygivenfuck

Автор accidentallygivenfuck, 14 лет назад, По-английски

Hi everybody. Does anybody know a way how to test your program in Linux. I know how to do it in Windows 7.

For example (file gr.bat) ::

copy <input_file_name_in_test_data>.in.%1 <input_file_name_default>.in
<executable_file_name>
fc <output_file_name_in_test_data>.out.%1 <output_file_name_default>.out

(you can set the syntax yourself)

to test just enter in cmd gr 1 , gr 2 , ... or gr x for test x.

Thanx in advance.

UPD: LOTS OF THANKS to razimantv and Xerxes. [SOLVED]

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
14 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +2 Проголосовать: не нравится

cmp command will help. http://en.wikipedia.org/wiki/Cmp_(Unix) In order to get more familiar with this, open your terminal and type cmp --help

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Suppose that your executable is named exec and your input files are named input.1 ... input.10 and similarly for output files. In bash, you can write the following script in the bash terminal:

for((i=0;i<=10;i++))
do
./exec <input.$i | diff -bsq - output.$i
done

This will check whether the output your program produces for each input file is the same as the output file.