test-strverscmp.c

Go to the documentation of this file.
00001 /* Test of strverscmp() function.
00002    Copyright (C) 2008 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software Foundation,
00016    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
00017 
00018 /* Written by Eric Blake <ebb9@byu.net>, 2008.  */
00019 
00020 #include <config.h>
00021 
00022 #include <string.h>
00023 
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 
00027 #define ASSERT(expr) \
00028   do                                                                         \
00029     {                                                                        \
00030       if (!(expr))                                                           \
00031         {                                                                    \
00032           fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
00033           fflush (stderr);                                                   \
00034           abort ();                                                          \
00035         }                                                                    \
00036     }                                                                        \
00037   while (0)
00038 
00039 int
00040 main (int argc, char **argv)
00041 {
00042   ASSERT (strverscmp ("", "") == 0);
00043   ASSERT (strverscmp ("a", "a") == 0);
00044   ASSERT (strverscmp ("a", "b") < 0);
00045   ASSERT (strverscmp ("b", "a") > 0);
00046   ASSERT (strverscmp ("000", "00") < 0);
00047   ASSERT (strverscmp ("00", "000") > 0);
00048   ASSERT (strverscmp ("a0", "a") > 0);
00049   ASSERT (strverscmp ("00", "01") < 0);
00050   ASSERT (strverscmp ("01", "010") < 0);
00051   ASSERT (strverscmp ("010", "09") < 0);
00052   ASSERT (strverscmp ("09", "0") < 0);
00053   ASSERT (strverscmp ("9", "10") < 0);
00054   ASSERT (strverscmp ("0a", "0") > 0);
00055   return 0;
00056 }

Generated on Tue Oct 21 18:28:19 2008 for gsasl by  doxygen 1.5.6