-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patharghandler_test.cpp
More file actions
48 lines (39 loc) · 862 Bytes
/
arghandler_test.cpp
File metadata and controls
48 lines (39 loc) · 862 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "arghandler.h"
const char* targv[] =
{
"progname",
"-c=1",
"-d", "2",
"-f=4",
"--g=5",
"--e", "3"
};
int test(int argc, char** argv) {
int argi = 1;
char* c;
char* d;
char* e;
char* f;
char* g;
while (argi < argc) {
StringArgWithCopy("c", &c);
StringArgWithCopy("d", &d);
StringArgWithCopy("e", &e);
StringArgWithCopy("f", &f);
StringArgWithCopy("g", &g);
assert(0); // this should never be reached, macros should always `continue`
}
assert(0 == strcmp(c, "1"));
assert(0 == strcmp(d, "2"));
assert(0 == strcmp(e, "3"));
assert(0 == strcmp(f, "4"));
assert(0 == strcmp(g, "5"));
return 0;
}
int main(int argc, char** argv) {
test(sizeof(targv)/sizeof(char*), (char**)targv);
return 0;
}