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

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

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
  • Проголосовать: не нравится

»
11 лет назад, # |
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

»
11 лет назад, # |
  Проголосовать: нравится +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.

  • »
    »
    11 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Thanx. how to save your script ( what should be the extension ) ? and how to run it on terminal ?

    • »
      »
      »
      11 лет назад, # ^ |
        Проголосовать: нравится +5 Проголосовать: не нравится

      Save the script with .sh extension. You can run it with bash <name>.sh or, if you have set executable permissions for it, ./<name>.sh. All these are to be run on terminal only.