Simplifications to --size tests
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent e2b2701 · Browse files · 1 file·+37 added−60 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+37 added−60 removed
- tests:+37 added−60 removed
Provenance
- Commit
a320020- Tree
d645615- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
e2b2701
1 file changed+37 added−60 removed
modified:tests/tests.rs+37 added-60 removed
1008 unmodified lines1009 // Should not be found under a different extension1010 te.assert_output(&["-e", "zip", "", "test1/"], "");1011 }1012 1013-/// (--size)1013+/// Filtering for file size (--size)1014 #[test]1015 fn test_size() {1016- let dirs = &["test1", "test2"];1017- let files = &["test1/a.foo", "test1/b.foo", "test1/c.foo"];1018- let te = TestEnv::new(dirs, files);1016+ let te = TestEnv::new(&[], &[]);1017 1020- create_file_with_size(te.test_root().join("test1/11_bytes.foo"), 11);1021- create_file_with_size(te.test_root().join("test2/30_bytes.foo"), 30);1022- create_file_with_size(te.test_root().join("test1/3_kilobytes.foo"), 3 * 1000);1023- create_file_with_size(te.test_root().join("test2/4_kibibytes.foo"), 4 * 1024);1018+ create_file_with_size(te.test_root().join("0_bytes.foo"), 0);1019+ create_file_with_size(te.test_root().join("11_bytes.foo"), 11);1020+ create_file_with_size(te.test_root().join("30_bytes.foo"), 30);1021+ create_file_with_size(te.test_root().join("3_kilobytes.foo"), 3 * 1000);1022+ create_file_with_size(te.test_root().join("4_kibibytes.foo"), 4 * 1024);1023 1024 // Zero and non-zero sized files.1025 te.assert_output(1027- &["", "test1", "test2", "--size", "+0B"],1028- "test1/11_bytes.foo1029- test1/a.foo1030- test1/b.foo1031- test1/c.foo1032- test1/3_kilobytes.foo1033- test2/30_bytes.foo1034- test2/4_kibibytes.foo"1026+ &["", "--size", "+0B"],1027+ "0_bytes.foo1028+ 11_bytes.foo1029+ 30_bytes.foo1030+ 3_kilobytes.foo1031+ 4_kibibytes.foo",1032 );1033 1034 // Zero sized files.1038- te.assert_output(1039- &["", "test1", "test2", "--size", "-0B"],1040- "test1/a.foo1041- test1/b.foo1042- test1/c.foo"1043- );1035+ te.assert_output(&["", "--size", "-0B"], "0_bytes.foo");1036 1037 // Files with 2 bytes or more.1038 te.assert_output(1047- &["", "test1", "test2", "--size", "+2B"],1048- "test1/11_bytes.foo1049- test1/3_kilobytes.foo1050- test2/30_bytes.foo1051- test2/4_kibibytes.foo"1039+ &["", "--size", "+2B"],1040+ "11_bytes.foo1041+ 30_bytes.foo1042+ 3_kilobytes.foo1043+ 4_kibibytes.foo",1044 );1045 1046 // Files with 2 bytes or less.1055- te.assert_output(1056- &["", "test1", "test2", "--size", "-2B"],1057- "test1/a.foo1058- test1/b.foo1059- test1/c.foo"1060- );1047+ te.assert_output(&["", "--size", "-2B"], "0_bytes.foo");1048 1049 // Files with size between 1 byte and 11 bytes.1063- te.assert_output(1064- &["", "test1", "test2", "--size", "+1B", "--size", "-11B"],1065- "test1/11_bytes.foo"1066- );1050+ te.assert_output(&["", "--size", "+1B", "--size", "-11B"], "11_bytes.foo");1051 1052 // Files with size between 1 byte and 30 bytes.1053 te.assert_output(1070- &["", "test1", "test2", "--size", "+1B", "--size", "-30B"],1071- "test1/11_bytes.foo1072- test2/30_bytes.foo"1054+ &["", "--size", "+1B", "--size", "-30B"],1055+ "11_bytes.foo1056+ 30_bytes.foo",1057 );1058 1059+ // Combine with a search pattern1060+ te.assert_output(&["^11_", "--size", "+1B", "--size", "-30B"], "11_bytes.foo");1061+1062 // Files with size between 12 and 30 bytes.1076- te.assert_output(1077- &["", "test1", "test2", "--size", "+12B", "--size", "-30B"],1078- "test2/30_bytes.foo"1079- );1063+ te.assert_output(&["", "--size", "+12B", "--size", "-30B"], "30_bytes.foo");1064 1065 // Files with size between 31 and 100 bytes.1082- te.assert_output(1083- &["", "test1", "test2", "--size", "+31B", "--size", "-100B"],1084- ""1085- );1066+ te.assert_output(&["", "--size", "+31B", "--size", "-100B"], "");1067 1068 // Files with size between 3 kibibytes and 5 kibibytes.1088- te.assert_output(1089- &["", "test1", "test2", "--size", "+3ki", "--size", "-5ki"],1090- "test2/4_kibibytes.foo"1091- );1069+ te.assert_output(&["", "--size", "+3ki", "--size", "-5ki"], "4_kibibytes.foo");1070 1071 // Files with size between 3 kilobytes and 5 kilobytes.1072 te.assert_output(1095- &["", "test1", "test2", "--size", "+3k", "--size", "-5k"],1096- "test1/3_kilobytes.foo1097- test2/4_kibibytes.foo"1073+ &["", "--size", "+3k", "--size", "-5k"],1074+ "3_kilobytes.foo1075+ 4_kibibytes.foo",1076 );1077 1100- // Files with size greater than 3 kilobytes and less than 4 kibibytes.1101- te.assert_output(1102- &["", "test1", "test2", "--size", "+3k", "--size", "-3ki"],1103- "test1/3_kilobytes.foo"1104- );1078+ // Files with size greater than 3 kilobytes and less than 3 kibibytes.1079+ te.assert_output(&["", "--size", "+3k", "--size", "-3ki"], "3_kilobytes.foo");1080 1081+ // Files with size equal 4 kibibytes.1082+ te.assert_output(&["", "--size", "+4ki", "--size", "-4ki"], "4_kibibytes.foo");1083 }