1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2007 Andrew Ziem <ahz001@gmail.com>
4
* Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the
18
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
* Boston, MA 02110-1301, USA.
26
#include "s-common-utils.h"
27
#include "gdm-common.h"
29
START_TEST (test_gdm_string_hex_encode)
34
a = g_string_new ("foo");
35
b = g_string_sized_new (100);
36
fail_unless (TRUE == gdm_string_hex_encode (a, 0, b, 0), NULL);
37
fail_unless (0 == strncmp (b->str, "666f6f", 7), NULL);
39
#ifndef NO_INVALID_INPUT
41
fail_unless (FALSE == gdm_string_hex_encode (a, -1, b, -1), NULL);
42
fail_unless (FALSE == gdm_string_hex_encode (NULL, 0, NULL, 0), NULL);
43
fail_unless (FALSE == gdm_string_hex_encode (a, 0, a, 0), NULL);
46
g_string_free (a, TRUE);
47
g_string_free (b, TRUE);
52
START_TEST (test_gdm_string_hex_decode)
56
a = g_string_new ("666f6f");
57
b = g_string_sized_new (100);
59
fail_unless (TRUE == gdm_string_hex_decode (a, 0, NULL, b, 0), NULL);
61
fail_unless (0 == strncmp (b->str, "foo", 7), NULL);
63
#ifndef NO_INVALID_INPUT
65
fail_unless (FALSE == gdm_string_hex_decode (a, -1, NULL, b, -1), NULL);
66
fail_unless (FALSE == gdm_string_hex_decode (NULL, 0, NULL, NULL, 0), NULL);
67
fail_unless (FALSE == gdm_string_hex_decode (a, 0, NULL, a, 0), NULL);
70
g_string_free (a, TRUE);
71
g_string_free (b, TRUE);
75
suite_common_utils (void)
80
s = suite_create ("gdm-common");
81
tc_core = tcase_create ("core");
83
tcase_add_test (tc_core, test_gdm_string_hex_encode);
84
tcase_add_test (tc_core, test_gdm_string_hex_decode);
86
suite_add_tcase (s, tc_core);