AlexeyDmitriev / JHelper

GNU Lesser General Public License v3.0
119 stars 31 forks source link

Is There Test Cases Generator Class As in CHelper ? #94

Closed hack1nt0 closed 4 years ago

AlexeyDmitriev commented 5 years ago

No, there's no such feature at the moment

вс, 19 авг. 2018 г. в 22:19, hack1nt0 notifications@github.com:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlexeyDmitriev/JHelper/issues/94, or mute the thread https://github.com/notifications/unsubscribe-auth/ABI0ehoIaNY6ouyu8g29y0IAyYPZK1gGks5uSbpJgaJpZM4WDFW0 .

AlexeyDmitriev commented 5 years ago

Hi, @hack1nt0 I now understood that something similar is doable by just changing templates.

So, for example, in my task.template I added static function that generates test and a static switch, that shows whether I should use generated tests.

class %ClassName% {
public:
    static constexpr int kStressCount = 0;
    void generateTest(std::ostream& test) {
    }
    void solve(std::istream& in, std::ostream& out) {
        //static int testnumber = 0;
        //out << "Case #" << ++testnumber << ": ";
    }
};

and also in run.template I use this variable and call this function after running on added tests

        for(const jhelper::Test& test: tests) {
        run_test(test);
    }
    for (int i = 0; i < %ClassName%::kStressCount; ++i) {
        std::ostringstream generated_test;
        %ClassName%::generateTest(generated_test);
        run_test({generated_test.str(), "", true, false});
    }

where run_test(test) is function that runs a test and prints OK/Wrong Answer, etc.

I'm going to check whether it'll be usable for me, so you can also try if you still interested

It still becomes part of the code to be submitted which may result in problem with source limit sometimes, but I don't think that's a big issue.

AlexeyDmitriev commented 5 years ago

I've added a page on wiki with a description how to do something like that

AlexeyDmitriev commented 4 years ago

I think that current situation (configuration via template as one wishes is fine)