Skip to content
Myr

Add tests for SizeFilter (--size) fixes sharkdp/fd#289

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jonathan · committed by David Peter · parent 060d14b · Browse files · 1 file+77 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+77 added−0 removed

  • tests:+77 added−0 removed

1 file+77 added−0 removed

modified:tests/tests.rs+77 added
999 unmodified lines
10001001 // Should not be found under a different extension1002 te.assert_output(&["-e", "zip", "", "test1/"], "");1003}10041005/// (--size)1006#[test]1007fn test_size() {1008 use std::ffi::OsStr;1009 use std::os::unix::ffi::OsStrExt;10101011 let dirs = &["test1", "test2"];1012 let files = &["test1/a.foo", "test1/b.foo", "test1/c.foo"];1013 let te = TestEnv::new(dirs, files);10141015 let mut f = fs::File::create(te.test_root().join("test1/tiny.foo")).unwrap();1016 f.write("Hello world".as_bytes()).unwrap(); // 11 bytes1017 f.flush().unwrap();10181019 let mut f = fs::File::create(te.test_root().join("test2/big.foo")).unwrap();1020 f.write("Hello user, fd is a nice tool.".as_bytes()).unwrap(); // 30 bytes1021 f.flush().unwrap();10221023 // Zero and non-zero sized files.1024 te.assert_output(1025 &["", "test1", "test2", "--size", "+0B"],1026 "test1/a.foo1027 test1/b.foo1028 test1/c.foo1029 test1/tiny.foo1030 test2/big.foo"1031 );10321033 // Zero sized files.1034 te.assert_output(1035 &["", "test1", "test2", "--size", "-0B"],1036 "test1/a.foo1037 test1/b.foo1038 test1/c.foo"1039 );10401041 // Files with 2 bytes or more.1042 te.assert_output(1043 &["", "test1", "test2", "--size", "+2B"],1044 "test1/tiny.foo1045 test2/big.foo"1046 );10471048 // Files with 2 bytes or less.1049 te.assert_output(1050 &["", "test1", "test2", "--size", "-2B"],1051 "test1/a.foo1052 test1/b.foo1053 test1/c.foo"1054 );10551056 // Files with size between 1 byte and 11 bytes.1057 te.assert_output(1058 &["", "test1", "test2", "--size", "+1B", "--size", "-11B"],1059 "test1/tiny.foo"1060 );10611062 // Files with size between 1 byte and 30 bytes.1063 te.assert_output(1064 &["", "test1", "test2", "--size", "+1B", "--size", "-30B"],1065 "test1/tiny.foo1066 test2/big.foo"1067 );10681069 // Files with size between 12 and 30 bytes.1070 te.assert_output(1071 &["", "test1", "test2", "--size", "+12B", "--size", "-30B"],1072 "test2/big.foo"1073 );10741075 // Files with size between 31 and 100 bytes.1076 te.assert_output(1077 &["", "test1", "test2", "--size", "+31B", "--size", "-100B"],1078 ""1079 );1080}