File: integration_test.rs

package info (click to toggle)
rust-libheif-sys 5.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 812 kB
  • sloc: makefile: 11; ansic: 6
file content (34 lines) | stat: -rw-r--r-- 779 bytes parent folder | download
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
use std::ffi::CStr;
use std::ptr;

use libheif_sys as lh;

#[test]
fn create_heic_context() {
    let expected_version = get_version().to_string() + ".";
    unsafe {
        lh::heif_init(ptr::null_mut());
        let version = CStr::from_ptr(lh::heif_get_version()).to_string_lossy();
        assert!(version.starts_with(&expected_version));

        let ctx = lh::heif_context_alloc();
        assert!(!ctx.is_null());
        lh::heif_context_free(ctx);

        lh::heif_deinit();
    }
}

fn get_version() -> &'static str {
    if cfg!(feature = "v1_20") {
        "1.20"
    } else if cfg!(feature = "v1_19") {
        "1.19"
    } else if cfg!(feature = "v1_18") {
        "1.18"
    } else if cfg!(feature = "v1_17") {
        "1.17"
    } else {
        "1.20"
    }
}