Changed the programmer error tests to require a strict match. Now I want to restructure them to both be reusable and to not require global state.
This commit is contained in:
parent
a2b9145931
commit
7486ff6b25
|
@ -11,11 +11,13 @@ struct errorParams errorParams;
|
|||
void catchProgrammerError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
||||
{
|
||||
errorParams.caught = true;
|
||||
if (strstr(prefix, "programmer error") == NULL)
|
||||
if (strcmp(prefix, "libui programmer error") != 0)
|
||||
// TODO use diff
|
||||
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s prefix string doesn't contain \"programmer error\": %s", errorParams.exprstr, prefix);
|
||||
if (internal)
|
||||
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s error is marked internal; should not have been", errorParams.exprstr);
|
||||
if (strstr(msg, errorParams.msgWant) == NULL)
|
||||
if (strcmp(msg, errorParams.msgWant) != 0)
|
||||
// TODO use diff
|
||||
testingTErrorfFull(errorParams.t, errorParams.file, errorParams.line, "%s: message doesn't contain expected substring:" diff("%s"),
|
||||
errorParams.exprstr, msg, errorParams.msgWant);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ static void catalogProgrammerError(const char *prefix, const char *msg, const ch
|
|||
size_t n;
|
||||
|
||||
current->caught = true;
|
||||
if (strstr(prefix, "programmer error") == NULL) {
|
||||
if (strcmp(prefix, "libui programmer error") != 0) {
|
||||
n = strlen(prefix);
|
||||
current->prefixGot = (char *) malloc((n + 1) * sizeof (char));
|
||||
if (current->prefixGot == NULL) {
|
||||
|
@ -69,7 +69,7 @@ static void catalogProgrammerError(const char *prefix, const char *msg, const ch
|
|||
return;
|
||||
}
|
||||
current->internalGot = internal;
|
||||
if (strstr(msg, current->msgWant) == NULL) {
|
||||
if (strcmp(msg, current->msgWant) != 0) {
|
||||
n = strlen(msg);
|
||||
current->msgGot = (char *) malloc((n + 1) * sizeof (char));
|
||||
if (current->msgGot == NULL) {
|
||||
|
@ -121,10 +121,12 @@ static void reportCases(testingT *t, struct errorCase *p)
|
|||
continue;
|
||||
}
|
||||
if (p->prefixGot != NULL)
|
||||
// TODO use diff
|
||||
testingTErrorfFull(t, p->file, p->line, "%s prefix string doesn't contain \"programmer error\": %s", p->name, p->prefixGot);
|
||||
if (p->internalGot)
|
||||
testingTErrorfFull(t, p->file, p->line, "%s error is marked internal; should not have been", p->name);
|
||||
if (p->msgGot != NULL)
|
||||
// TODO use diff
|
||||
testingTErrorfFull(t, p->file, p->line, "%s message doesn't contain expected substring:" diff("%s"),
|
||||
p->name, p->msgGot, p->msgWant);
|
||||
p = p->next;
|
||||
|
|
Loading…
Reference in New Issue