strtonum-tests.c revision 9e2c64c6d4f5560e27207193efea6536a566865e
967e5f3c25249c779575864692935627004d3f9eChristian Maeder Copyright (C) Stephen Gallagher <sgallagh@redhat.com> 2009
967e5f3c25249c779575864692935627004d3f9eChristian Maeder This program is free software; you can redistribute it and/or modify
89054b2b95a3f92e78324dc852f3d34704e2ca49Christian Maeder it under the terms of the GNU General Public License as published by
f3a94a197960e548ecd6520bb768cb0d547457bbChristian Maeder the Free Software Foundation; either version 3 of the License, or
717686b54b9650402e2ebfbaadf433eab8ba5171Christian Maeder (at your option) any later version.
967e5f3c25249c779575864692935627004d3f9eChristian Maeder This program is distributed in the hope that it will be useful,
967e5f3c25249c779575864692935627004d3f9eChristian Maeder but WITHOUT ANY WARRANTY; without even the implied warranty of
967e5f3c25249c779575864692935627004d3f9eChristian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
967e5f3c25249c779575864692935627004d3f9eChristian Maeder GNU General Public License for more details.
7221c71b38c871ce66eee4537cb681d468308dfbChristian Maeder You should have received a copy of the GNU General Public License
ee93fb771fcf3000d73c8e2f2000adb4b9a5158cChristian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
967e5f3c25249c779575864692935627004d3f9eChristian Maeder/********************
8e9c3881fb6e710b1e08bf5ac8ff9d393df2e74eChristian Maeder * Utility routines *
78eeae099616e255ccf2e5f9122387bb10c68338Christian Maeder ********************/
fd896e2068ad7e50aed66ac18c3720ea7ff2619fChristian Maeder fail_unless(error == 0, "errno unexpectedly set to %d[%s]", \
551af0e4ba6d96bb24f3555f3b30ed648e22e34aChristian Maeder fail_unless(actual == expected, "Expected %ld, got %ld", \
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder fail_unless(actual == expected, "Expected errno %d[%s], got %d[%s]", \
67d92da5e9610aabad39055a16031154b4dc3748Christian Maeder fail_unless(actual == expected, "Expected endptr %p, got %p", \
67d92da5e9610aabad39055a16031154b4dc3748Christian Maeder fail_unless(endptr && *endptr == '\0', "Invalid endptr"); \
7a879b08ae0ca30006f9be887a73212b07f10204Christian Maeder/******************
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder * strtoint tests *
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder ******************/
67d92da5e9610aabad39055a16031154b4dc3748Christian MaederSTART_TEST (test_strtoint32_pos_integer_base_10)
a89389521ddf76109168a0b339031575aafbd512Christian MaederSTART_TEST (test_strtoint32_neg_integer_base_10)
51fb5d7edd9369c367dda2f8b15ddd6f8a146606Christian MaederSTART_TEST (test_strtoint32_pos_integer_intmax_base_10)
ee93fb771fcf3000d73c8e2f2000adb4b9a5158cChristian MaederSTART_TEST (test_strtoint32_neg_integer_intmin_base_10)
b66eb6038bfbcd2fe520d87c151bb4f1f510e985Christian MaederSTART_TEST (test_strtoint32_pos_integer_overflow_base_10)
967e5f3c25249c779575864692935627004d3f9eChristian MaederSTART_TEST (test_strtoint32_pos_integer_underflow_base_10)
d769b9ca726a9b50d661847c0e58c41d6ef334b4Christian MaederSTART_TEST (test_strtoint32_mixed_alphanumeric_base_10)
588c0c022a0f4e129a89c3bc569daf6a835e182dChristian MaederSTART_TEST (test_strtoint32_alphaonly_base_10)
a95f5379cabb30d3beb0545002cf50e9e4fc2c86Christian MaederSTART_TEST (test_strtoint32_alphastart_base_10)
a95f5379cabb30d3beb0545002cf50e9e4fc2c86Christian MaederSTART_TEST (test_strtoint32_emptystring_base_10)
ad187062b0009820118c1b773a232e29b879a2faChristian Maeder/*******************
ad187062b0009820118c1b773a232e29b879a2faChristian Maeder * strtouint tests *
1a75698c909ad515d59c76e65bd783f015c21c4dChristian Maeder *******************/
a95f5379cabb30d3beb0545002cf50e9e4fc2c86Christian MaederSTART_TEST (test_strtouint32_pos_integer_base_10)
83814002b4922114cbe7e9ba728472a0bf44aac5Christian MaederSTART_TEST (test_strtouint32_neg_integer_base_10)
dedabc954aa15f6ad0764472a9434dc6dafe3db2Christian MaederSTART_TEST (test_strtouint32_pos_integer_uintmax_base_10)
char *endptr;
char *endptr;
char *endptr;
char *endptr;
char *endptr;
int opt;
int failure_count;
switch(opt) {