diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-12-21 15:56:24 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-12-21 15:56:24 +0100 |
| commit | 0e1bf83811c4a9e4e2869190cfc94bf32476b9ee (patch) | |
| tree | fd518a91cc92f756dc9b8959762f7553533ce60e /rust-cli/grrs/tests/finds_matches.rs | |
| parent | 87ee550abea331430fc2db0f1d96d6acbfa6c8f2 (diff) | |
| download | learning-rust-0e1bf83811c4a9e4e2869190cfc94bf32476b9ee.tar.xz learning-rust-0e1bf83811c4a9e4e2869190cfc94bf32476b9ee.zip | |
12/21/22 15:56:24
Diffstat (limited to 'rust-cli/grrs/tests/finds_matches.rs')
| -rw-r--r-- | rust-cli/grrs/tests/finds_matches.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/rust-cli/grrs/tests/finds_matches.rs b/rust-cli/grrs/tests/finds_matches.rs new file mode 100644 index 0000000..5f301fc --- /dev/null +++ b/rust-cli/grrs/tests/finds_matches.rs @@ -0,0 +1,12 @@ +use std::fs::File; + +#[test] +fn finds_matches() { + let mut test_file = File::create("finds_matches.txt").unwrap(); + std::io::Write::write_all(&mut test_file, b"asdf\ntesting").unwrap(); + std::io::Write::flush(&mut test_file).unwrap(); + let file_to_test = File::open("finds_matches.txt").expect("could not read test file"); + let matches = grrs::find_matches(&file_to_test, "asdf").unwrap(); + assert_eq!(matches.len(), 1); + std::fs::remove_file("finds_matches.txt").unwrap(); +}
\ No newline at end of file |
