|
29 | 29 | #include <string.h>
|
30 | 30 | #include "common/util.h"
|
31 | 31 |
|
| 32 | +int test_oscap_path_startswith(void); |
32 | 33 | int test_oscap_strrm(void);
|
33 | 34 |
|
| 35 | +int test_oscap_path_startswith() |
| 36 | +{ |
| 37 | + if (!oscap_path_startswith("/", "/")) |
| 38 | + return 1; |
| 39 | + if (!oscap_path_startswith("/aaa", "/")) |
| 40 | + return 2; |
| 41 | + if (!oscap_path_startswith("/aaa", "/aaa")) |
| 42 | + return 3; |
| 43 | + if (!oscap_path_startswith("/aaa/bbb", "/aaa")) |
| 44 | + return 4; |
| 45 | + if (!oscap_path_startswith("/aaa/bbb/ccc", "/aaa")) |
| 46 | + return 5; |
| 47 | + if (!oscap_path_startswith("/aaa/bbb/ccc/", "/aaa/")) |
| 48 | + return 6; |
| 49 | + if (!oscap_path_startswith("/aaa/bbb/ccc", "/aaa/bbb/ccc")) |
| 50 | + return 7; |
| 51 | + if (!oscap_path_startswith("/aaa/bbb/ccc", "")) |
| 52 | + return 8; |
| 53 | + if (!oscap_path_startswith("", "")) |
| 54 | + return 9; |
| 55 | + if (!oscap_path_startswith("", "/")) |
| 56 | + return 10; |
| 57 | + |
| 58 | + if (oscap_path_startswith("/bbb", "/aaa")) |
| 59 | + return 101; |
| 60 | + if (oscap_path_startswith("/bbb/aaa", "/aaa")) |
| 61 | + return 102; |
| 62 | + if (oscap_path_startswith("/bbb/aaa/", "/aaa")) |
| 63 | + return 103; |
| 64 | + if (oscap_path_startswith("/bbb/aaa/", "/aaa/")) |
| 65 | + return 104; |
| 66 | + |
| 67 | + return 0; |
| 68 | +} |
| 69 | + |
34 | 70 | int test_oscap_strrm()
|
35 | 71 | {
|
36 | 72 | char str[] = "abcdef12345678def90";
|
@@ -59,6 +95,8 @@ int main (int argc, char *argv[])
|
59 | 95 | {
|
60 | 96 | int retval = 0;
|
61 | 97 |
|
| 98 | + if ((retval = test_oscap_path_startswith()) != 0) |
| 99 | + return retval; |
62 | 100 | if ((retval = test_oscap_strrm()) != 0)
|
63 | 101 | return retval;
|
64 | 102 |
|
|
0 commit comments