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:
Andreas Longva 2020-11-23 10:16:18 +01:00
parent 54329146c9
commit f20e764edc
1 changed files with 114 additions and 114 deletions

View File

@ -1,25 +1,29 @@
use nalgebra_sparse::proptest::{coo_with_duplicates, coo_no_duplicates};
use nalgebra::DMatrix;
use proptest::prelude::*;
use itertools::Itertools;
use std::collections::HashSet;
use std::iter::repeat;
#[test]
#[ignore]
fn coo_no_duplicates_generates_admissible_matrices() {
//TODO
}
#[cfg(feature = "slow-tests")]
use {
proptest::test_runner::TestRunner,
proptest::strategy::ValueTree
};
use std::ops::RangeInclusive;
mod slow {
use nalgebra_sparse::proptest::{coo_with_duplicates, coo_no_duplicates};
use nalgebra::DMatrix;
#[cfg(feature = "slow-tests")]
fn generate_all_possible_matrices(value_range: RangeInclusive<i32>,
use proptest::test_runner::TestRunner;
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>,
cols_range: RangeInclusive<usize>)
-> HashSet<DMatrix<i32>>
{
{
// Enumerate all possible combinations
let mut all_combinations = HashSet::new();
for nrows in rows_range {
@ -49,11 +53,11 @@ fn generate_all_possible_matrices(value_range: RangeInclusive<i32>,
}
}
all_combinations
}
}
#[cfg(feature = "slow-tests")]
#[test]
fn coo_no_duplicates_samples_all_admissible_outputs() {
#[cfg(feature = "slow-tests")]
#[test]
fn coo_no_duplicates_samples_all_admissible_outputs() {
// 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
@ -85,11 +89,11 @@ fn coo_no_duplicates_samples_all_admissible_outputs() {
assert_eq!(visited_combinations.len(), all_combinations.len());
assert_eq!(visited_combinations, all_combinations, "Did not sample all possible values.");
}
}
#[cfg(feature = "slow-tests")]
#[test]
fn coo_with_duplicates_samples_all_admissible_outputs() {
#[cfg(feature = "slow-tests")]
#[test]
fn coo_with_duplicates_samples_all_admissible_outputs() {
// 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
// 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
// is contained in the set of visited matrices
assert!(all_combinations.is_subset(&visited_combinations));
}
#[test]
fn coo_no_duplicates_generates_admissible_matrices() {
}
}