| 1 | /* |
| 2 | * This file is part of DisOrder. |
| 3 | * Copyright (C) 2008 Richard Kettlewell |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | #include "test.h" |
| 19 | #include "trackname.h" |
| 20 | |
| 21 | #define CHECK_PATH_ORDER(A,B,EXPECTED) do { \ |
| 22 | const unsigned char a[] = A, b[] = B; \ |
| 23 | insist(compare_path_raw(a, (sizeof a) - 1, \ |
| 24 | b, (sizeof b) - 1) == (EXPECTED)); \ |
| 25 | insist(compare_path_raw(b, (sizeof b) - 1, \ |
| 26 | a, (sizeof a) - 1) == -(EXPECTED)); \ |
| 27 | } while(0) |
| 28 | |
| 29 | static void test_trackname(void) { |
| 30 | CHECK_PATH_ORDER("/a/b", "/aa/", -1); |
| 31 | CHECK_PATH_ORDER("/a/b", "/a", 1); |
| 32 | CHECK_PATH_ORDER("/ab", "/a", 1); |
| 33 | CHECK_PATH_ORDER("/ab", "/aa", 1); |
| 34 | CHECK_PATH_ORDER("/aa", "/aa", 0); |
| 35 | CHECK_PATH_ORDER("/", "/", 0); |
| 36 | } |
| 37 | |
| 38 | TEST(trackname); |
| 39 | |
| 40 | /* |
| 41 | Local Variables: |
| 42 | c-basic-offset:2 |
| 43 | comment-column:40 |
| 44 | fill-column:79 |
| 45 | indent-tabs-mode:nil |
| 46 | End: |
| 47 | */ |