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

Автор nhivd, история, 5 лет назад, По-английски

Hi everyone! I have a testcases include a lot of tests (example 1.in/1.out,...). But I do not know how to write a script (or a program with C++ or any language) to test my testcases. If you know how to do it, hope you will help me! Thank you.

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

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

I use https://ideone.com/88FCXo to generate the outputs for all input files. You can throw in a diff command to compare the output files.

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

You can check out this mini-grader bash script made by marsenis. It is very easy to use.

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

    Thank you, it actually helpful.

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

    chpipis But, I use a brute-force solution to test, it returned Runtime Error instead of Time Limit Exceed :( Can you help me?

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

      Hi, did you check if you actually had a Runtime Error (eg. allocating too much memory)?

      Also, do you return 0; at the end of main()? That may be a possible reason. I cannot think of anything else at the moment, it usually works smoothly for me.

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

        I had recheck but nothing wrong :( I have return 0;. Oh, I'm using MacOS High Sierra, what OS are you using?

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

          Ubuntu 16.04 but I am not sure it has to do with the OS. Have you tried replacing the default G++ flags of the script by your own?

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

            Yes, I add 2 flag to the default script? What wrong with it? I think the it also can depend on OS, because your C++ compiler can be g++ and my own is clang, is that true?

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

              Oh yeah, you must be right. I have g++ so I cannot test this on my machine.

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

I use very simple script on python to run exe-file on many tests. It can be easily modified, hope it will help you. Link

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

    I think your script can't check TLE and RE?

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

      This script is not checking TLE and RE but I'm sure that you can find more information about subprocess and its return value or configuration at the official Python site.

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

    The link is not working, Can you please update it?

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

      Oh, I changed my GitHub login from VladimirPetrov to vovuh so you can just change this part of URL (here is the correct link)

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

        change: p = subprocess.Popen(path, stdin=fin, stdout=fout)

        to: p = subprocess.Popen(exepath, stdin=fin, stdout=fout)

»
5 лет назад, # |
  Проголосовать: нравится -37 Проголосовать: не нравится

But I do not know how to write a script (or a program with C++ or any language) to test my testcases.

LooOoLoOoooOoLoOooOoOoOoL. ROFL. LMAO. How have you been trying to learn "programming"? Have you written so much unreadable code to solve unrealistic problems that you cannot even write a simple program to solve a trivial problem?

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

    You think it a simple trivial problem? Can you give me your code to test a testcases? Your code have to annouce all results such as accepts, time run, run time error or anything else like an online judge?

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

https://github.com/convict-git/.vimrc/blob/master/compile
It's a shell script. Save it as /usr/bin/compile Make a folder for every problem you solve. And save the inputs as input1, input2, .... and outputs as output1, output2, ... And whenever you want to run your code against these test cases,
compile [cppfile] [allowed run time]
eg. compile sol.cpp 1

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

you can use polygon

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

    I mean test locally. I have created problems on polygon, it only require input file and solution file to generate output. It doesn't check whether my solution is correct or not.

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

      My bad, I read one of your comments above and for some reason thought you were testing it against a bruteforce solution, sorry.

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

Khủng

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится