blob: 08c5acc6c2d5ec3400f4b5e90f4dcbc711ddc024 (
plain)
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
|
/*
* blogc: A blog compiler.
* Copyright (C) 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br>
*
* This program can be distributed under the terms of the BSD License.
* See the file COPYING.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <string.h>
#include "../src/loader.h"
#include "../src/utils/utils.h"
static void
test_get_filename(void **state)
{
char *f = blogc_get_filename("/home/foo/asd/bola.txt");
assert_string_equal(f, "bola");
free(f);
f = blogc_get_filename("/home/foo/asd/bola.guda.txt");
assert_string_equal(f, "bola.guda");
free(f);
f = blogc_get_filename("bola.txt");
assert_string_equal(f, "bola");
free(f);
f = blogc_get_filename("bola.guda.txt");
assert_string_equal(f, "bola.guda");
free(f);
f = blogc_get_filename("/home/foo/asd/bola");
assert_string_equal(f, "bola");
free(f);
f = blogc_get_filename("bola");
assert_string_equal(f, "bola");
free(f);
f = blogc_get_filename("");
assert_null(f);
free(f);
f = blogc_get_filename(NULL);
assert_null(f);
free(f);
}
int
main(void)
{
const UnitTest tests[] = {
unit_test(test_get_filename),
};
return run_tests(tests);
}
|