Skip to content

Commit f1eb228

Browse files
committed
Updated tmc-check
1 parent 8261b78 commit f1eb228

File tree

11 files changed

+229
-152
lines changed

11 files changed

+229
-152
lines changed

plugins/make/tests/data/failing-exercise/test/tmc-check.c

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static void parse_points(const char *points, PointsList **target_list);
3535
static void add_to_point_set(const char *point, ssize_t len, PointsList **target_list);
3636
static int points_list_contains(const PointsList *list, const char *point, ssize_t len);
3737

38+
static void delete_points_assoc();
39+
static void delete_suite_points();
40+
static void delete_all_points();
41+
3842
void tmc_set_tcase_points(TCase *tc, const char *tc_name, const char *points)
3943
{
4044
PointsAssoc *pa = (PointsAssoc*)malloc(sizeof(PointsAssoc));
@@ -47,11 +51,11 @@ void tmc_set_tcase_points(TCase *tc, const char *tc_name, const char *points)
4751
parse_points(points, &all_points);
4852
}
4953

50-
void _tmc_register_test(Suite *s, TFun tf, const char *fname, const char *points)
54+
void _tmc_register_test(Suite *s, const TTest *tt, const char *fname, const char *points)
5155
{
5256
TCase *tc = tcase_create(fname);
5357
tmc_set_tcase_points(tc, fname, points);
54-
_tcase_add_test(tc, tf, fname, 0, 0, 0, 1);
58+
_tcase_add_test(tc, tt, 0, 0, 0, 1);
5559
suite_add_tcase(s, tc);
5660
}
5761

@@ -74,29 +78,6 @@ Suite* tmc_suite_create(const char *name, const char *points)
7478
return s;
7579
}
7680

77-
void delete_points_assoc()
78-
{
79-
PointsAssoc *pa = points_assocs;
80-
while(pa) {
81-
PointsAssoc *next = pa->next;
82-
free(pa);
83-
pa = next;
84-
}
85-
}
86-
87-
void delete_all_points()
88-
{
89-
PointsList *pl = all_points;
90-
while(pl) {
91-
PointsList *next = pl->next;
92-
if (pl->point)
93-
free(pl->point);
94-
free(pl);
95-
pl = next;
96-
}
97-
}
98-
99-
10081
int tmc_run_tests(int argc, const char **argv, Suite *s)
10182
{
10283
int i;
@@ -124,7 +105,8 @@ int tmc_run_tests(int argc, const char **argv, Suite *s)
124105

125106
delete_points_assoc();
126107
delete_all_points();
127-
108+
delete_suite_points();
109+
128110
return EXIT_SUCCESS;
129111
}
130112

