//! Property tests: random queries and random file contents never panic, and //! query results respect the limit and the ranking order. #![allow( clippy::unwrap_used, clippy::expect_used, clippy::indexing_slicing, clippy::panic )] use lutra_index::{Index, IndexedFile, index_text}; use lutra_syntax::Parser; use proptest::prelude::*; /// A small index with project and library files, unicode names included. fn sample() -> Index { let mut parser = Parser::new().unwrap(); let mut index = Index::new(); let files = [ ( "src/Models/User.php", "= pair[1].score); } } for hit in &files { let len: usize = hit.path.encode_utf16().count(); for range in &hit.matches { prop_assert!(range[0] < range[1] && range[1] <= len); } prop_assert!(hit.matches.windows(2).all(|w| w[0][1] < w[1][0])); } prop_assert!(classes.iter().all(|h| h.symbol.kind.is_class_like())); prop_assert!(symbols.iter().all(|h| !h.symbol.kind.is_class_like())); } #[test] fn random_sources_never_panic(bytes in proptest::collection::vec(any::(), 0..2_000)) { let mut parser = Parser::new().unwrap(); let mut text = String::from("