AlexeyDmitriev / JHelper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is There Test Cases Generator Class As in CHelper ?

hack1nt0 opened this issue · comments

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.

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

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