roc/roc_std/tests/test_roc_std.rs
2021-12-27 16:34:43 +01:00

44 lines
1.1 KiB
Rust

#[macro_use]
extern crate pretty_assertions;
// #[macro_use]
// extern crate indoc;
extern crate quickcheck;
extern crate roc_std;
#[cfg(test)]
mod test_roc_std {
use roc_std::RocResult;
#[test]
fn roc_result_to_rust_result() {
let greeting = "Hello, World!";
let roc_result: RocResult<String, ()> = RocResult::ok(greeting.into());
match roc_result.into() {
Ok(answer) => {
assert_eq!(answer.as_str(), greeting);
}
Err(()) => {
panic!("Received an Err when Ok was expected.")
}
}
}
#[test]
fn roc_result_is_ok() {
let greeting = "Hello, World!";
let roc_result: RocResult<String, ()> = RocResult::ok(greeting.into());
assert!(roc_result.is_ok());
assert!(!roc_result.is_err());
}
#[test]
fn roc_result_is_err() {
let greeting = "Hello, World!";
let roc_result: RocResult<(), String> = RocResult::err(greeting.into());
assert!(!roc_result.is_ok());
assert!(roc_result.is_err());
}
}