diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-24 06:58:09 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-24 06:58:09 +0800 |
| commit | dc13fa58448b7e267fb0ba63427534127f76beca (patch) | |
| tree | 7219f10bf3da22fdbe2cf4f41719505dcb75d6d2 /mingling_core/src | |
| parent | dd6253ba8c37b51927ab4dc0e71f5b3a264f36b3 (diff) | |
Move flag tests to separate module and clean up deref patterns
Diffstat (limited to 'mingling_core/src')
| -rw-r--r-- | mingling_core/src/asset/dispatcher.rs | 2 | ||||
| -rw-r--r-- | mingling_core/src/comp/shell_ctx.rs | 2 | ||||
| -rw-r--r-- | mingling_core/src/comp/suggest.rs | 6 | ||||
| -rw-r--r-- | mingling_core/src/program/flag.rs | 361 | ||||
| -rw-r--r-- | mingling_core/src/program/flag/tests.rs | 358 | ||||
| -rw-r--r-- | mingling_core/src/program/hook/hook_info.rs | 0 | ||||
| -rw-r--r-- | mingling_core/src/program/string_vec.rs | 2 | ||||
| -rw-r--r-- | mingling_core/src/renderer/general/error.rs | 2 |
8 files changed, 366 insertions, 367 deletions
diff --git a/mingling_core/src/asset/dispatcher.rs b/mingling_core/src/asset/dispatcher.rs index 1652ced..8f04955 100644 --- a/mingling_core/src/asset/dispatcher.rs +++ b/mingling_core/src/asset/dispatcher.rs @@ -356,7 +356,7 @@ mod tests { fn test_dispatchers_deref() { let disp = MockDispatcher { name: "test" }; let dispatchers: Dispatchers<MockG> = Dispatchers::from((disp,)); - let inner: &Vec<Box<dyn Dispatcher<MockG> + Send + Sync + 'static>> = &*dispatchers; + let inner: &Vec<Box<dyn Dispatcher<MockG> + Send + Sync + 'static>> = &dispatchers; assert_eq!(inner.len(), 1); } diff --git a/mingling_core/src/comp/shell_ctx.rs b/mingling_core/src/comp/shell_ctx.rs index 9d84aa7..616eade 100644 --- a/mingling_core/src/comp/shell_ctx.rs +++ b/mingling_core/src/comp/shell_ctx.rs @@ -307,7 +307,7 @@ mod tests { fn test_try_from_flag_without_value() { let args = vec!["-F".to_string()]; let context = ShellContext::try_from(args).unwrap(); - assert!(matches!(context.shell_flag, ShellFlag::Other(ref s) if s == "")); + assert!(matches!(context.shell_flag, ShellFlag::Other(ref s) if s.is_empty())); } #[test] diff --git a/mingling_core/src/comp/suggest.rs b/mingling_core/src/comp/suggest.rs index 03842e1..bd5dea6 100644 --- a/mingling_core/src/comp/suggest.rs +++ b/mingling_core/src/comp/suggest.rs @@ -243,7 +243,7 @@ mod tests { #[test] fn test_deref_suggest() { let s: Suggest = ["hello"].into(); - let set: &BTreeSet<SuggestItem> = &*s; + let set: &BTreeSet<SuggestItem> = &s; assert_eq!(set.len(), 1); } @@ -354,7 +354,7 @@ mod tests { #[test] fn test_ord_by_suggest_text() { - let mut items = vec![ + let mut items = [ SuggestItem::new("z".to_string()), SuggestItem::new("a".to_string()), SuggestItem::new("m".to_string()), @@ -367,7 +367,7 @@ mod tests { #[test] fn test_ord_with_description() { - let mut items = vec![ + let mut items = [ SuggestItem::new_with_desc("z".to_string(), "zzz".to_string()), SuggestItem::new("a".to_string()), SuggestItem::new_with_desc("m".to_string(), "mmm".to_string()), diff --git a/mingling_core/src/program/flag.rs b/mingling_core/src/program/flag.rs index 0865414..6cf126d 100644 --- a/mingling_core/src/program/flag.rs +++ b/mingling_core/src/program/flag.rs @@ -160,366 +160,7 @@ macro_rules! special_arguments { } #[cfg(test)] -mod tests { - use crate::Flag; - - #[test] - fn test_special_flag() { - // Test flag found and removed - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--help".to_string(), - "c".to_string(), - ]; - let result = special_flag!(args, "--help"); - assert!(result); - assert_eq!(args, vec!["a", "b", "c"]); - - // Test flag found at beginning - let mut args = vec![ - "--help".to_string(), - "a".to_string(), - "b".to_string(), - "c".to_string(), - ]; - let result = special_flag!(args, "--help"); - assert!(result); - assert_eq!(args, vec!["a", "b", "c"]); - - // Test flag found at end - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "c".to_string(), - "--help".to_string(), - ]; - let result = special_flag!(args, "--help"); - assert!(result); - assert_eq!(args, vec!["a", "b", "c"]); - - // Test flag not found - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--other".to_string(), - "c".to_string(), - ]; - let result = special_flag!(args, "--help"); - assert!(!result); - assert_eq!(args, vec!["a", "b", "--other", "c"]); - - // Test multiple same flags all removed - let mut args = vec![ - "--help".to_string(), - "a".to_string(), - "--help".to_string(), - "b".to_string(), - "--help".to_string(), - ]; - let result = special_flag!(args, "--help"); - assert!(result); - assert_eq!(args, vec!["a", "b"]); - - // Test empty args - let mut args: Vec<String> = Vec::new(); - let result = special_flag!(args, "--help"); - assert!(!result); - assert_eq!(args, Vec::<String>::new()); - - // Test flag with empty string - let mut args = vec!["a".to_string(), "".to_string(), "b".to_string()]; - let result = special_flag!(args, ""); - assert!(result); - assert_eq!(args, vec!["a", "b"]); - - // Test flag with dash in middle - let mut args = vec!["a".to_string(), "test-flag".to_string(), "b".to_string()]; - let result = special_flag!(args, "test-flag"); - assert!(result); - assert_eq!(args, vec!["a", "b"]); - - // Test flag that's a substring of another flag (should not match) - let mut args = vec!["a".to_string(), "--helpful".to_string(), "b".to_string()]; - let result = special_flag!(args, "--help"); - assert!(!result); - assert_eq!(args, vec!["a", "--helpful", "b"]); - } - - #[test] - fn test_special_argument() { - // Test extracting value after flag - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--file".to_string(), - "test.txt".to_string(), - "c".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("test.txt".to_string())); - assert_eq!(args, vec!["a", "b", "c"]); - - // Test extracting value when flag is at beginning - let mut args = vec![ - "--file".to_string(), - "test.txt".to_string(), - "a".to_string(), - "b".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("test.txt".to_string())); - assert_eq!(args, vec!["a", "b"]); - - // Test extracting value when flag is at end - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--file".to_string(), - "test.txt".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("test.txt".to_string())); - assert_eq!(args, vec!["a", "b"]); - - // Test flag without value (at end) - let mut args = vec!["a".to_string(), "b".to_string(), "--file".to_string()]; - let result = special_argument!(args, "--file"); - assert_eq!(result, None); - assert_eq!(args, vec!["a", "b"]); - - // Test flag without value (not at end) - let mut args = vec!["a".to_string(), "--file".to_string(), "b".to_string()]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("b".to_string())); - assert_eq!(args, vec!["a"]); - - // Test flag not found - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--other".to_string(), - "value".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, None); - assert_eq!(args, vec!["a", "b", "--other", "value"]); - - // Test empty args - let mut args: Vec<String> = Vec::new(); - let result = special_argument!(args, "--file"); - assert_eq!(result, None); - assert_eq!(args, Vec::<String>::new()); - - // Test multiple same flags (should only extract first) - let mut args = vec![ - "--file".to_string(), - "first.txt".to_string(), - "--file".to_string(), - "second.txt".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("first.txt".to_string())); - assert_eq!(args, vec!["--file", "second.txt"]); - - // Test flag with empty string value - let mut args = vec![ - "a".to_string(), - "--file".to_string(), - "".to_string(), - "b".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("".to_string())); - assert_eq!(args, vec!["a", "b"]); - - // Test flag with value starting with dash - let mut args = vec![ - "a".to_string(), - "--file".to_string(), - "-value".to_string(), - "b".to_string(), - ]; - let result = special_argument!(args, "--file"); - assert_eq!(result, Some("-value".to_string())); - assert_eq!(args, vec!["a", "b"]); - } - - #[test] - fn test_special_arguments() { - // Test extracting multiple values after flag - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--list".to_string(), - "a".to_string(), - "b".to_string(), - "c".to_string(), - "d".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, vec!["a", "b", "c", "d"]); - assert_eq!(args, vec!["a", "b", "--next", "1"]); - - // Test extracting single value - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, "--next"); - assert_eq!(result, vec!["1"]); - assert_eq!(args, vec!["a", "b"]); - - // Test extracting from beginning - let mut args = vec![ - "--list".to_string(), - "a".to_string(), - "b".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, vec!["a", "b"]); - assert_eq!(args, vec!["--next", "1"]); - - // Test extracting when no values after flag - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--list".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, Vec::<String>::new()); - assert_eq!(args, vec!["a", "b", "--next", "1"]); - - // Test extracting when flag not found - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--list".to_string(), - "c".to_string(), - "d".to_string(), - ]; - let result = special_arguments!(args, "--none"); - assert_eq!(result, Vec::<String>::new()); - assert_eq!(args, vec!["a", "b", "--list", "c", "d"]); - - // Test extracting empty args - let mut args: Vec<String> = Vec::new(); - let result = special_arguments!(args, "--list"); - assert_eq!(result, Vec::<String>::new()); - assert_eq!(args, Vec::<String>::new()); - - // Test extracting with only flag at end - let mut args = vec!["--list".to_string()]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, Vec::<String>::new()); - assert_eq!(args, Vec::<String>::new()); - - // Test extracting multiple values until end of args - let mut args = vec![ - "--list".to_string(), - "a".to_string(), - "b".to_string(), - "c".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, vec!["a", "b", "c"]); - assert_eq!(args, Vec::<String>::new()); - - // Test extracting with mixed non-dash values - let mut args = vec![ - "--list".to_string(), - "value1".to_string(), - "value2".to_string(), - "-next".to_string(), - "value3".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, vec!["value1", "value2"]); - assert_eq!(args, vec!["-next", "value3"]); - - // Test extracting with single dash values - let mut args = vec![ - "--list".to_string(), - "-a".to_string(), - "-b".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, "--list"); - assert_eq!(result, Vec::<String>::new()); - assert_eq!(args, vec!["-a", "-b", "--next", "1"]); - - // Test extracting with empty flag - let mut args = vec![ - "a".to_string(), - "b".to_string(), - "--next".to_string(), - "1".to_string(), - ]; - let result = special_arguments!(args, ""); - assert_eq!(result, vec!["a", "b"]); - assert_eq!(args, vec!["--next", "1"]); - } - - #[test] - fn test_flag_from_empty_tuple() { - let flag = Flag::from(()); - assert_eq!(flag.as_ref(), &[] as &[&str]); - } - - #[test] - fn test_flag_from_static_str() { - let flag = Flag::from("-h"); - assert_eq!(flag.as_ref(), &["-h"]); - } - - #[test] - fn test_flag_from_slice() { - let flag = Flag::from(&["-h", "--help"][..]); - assert_eq!(flag.as_ref(), &["-h", "--help"]); - } - - #[test] - fn test_flag_from_array() { - let flag = Flag::from(["-v", "--verbose"]); - assert_eq!(flag.as_ref(), &["-v", "--verbose"]); - } - - #[test] - fn test_flag_from_ref_array() { - let flag = Flag::from(&["-f", "--file"]); - assert_eq!(flag.as_ref(), &["-f", "--file"]); - } - - #[test] - fn test_flag_from_ref_flag() { - let original = Flag::from("-x"); - let cloned = Flag::from(&original); - assert_eq!(cloned.as_ref(), &["-x"]); - } - - #[test] - fn test_flag_as_ref() { - let flag = Flag::from("-h"); - let r: &[&str] = flag.as_ref(); - assert_eq!(r, &["-h"]); - } - - #[test] - fn test_flag_deref() { - let flag = Flag::from(["-a", "-b"]); - let collected: Vec<&&str> = flag.iter().collect(); - assert_eq!(collected, vec![&"-a", &"-b"]); - } -} +mod tests; impl<C> Program<C> where diff --git a/mingling_core/src/program/flag/tests.rs b/mingling_core/src/program/flag/tests.rs new file mode 100644 index 0000000..60f90eb --- /dev/null +++ b/mingling_core/src/program/flag/tests.rs @@ -0,0 +1,358 @@ +use crate::Flag; + +#[test] +fn test_special_flag() { + // Test flag found and removed + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--help".to_string(), + "c".to_string(), + ]; + let result = special_flag!(args, "--help"); + assert!(result); + assert_eq!(args, vec!["a", "b", "c"]); + + // Test flag found at beginning + let mut args = vec![ + "--help".to_string(), + "a".to_string(), + "b".to_string(), + "c".to_string(), + ]; + let result = special_flag!(args, "--help"); + assert!(result); + assert_eq!(args, vec!["a", "b", "c"]); + + // Test flag found at end + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "c".to_string(), + "--help".to_string(), + ]; + let result = special_flag!(args, "--help"); + assert!(result); + assert_eq!(args, vec!["a", "b", "c"]); + + // Test flag not found + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--other".to_string(), + "c".to_string(), + ]; + let result = special_flag!(args, "--help"); + assert!(!result); + assert_eq!(args, vec!["a", "b", "--other", "c"]); + + // Test multiple same flags all removed + let mut args = vec![ + "--help".to_string(), + "a".to_string(), + "--help".to_string(), + "b".to_string(), + "--help".to_string(), + ]; + let result = special_flag!(args, "--help"); + assert!(result); + assert_eq!(args, vec!["a", "b"]); + + // Test empty args + let mut args: Vec<String> = Vec::new(); + let result = special_flag!(args, "--help"); + assert!(!result); + assert_eq!(args, Vec::<String>::new()); + + // Test flag with empty string + let mut args = vec!["a".to_string(), "".to_string(), "b".to_string()]; + let result = special_flag!(args, ""); + assert!(result); + assert_eq!(args, vec!["a", "b"]); + + // Test flag with dash in middle + let mut args = vec!["a".to_string(), "test-flag".to_string(), "b".to_string()]; + let result = special_flag!(args, "test-flag"); + assert!(result); + assert_eq!(args, vec!["a", "b"]); + + // Test flag that's a substring of another flag (should not match) + let mut args = vec!["a".to_string(), "--helpful".to_string(), "b".to_string()]; + let result = special_flag!(args, "--help"); + assert!(!result); + assert_eq!(args, vec!["a", "--helpful", "b"]); +} + +#[test] +fn test_special_argument() { + // Test extracting value after flag + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--file".to_string(), + "test.txt".to_string(), + "c".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("test.txt".to_string())); + assert_eq!(args, vec!["a", "b", "c"]); + + // Test extracting value when flag is at beginning + let mut args = vec![ + "--file".to_string(), + "test.txt".to_string(), + "a".to_string(), + "b".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("test.txt".to_string())); + assert_eq!(args, vec!["a", "b"]); + + // Test extracting value when flag is at end + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--file".to_string(), + "test.txt".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("test.txt".to_string())); + assert_eq!(args, vec!["a", "b"]); + + // Test flag without value (at end) + let mut args = vec!["a".to_string(), "b".to_string(), "--file".to_string()]; + let result = special_argument!(args, "--file"); + assert_eq!(result, None); + assert_eq!(args, vec!["a", "b"]); + + // Test flag without value (not at end) + let mut args = vec!["a".to_string(), "--file".to_string(), "b".to_string()]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("b".to_string())); + assert_eq!(args, vec!["a"]); + + // Test flag not found + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--other".to_string(), + "value".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, None); + assert_eq!(args, vec!["a", "b", "--other", "value"]); + + // Test empty args + let mut args: Vec<String> = Vec::new(); + let result = special_argument!(args, "--file"); + assert_eq!(result, None); + assert_eq!(args, Vec::<String>::new()); + + // Test multiple same flags (should only extract first) + let mut args = vec![ + "--file".to_string(), + "first.txt".to_string(), + "--file".to_string(), + "second.txt".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("first.txt".to_string())); + assert_eq!(args, vec!["--file", "second.txt"]); + + // Test flag with empty string value + let mut args = vec![ + "a".to_string(), + "--file".to_string(), + "".to_string(), + "b".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("".to_string())); + assert_eq!(args, vec!["a", "b"]); + + // Test flag with value starting with dash + let mut args = vec![ + "a".to_string(), + "--file".to_string(), + "-value".to_string(), + "b".to_string(), + ]; + let result = special_argument!(args, "--file"); + assert_eq!(result, Some("-value".to_string())); + assert_eq!(args, vec!["a", "b"]); +} + +#[test] +fn test_special_arguments() { + // Test extracting multiple values after flag + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--list".to_string(), + "a".to_string(), + "b".to_string(), + "c".to_string(), + "d".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, vec!["a", "b", "c", "d"]); + assert_eq!(args, vec!["a", "b", "--next", "1"]); + + // Test extracting single value + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, "--next"); + assert_eq!(result, vec!["1"]); + assert_eq!(args, vec!["a", "b"]); + + // Test extracting from beginning + let mut args = vec![ + "--list".to_string(), + "a".to_string(), + "b".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, vec!["a", "b"]); + assert_eq!(args, vec!["--next", "1"]); + + // Test extracting when no values after flag + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--list".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, Vec::<String>::new()); + assert_eq!(args, vec!["a", "b", "--next", "1"]); + + // Test extracting when flag not found + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--list".to_string(), + "c".to_string(), + "d".to_string(), + ]; + let result = special_arguments!(args, "--none"); + assert_eq!(result, Vec::<String>::new()); + assert_eq!(args, vec!["a", "b", "--list", "c", "d"]); + + // Test extracting empty args + let mut args: Vec<String> = Vec::new(); + let result = special_arguments!(args, "--list"); + assert_eq!(result, Vec::<String>::new()); + assert_eq!(args, Vec::<String>::new()); + + // Test extracting with only flag at end + let mut args = vec!["--list".to_string()]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, Vec::<String>::new()); + assert_eq!(args, Vec::<String>::new()); + + // Test extracting multiple values until end of args + let mut args = vec![ + "--list".to_string(), + "a".to_string(), + "b".to_string(), + "c".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, vec!["a", "b", "c"]); + assert_eq!(args, Vec::<String>::new()); + + // Test extracting with mixed non-dash values + let mut args = vec![ + "--list".to_string(), + "value1".to_string(), + "value2".to_string(), + "-next".to_string(), + "value3".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, vec!["value1", "value2"]); + assert_eq!(args, vec!["-next", "value3"]); + + // Test extracting with single dash values + let mut args = vec![ + "--list".to_string(), + "-a".to_string(), + "-b".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, "--list"); + assert_eq!(result, Vec::<String>::new()); + assert_eq!(args, vec!["-a", "-b", "--next", "1"]); + + // Test extracting with empty flag + let mut args = vec![ + "a".to_string(), + "b".to_string(), + "--next".to_string(), + "1".to_string(), + ]; + let result = special_arguments!(args, ""); + assert_eq!(result, vec!["a", "b"]); + assert_eq!(args, vec!["--next", "1"]); +} + +#[test] +fn test_flag_from_empty_tuple() { + let flag = Flag::from(()); + assert_eq!(flag.as_ref(), &[] as &[&str]); +} + +#[test] +fn test_flag_from_static_str() { + let flag = Flag::from("-h"); + assert_eq!(flag.as_ref(), &["-h"]); +} + +#[test] +fn test_flag_from_slice() { + let flag = Flag::from(&["-h", "--help"][..]); + assert_eq!(flag.as_ref(), &["-h", "--help"]); +} + +#[test] +fn test_flag_from_array() { + let flag = Flag::from(["-v", "--verbose"]); + assert_eq!(flag.as_ref(), &["-v", "--verbose"]); +} + +#[test] +fn test_flag_from_ref_array() { + let flag = Flag::from(&["-f", "--file"]); + assert_eq!(flag.as_ref(), &["-f", "--file"]); +} + +#[test] +fn test_flag_from_ref_flag() { + let original = Flag::from("-x"); + let cloned = Flag::from(&original); + assert_eq!(cloned.as_ref(), &["-x"]); +} + +#[test] +fn test_flag_as_ref() { + let flag = Flag::from("-h"); + let r: &[&str] = flag.as_ref(); + assert_eq!(r, &["-h"]); +} + +#[test] +fn test_flag_deref() { + let flag = Flag::from(["-a", "-b"]); + let collected: Vec<&&str> = flag.iter().collect(); + assert_eq!(collected, vec![&"-a", &"-b"]); +} diff --git a/mingling_core/src/program/hook/hook_info.rs b/mingling_core/src/program/hook/hook_info.rs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/mingling_core/src/program/hook/hook_info.rs diff --git a/mingling_core/src/program/string_vec.rs b/mingling_core/src/program/string_vec.rs index 1ccedf4..c2e6220 100644 --- a/mingling_core/src/program/string_vec.rs +++ b/mingling_core/src/program/string_vec.rs @@ -96,7 +96,7 @@ mod tests { #[test] fn test_string_vec_deref() { let sv = StringVec::from(["alpha", "beta"]); - let inner: &Vec<String> = &*sv; + let inner: &Vec<String> = &sv; assert_eq!(inner.len(), 2); assert_eq!(inner[0], "alpha"); } diff --git a/mingling_core/src/renderer/general/error.rs b/mingling_core/src/renderer/general/error.rs index 8c89266..07ca92b 100644 --- a/mingling_core/src/renderer/general/error.rs +++ b/mingling_core/src/renderer/general/error.rs @@ -55,7 +55,7 @@ mod tests { #[test] fn deref_accesses_inner_error_string() { let err = GeneralRendererSerializeError::new("inner message".to_string()); - let derefed: &String = &*err; + let derefed: &String = &err; assert_eq!(derefed, "inner message"); } |
