Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/chmod/src/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,6 @@ mod tests {
let (c, a, i) = extract_negative_modes(["--", "-r", "file"].iter().map(OsString::from));
assert_eq!(c, None);
assert_eq!(a, ["--", "-r", "file"]);
assert!(i.is_empty());
assert_eq!(i, [] as [_; 0]);
}
}
4 changes: 2 additions & 2 deletions src/uu/cut/src/matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct ExactMatcher<'a> {

impl<'a> ExactMatcher<'a> {
pub fn new(needle: &'a [u8]) -> Self {
assert!(!needle.is_empty());
assert_ne!(needle, []);
Self { needle }
}
}
Expand Down Expand Up @@ -51,7 +51,7 @@ pub struct MbExactMatcher<'a> {

impl<'a> MbExactMatcher<'a> {
pub fn new(needle: &'a [u8]) -> Self {
assert!(!needle.is_empty());
assert_ne!(needle, []);
Self { needle }
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/uu/cut/src/searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod exact_searcher_tests {
let matcher = ExactMatcher::new("a".as_bytes());
let iter = Searcher::new(&matcher, "".as_bytes());
let items: Vec<(usize, usize)> = iter.collect();
assert!(items.is_empty());
assert_eq!(items, [] as [_; 0]);
}

fn test_multibyte(line: &[u8], expected: &[(usize, usize)]) {
Expand Down Expand Up @@ -137,7 +137,7 @@ mod whitespace_searcher_tests {
let matcher = WhitespaceMatcher {};
let iter = Searcher::new(&matcher, "".as_bytes());
let items: Vec<(usize, usize)> = iter.collect();
assert!(items.is_empty());
assert_eq!(items, [] as [_; 0]);
}

fn test_multispace(line: &[u8], expected: &[(usize, usize)]) {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,6 @@ mod tests {
use crate::AlignedBuf;

let buf = AlignedBuf::new(0).unwrap();
assert!(buf.as_bytes().is_empty());
assert_eq!(buf.as_bytes(), []);
}
}
2 changes: 1 addition & 1 deletion src/uu/head/src/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ mod tests {
assert!(!opts.quiet);
assert_eq!(opts.line_ending, LineEnding::Newline);
assert_eq!(opts.mode, Mode::FirstLines(10));
assert!(opts.files.is_empty());
assert_eq!(opts.files, [] as [OsString; 0]);
}

fn arg_outputs(src: &str) -> Result<String, ()> {
Expand Down
2 changes: 1 addition & 1 deletion src/uu/ls/src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl<'a> StyleManager<'a> {
style_code: &mut String,
) {
if let Some(raw) = self.indicator_codes.get(&indicator).cloned() {
debug_assert!(!raw.is_empty());
debug_assert_ne!(raw, "");
style_code.push_str(self.reset(!self.initial_reset_is_done));
style_code.push_str(ANSI_CSI);
style_code.push_str(&raw);
Expand Down
8 changes: 4 additions & 4 deletions src/uu/ls/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ mod tests {
fn test_streaming_output_new() {
let collector = StreamingOutput::new();
assert!(collector.entries().is_empty());
assert!(collector.directories().is_empty());
assert!(collector.totals().is_empty());
assert_eq!(collector.directories(), [] as [PathBuf; 0]);
assert_eq!(collector.totals(), []);
}

#[test]
Expand Down Expand Up @@ -369,8 +369,8 @@ mod tests {

collector.clear();
assert!(collector.entries().is_empty());
assert!(collector.directories().is_empty());
assert!(collector.totals().is_empty());
assert_eq!(collector.directories(), [] as [PathBuf; 0]);
assert_eq!(collector.totals(), []);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/uu/shuf/src/shuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ mod test_split_seps {

#[test]
fn test_empty_input() {
assert!(split_seps(b"", b'\n').is_empty());
assert_eq!(split_seps(b"", b'\n'), [] as [&[_]; 0]);
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions src/uu/sort/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ fn parse_lines<'a>(
let read = read.strip_suffix(&[separator]).unwrap_or(read);

assert!(lines.is_empty());
assert!(line_data.selections.is_empty());
assert!(line_data.num_infos.is_empty());
assert!(line_data.parsed_floats.is_empty());
assert!(line_data.line_num_floats.is_empty());
assert!(line_data.collation_key_buffer.is_empty());
assert!(line_data.collation_key_ends.is_empty());
assert_eq!(line_data.selections, [] as [&[_]; 0]);
assert_eq!(line_data.num_infos, [] as [_; 0]);
assert_eq!(line_data.parsed_floats, [] as [_; 0]);
assert_eq!(line_data.line_num_floats, [] as [_; 0]);
assert_eq!(line_data.collation_key_buffer, [] as [_; 0]);
assert_eq!(line_data.collation_key_ends, [] as [_; 0]);
token_buffer.clear();
let mut estimated = (*line_count_hint).max(1);
let mut exact_line_count = None;
Expand Down
2 changes: 1 addition & 1 deletion src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ fn tokenize(
token_buffer: &mut Vec<Field>,
precomputed: &Precomputed,
) {
assert!(token_buffer.is_empty());
assert_eq!(token_buffer, &[] as &[Field; 0]);
if let Some(separator) = separator {
tokenize_with_separator(line, separator, token_buffer);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/uucore/src/lib/features/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Base64SimdWrapper {
) -> Self {
assert!(valid_decoding_multiple > 0);
assert!(unpadded_multiple > 0);
assert!(!alphabet.is_empty());
assert_ne!(alphabet, []);

Self {
alphabet,
Expand Down Expand Up @@ -195,7 +195,7 @@ impl EncodingWrapper {

assert!(unpadded_multiple > 0);

assert!(!alphabet.is_empty());
assert_ne!(alphabet, []);

Self {
alphabet,
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/features/i18n/charmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Encoding {
/// `bytes.len()`, and never `0` for a non-empty slice.
#[inline]
pub fn char_len(self, bytes: &[u8]) -> usize {
debug_assert!(!bytes.is_empty());
debug_assert_ne!(bytes, []);
let b0 = bytes[0];
if b0 <= 0x7F {
return 1;
Expand Down
12 changes: 6 additions & 6 deletions src/uucore/src/lib/mods/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ invalid-syntax = This is { $missing
// Test that we can get messages (should use embedded English for "test" utility)
let message = get_message("test-about");
// Since we're using embedded resources, we should get the expected message
assert!(!message.is_empty());
assert_ne!(message, "");

// Restore original LANG value
if let Some(val) = original_lang {
Expand Down Expand Up @@ -1718,7 +1718,7 @@ invalid-syntax = This is { $missing

// Should fall back to English embedded resources
let message = get_message("test-about");
assert!(!message.is_empty()); // Should get something, not just the key
assert_ne!(message, ""); // Should get something, not just the key

// Restore original LANG value
if let Some(val) = original_lang {
Expand Down Expand Up @@ -1797,18 +1797,18 @@ invalid-syntax = This is { $missing
// Test that common strings are available after initialization
let error_after_init = get_message("common-error");
// Should either be translated or return the key (but not panic)
assert!(!error_after_init.is_empty());
assert_ne!(error_after_init, "");

let tip_after_init = get_message("common-tip");
assert!(!tip_after_init.is_empty());
assert_ne!(tip_after_init, "");

// Test that clap error keys work with fallbacks
let unknown_arg_key = get_message("clap-error-unexpected-argument");
assert!(!unknown_arg_key.is_empty());
assert_ne!(unknown_arg_key, "");

// Test usage key fallback
let usage_key = get_message("common-usage");
assert!(!usage_key.is_empty());
assert_ne!(usage_key, "");
})
.join()
.unwrap();
Expand Down
9 changes: 1 addition & 8 deletions tests/by-util/test_basename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,7 @@ fn test_zero_param() {
}

fn expect_error(input: &[&str]) {
assert!(
!new_ucmd!()
.args(input)
.fails()
.no_stdout()
.stderr_str()
.is_empty()
);
assert_ne!(new_ucmd!().args(input).fails().no_stdout().stderr_str(), "");
}

#[test]
Expand Down
Loading
Loading