Hash :
ced645ea
Author :
Date :
2009-01-12T19:42:13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
#include "test_lib.h"
#include "common.h"
BEGIN_TEST(prefixcmp_empty_empty)
must_be_true(git__prefixcmp("", "") == 0);
END_TEST
BEGIN_TEST(prefixcmp_a_empty)
must_be_true(git__prefixcmp("a", "") == 0);
END_TEST
BEGIN_TEST(prefixcmp_empty_a)
must_be_true(git__prefixcmp("", "a") < 0);
END_TEST
BEGIN_TEST(prefixcmp_a_b)
must_be_true(git__prefixcmp("a", "b") < 0);
END_TEST
BEGIN_TEST(prefixcmp_b_a)
must_be_true(git__prefixcmp("b", "a") > 0);
END_TEST
BEGIN_TEST(prefixcmp_ab_a)
must_be_true(git__prefixcmp("ab", "a") == 0);
END_TEST
BEGIN_TEST(prefixcmp_ab_ac)
must_be_true(git__prefixcmp("ab", "ac") < 0);
END_TEST
BEGIN_TEST(prefixcmp_ab_aa)
must_be_true(git__prefixcmp("ab", "aa") > 0);
END_TEST
BEGIN_TEST(suffixcmp_empty_empty)
must_be_true(git__suffixcmp("", "") == 0);
END_TEST
BEGIN_TEST(suffixcmp_a_empty)
must_be_true(git__suffixcmp("a", "") == 0);
END_TEST
BEGIN_TEST(suffixcmp_empty_a)
must_be_true(git__suffixcmp("", "a") < 0);
END_TEST
BEGIN_TEST(suffixcmp_a_b)
must_be_true(git__suffixcmp("a", "b") < 0);
END_TEST
BEGIN_TEST(suffixcmp_b_a)
must_be_true(git__suffixcmp("b", "a") > 0);
END_TEST
BEGIN_TEST(suffixcmp_ba_a)
must_be_true(git__suffixcmp("ba", "a") == 0);
END_TEST
BEGIN_TEST(suffixcmp_zaa_ac)
must_be_true(git__suffixcmp("zaa", "ac") < 0);
END_TEST
BEGIN_TEST(suffixcmp_zaz_ac)
must_be_true(git__suffixcmp("zaz", "ac") > 0);
END_TEST
BEGIN_TEST(dirname)
char dir[64];
must_be_true(!(git__dirname(dir, sizeof(dir), NULL) < 0));
must_be_true(!strcmp(dir, "."));
must_be_true(!(git__dirname(dir, sizeof(dir), "") < 0));
must_be_true(!strcmp(dir, "."));
must_be_true(!(git__dirname(dir, sizeof(dir), "a") < 0));
must_be_true(!strcmp(dir, "."));
must_be_true(!(git__dirname(dir, sizeof(dir), "/") < 0));
must_be_true(!strcmp(dir, "/"));
must_be_true(!(git__dirname(dir, sizeof(dir), "/usr") < 0));
must_be_true(!strcmp(dir, "/"));
/* TODO: should this be "/" instead (ie strip trailing / first) */
must_be_true(!(git__dirname(dir, sizeof(dir), "/usr/") < 0));
must_be_true(!strcmp(dir, "/usr"));
must_be_true(!(git__dirname(dir, sizeof(dir), "/usr/lib") < 0));
must_be_true(!strcmp(dir, "/usr"));
must_be_true(!(git__dirname(dir, sizeof(dir), "usr/lib") < 0));
must_be_true(!strcmp(dir, "usr"));
END_TEST
BEGIN_TEST(basename)
char base[64];
must_be_true(!(git__basename(base, sizeof(base), NULL) < 0));
must_be_true(!strcmp(base, "."));
must_be_true(!(git__basename(base, sizeof(base), "") < 0));
must_be_true(!strcmp(base, "."));
must_be_true(!(git__basename(base, sizeof(base), "a") < 0));
must_be_true(!strcmp(base, "a"));
must_be_true(!(git__basename(base, sizeof(base), "/") < 0));
must_be_true(!strcmp(base, "/"));
must_be_true(!(git__basename(base, sizeof(base), "/usr") < 0));
must_be_true(!strcmp(base, "usr"));
/* TODO: should this be "usr" instead (ie strip trailing / first) */
must_be_true(!(git__basename(base, sizeof(base), "/usr/") < 0));
must_be_true(!strcmp(base, ""));
must_be_true(!(git__basename(base, sizeof(base), "/usr/lib") < 0));
must_be_true(!strcmp(base, "lib"));
must_be_true(!(git__basename(base, sizeof(base), "usr/lib") < 0));
must_be_true(!strcmp(base, "lib"));
END_TEST