nalgebra-sparse: Move slow tests and imports into 'slow' child module
This way it's easier to prevent accidental unused imports when running tests without the slow-tests feature.
This commit is contained in:
parent
54329146c9
commit
f20e764edc
|
@ -1,25 +1,29 @@
|
||||||
use nalgebra_sparse::proptest::{coo_with_duplicates, coo_no_duplicates};
|
#[test]
|
||||||
use nalgebra::DMatrix;
|
#[ignore]
|
||||||
|
fn coo_no_duplicates_generates_admissible_matrices() {
|
||||||
use proptest::prelude::*;
|
//TODO
|
||||||
use itertools::Itertools;
|
}
|
||||||
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::iter::repeat;
|
|
||||||
|
|
||||||
#[cfg(feature = "slow-tests")]
|
#[cfg(feature = "slow-tests")]
|
||||||
use {
|
mod slow {
|
||||||
proptest::test_runner::TestRunner,
|
use nalgebra_sparse::proptest::{coo_with_duplicates, coo_no_duplicates};
|
||||||
proptest::strategy::ValueTree
|
use nalgebra::DMatrix;
|
||||||
};
|
|
||||||
use std::ops::RangeInclusive;
|
|
||||||
|
|
||||||
#[cfg(feature = "slow-tests")]
|
use proptest::test_runner::TestRunner;
|
||||||
fn generate_all_possible_matrices(value_range: RangeInclusive<i32>,
|
use proptest::strategy::ValueTree;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
use proptest::prelude::*;
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::iter::repeat;
|
||||||
|
use std::ops::RangeInclusive;
|
||||||
|
|
||||||
|
fn generate_all_possible_matrices(value_range: RangeInclusive<i32>,
|
||||||
rows_range: RangeInclusive<usize>,
|
rows_range: RangeInclusive<usize>,
|
||||||
cols_range: RangeInclusive<usize>)
|
cols_range: RangeInclusive<usize>)
|
||||||
-> HashSet<DMatrix<i32>>
|
-> HashSet<DMatrix<i32>>
|
||||||
{
|
{
|
||||||
// Enumerate all possible combinations
|
// Enumerate all possible combinations
|
||||||
let mut all_combinations = HashSet::new();
|
let mut all_combinations = HashSet::new();
|
||||||
for nrows in rows_range {
|
for nrows in rows_range {
|
||||||
|
@ -49,11 +53,11 @@ fn generate_all_possible_matrices(value_range: RangeInclusive<i32>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
all_combinations
|
all_combinations
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "slow-tests")]
|
#[cfg(feature = "slow-tests")]
|
||||||
#[test]
|
#[test]
|
||||||
fn coo_no_duplicates_samples_all_admissible_outputs() {
|
fn coo_no_duplicates_samples_all_admissible_outputs() {
|
||||||
// Note: This test basically mirrors a similar test for `matrix` in the `nalgebra` repo.
|
// Note: This test basically mirrors a similar test for `matrix` in the `nalgebra` repo.
|
||||||
|
|
||||||
// Test that the proptest generation covers all possible outputs for a small space of inputs
|
// Test that the proptest generation covers all possible outputs for a small space of inputs
|
||||||
|
@ -85,11 +89,11 @@ fn coo_no_duplicates_samples_all_admissible_outputs() {
|
||||||
|
|
||||||
assert_eq!(visited_combinations.len(), all_combinations.len());
|
assert_eq!(visited_combinations.len(), all_combinations.len());
|
||||||
assert_eq!(visited_combinations, all_combinations, "Did not sample all possible values.");
|
assert_eq!(visited_combinations, all_combinations, "Did not sample all possible values.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "slow-tests")]
|
#[cfg(feature = "slow-tests")]
|
||||||
#[test]
|
#[test]
|
||||||
fn coo_with_duplicates_samples_all_admissible_outputs() {
|
fn coo_with_duplicates_samples_all_admissible_outputs() {
|
||||||
// This is almost the same as the test for coo_no_duplicates, except that we need
|
// This is almost the same as the test for coo_no_duplicates, except that we need
|
||||||
// a different "success" criterion, since coo_with_duplicates is able to generate
|
// a different "success" criterion, since coo_with_duplicates is able to generate
|
||||||
// matrices with values outside of the value constraints. See below for details.
|
// matrices with values outside of the value constraints. See below for details.
|
||||||
|
@ -126,9 +130,5 @@ fn coo_with_duplicates_samples_all_admissible_outputs() {
|
||||||
// In other words, we need to determine that set of all admissible matrices
|
// In other words, we need to determine that set of all admissible matrices
|
||||||
// is contained in the set of visited matrices
|
// is contained in the set of visited matrices
|
||||||
assert!(all_combinations.is_subset(&visited_combinations));
|
assert!(all_combinations.is_subset(&visited_combinations));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn coo_no_duplicates_generates_admissible_matrices() {
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue