-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* search: fix regression * Add two more test cases --------- Co-authored-by: Sandro Jäckel <[email protected]>
- Loading branch information
1 parent
bf67342
commit fb89d2c
Showing
3 changed files
with
51 additions
and
71,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
use std::{collections::HashMap, fs::File}; | ||
|
||
use crate::Index; | ||
|
||
#[test] | ||
fn test() { | ||
let options: HashMap<String, crate::option::Option> = | ||
serde_json::from_str(include_str!("./options.json")).unwrap(); | ||
let mut index = Index::default(); | ||
|
||
let options = options.keys().collect::<Vec<_>>(); | ||
index.push("home.enableDebugInfo"); | ||
index.push("home.enableNixpkgsReleaseCheck"); | ||
index.push("home.file.<name>.enable"); | ||
index.push("home.language.measurement"); | ||
index.push("home.pointerCursor.gtk.enable"); | ||
index.push("home.pointerCursor.x11.enable"); | ||
index.push("programs.home-manager.enable"); | ||
index.push("services.home-manager.autoUpgrade.enable"); | ||
index.push("services.home-manager.autoUpgrade.frequency"); | ||
|
||
let mut index = Index::default(); | ||
for option in &options { | ||
index.push(option); | ||
} | ||
assert_eq!( | ||
index.search("ho*auto", 10).unwrap(), | ||
vec![ | ||
( | ||
7usize, | ||
"services.home-manager.autoUpgrade.enable".to_string() | ||
), | ||
( | ||
8usize, | ||
"services.home-manager.autoUpgrade.frequency".to_string() | ||
) | ||
] | ||
); | ||
|
||
assert_eq!( | ||
index.search("ho*auto*ena", 10).unwrap(), | ||
vec![( | ||
7usize, | ||
"services.home-manager.autoUpgrade.enable".to_string() | ||
)] | ||
); | ||
|
||
assert_eq!( | ||
index.search("ho*en*Nix", 10).unwrap(), | ||
vec![(1usize, "home.enableNixpkgsReleaseCheck".to_string())] | ||
); | ||
|
||
println!("{:?}", index.search("ho*exta", 10).unwrap()); | ||
assert_eq!( | ||
index.search("ho*en*Nix*Rel*Che", 10).unwrap(), | ||
vec![(1usize, "home.enableNixpkgsReleaseCheck".to_string())] | ||
); | ||
|
||
let mut file = File::create("index.nuscht").unwrap(); | ||
index.write_into(&mut file).unwrap(); | ||
assert_eq!( | ||
index.search("enablenixpkgsreleasecheck", 10).unwrap(), | ||
vec![(1usize, "home.enableNixpkgsReleaseCheck".to_string())] | ||
); | ||
} |
Oops, something went wrong.