Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions checkers/gvaluer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class Group
vector<set<int> > zero_subsets;
set<int> passed_set;

vector<int> test_points;

public:
Group() {}

Expand Down Expand Up @@ -249,10 +251,23 @@ class Group
zero_subsets.emplace_back(zs);
}

void add_test_points(int tp)
{
test_points.push_back(tp);
}

bool has_test_points() const {
return !test_points.empty();
}

bool meet_requirements(const ConfigParser &cfg, const Group *& grp) const;

void add_total_score()
void add_total_score(int test_num)
{
if (has_test_points()) {
total_score += test_points[test_num - first];
return;
}
if (test_score > 0 && !use_lowest_test_score) {
total_score += test_score;
}
Expand All @@ -275,7 +290,7 @@ class Group
{
if (test_score < 0 && passed_count == (last - first + 1)) {
return score;
} else if (test_score >= 0) {
} else if (test_score >= 0 || has_test_points()) {
return total_score;
}
return 0;
Expand Down Expand Up @@ -583,6 +598,32 @@ class ConfigParser
if (t_type != ';') parse_error("';' expected");
next_token();
g.set_test_score(test_score);
} else if (token == "test_points") {
int entry_count = 0;
try {
next_token();
int tp = stoi(token);
g.add_test_points(tp);
++entry_count;
next_token();
while (t_type == ',') {
next_token();
tp = stoi(token);
g.add_test_points(tp);
++entry_count;
next_token();
}
} catch (...) {
parse_error("NUM expected");
}
if (entry_count != g.get_last() - g.get_first() + 1)
{
string ec = to_string(entry_count);
string tc = to_string(g.get_last() - g.get_first() + 1);
parse_error(string("test_points length=") + ec + string(" doesn't match group's tests count=") + tc);
}
if (t_type != ';') parse_error("';' expected");
next_token();
} else if (token == "pass_if_count") {
next_token();
if (t_type != T_IDENT) parse_error("NUM expected");
Expand Down Expand Up @@ -847,15 +888,15 @@ main(int argc, char *argv[])
if (t_status == RUN_OK) {
// just go to the next test...
g->inc_passed_count();
g->add_total_score();
g->add_total_score(test_num);
g->add_passed_test(test_num);
++test_num;
} else if (t_score > 0) {
g->inc_passed_count();
g->add_test_score(t_score);
g->add_passed_test(test_num);
++test_num;
} else if (g->get_test_score() >= 0 && !g->get_use_lowest_test_score()) {
} else if ((g->get_test_score() >= 0 || g->has_test_points()) && !g->get_use_lowest_test_score()) {
// by-test score, just go on
if (test_num == g->get_last()) {
if (g->is_zero_score()) {
Expand Down