File: lib.rs

package info (click to toggle)
rust-clang-sys 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 292 kB
  • sloc: makefile: 4; ansic: 4
file content (48 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (5)
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
extern crate clang_sys;
extern crate libc;

use std::ptr;

use clang_sys::*;

use libc::c_char;

fn parse() {
    unsafe {
        let index = clang_createIndex(0, 0);
        assert!(!index.is_null());

        let tu = clang_parseTranslationUnit(
            index,
            "tests/header.h\0".as_ptr() as *const c_char,
            ptr::null_mut(),
            0,
            ptr::null_mut(),
            0,
            0,
        );
        assert!(!tu.is_null());
    }
}

#[cfg(feature = "runtime")]
#[test]
fn test() {
    load().unwrap();
    let library = get_library().unwrap();
    println!("{:?} ({:?})", library.version(), library.path());
    parse();
    unload().unwrap();
}

#[cfg(not(feature = "runtime"))]
#[test]
fn test() {
    parse();
}

#[test]
fn test_support() {
    let clang = support::Clang::find(None, &[]).unwrap();
    println!("{:?}", clang);
}