Skip to content

Commit

Permalink
test every OofError variant done
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricio Dematte committed May 24, 2021
1 parent 67bd239 commit 1059ba0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions oof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ where

#[cfg(test)]
mod tests {
use std::os::unix::prelude::OsStringExt;

use crate::*;

fn gen_args(text: &str) -> Vec<OsString> {
Expand Down Expand Up @@ -283,8 +285,14 @@ mod tests {

#[test]
fn test_invalid_unicode_flag() {
// let invalid_unicode_flag = char::from();
// TODO: how to store invalid unicode?
// `invalid_unicode_flag` has to contain a leading hyphen to be considered a flag.
let invalid_unicode_flag = OsString::from_vec(vec![45, 0, 0, 0, 255, 255, 255, 255]);
let result = filter_flags(vec![invalid_unicode_flag.clone()], &[]).unwrap_err();

assert!(match result {
OofError::InvalidUnicode(flag) if flag == invalid_unicode_flag => true,
_ => false,
})
}

// asdasdsa
Expand Down

0 comments on commit 1059ba0

Please sign in to comment.