Skip to content

Commit 7ebedc8

Browse files
committed
test: Add test for feature flag
1 parent d8fbaf7 commit 7ebedc8

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

dlib-test/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ dlib = { path = "../" }
1010
lazy_static = { version = "1.0", optional = true }
1111

1212
[features]
13-
"dlopen" = ["lazy_static"]
13+
default = ["sin"]
14+
sin = []
15+
nonexistant = []
16+
dlopen = ["lazy_static"]

dlib-test/src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ use dlib::external_library;
33
external_library!(Mlib, "m",
44
functions:
55
fn cos(f64) -> f64,
6+
#[cfg(feature = "sin")]
7+
fn sin(f64) -> f64,
8+
#[cfg(feature = "nonexistant")]
9+
fn nonexistant_function(f64) -> f64,
610
);
711

812
#[cfg(feature = "dlopen")]
@@ -20,5 +24,14 @@ mod tests {
2024
let angle = 1.8;
2125
let cosinus = unsafe { ffi_dispatch!(M_STATIC, cos, angle) };
2226
assert_eq!(cosinus, angle.cos());
27+
28+
}
29+
30+
#[cfg(feature = "sin")]
31+
#[test]
32+
fn invoke_sin() {
33+
let angle = 1.8;
34+
let sine = unsafe { ffi_dispatch!(M_STATIC, sin, angle) };
35+
assert_eq!(sine, angle.sin());
2336
}
2437
}

0 commit comments

Comments
 (0)