summaryrefslogtreecommitdiff
path: root/src/util/test_getopt.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
committerng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
commit6e599264ad13e8fc105493d74d7c11d46f8739ed (patch)
tree169bef1ecbade5a659831fb169f3ae6943af127f /src/util/test_getopt.c
parent4f13bc15113021ebf71d5d81e99bc29f8a07fc9c (diff)
first step to remove plibc
Diffstat (limited to 'src/util/test_getopt.c')
-rw-r--r--src/util/test_getopt.c119
1 files changed, 31 insertions, 88 deletions
diff --git a/src/util/test_getopt.c b/src/util/test_getopt.c
index 4294117a6..d9dd7121f 100644
--- a/src/util/test_getopt.c
+++ b/src/util/test_getopt.c
@@ -28,13 +28,9 @@
static int
testMinimal ()
{
- char *const emptyargv[] = {
- "test",
- NULL
- };
+ char *const emptyargv[] = {"test", NULL};
const struct GNUNET_GETOPT_CommandLineOption emptyoptionlist[] = {
- GNUNET_GETOPT_OPTION_END
- };
+ GNUNET_GETOPT_OPTION_END};
if (1 != GNUNET_GETOPT_run ("test", emptyoptionlist, 1, emptyargv))
return 1;
@@ -46,19 +42,11 @@ testMinimal ()
static int
testVerbose ()
{
- char *const myargv[] = {
- "test",
- "-V",
- "-V",
- "more",
- NULL
- };
+ char *const myargv[] = {"test", "-V", "-V", "more", NULL};
unsigned int vflags = 0;
- const struct GNUNET_GETOPT_CommandLineOption verboseoptionlist[] = {
- GNUNET_GETOPT_option_verbose (&vflags),
- GNUNET_GETOPT_OPTION_END
- };
+ const struct GNUNET_GETOPT_CommandLineOption verboseoptionlist[] =
+ {GNUNET_GETOPT_option_verbose (&vflags), GNUNET_GETOPT_OPTION_END};
if (3 != GNUNET_GETOPT_run ("test", verboseoptionlist, 4, myargv))
{
@@ -77,15 +65,10 @@ testVerbose ()
static int
testVersion ()
{
- char *const myargv[] = {
- "test_getopt",
- "-v",
- NULL
- };
- const struct GNUNET_GETOPT_CommandLineOption versionoptionlist[] = {
- GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
- GNUNET_GETOPT_OPTION_END
- };
+ char *const myargv[] = {"test_getopt", "-v", NULL};
+ const struct GNUNET_GETOPT_CommandLineOption versionoptionlist[] =
+ {GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
+ GNUNET_GETOPT_OPTION_END};
if (0 != GNUNET_GETOPT_run ("test_getopt", versionoptionlist, 2, myargv))
{
@@ -99,15 +82,9 @@ testVersion ()
static int
testAbout ()
{
- char *const myargv[] = {
- "test_getopt",
- "-h",
- NULL
- };
- const struct GNUNET_GETOPT_CommandLineOption aboutoptionlist[] = {
- GNUNET_GETOPT_option_help ("Testing"),
- GNUNET_GETOPT_OPTION_END
- };
+ char *const myargv[] = {"test_getopt", "-h", NULL};
+ const struct GNUNET_GETOPT_CommandLineOption aboutoptionlist[] =
+ {GNUNET_GETOPT_option_help ("Testing"), GNUNET_GETOPT_OPTION_END};
if (0 != GNUNET_GETOPT_run ("test_getopt", aboutoptionlist, 2, myargv))
{
@@ -121,31 +98,23 @@ testAbout ()
static int
testLogOpts ()
{
- char *const myargv[] = {
- "test_getopt",
- "-l", "filename",
- "-L", "WARNING",
- NULL
- };
+ char *const myargv[] =
+ {"test_getopt", "-l", "filename", "-L", "WARNING", NULL};
char *level = GNUNET_strdup ("stuff");
char *fn = NULL;
- const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = {
- GNUNET_GETOPT_option_logfile (&fn),
- GNUNET_GETOPT_option_loglevel (&level),
- GNUNET_GETOPT_OPTION_END
- };
+ const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] =
+ {GNUNET_GETOPT_option_logfile (&fn),
+ GNUNET_GETOPT_option_loglevel (&level),
+ GNUNET_GETOPT_OPTION_END};
- if (5 != GNUNET_GETOPT_run ("test_getopt",
- logoptionlist,
- 5, myargv))
+ if (5 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 5, myargv))
{
GNUNET_break (0);
return 1;
}
GNUNET_assert (NULL != fn);
- if ( (0 != strcmp (level, "WARNING")) ||
- (NULL == strstr (fn, "/filename")) )
+ if ((0 != strcmp (level, "WARNING")) || (NULL == strstr (fn, "/filename")))
{
GNUNET_break (0);
GNUNET_free (level);
@@ -161,47 +130,23 @@ testLogOpts ()
static int
testFlagNum ()
{
- char *const myargv[] = {
- "test_getopt",
- "-f",
- "-n", "42",
- "-N", "42",
- NULL
- };
+ char *const myargv[] = {"test_getopt", "-f", "-n", "42", "-N", "42", NULL};
int flag = 0;
unsigned int num = 0;
unsigned long long lnum = 0;
- const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] = {
- GNUNET_GETOPT_option_flag ('f',
- "--flag",
- "helptext",
- &flag),
- GNUNET_GETOPT_option_uint ('n',
- "--num",
- "ARG",
- "helptext",
- &num),
- GNUNET_GETOPT_option_ulong ('N',
- "--lnum",
- "ARG",
- "helptext",
- &lnum),
- GNUNET_GETOPT_OPTION_END
- };
-
- if (6 !=
- GNUNET_GETOPT_run ("test_getopt",
- logoptionlist,
- 6,
- myargv))
+ const struct GNUNET_GETOPT_CommandLineOption logoptionlist[] =
+ {GNUNET_GETOPT_option_flag ('f', "--flag", "helptext", &flag),
+ GNUNET_GETOPT_option_uint ('n', "--num", "ARG", "helptext", &num),
+ GNUNET_GETOPT_option_ulong ('N', "--lnum", "ARG", "helptext", &lnum),
+ GNUNET_GETOPT_OPTION_END};
+
+ if (6 != GNUNET_GETOPT_run ("test_getopt", logoptionlist, 6, myargv))
{
GNUNET_break (0);
return 1;
}
- if ( (1 != flag) ||
- (42 != num) ||
- (42 != lnum))
+ if ((1 != flag) || (42 != num) || (42 != lnum))
{
GNUNET_break (0);
return 1;
@@ -215,12 +160,10 @@ main (int argc, char *argv[])
{
int errCnt = 0;
- GNUNET_log_setup ("test_getopt",
- "WARNING",
- NULL);
+ GNUNET_log_setup ("test_getopt", "WARNING", NULL);
/* suppress output from -h, -v options */
#ifndef MINGW
- GNUNET_break (0 == CLOSE (1));
+ GNUNET_break (0 == close (1));
#endif
if (0 != testMinimal ())
errCnt++;