1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include "spm.h"
#include "framework.h"
const char *testFmt = "case: '%s': returned %d, expected %d\n";
struct TestCase testCase[] = {
{.caseValue.sptr = "not quoted", .truthValue.signed_int = 0},
{.caseValue.sptr = "\"double quoted\"", .truthValue.signed_int = 1},
{.caseValue.sptr = "\'single quoted\'", .truthValue.signed_int = 1},
{.caseValue.sptr = "\"no closing quote", .truthValue.signed_int = 0},
{.caseValue.sptr = "no opening quote\"", .truthValue.signed_int = 0},
{.caseValue.sptr = NULL, .truthValue.signed_int = -1},
};
size_t numCases = sizeof(testCase) / sizeof(struct TestCase);
int main(int argc, char *argv[]) {
for (size_t i = 0; i < numCases; i++) {
int result = isquoted(testCase[i].caseValue.sptr);
myassert(result == testCase[i].truthValue.signed_int, testFmt, testCase[i].caseValue.sptr, result, testCase[i].truthValue.signed_int);
}
return 0;
}
|