util-tests.c revision dbea04f585a30d001b574317c068cd03a4fa332b
/*
SSSD
Authors:
Stephen Gallagher <sgallagh@redhat.com>
Copyright (C) 2010 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <popt.h>
#include <talloc.h>
#include <check.h>
#include "util/sss_utf8.h"
{
struct pa_testcase {
const char *argstr;
const char **parsed;
};
int i, ii;
int ret;
char **parsed;
char **only_ret;
char **only_exp;
char **both;
/* Positive tests */
struct pa_testcase tc[] = {
{ "foo", parsed1 },
{ "foo a", parsed2 },
{ "foo b", parsed3 },
{ "foo a\\ c", parsed4 },
{ "foo a d ", parsed5 },
{ "foo a e ", parsed6 },
{ "foo a f ", parsed7 },
{ "foo a\\\tg", parsed8 },
};
"Could not parse correct argument string '%s'\n");
}
}
{
char **l1;
char **l2;
char **l3;
char **only_l1;
char **only_l2;
char **both;
int ret;
/* Test with all values returned */
/* Test with restricted return values */
/* Test with no overlap */
/* Test with 100% overlap */
/* Test with no second list */
}
{
const char no_specials[] = "username";
"Expected [%s], got [%s]",
const char has_asterisk[] = "*username";
const char has_asterisk_expected[] = "\\2ausername";
"Expected [%s], got [%s]",
const char has_lparen[] = "user(name";
const char has_lparen_expected[] = "user\\28name";
"Expected [%s], got [%s]",
const char has_rparen[] = "user)name";
const char has_rparen_expected[] = "user\\29name";
"Expected [%s], got [%s]",
const char has_backslash[] = "username\\";
const char has_backslash_expected[] = "username\\5c";
"Expected [%s], got [%s]",
const char has_all[] = "\\(user)*name";
const char has_all_expected[] = "\\5c\\28user\\29\\2aname";
"Expected [%s], got [%s]",
}
{
"overflow not detected");
"overflow not detected");
}
{
strlen((const char *)munchen_utf8_upcase),
&nlen);
fail_if(strlen((const char *) munchen_utf8_upcase) != nlen); /* This is not true for utf8 strings in general */
}
{
strlen((const char *) munchen_utf8_upcase),
&nsize);
}
{
char *lcase;
}
{
}
{
const char *invalid = "ad\351la\357d";
bool ret;
}
Suite *util_suite(void)
{
suite_add_tcase (s, tc_util);
suite_add_tcase (s, tc_utf8);
return s;
}
{
int opt;
int failure_count;
Suite *s = util_suite();
struct poptOption long_options[] = {
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
srunner_free (sr);
if (failure_count == 0) {
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}