2 * ipv4.c: Tests for Virtualized Super Computer Management
4 * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 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 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "../utils/utils.h"
30 static struct ParseInput _parse_input[] = {
31 { "131.234.92.31", TRUE },
33 { "131.234.92.31.42", FALSE },
34 { "131.999.92.31", FALSE },
36 { "this is no valid IPv4", FALSE },
38 { " 131.234.92.31", FALSE },
39 { "131.234 .92.31", FALSE },
40 { "131.234.92.31 ", FALSE },
41 { "+131.234.92.31", FALSE },
42 { "131.23a4 .92.31", FALSE },
43 { "131.234 .92.31a", FALSE },
47 START_TEST (test_parse)
49 struct VscMgmtError error;
50 struct VscMgmtIpv4 ipv4;
53 while (_parse_input[i].string != NULL) {
54 vsc_mgmt_error_init (&error);
56 vsc_mgmt_ipv4_parse (&error, _parse_input[i].string, &ipv4);
58 if (_parse_input[i].valid) {
59 fail_if (error.occured);
61 fail_unless (error.occured);
64 vsc_mgmt_error_cleanup (&error);
74 Suite *suite = suite_create ("IPv4");
75 TCase *tcase = tcase_create ("general");
77 tcase_add_test (tcase, test_parse);
79 suite_add_tcase (suite, tcase);
88 SRunner *srunner = srunner_create (ipv4_suite());
90 srunner_run_all (srunner, CK_NORMAL);
91 failed = srunner_ntests_failed (srunner);
92 srunner_free (srunner);