nalgebra/tests/lib.rs

44 lines
1.2 KiB
Rust
Raw Permalink Normal View History

2021-05-03 19:50:48 +08:00
#[cfg(not(all(
feature = "debug",
feature = "compare",
feature = "rand",
feature = "macros"
)))]
compile_error!(
"Please enable the `debug`, `compare`, `rand` and `macros` features in order to compile and run the tests.
Example: `cargo test --features debug,compare,rand,macros`"
);
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
2018-02-02 19:26:35 +08:00
#[macro_use]
extern crate approx;
extern crate nalgebra as na;
2018-02-02 19:26:35 +08:00
extern crate num_traits as num;
#[cfg(feature = "rand")]
2021-03-02 19:37:00 +08:00
extern crate rand_package as rand;
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
mod core;
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
2018-02-03 17:44:32 +08:00
mod geometry;
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
2018-10-21 04:26:44 +08:00
mod linalg;
#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
#[cfg(feature = "proptest-support")]
mod proptest;
Improved stack! implementation, tests (#1375) * Add macro for concatenating matrices * Replace DimUnify with DimEq::representative * Add some simple cat macro output generation tests * Fix formatting in cat macro code * Add random prefix to cat macro output * Add simple quote_spanned for cat macro * Use `generic_view_mut` in cat macro * Fix clippy lints in cat macro * Clean up documentation for cat macro * Remove identity literal from cat macro * Allow references in input to cat macro * Rename cat macro to stack * Add more stack macro tests * Add comment to explain reason for prefix in stack! macro * Refactor matrix!, stack! macros into separate modules * Take all blocks by reference in stack! macro * Make empty stack![] invocation well-defined * Fix stack! macro incorrect reference to data * More extensive tests for stack! macro * Move nalgebra-macros tests to nalgebra tests By testing matrix!, stack! macros etc. in nalgebra, we ensure that these macros are used in the same way that users will be using them. * Fix stack! code generation tests * Add back nalgebra as dev-dependency of nalgebra-macros * Fix accidental wrong matrix! macro references in docs * Rewrite stack! documentation for clarity * Formatting * Skip formatting of macro, rustfmt messes it up * Rewrite stack! impl for improved clarity, Span behavior This improves error messages upon dimension mismatch, among other things. I've also tried to make the implementation easier to understand, adding some comments to help the reader understand the individual steps. * Use SameNumberOfRows/Columns instead of DimEq in stack! macro This gives more accurate compiler errors if matrix dimensions are mismatched. * Check that stack! panics at runtime for basic dimension mismatch * Add suggested edge cases from initial PR to tests * stack! impl: use fixed prefix everywhere This ensures that the expected generated code in tests is the actual generated code when used in the wild. * nalgebra-macros: Remove clippy pedantic, fix clippy complaints pedantic seems to be mostly intent on wasting the programmer's time * Add stack! sanity tests for built-ins and Complex * Fix formatting in test * Improve readability of format_ident! calls in stack! impl * fix trybuild tests * chore: run tests with a specific rust version * More trybuild fixes --------- Co-authored-by: Birk Tjelmeland <git@birktj.no> Co-authored-by: Sébastien Crozet <sebcrozet@dimforge.com>
2024-06-23 17:29:28 +08:00
#[cfg(feature = "macros")]
mod macros;
//#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))]
//#[cfg(feature = "sparse")]
//mod sparse;
mod utils {
/// Checks if a slice is sorted in descending order.
pub fn is_sorted_descending<T: PartialOrd>(slice: &[T]) -> bool {
slice.windows(2).all(|elts| elts[0] >= elts[1])
}
}