File: module_selection_test.c

package info (click to toggle)
liblicense 0.8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 6,428 kB
  • ctags: 868
  • sloc: sh: 9,739; ansic: 8,315; makefile: 859; xml: 178; cpp: 111; ruby: 41; python: 39
file content (56 lines) | stat: -rw-r--r-- 1,561 bytes parent folder | download | duplicates (2)
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
/*
 * Creative Commons has made the contents of this file
 * available under a CC-GNU-LGPL license:
 *
 * http://creativecommons.org/licenses/LGPL/2.1/
 *
 * A copy of the full license can be found as part of this
 * distribution in the file COPYING.
 *
 * You may use the liblicense software in accordance with the
 * terms of that license. You agree that you are solely
 * responsible for your use of the liblicense software and you
 * represent and warrant to Creative Commons that your use
 * of the liblicense software will comply with the CC-GNU-LGPL.
 *
 * Copyright 2007, Creative Commons, www.creativecommons.org.
 * Copyright 2007, Scott Shawcroft.
 * Copyright (C) 2007 Peter Miller
 */

#include "liblicense.h"

#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>

int main() {
	 /* Assert that a PDF file uses only the Exempi module... */
	 
	 char* file;
	 LLModuleDesc * module;
	 LLModuleSearchState state;
	 
	 file = "../tests/data_empty.pdf";
	 memset(&state, 0, sizeof(LLModuleSearchState));

	 ll_init();
	 
	 module = ll_module_search(file, LL_LICENSE, &state);
	 assert (strcmp("exempi.so", module->name) == 0); /* Exempi can
						       toy with PDF */
	 
	 module = ll_module_search(file, LL_LICENSE, &state);
	 assert (module == NULL); /* Only Exempi */

	 /* Assert that a .UNKNOWN file gets back NULL */
	 file = "../tests/nonexistent.unknown";
	 memset(&state, 0, sizeof(LLModuleSearchState));
	 module = ll_module_search(file, LL_LICENSE, &state);
	 assert(module==NULL);

	 ll_stop();
	 
	 return 0;
}