test-strverscmp.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }