Crates.io | numtest |
lib.rs | numtest |
version | 0.1.6 |
source | src |
created_at | 2024-04-04 03:35:35.300006 |
updated_at | 2024-09-21 18:28:38.124945 |
description | Unit testing for numerical methods. |
homepage | |
repository | https://github.com/tamaskis/numtest |
max_upload_size | |
id | 1195814 |
size | 109,423 |
Unit testing for numerical applications in Rust.
Please see https://docs.rs/numtest.
use numtest::*;
assert_equal!(2.0, 2.0);
assert_equal_to_decimal!(2.0, 2.012, 1);
assert_equal_to_atol!(2.0, 2.00001, 1e-3);
assert_equal_to_rtol!(2.0, 2.01, 0.01);
use numtest::*;
let arr1 = [1.1, 2.2, 3.3];
let arr2 = [1.1, 2.2, 3.3];
assert_arrays_equal!(&arr1, &arr2);
use numtest::*;
let arr1 = [1.1, 2.2, 3.3];
let arr2 = [1.1, 2.22, 3.33];
assert_arrays_equal_to_decimal!(&arr1, &arr2, 1);
use nalgebra::Vector3;
use ndarray::Array1;
use numtest::*;
let std_arr = [1.1, 2.2, 3.3];
let std_vec = vec![1.1, 2.22, 3.33];
let ndarray_arr = Array1::from_vec(vec![1.12, 2.23, 3.34]);
let nalgebra_vec = Vector3::new(1.13, 2.24, 3.35);
assert_arrays_equal_to_decimal!(&std_arr, &std_vec, 1);
assert_arrays_equal_to_atol!(&std_arr, &ndarray_arr, 0.06);
assert_arrays_equal_to_rtol!(&std_arr, &nalgebra_vec, 0.03);
use nalgebra::Matrix3;
use numtest::*;
let mat1 = Matrix3::new(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9);
let mat2 = Matrix3::new(1.1, 2.22, 3.33, 4.4, 5.55, 6.66, 7.7, 8.88, 9.99);
assert_arrays_equal_to_decimal!(&mat1, &mat2, 1);