MCPcopy Create free account
hub / github.com/WheretIB/nullc / TEST_FOR_FAIL_GENERIC

Function TEST_FOR_FAIL_GENERIC

tests/TestBase.cpp:370–395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370void TEST_FOR_FAIL_GENERIC(const char* name, const char* str, const char* error1, const char* error2)
371{
372 testsCount[TEST_FAILURE_INDEX]++;
373 nullres good = nullcCompile(str);
374 if(!good)
375 {
376 char buf[1024];
377 strcpy(buf, strstr(nullcGetLastError(), "ERROR:"));
378 if(memcmp(buf, error1, strlen(error1)) != 0)
379 {
380 printf("Failed %s but for wrong reason:\r\n %s\r\nexpected:\r\n %s\r\n", name, buf, error1);
381 }else{
382 char *bufNext = strstr(buf + 1, "ERROR:");
383 if(char *lineEnd = strchr(bufNext, '\r'))
384 *lineEnd = 0;
385 if(strcmp(error2, bufNext) != 0)
386 {
387 printf("Failed %s but for wrong reason:\r\n %s\r\nexpected:\r\n %s\r\n", name, bufNext, error2);
388 }else{
389 testsPassed[TEST_FAILURE_INDEX]++;
390 }
391 }
392 }else{
393 printf("Test \"%s\" failed to fail.\r\n", name);
394 }
395}

Callers 1

Calls 5

nullcCompileFunction · 0.85
strstrFunction · 0.85
nullcGetLastErrorFunction · 0.85
strchrFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected