2008-08-07 06:09:50 +02:00
|
|
|
|
/*
|
2013-01-07 05:43:01 +01:00
|
|
|
|
TEST-CONFIGLOADER - test the config system
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
Copyright (C)
|
|
|
|
|
|
2008, Christian Thaeter <ct@pipapo.org>
|
|
|
|
|
|
2008, Simeon Voelkel <simeon_voelkel@arcor.de>
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
**Lumiera** is free software; you can redistribute it and/or modify it
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
|
|
Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
|
option) any later version. See the file COPYING for further details.
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
Copyright: clarify and simplify the file headers
* Lumiera source code always was copyrighted by individual contributors
* there is no entity "Lumiera.org" which holds any copyrights
* Lumiera source code is provided under the GPL Version 2+
== Explanations ==
Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above.
For this to become legally effective, the ''File COPYING in the root directory is sufficient.''
The licensing header in each file is not strictly necessary, yet considered good practice;
attaching a licence notice increases the likeliness that this information is retained
in case someone extracts individual code files. However, it is not by the presence of some
text, that legally binding licensing terms become effective; rather the fact matters that a
given piece of code was provably copyrighted and published under a license. Even reformatting
the code, renaming some variables or deleting parts of the code will not alter this legal
situation, but rather creates a derivative work, which is likewise covered by the GPL!
The most relevant information in the file header is the notice regarding the
time of the first individual copyright claim. By virtue of this initial copyright,
the first author is entitled to choose the terms of licensing. All further
modifications are permitted and covered by the License. The specific wording
or format of the copyright header is not legally relevant, as long as the
intention to publish under the GPL remains clear. The extended wording was
based on a recommendation by the FSF. It can be shortened, because the full terms
of the license are provided alongside the distribution, in the file COPYING.
2024-11-17 23:42:55 +01:00
|
|
|
|
* *****************************************************************/
|
2013-01-07 05:43:01 +01:00
|
|
|
|
|
2017-02-22 03:46:23 +01:00
|
|
|
|
/** @file test-configloader.c
|
|
|
|
|
|
** C unit test to cover a config system draft implementation
|
|
|
|
|
|
** @deprecated as of 2017 it is very likely we'll use a different approach
|
2016-11-03 18:26:43 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2013-01-07 05:43:01 +01:00
|
|
|
|
|
2010-07-21 04:17:34 +02:00
|
|
|
|
#include "lib/tmpbuf.h"
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
2008-12-18 08:54:33 +01:00
|
|
|
|
#include "common/config.h"
|
|
|
|
|
|
#include "common/configitem.h"
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
2011-12-02 21:34:29 +01:00
|
|
|
|
#include "lib/test/test.h"
|
2008-08-07 06:09:50 +02:00
|
|
|
|
|
|
|
|
|
|
TESTS_BEGIN
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (init)
|
2008-08-07 06:09:50 +02:00
|
|
|
|
{
|
2011-05-20 18:25:55 +02:00
|
|
|
|
/* Note: lumiera_config_init and lumiera_config_destroy are
|
|
|
|
|
|
* invoked automatically from ConfigFacade
|
|
|
|
|
|
*/
|
2014-10-15 23:08:53 +02:00
|
|
|
|
printf ("initialised\n");
|
2008-08-07 06:09:50 +02:00
|
|
|
|
lumiera_config_destroy ();
|
|
|
|
|
|
printf ("destroyed\n");
|
2011-05-20 18:25:55 +02:00
|
|
|
|
/* there will be a warning about destroying the already
|
|
|
|
|
|
* destroyed or uninitialised config system....
|
|
|
|
|
|
*/
|
2008-08-07 06:09:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (configitem_simple)
|
2008-08-17 00:35:40 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
2008-08-17 00:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
LumieraConfigitem item;
|
|
|
|
|
|
|
|
|
|
|
|
item = lumiera_configitem_new (argv[2]);
|
2010-12-10 03:01:38 +01:00
|
|
|
|
CHECK (item);
|
2008-08-17 00:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
printf ("line = '%s'\n", item->line);
|
|
|
|
|
|
if (item->key)
|
|
|
|
|
|
printf ("key = '%.*s'\n", (int)item->key_size, item->key);
|
|
|
|
|
|
if (item->delim)
|
|
|
|
|
|
{
|
|
|
|
|
|
printf ("delim = '%c'\n", *item->delim);
|
|
|
|
|
|
printf ("value = '%s'\n", item->delim+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-08-19 22:32:54 +02:00
|
|
|
|
lumiera_configitem_delete (item, NULL);
|
2008-08-17 00:35:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (lookup)
|
2008-08-17 00:35:40 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
lumiera_config_lookup lookup;
|
|
|
|
|
|
lumiera_config_lookup_init (&lookup);
|
|
|
|
|
|
|
|
|
|
|
|
LumieraConfigitem item = lumiera_configitem_new ("foo.bar = test");
|
|
|
|
|
|
lumiera_config_lookup_insert (&lookup, item);
|
|
|
|
|
|
|
2008-08-17 00:50:56 +02:00
|
|
|
|
LumieraConfigitem found = lumiera_config_lookup_item_find (&lookup, "foo.bar");
|
2010-12-10 03:01:38 +01:00
|
|
|
|
CHECK (found == item);
|
2008-08-17 00:35:40 +02:00
|
|
|
|
|
2008-08-17 00:50:56 +02:00
|
|
|
|
lumiera_config_lookup_remove (&lookup, found);
|
2010-12-10 03:01:38 +01:00
|
|
|
|
CHECK (!lumiera_config_lookup_item_find (&lookup, "foo.bar"));
|
2008-08-17 00:35:40 +02:00
|
|
|
|
|
|
|
|
|
|
lumiera_config_lookup_destroy (&lookup);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (change_value)
|
2008-09-25 00:09:00 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
|
|
|
|
|
CHECK (argv[4]);
|
2008-09-25 00:09:00 +02:00
|
|
|
|
|
|
|
|
|
|
const char* value;
|
|
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_set (argv[2], argv[3]))
|
|
|
|
|
|
printf ("failure setting first time '%s%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
if (lumiera_config_get (argv[2], &value))
|
|
|
|
|
|
printf ("%s\n", value);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("failure retrieving '%s': %s\n", argv[2], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_set (argv[2], argv[4]))
|
|
|
|
|
|
printf ("failure setting second time '%s%s': %s\n", argv[2], argv[4], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
if (lumiera_config_get (argv[2], &value))
|
|
|
|
|
|
printf ("%s\n", value);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("failure retrieving '%s': %s\n", argv[2], lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (basic_set_get)
|
2008-09-09 21:38:28 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-09-09 21:38:28 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_set (argv[2], argv[3]))
|
|
|
|
|
|
printf ("failure setting first time '%s%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_set (argv[2], argv[3]))
|
|
|
|
|
|
printf ("failure setting second time '%s%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
const char* value;
|
|
|
|
|
|
if (lumiera_config_get (argv[2], &value))
|
|
|
|
|
|
printf ("%s\n", value);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("failure retrieving '%s': %s\n", argv[2], lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (number_get)
|
2008-08-07 11:43:06 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-08-07 14:55:17 +02:00
|
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
|
long long number = 0;
|
|
|
|
|
|
|
2008-08-19 22:32:54 +02:00
|
|
|
|
lumiera_config_setdefault (lumiera_tmpbuf_snprintf (SIZE_MAX, "%s = %s", argv[2], argv[3]));
|
|
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
if (lumiera_config_number_get (argv[2], &number))
|
2008-08-07 11:43:06 +02:00
|
|
|
|
printf ("%lld\n", number);
|
|
|
|
|
|
else
|
2008-08-08 08:21:38 +02:00
|
|
|
|
printf ("%s, %lld\n", lumiera_error (), number);
|
2008-08-07 11:43:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (number_get_nodefault)
|
2008-08-07 11:43:06 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
2008-08-07 14:55:17 +02:00
|
|
|
|
|
2008-08-07 11:43:06 +02:00
|
|
|
|
long long number = 0;
|
|
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
if (lumiera_config_number_get (argv[2], &number))
|
2008-08-07 11:43:06 +02:00
|
|
|
|
printf ("%lld\n", number);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-08-08 08:28:07 +02:00
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (number_set)
|
2008-09-10 15:16:40 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-09-10 15:16:40 +02:00
|
|
|
|
|
|
|
|
|
|
signed long long number = atoll (argv[3]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_number_set (argv[2], &number))
|
|
|
|
|
|
printf ("failed setting number '%s=%lld': %s\n", argv[2], number, lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
if (lumiera_config_number_get (argv[2], &number))
|
|
|
|
|
|
printf ("'%lld'\n", number);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (string_get)
|
2008-08-08 08:28:07 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-08-08 08:28:07 +02:00
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
const char* string;
|
2008-08-08 08:28:07 +02:00
|
|
|
|
|
2008-08-19 22:32:54 +02:00
|
|
|
|
lumiera_config_setdefault (lumiera_tmpbuf_snprintf (SIZE_MAX, "%s = %s", argv[2], argv[3]));
|
|
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
if (lumiera_config_string_get (argv[2], &string))
|
2008-08-08 08:28:07 +02:00
|
|
|
|
printf ("'%s'\n", string);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s, '%s'\n", lumiera_error (), string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (string_set)
|
2008-08-10 11:52:24 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-08-10 11:52:24 +02:00
|
|
|
|
|
2008-09-10 13:14:07 +02:00
|
|
|
|
if (!lumiera_config_string_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting string '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
2008-08-10 11:52:24 +02:00
|
|
|
|
|
|
|
|
|
|
const char* string;
|
2008-09-10 13:14:07 +02:00
|
|
|
|
if (lumiera_config_string_get (argv[2], &string))
|
2008-08-10 11:52:24 +02:00
|
|
|
|
printf ("'%s'\n", string);
|
|
|
|
|
|
else
|
2008-09-10 13:14:07 +02:00
|
|
|
|
printf ("%s\n", lumiera_error ());
|
2008-08-10 11:52:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (word_get)
|
2008-08-10 11:52:24 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-08-10 11:52:24 +02:00
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
const char* word;
|
2008-08-10 11:52:24 +02:00
|
|
|
|
|
2008-08-19 22:32:54 +02:00
|
|
|
|
lumiera_config_setdefault (lumiera_tmpbuf_snprintf (SIZE_MAX, "%s = %s", argv[2], argv[3]));
|
|
|
|
|
|
|
2008-09-09 21:34:40 +02:00
|
|
|
|
if (lumiera_config_word_get (argv[2], &word))
|
2008-08-10 11:52:24 +02:00
|
|
|
|
printf ("'%s'\n", word);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s, '%s'\n", lumiera_error (), word);
|
|
|
|
|
|
|
|
|
|
|
|
lumiera_config_destroy ();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-09-10 15:16:40 +02:00
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (word_set)
|
2008-09-10 15:16:40 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
2008-09-10 15:16:40 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_word_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting word '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
|
|
|
|
|
const char* word;
|
|
|
|
|
|
if (lumiera_config_word_get (argv[2], &word))
|
|
|
|
|
|
printf ("'%s'\n", word);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (configitem_simple_ctor_dtor)
|
2008-08-13 08:35:31 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
2008-08-13 08:35:31 +02:00
|
|
|
|
|
|
|
|
|
|
LumieraConfigitem item;
|
|
|
|
|
|
|
2008-08-13 10:50:27 +02:00
|
|
|
|
item = lumiera_configitem_new (argv[2]);
|
2008-08-13 08:35:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2008-09-25 17:29:00 +02:00
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (configitem_simple_content_check)
|
2008-08-27 11:00:10 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
2008-08-27 11:00:10 +02:00
|
|
|
|
|
|
|
|
|
|
LumieraConfigitem item;
|
|
|
|
|
|
|
|
|
|
|
|
item = lumiera_configitem_new (argv[2]);
|
|
|
|
|
|
|
|
|
|
|
|
if ( item->line )
|
|
|
|
|
|
{
|
2008-09-06 13:18:29 +02:00
|
|
|
|
printf("item->line = '%s'\n", item->line);
|
2008-08-27 11:00:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ( item->key_size )
|
|
|
|
|
|
{
|
2008-09-06 13:18:29 +02:00
|
|
|
|
printf("item->key_size = '%zi'\n", item->key_size);
|
2008-08-27 11:00:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ( item->key )
|
|
|
|
|
|
{
|
2008-09-06 13:18:29 +02:00
|
|
|
|
printf("item->key = '%s'\n", item->key);
|
2008-08-27 11:00:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
if ( item->delim )
|
|
|
|
|
|
{
|
2008-09-06 13:18:29 +02:00
|
|
|
|
printf("item->delim = '%s'\n", item->delim);
|
2008-08-27 11:00:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2008-09-22 22:38:17 +02:00
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (wordlist_get_nth)
|
2008-09-22 22:38:17 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
|
|
|
|
|
CHECK (argv[4]);
|
2008-09-22 22:38:17 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting word '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
2008-10-31 06:43:54 +01:00
|
|
|
|
const char* word = lumiera_config_wordlist_get_nth (argv[2], atoi (argv[4]), " \t,;");
|
2008-09-22 22:38:17 +02:00
|
|
|
|
|
|
|
|
|
|
printf ("'%s'\n", word?word:"NULL");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (wordlist_find)
|
2008-09-25 17:29:00 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
|
|
|
|
|
CHECK (argv[4]);
|
2008-09-25 17:29:00 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting word '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
2008-10-31 06:43:54 +01:00
|
|
|
|
int n = lumiera_config_wordlist_find (argv[2], argv[4], " \t,;");
|
2008-09-25 17:29:00 +02:00
|
|
|
|
|
|
|
|
|
|
printf ("'%d'\n", n);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (wordlist_replace)
|
2008-09-25 17:29:00 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
|
|
|
|
|
CHECK (argv[4]);
|
|
|
|
|
|
CHECK (argv[5]);
|
|
|
|
|
|
CHECK (argv[6]);
|
2008-09-25 17:29:00 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting word '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
2008-10-31 06:43:54 +01:00
|
|
|
|
const char* wordlist = lumiera_config_wordlist_replace (argv[2], argv[4], *argv[5]?argv[5]:NULL, *argv[6]?argv[6]:NULL, " \t,;");
|
2008-09-25 17:29:00 +02:00
|
|
|
|
|
|
|
|
|
|
if (wordlist)
|
|
|
|
|
|
printf ("'%s'\n", wordlist);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-04 16:23:57 +01:00
|
|
|
|
TEST (wordlist_add)
|
2008-09-26 03:31:22 +02:00
|
|
|
|
{
|
2010-12-10 03:00:17 +01:00
|
|
|
|
CHECK (argv[2]);
|
|
|
|
|
|
CHECK (argv[3]);
|
|
|
|
|
|
CHECK (argv[4]);
|
|
|
|
|
|
CHECK (argv[5]);
|
2008-09-26 03:31:22 +02:00
|
|
|
|
|
|
|
|
|
|
if (!lumiera_config_wordlist_set (argv[2], &argv[3]))
|
|
|
|
|
|
printf ("failed setting word '%s=%s': %s\n", argv[2], argv[3], lumiera_error ());
|
|
|
|
|
|
|
2008-10-31 06:43:54 +01:00
|
|
|
|
const char* wordlist = lumiera_config_wordlist_add (argv[2], argv[4], " \t,;");
|
2008-09-26 03:31:22 +02:00
|
|
|
|
if (wordlist)
|
|
|
|
|
|
printf ("'%s'\n", wordlist);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
|
2008-10-31 06:43:54 +01:00
|
|
|
|
wordlist = lumiera_config_wordlist_add (argv[2], argv[5], " \t,;");
|
2008-09-26 03:31:22 +02:00
|
|
|
|
if (wordlist)
|
|
|
|
|
|
printf ("'%s'\n", wordlist);
|
|
|
|
|
|
else
|
|
|
|
|
|
printf ("%s\n", lumiera_error ());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-08-07 06:09:50 +02:00
|
|
|
|
TESTS_END
|