123456789101112131415161718192021222324252627282930 |
- use std::fs::File;
- use std::io::*;
- use gecliht;
- // This test is in integration tests because it uses files
- #[test]
- fn test_porter ()-> std::io::Result<()> {
- let f = File::open("tests/porter-words.txt")?;
- let mut words = BufReader::new(f);
- let g = File::open("tests/porter-stems.txt")?;
- let mut stems = BufReader::new(g);
- let mut count = 0;
- loop {
- let mut word = String::new();
- let wlen = words.read_line(&mut word)?;
- if wlen == 0 { break; }
- let mut stem = String::new();
- let slen = stems.read_line(&mut stem)?;
- if slen == 0 { break; }
- word = word.trim().to_string();
- stem = stem.trim().to_string();
- assert_eq!(Ok(stem), gecliht::porter_stem(&word));
- count += 1;
- }
- println!("Ran {} tests", count);
- Ok(())
- }
|