Closed mssun closed 4 years ago
NOTE: Choose a PR template below and delete others.
Add either 1.5.3.
diff --git a/Cargo.toml b/Cargo.toml index cbb2c68..deb600b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,15 @@ keywords = ["data-structure", "no_std"] categories = ["data-structures", "no-std"] [dependencies] -serde = { version = "1.0", optional = true, features = ["derive"] } +serde = { git = "https://github.com/universal-secure-computing-community/crates-sgx.git", tag = "v0.2.1+sgx1.1.1", features = ["derive"], optional = true } +sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true } +sgx_tunittest = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", tag = "v1.1.1", optional = true } [features] default = ["use_std"] -use_std = [] +use_std = ["mesalock_sgx"] +mesalock_sgx = ["sgx_tstd"] +enclave_unit_test = ["sgx_tunittest"] [package.metadata.release] no-dev-version = true diff --git a/src/lib.rs b/src/lib.rs index 1ba5ed7..531a0e8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,9 +14,19 @@ #![doc(html_root_url = "https://docs.rs/either/1/")] #![cfg_attr(all(not(test), not(feature = "use_std")), no_std)] +#![cfg_attr(all(feature = "mesalock_sgx", not(target_env = "sgx")), no_std)] +#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"), feature(rustc_private))] + #[cfg(all(not(test), not(feature = "use_std")))] extern crate core as std; +#[cfg(all(feature = "mesalock_sgx", not(target_env = "sgx")))] +#[macro_use] +extern crate sgx_tstd as std; +use std::prelude::v1::*; +#[cfg(all(feature = "mesalock_sgx", not(target_env = "sgx")))] +extern crate sgx_tunittest; + #[cfg(feature = "serde")] #[macro_use] extern crate serde; @@ -849,7 +859,7 @@ impl<L, R> fmt::Display for Either<L, R> } } -#[test] +// #[test] fn basic() { let mut e = Left(2); let r = Right(2); @@ -862,7 +872,7 @@ fn basic() { assert_eq!(e.as_mut().right(), Some(&mut 2)); } -#[test] +// #[test] fn macros() { fn a() -> Either<u32, u32> { let x: u32 = try_left!(Right(1337u32)); @@ -876,14 +886,14 @@ fn macros() { assert_eq!(b(), Left(String::from("foo bar"))); } -#[test] +// #[test] fn deref() { fn is_str(_: &str) {} let value: Either<String, &str> = Left(String::from("test")); is_str(&*value); } -#[test] +// #[test] fn iter() { let x = 3; let mut iter = match x { @@ -895,7 +905,7 @@ fn iter() { assert_eq!(iter.count(), 9); } -#[test] +// #[test] fn read_write() { use std::io; @@ -923,7 +933,7 @@ fn read_write() { assert_eq!(writer.write(&buf).unwrap(), buf.len()); } -#[test] +// #[test] fn error() { let invalid_utf8 = b"\xff"; let res = || -> Result<_, Either<_, _>> { @@ -972,3 +982,20 @@ fn _unsized_std_propagation() { check_t!(::std::ffi::OsStr); check_t!(::std::ffi::CStr); } + +#[cfg(feature = "enclave_unit_test")] +pub mod tests { + use super::*; + use sgx_tunittest::*; + + pub fn run_tests() { + rsgx_unit_tests!( + basic, + macros, + deref, + iter, + read_write, + error, + ); + } +}
NOTE: Choose a PR template below and delete others.
Add either 1.5.3
Description
Add either 1.5.3.
Crate Meta
Diff of Changes