X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fregression%2Fstrverscmp.c;fp=src%2Fregression%2Fstrverscmp.c;h=a4daa26a6f4865c722c5d550b21fb7e3afbb3be0;hb=da2b7d64ac5693bc2a3dbfd1138972afae1466bc;hp=0000000000000000000000000000000000000000;hpb=7d350259ac1468c9744839b0e6b78acb99dfd1c2;p=libc-test diff --git a/src/regression/strverscmp.c b/src/regression/strverscmp.c new file mode 100644 index 0000000..a4daa26 --- /dev/null +++ b/src/regression/strverscmp.c @@ -0,0 +1,26 @@ +// leading zero handling according to the manual +#define _GNU_SOURCE +#include +#include "test.h" + +#define ASSERT(x) ((x) || (t_error(#x " failed\n"),0)) + +int main() +{ + ASSERT(strverscmp("", "") == 0); + ASSERT(strverscmp("a", "a") == 0); + ASSERT(strverscmp("a", "b") < 0); + ASSERT(strverscmp("b", "a") > 0); + ASSERT(strverscmp("000", "00") < 0); + ASSERT(strverscmp("00", "000") > 0); + ASSERT(strverscmp("a0", "a") > 0); + ASSERT(strverscmp("00", "01") < 0); + ASSERT(strverscmp("01", "010") < 0); + ASSERT(strverscmp("010", "09") < 0); + ASSERT(strverscmp("09", "0") < 0); + ASSERT(strverscmp("9", "10") < 0); + ASSERT(strverscmp("0a", "0") > 0); + ASSERT(strverscmp("foobar-1.1.2", "foobar-1.1.3") < 0); + ASSERT(strverscmp("foobar-1.1.2", "foobar-1.01.3") > 0); + return t_status; +}