aboutsummaryrefslogtreecommitdiff
path: root/tests/test_str_isempty.c
blob: 9f528133e074f042ad6f7846da670e05e9826c7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "spm.h"
#include "framework.h"

const char *testFmt = "case: '%s': returned %d, expected %d\n";
struct TestCase testCase[] = {
        {.caseValue.sptr = " not empty", .truthValue.signed_int = 0},
        {.caseValue.sptr = "not empty", .truthValue.signed_int = 0},
        {.caseValue.sptr = "    ", .truthValue.signed_int = 1},
        {.caseValue.sptr = "\t", .truthValue.signed_int = 1},
        {.caseValue.sptr = "\n", .truthValue.signed_int = 1},
        {.caseValue.sptr = "", .truthValue.signed_int = 1},
        {.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 = isempty(testCase[i].caseValue.sptr);
        myassert(result == testCase[i].truthValue.signed_int, testFmt, testCase[i].caseValue.sptr, result, testCase[i].truthValue.sptr);
    }
    return 0;
}