repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / tests / system / libroot / posix / getsubopt_test.cpp
blob6a2c56e745af2fd347bb1a81327fba059154742f
1 /*
2 * Copyright 2010, Oliver Tappe <zooey@hirschkaefer.de>.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
12 int
13 main()
15 char* const keys[] = {
16 "mode", "be-lenient", NULL
19 char* option = strdup("mode=readwrite,unknown,be-lenient");
20 char* value = NULL;
21 int result = getsubopt(&option, keys, &value);
22 if (result != 0)
23 fprintf(stderr, "failed 1: result=%d, expected %d\n", result, 0);
24 if (value == NULL || strcmp(value, "readwrite") != 0)
25 fprintf(stderr, "failed 2: value=%s, expected 'readwrite'\n", value);
26 result = getsubopt(&option, keys, &value);
27 if (result != -1)
28 fprintf(stderr, "failed 3: result=%d, expected %d\n", result, -1);
29 if (value != NULL)
30 fprintf(stderr, "failed 4: value=%p, expected NULL\n", value);
31 result = getsubopt(&option, keys, &value);
32 if (result != 1)
33 fprintf(stderr, "failed 5: result=%d, expected %d\n", result, 1);
34 if (value != NULL)
35 fprintf(stderr, "failed 6: value=%p, expected NULL\n", value);
37 return 0;