Skip to content

Commit 68d5a48

Browse files
committed
Make sanity tests into doc tests
1 parent acfba9d commit 68d5a48

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

crates/openvino-sys/src/lib.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
//! This crate provides low-level, unsafe, Rust bindings to OpenVINO™ using its [C API]. If you are
2+
//! looking to use OpenVINO™ from Rust, you likely should look at the ergonomic, safe bindings in
3+
//! [openvino], which depends on this crate. See the repository [README] for more information,
4+
//! including build instructions.
5+
//!
6+
//! [C API]: https://docs.openvinotoolkit.org/2020.1/ie_c_api/groups.html
7+
//! [openvino-sys]: https://crates.io/crates/openvino-sys
8+
//! [openvino]: https://crates.io/crates/openvino
9+
//! [README]: https://github.com/intel/openvino-rs/tree/main/crates/openvino-sys
10+
//!
11+
//! An example interaction with raw [openvino-sys]:
12+
//! ```
13+
//! # use std::ffi::CStr;
14+
//! openvino_sys::library::load().expect("to have an OpenVINO library available");
15+
//! let version = unsafe { CStr::from_ptr(openvino_sys::ie_c_api_version().api_version) };
16+
//! assert!(version.to_string_lossy().starts_with("2.1"));
17+
//! ```
118
#![allow(non_upper_case_globals)]
219
#![allow(non_camel_case_types)]
320
#![allow(non_snake_case)]
@@ -38,16 +55,3 @@ pub mod library {
3855
}
3956
}
4057
}
41-
42-
#[cfg(test)]
43-
mod tests {
44-
use super::*;
45-
use std::ffi::CStr;
46-
47-
#[test]
48-
fn check_version() {
49-
load().expect("to have an OpenVINO library available");
50-
let version = unsafe { CStr::from_ptr(ie_c_api_version().api_version) };
51-
assert!(version.to_string_lossy().starts_with("2.1"));
52-
}
53-
}

crates/openvino/src/core.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,3 @@ impl Core {
105105
Ok(ExecutableNetwork { instance })
106106
}
107107
}
108-
109-
#[cfg(test)]
110-
mod tests {
111-
use super::*;
112-
113-
#[test]
114-
fn construct_core() {
115-
let _ = Core::new(None).unwrap();
116-
}
117-
}

crates/openvino/src/lib.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
//! The [openvino] crate provides high-level, ergonomic, safe Rust bindings to OpenVINO. See the
2+
//! repository [README] for more information, such as build instructions.
3+
//!
4+
//! [openvino]: https://crates.io/crates/openvino
5+
//! [README]: https://github.com/intel/openvino-rs
6+
//!
7+
//! Check the loaded version of OpenVINO:
8+
//! ```
9+
//! assert!(openvino::version().starts_with("2.1"))
10+
//! ```
11+
//!
12+
//! Most interaction with OpenVINO begins with instantiating a [Core]:
13+
//! ```
14+
//! let _ = openvino::Core::new(None).expect("to instantiate the OpenVINO library");
15+
//! ```
16+
117
mod blob;
218
mod core;
319
mod error;
@@ -29,13 +45,3 @@ pub fn version() -> String {
2945
unsafe { openvino_sys::ie_version_free(&mut ie_version as *mut openvino_sys::ie_version_t) };
3046
str_version
3147
}
32-
33-
#[cfg(test)]
34-
mod tests {
35-
use super::*;
36-
37-
#[test]
38-
fn check_version() {
39-
assert!(version().starts_with("2.1"),)
40-
}
41-
}

0 commit comments

Comments
 (0)