fish-shell/fish-rust/src/smoke.rs

27 lines
434 B
Rust
Raw Normal View History

2023-01-15 06:56:24 +08:00
#[cxx::bridge(namespace = rust)]
mod ffi {
extern "Rust" {
fn add(left: usize, right: usize) -> usize;
}
}
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
use crate::ffi_tests::add_test;
add_test!("test_add", || {
assert_eq!(add(2, 3), 5);
});