@@ -167,10 +149,10 @@ static void parse_points(const char *points, PointsList **target_list)
167149
const char *p = points;
168150
const char *q = p;
169151
while (*q != '\0') {
170-
if (isspace(*q)) {
152+
if (isspace((int)*q)) {
171153
const ssize_t len = q - p;
172154

173-
if (!isspace(*p)) {
155+
if (!isspace((int)*p)) {
174156
add_to_point_set(p, len, target_list);
175157
}
176158

@@ -181,7 +163,7 @@ static void parse_points(const char *points, PointsList **target_list)
181163
}
182164
}
183165

184-
if (!isspace(*p) && q > p) {
166+
if (!isspace((int)*p) && q > p) {
185167
const ssize_t len = q - p;
186168
add_to_point_set(p, len, target_list);
187169
}
@@ -201,8 +183,7 @@ static void add_to_point_set(const char *point, ssize_t len, PointsList **target
201183

202184
static int points_list_contains(const PointsList *list, const char *point, ssize_t len)
203185
{
204-
const PointsList *pl = list; // hack to clean up warnings
205-
pl = all_points;
186+
const PointsList *pl = all_points;
206187
while (pl != NULL) {
207188
if (strncmp(pl->point, point, len) == 0) {
208189
return 1;
@@ -211,3 +192,38 @@ static int points_list_contains(const PointsList *list, const char *point, ssize
211192
}
212193
return 0;
213194
}
195+
196+
static void delete_points_assoc()
197+
{
198+
PointsAssoc *pa = points_assocs;
199+
while(pa) {
200+
PointsAssoc *next = pa->next;
201+
free(pa);
202+
pa = next;
203+
}
204+
points_assocs = NULL;
205+
}
206+
207+
static void delete_suite_points()
208+
{
209+
SuitePoints *sp = suite_points;
210+
while(sp) {
211+
SuitePoints *next = sp->next;
212+
free(sp);
213+
sp = next;
214+
}
215+
suite_points = NULL;
216+
}
217+
218+
219+
static void delete_all_points()
220+
{
221+
PointsList *pl = all_points;
222+
while(pl) {
223+
PointsList *next = pl->next;
224+
free(pl->point);
225+
free(pl);
226+
pl = next;
227+
}
228+
all_points = NULL;
229+
}

plugins/make/tests/data/failing-exercise/test/tmc-check.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#include <check.h>
23
#include <stdio.h>
34

@@ -15,8 +16,8 @@ Suite* tmc_suite_create(const char *name, const char *points);
1516
*
1617
* One can also register the test function normally and then call tmc_set_tcase_points.
1718
*/
18-
#define tmc_register_test(suite, tf, points) _tmc_register_test((suite), (tf), "" # tf, points)
19-
void _tmc_register_test(Suite *s, TFun tf, const char *fname, const char *points);
19+
#define tmc_register_test(suite, tt, points) _tmc_register_test((suite), (tt), "" # tt, points)
20+
void _tmc_register_test(Suite *s, const TTest *tt, const char *fname, const char *points);
2021

2122

2223
/**
@@ -56,8 +57,3 @@ int tmc_print_available_points(FILE *f, char delimiter);
5657
int tmc_print_test_points(FILE *f);
5758
/** Prints lines with "[suite] suitename pointname1 pointname2" to given file */
5859
int tmc_print_suite_points(FILE *f);
59-
60-
61-
/* Checkhelp functions */
62-
void remove_nonascii(char *str);
63-
int mycompare(char *student, char *model, char *infostr);

plugins/make/tests/data/passing-exercise/test/tmc-check.c

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ static void parse_points(const char *points, PointsList **target_list);
3535
static void add_to_point_set(const char *point, ssize_t len, PointsList **target_list);
3636
static int points_list_contains(const PointsList *list, const char *point, ssize_t len);
3737

38+
static void delete_points_assoc();
39+
static void delete_suite_points();
40+
static void delete_all_points();
41+
3842
void tmc_set_tcase_points(TCase *tc, const char *tc_name, const char *points)
3943
{
4044
PointsAssoc *pa = (PointsAssoc*)malloc(sizeof(PointsAssoc));
@@ -47,11 +51,11 @@ void tmc_set_tcase_points(TCase *tc, const char *tc_name, const char *points)
4751
parse_points(points, &all_points);
4852
}
4953

50-
void _tmc_register_test(Suite *s, TFun tf, const char *fname, const char *points)
54+
void _tmc_register_test(Suite *s, const TTest *tt, const char *fname, const char *points)
5155
{
5256
TCase *tc = tcase_create(fname);
5357
tmc_set_tcase_points(tc, fname, points);
54-
_tcase_add_test(tc, tf, fname, 0, 0, 0, 1);
58+
_tcase_add_test(tc, tt, 0, 0, 0, 1);
5559
suite_add_tcase(s, tc);
5660
}
5761

@@ -74,29 +78,6 @@ Suite* tmc_suite_create(const char *name, const char *points)
7478
return s;
7579
}
7680

77-
void delete_points_assoc()
78-
{
79-
PointsAssoc *pa = points_assocs;
80-
while(pa) {
81-
PointsAssoc *next = pa->next;
82-
free(pa);
83-
pa = next;
84-
}
85-
}
86-
87-
void delete_all_points()
88-
{
89-
PointsList *pl = all_points;
90-
while(pl) {
91-
PointsList *next = pl->next;
92-
if (pl->point)
93-
free(pl->point);
94-
free(pl);
95-
pl = next;
96-
}
97-
}
98-
99-
10081
int tmc_run_tests(int argc, const char **argv, Suite *s)
10182
{
10283
int i;
@@ -124,7 +105,8 @@ int tmc_run_tests(int argc, const char **argv, Suite *s)
124105

125106
delete_points_assoc();
126107
delete_all_points();
127-
108+
delete_suite_points();
109+
128110
return EXIT_SUCCESS;
129111
}
130112

@@ -167,10 +149,10 @@ static void parse_points(const char *points, PointsList **target_list)
167149
const char *p = points;
168150
const char *q = p;
169151
while (*q != '\0') {
170-
if (isspace(*q)) {
152+
if (isspace((int)*q)) {
171153
const ssize_t len = q - p;
172154

173-
if (!isspace(*p)) {
155+
if (!isspace((int)*p)) {
174156
add_to_point_set(p, len, target_list);
175157
}
176158

@@ -181,7 +163,7 @@ static void parse_points(const char *points, PointsList **target_list)
181163
}
182164
}
183165

184-
if (!isspace(*p) && q > p) {
166+
if (!isspace((int)*p) && q > p) {
185167
const ssize_t len = q - p;
186168
add_to_point_set(p, len, target_list);
187169
}
@@ -201,8 +183,7 @@ static void add_to_point_set(const char *point, ssize_t len, PointsList **target
201183

202184
static int points_list_contains(const PointsList *list, const char *point, ssize_t len)
203185
{
204-
const PointsList *pl = list; // hack to clean up warnings
205-
pl = all_points;
186+
const PointsList *pl = all_points;
206187
while (pl != NULL) {
207188
if (strncmp(pl->point, point, len) == 0) {
208189
return 1;
@@ -211,3 +192,38 @@ static int points_list_contains(const PointsList *list, const char *point, ssize
211192
}
212193
return 0;
213194
}
195+
196+
static void delete_points_assoc()
197+
{
198+
PointsAssoc *pa = points_assocs;
199+
while(pa) {
200+
PointsAssoc *next = pa->next;
201+
free(pa);
202+
pa = next;
203+
}
204+
points_assocs = NULL;
205+
}
206+
207+
static void delete_suite_points()
208+
{
209+
SuitePoints *sp = suite_points;
210+
while(sp) {
211+
SuitePoints *next = sp->next;
212+
free(sp);
213+
sp = next;
214+
}
215+
suite_points = NULL;
216+
}
217+
218+
219+
static void delete_all_points()
220+
{
221+
PointsList *pl = all_points;
222+
while(pl) {
223+
PointsList *next = pl->next;
224+
free(pl->point);
225+
free(pl);
226+
pl = next;
227+
}
228+
all_points = NULL;
229+
}

plugins/make/tests/data/passing-exercise/test/tmc-check.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
#include <check.h>
23
#include <stdio.h>
34

@@ -15,8 +16,8 @@ Suite* tmc_suite_create(const char *name, const char *points);
1516
*
1617
* One can also register the test function normally and then call tmc_set_tcase_points.
1718
*/
18-
#define tmc_register_test(suite, tf, points) _tmc_register_test((suite), (tf), "" # tf, points)
19-
void _tmc_register_test(Suite *s, TFun tf, const char *fname, const char *points);
19+
#define tmc_register_test(suite, tt, points) _tmc_register_test((suite), (tt), "" # tt, points)
20+
void _tmc_register_test(Suite *s, const TTest *tt, const char *fname, const char *points);
2021

2122

2223
/**
@@ -56,8 +57,3 @@ int tmc_print_available_points(FILE *f, char delimiter);
5657
int tmc_print_test_points(FILE *f);
5758
/** Prints lines with "[suite] suitename pointname1 pointname2" to given file */
5859
int tmc_print_suite_points(FILE *f);
59-
60-
61-
/* Checkhelp functions */
62-
void remove_nonascii(char *str);
63-
int mycompare(char *student, char *model, char *infostr);
66.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)