xref: /lighttpd1.4/src/t/test_mod_simple_vhost.c (revision 9b3fa6eb)
1 #include "first.h"
2 
3 #undef NDEBUG
4 #include <assert.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7 
8 #include "mod_simple_vhost.c"
9 
test_mod_simple_vhost_build_doc_root_path(void)10 static void test_mod_simple_vhost_build_doc_root_path(void) {
11     buffer *sroot = buffer_init();
12     buffer *host  = buffer_init();
13     buffer *droot = buffer_init();
14     buffer *result= buffer_init();
15 
16     buffer_copy_string_len(sroot, CONST_STR_LEN("/sroot/a/"));
17     buffer_copy_string_len(host,  CONST_STR_LEN("www.example.org"));
18     buffer_copy_string_len(droot, CONST_STR_LEN("/droot/b/"));
19     build_doc_root_path(result, sroot, host, droot);
20     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/droot/b/")));
21 
22     buffer_copy_string_len(host,  CONST_STR_LEN("www.example.org:8080"));
23     build_doc_root_path(result, sroot, host, droot);
24     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/droot/b/")));
25 
26     buffer_copy_string_len(droot, CONST_STR_LEN(""));
27     build_doc_root_path(result, sroot, host, droot);
28     assert(buffer_eq_slen(result, CONST_STR_LEN("/sroot/a/www.example.org/")));
29 
30     buffer_free(sroot);
31     buffer_free(host);
32     buffer_free(droot);
33     buffer_free(result);
34 }
35 
36 void test_mod_simple_vhost (void);
test_mod_simple_vhost(void)37 void test_mod_simple_vhost (void)
38 {
39     test_mod_simple_vhost_build_doc_root_path();
40 }
41