From 103944f605bda6507a78ce43cbe06b27065cedcb Mon Sep 17 00:00:00 2001 From: Soispha Date: Wed, 1 Nov 2023 13:19:22 +0100 Subject: [PATCH] tests(trinitry): Add some sort of fuzzing --- trinitry/src/tests.rs | 1365 +++++++++++++++++++++++++++++++++++++++++ trinitry/update.sh | 88 +++ 2 files changed, 1453 insertions(+) create mode 100644 trinitry/src/tests.rs create mode 100755 trinitry/update.sh diff --git a/trinitry/src/tests.rs b/trinitry/src/tests.rs new file mode 100644 index 0000000..4a65b94 --- /dev/null +++ b/trinitry/src/tests.rs @@ -0,0 +1,1365 @@ +// DO NOT EDIT +// This file is automatically generated by the 'update.sh' file, with data from: +// https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt + +#[cfg(test)] +mod test { + use crate::Trinitry; + #[test] + fn parse_0() { + let p = Trinitry::new(r##"undefined"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"undefined"##, &p.to_string()); + } + #[test] + fn parse_1() { + let p = Trinitry::new(r##"undef"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"undef"##, &p.to_string()); + } + #[test] + fn parse_2() { + let p = Trinitry::new(r##"null"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"null"##, &p.to_string()); + } + #[test] + fn parse_3() { + let p = Trinitry::new(r##"NULL"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"NULL"##, &p.to_string()); + } + #[test] + fn parse_4() { + let p = Trinitry::new(r##"(null)"##); + assert!(p.is_err()); + } + #[test] + fn parse_5() { + let p = Trinitry::new(r##"nil"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"nil"##, &p.to_string()); + } + #[test] + fn parse_6() { + let p = Trinitry::new(r##"NIL"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"NIL"##, &p.to_string()); + } + #[test] + fn parse_7() { + let p = Trinitry::new(r##"true"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"true"##, &p.to_string()); + } + #[test] + fn parse_8() { + let p = Trinitry::new(r##"True"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"True"##, &p.to_string()); + } + #[test] + fn parse_9() { + let p = Trinitry::new(r##"TRUE"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"TRUE"##, &p.to_string()); + } + #[test] + fn parse_10() { + let p = Trinitry::new(r##"FALSE"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"FALSE"##, &p.to_string()); + } + #[test] + fn parse_11() { + let p = Trinitry::new(r##"None"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"None"##, &p.to_string()); + } + #[test] + fn parse_12() { + let p = Trinitry::new(r##"then"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"then"##, &p.to_string()); + } + #[test] + fn parse_13() { + let p = Trinitry::new(r##"\"##); + assert!(p.is_err()); + } + #[test] + fn parse_14() { + let p = Trinitry::new(r##"\\"##); + assert!(p.is_err()); + } + #[test] + fn parse_15() { + let p = Trinitry::new(r##"0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0"##, &p.to_string()); + } + #[test] + fn parse_16() { + let p = Trinitry::new(r##"1"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1"##, &p.to_string()); + } + #[test] + fn parse_17() { + let p = Trinitry::new(r##"1.00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1.00"##, &p.to_string()); + } + #[test] + fn parse_18() { + let p = Trinitry::new(r##"$1.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_19() { + let p = Trinitry::new(r##"1/2"##); + assert!(p.is_err()); + } + #[test] + fn parse_20() { + let p = Trinitry::new(r##"1E2"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1E2"##, &p.to_string()); + } + #[test] + fn parse_21() { + let p = Trinitry::new(r##"1E02"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1E02"##, &p.to_string()); + } + #[test] + fn parse_22() { + let p = Trinitry::new(r##"1E+02"##); + assert!(p.is_err()); + } + #[test] + fn parse_23() { + let p = Trinitry::new(r##"-1"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-1"##, &p.to_string()); + } + #[test] + fn parse_24() { + let p = Trinitry::new(r##"-1.00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-1.00"##, &p.to_string()); + } + #[test] + fn parse_25() { + let p = Trinitry::new(r##"-$1.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_26() { + let p = Trinitry::new(r##"-1/2"##); + assert!(p.is_err()); + } + #[test] + fn parse_27() { + let p = Trinitry::new(r##"-1E2"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-1E2"##, &p.to_string()); + } + #[test] + fn parse_28() { + let p = Trinitry::new(r##"-1E02"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-1E02"##, &p.to_string()); + } + #[test] + fn parse_29() { + let p = Trinitry::new(r##"-1E+02"##); + assert!(p.is_err()); + } + #[test] + fn parse_30() { + let p = Trinitry::new(r##"1/0"##); + assert!(p.is_err()); + } + #[test] + fn parse_31() { + let p = Trinitry::new(r##"0/0"##); + assert!(p.is_err()); + } + #[test] + fn parse_32() { + let p = Trinitry::new(r##"-2147483648/-1"##); + assert!(p.is_err()); + } + #[test] + fn parse_33() { + let p = Trinitry::new(r##"-9223372036854775808/-1"##); + assert!(p.is_err()); + } + #[test] + fn parse_34() { + let p = Trinitry::new(r##"-0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-0"##, &p.to_string()); + } + #[test] + fn parse_35() { + let p = Trinitry::new(r##"-0.0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-0.0"##, &p.to_string()); + } + #[test] + fn parse_36() { + let p = Trinitry::new(r##"+0"##); + assert!(p.is_err()); + } + #[test] + fn parse_37() { + let p = Trinitry::new(r##"+0.0"##); + assert!(p.is_err()); + } + #[test] + fn parse_38() { + let p = Trinitry::new(r##"0.00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0.00"##, &p.to_string()); + } + #[test] + fn parse_39() { + let p = Trinitry::new(r##"0..0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0..0"##, &p.to_string()); + } + #[test] + fn parse_40() { + let p = Trinitry::new(r##"."##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"."##, &p.to_string()); + } + #[test] + fn parse_41() { + let p = Trinitry::new(r##"0.0.0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0.0.0"##, &p.to_string()); + } + #[test] + fn parse_42() { + let p = Trinitry::new(r##"0,00"##); + assert!(p.is_err()); + } + #[test] + fn parse_43() { + let p = Trinitry::new(r##"0,,0"##); + assert!(p.is_err()); + } + #[test] + fn parse_44() { + let p = Trinitry::new(r##","##); + assert!(p.is_err()); + } + #[test] + fn parse_45() { + let p = Trinitry::new(r##"0,0,0"##); + assert!(p.is_err()); + } + #[test] + fn parse_46() { + let p = Trinitry::new(r##"0.0/0"##); + assert!(p.is_err()); + } + #[test] + fn parse_47() { + let p = Trinitry::new(r##"1.0/0.0"##); + assert!(p.is_err()); + } + #[test] + fn parse_48() { + let p = Trinitry::new(r##"0.0/0.0"##); + assert!(p.is_err()); + } + #[test] + fn parse_49() { + let p = Trinitry::new(r##"1,0/0,0"##); + assert!(p.is_err()); + } + #[test] + fn parse_50() { + let p = Trinitry::new(r##"0,0/0,0"##); + assert!(p.is_err()); + } + #[test] + fn parse_51() { + let p = Trinitry::new(r##"--1"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"--1"##, &p.to_string()); + } + #[test] + fn parse_52() { + let p = Trinitry::new(r##"-"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-"##, &p.to_string()); + } + #[test] + fn parse_53() { + let p = Trinitry::new(r##"-."##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-."##, &p.to_string()); + } + #[test] + fn parse_54() { + let p = Trinitry::new(r##"-,"##); + assert!(p.is_err()); + } + #[test] + fn parse_55() { + let p = Trinitry::new(r##"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"##, &p.to_string()); + } + #[test] + fn parse_56() { + let p = Trinitry::new(r##"NaN"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"NaN"##, &p.to_string()); + } + #[test] + fn parse_57() { + let p = Trinitry::new(r##"Infinity"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Infinity"##, &p.to_string()); + } + #[test] + fn parse_58() { + let p = Trinitry::new(r##"-Infinity"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-Infinity"##, &p.to_string()); + } + #[test] + fn parse_59() { + let p = Trinitry::new(r##"INF"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"INF"##, &p.to_string()); + } + #[test] + fn parse_60() { + let p = Trinitry::new(r##"1#INF"##); + assert!(p.is_err()); + } + #[test] + fn parse_61() { + let p = Trinitry::new(r##"-1#IND"##); + assert!(p.is_err()); + } + #[test] + fn parse_62() { + let p = Trinitry::new(r##"1#QNAN"##); + assert!(p.is_err()); + } + #[test] + fn parse_63() { + let p = Trinitry::new(r##"1#SNAN"##); + assert!(p.is_err()); + } + #[test] + fn parse_64() { + let p = Trinitry::new(r##"1#IND"##); + assert!(p.is_err()); + } + #[test] + fn parse_65() { + let p = Trinitry::new(r##"0x0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0x0"##, &p.to_string()); + } + #[test] + fn parse_66() { + let p = Trinitry::new(r##"0xffffffff"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0xffffffff"##, &p.to_string()); + } + #[test] + fn parse_67() { + let p = Trinitry::new(r##"0xffffffffffffffff"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0xffffffffffffffff"##, &p.to_string()); + } + #[test] + fn parse_68() { + let p = Trinitry::new(r##"0xabad1dea"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0xabad1dea"##, &p.to_string()); + } + #[test] + fn parse_69() { + let p = Trinitry::new(r##"123456789012345678901234567890123456789"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"123456789012345678901234567890123456789"##, &p.to_string()); + } + #[test] + fn parse_70() { + let p = Trinitry::new(r##"1,000.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_71() { + let p = Trinitry::new(r##"1 000.00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1 000.00"##, &p.to_string()); + } + #[test] + fn parse_72() { + let p = Trinitry::new(r##"1'000.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_73() { + let p = Trinitry::new(r##"1,000,000.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_74() { + let p = Trinitry::new(r##"1 000 000.00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1 000 000.00"##, &p.to_string()); + } + #[test] + fn parse_75() { + let p = Trinitry::new(r##"1'000'000.00"##); + assert!(p.is_err()); + } + #[test] + fn parse_76() { + let p = Trinitry::new(r##"1.000,00"##); + assert!(p.is_err()); + } + #[test] + fn parse_77() { + let p = Trinitry::new(r##"1 000,00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1 000,00"##, &p.to_string()); + } + #[test] + fn parse_78() { + let p = Trinitry::new(r##"1'000,00"##); + assert!(p.is_err()); + } + #[test] + fn parse_79() { + let p = Trinitry::new(r##"1.000.000,00"##); + assert!(p.is_err()); + } + #[test] + fn parse_80() { + let p = Trinitry::new(r##"1 000 000,00"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"1 000 000,00"##, &p.to_string()); + } + #[test] + fn parse_81() { + let p = Trinitry::new(r##"1'000'000,00"##); + assert!(p.is_err()); + } + #[test] + fn parse_82() { + let p = Trinitry::new(r##"01000"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"01000"##, &p.to_string()); + } + #[test] + fn parse_83() { + let p = Trinitry::new(r##"08"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"08"##, &p.to_string()); + } + #[test] + fn parse_84() { + let p = Trinitry::new(r##"09"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"09"##, &p.to_string()); + } + #[test] + fn parse_85() { + let p = Trinitry::new(r##"2.2250738585072011e-308"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"2.2250738585072011e-308"##, &p.to_string()); + } + #[test] + fn parse_86() { + let p = Trinitry::new(r##",./;'[]\-="##); + assert!(p.is_err()); + } + #[test] + fn parse_87() { + let p = Trinitry::new(r##"<>?:"{}|_+"##); + assert!(p.is_err()); + } + #[test] + fn parse_88() { + let p = Trinitry::new(r##"!@#$%^&*()`~"##); + assert!(p.is_err()); + } + #[test] + fn parse_89() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_90() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_91() { + let p = Trinitry::new(r##" "##); + assert!(p.is_err()); + } + #[test] + fn parse_92() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_93() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_94() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_95() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_96() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_97() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_98() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_99() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_100() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_101() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_102() { + let p = Trinitry::new(r##"`"##); + assert!(p.is_err()); + } + #[test] + fn parse_103() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_104() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_105() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_106() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_107() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_108() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_109() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_110() { + let p = Trinitry::new(r##"'"##); + assert!(p.is_err()); + } + #[test] + fn parse_111() { + let p = Trinitry::new(r##"""##); + assert!(p.is_err()); + } + #[test] + fn parse_112() { + let p = Trinitry::new(r##"''"##); + assert!(p.is_err()); + } + #[test] + fn parse_113() { + let p = Trinitry::new(r##""""##); + assert!(p.is_err()); + } + #[test] + fn parse_114() { + let p = Trinitry::new(r##"'"'"##); + assert!(p.is_err()); + } + #[test] + fn parse_115() { + let p = Trinitry::new(r##""''''"'""##); + assert!(p.is_err()); + } + #[test] + fn parse_116() { + let p = Trinitry::new(r##""'"'"''''""##); + assert!(p.is_err()); + } + #[test] + fn parse_117() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_118() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_119() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_120() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_121() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_122() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_123() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_124() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_125() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_126() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_127() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_128() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_129() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_130() { + let p = Trinitry::new(r##"/"##); + assert!(p.is_err()); + } + #[test] + fn parse_131() { + let p = Trinitry::new(r##"A"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"A"##, &p.to_string()); + } + #[test] + fn parse_132() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_133() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_134() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_135() { + let p = Trinitry::new(r##"( )"##); + assert!(p.is_err()); + } + #[test] + fn parse_136() { + let p = Trinitry::new(r##"("##); + assert!(p.is_err()); + } + #[test] + fn parse_137() { + let p = Trinitry::new(r##"__(,_,*)"##); + assert!(p.is_err()); + } + #[test] + fn parse_138() { + let p = Trinitry::new(r##"():*:"##); + assert!(p.is_err()); + } + #[test] + fn parse_139() { + let p = Trinitry::new(r##"()"##); + assert!(p.is_err()); + } + #[test] + fn parse_140() { + let p = Trinitry::new(r##",:*:( ):*:"##); + assert!(p.is_err()); + } + #[test] + fn parse_141() { + let p = Trinitry::new(r##"( )"##); + assert!(p.is_err()); + } + #[test] + fn parse_142() { + let p = Trinitry::new(r##"("##); + assert!(p.is_err()); + } + #[test] + fn parse_143() { + let p = Trinitry::new(r##"( _ )"##); + assert!(p.is_err()); + } + #[test] + fn parse_144() { + let p = Trinitry::new(r##"( )"##); + assert!(p.is_err()); + } + #[test] + fn parse_145() { + let p = Trinitry::new(r##"\_()_/"##); + assert!(p.is_err()); + } + #[test] + fn parse_146() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_147() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_148() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_149() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_150() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_151() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_152() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_153() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_154() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_155() { + let p = Trinitry::new(r##"0 1 2 3 4 5 6 7 8 9"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0 1 2 3 4 5 6 7 8 9"##, &p.to_string()); + } + #[test] + fn parse_156() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_157() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_158() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_159() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_160() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_161() { + let p = Trinitry::new(r##", . . - . , , ."##); + assert!(p.is_err()); + } + #[test] + fn parse_162() { + let p = Trinitry::new(r##", , ,"##); + assert!(p.is_err()); + } + #[test] + fn parse_163() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_164() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_165() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_166() { + let p = Trinitry::new(r##"(5)"##); + assert!(p.is_err()); + } + #[test] + fn parse_167() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_168() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_169() { + let p = Trinitry::new(r##"ZGO"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"ZGO"##, &p.to_string()); + } + #[test] + fn parse_170() { + let p = Trinitry::new(r##"00$-"##); + assert!(p.is_err()); + } + #[test] + fn parse_171() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_172() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_173() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_174() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_175() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_176() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_177() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_178() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_179() { + let p = Trinitry::new(r##"";alert(15);t=""##); + assert!(p.is_err()); + } + #[test] + fn parse_180() { + let p = Trinitry::new(r##"';alert(16);t='"##); + assert!(p.is_err()); + } + #[test] + fn parse_181() { + let p = Trinitry::new(r##"JavaSCript:alert(17)"##); + assert!(p.is_err()); + } + #[test] + fn parse_182() { + let p = Trinitry::new(r##";alert(18);"##); + assert!(p.is_err()); + } + #[test] + fn parse_183() { + let p = Trinitry::new(r##"">"##); + assert!(p.is_err()); + } + #[test] + fn parse_184() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_185() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_186() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_187() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_188() { + let p = Trinitry::new(r##"<"##); + assert!(p.is_err()); + } + #[test] + fn parse_189() { + let p = Trinitry::new(r##"\";alert('223');//"##); + assert!(p.is_err()); + } + #[test] + fn parse_190() { + let p = Trinitry::new(r##" Copy me"##); + assert!(p.is_err()); + } + #[test] + fn parse_191() { + let p = Trinitry::new(r##" Scroll over me "##); + assert!(p.is_err()); + } + #[test] + fn parse_192() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_193() { + let p = Trinitry::new(r##"http://a/%%30%30"##); + assert!(p.is_err()); + } + #[test] + fn parse_194() { + let p = Trinitry::new(r##"' OR 1=1 -- 1"##); + assert!(p.is_err()); + } + #[test] + fn parse_195() { + let p = Trinitry::new(r##"' OR '1'='1"##); + assert!(p.is_err()); + } + #[test] + fn parse_196() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_197() { + let p = Trinitry::new(r##"%"##); + assert!(p.is_err()); + } + #[test] + fn parse_198() { + let p = Trinitry::new(r##"_"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"_"##, &p.to_string()); + } + #[test] + fn parse_199() { + let p = Trinitry::new(r##"-"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"-"##, &p.to_string()); + } + #[test] + fn parse_200() { + let p = Trinitry::new(r##"--"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"--"##, &p.to_string()); + } + #[test] + fn parse_201() { + let p = Trinitry::new(r##"--help"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"--help"##, &p.to_string()); + } + #[test] + fn parse_202() { + let p = Trinitry::new(r##"$USER"##); + assert!(p.is_err()); + } + #[test] + fn parse_203() { + let p = Trinitry::new(r##"Kernel.exit(1)"##); + assert!(p.is_err()); + } + #[test] + fn parse_204() { + let p = Trinitry::new(r##"$HOME"##); + assert!(p.is_err()); + } + #[test] + fn parse_205() { + let p = Trinitry::new(r##"$ENV{'HOME'}"##); + assert!(p.is_err()); + } + #[test] + fn parse_206() { + let p = Trinitry::new(r##"%d"##); + assert!(p.is_err()); + } + #[test] + fn parse_207() { + let p = Trinitry::new(r##"{0}"##); + assert!(p.is_err()); + } + #[test] + fn parse_208() { + let p = Trinitry::new(r##"%@"##); + assert!(p.is_err()); + } + #[test] + fn parse_209() { + let p = Trinitry::new(r##"%n"##); + assert!(p.is_err()); + } + #[test] + fn parse_210() { + let p = Trinitry::new(r##"File:///"##); + assert!(p.is_err()); + } + #[test] + fn parse_211() { + let p = Trinitry::new(r##"+++ATH0"##); + assert!(p.is_err()); + } + #[test] + fn parse_212() { + let p = Trinitry::new(r##"CON"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"CON"##, &p.to_string()); + } + #[test] + fn parse_213() { + let p = Trinitry::new(r##"PRN"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"PRN"##, &p.to_string()); + } + #[test] + fn parse_214() { + let p = Trinitry::new(r##"AUX"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"AUX"##, &p.to_string()); + } + #[test] + fn parse_215() { + let p = Trinitry::new(r##"CLOCK$"##); + assert!(p.is_err()); + } + #[test] + fn parse_216() { + let p = Trinitry::new(r##"NUL"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"NUL"##, &p.to_string()); + } + #[test] + fn parse_217() { + let p = Trinitry::new(r##"A:"##); + assert!(p.is_err()); + } + #[test] + fn parse_218() { + let p = Trinitry::new(r##"ZZ:"##); + assert!(p.is_err()); + } + #[test] + fn parse_219() { + let p = Trinitry::new(r##"COM1"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"COM1"##, &p.to_string()); + } + #[test] + fn parse_220() { + let p = Trinitry::new(r##"LPT1"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"LPT1"##, &p.to_string()); + } + #[test] + fn parse_221() { + let p = Trinitry::new(r##"LPT2"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"LPT2"##, &p.to_string()); + } + #[test] + fn parse_222() { + let p = Trinitry::new(r##"LPT3"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"LPT3"##, &p.to_string()); + } + #[test] + fn parse_223() { + let p = Trinitry::new(r##"COM2"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"COM2"##, &p.to_string()); + } + #[test] + fn parse_224() { + let p = Trinitry::new(r##"COM3"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"COM3"##, &p.to_string()); + } + #[test] + fn parse_225() { + let p = Trinitry::new(r##"COM4"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"COM4"##, &p.to_string()); + } + #[test] + fn parse_226() { + let p = Trinitry::new(r##"DCC SEND STARTKEYLOGGER 0 0 0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"DCC SEND STARTKEYLOGGER 0 0 0"##, &p.to_string()); + } + #[test] + fn parse_227() { + let p = Trinitry::new(r##"Lightwater Country Park"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Lightwater Country Park"##, &p.to_string()); + } + #[test] + fn parse_228() { + let p = Trinitry::new(r##"Jimmy Clitheroe"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Jimmy Clitheroe"##, &p.to_string()); + } + #[test] + fn parse_229() { + let p = Trinitry::new(r##"http://www.cum.qc.ca/"##); + assert!(p.is_err()); + } + #[test] + fn parse_230() { + let p = Trinitry::new(r##"Linda Callahan"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Linda Callahan"##, &p.to_string()); + } + #[test] + fn parse_231() { + let p = Trinitry::new(r##"magna cum laude"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"magna cum laude"##, &p.to_string()); + } + #[test] + fn parse_232() { + let p = Trinitry::new(r##"Super Bowl XXX"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Super Bowl XXX"##, &p.to_string()); + } + #[test] + fn parse_233() { + let p = Trinitry::new(r##"evaluate"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"evaluate"##, &p.to_string()); + } + #[test] + fn parse_234() { + let p = Trinitry::new(r##"mocha"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"mocha"##, &p.to_string()); + } + #[test] + fn parse_235() { + let p = Trinitry::new(r##"Dick Van Dyke"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"Dick Van Dyke"##, &p.to_string()); + } + #[test] + fn parse_236() { + let p = Trinitry::new(r##"The quick brown fox... [Beeeep]"##); + assert!(p.is_err()); + } + #[test] + fn parse_237() { + let p = Trinitry::new(r##"0"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"0"##, &p.to_string()); + } + #[test] + fn parse_238() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_239() { + let p = Trinitry::new(r##""##); + assert!(p.is_err()); + } + #[test] + fn parse_240() { + let p = Trinitry::new(r##"{% print 'x' * 64 * 1024**3 %}"##); + assert!(p.is_err()); + } +} diff --git a/trinitry/update.sh b/trinitry/update.sh new file mode 100755 index 0000000..51f1f58 --- /dev/null +++ b/trinitry/update.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env sh + +# Library {{{ +mktmp() { + ensure_tmp_dir + mktemp -p "$LIB_TEMP_DIR_FOR_SCRIPT" +} +ensure_tmp_dir() { + if ! [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ]; then + LIB_TEMP_DIR_FOR_SCRIPT="$(mktemp -d)" + export LIB_TEMP_DIR_FOR_SCRIPT + fi +} +remove_tmp_dir() { + # The test is here because some scripts still delete this on their own + if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ]; then + rm -r "$LIB_TEMP_DIR_FOR_SCRIPT" + fi +} + +trap remove_tmp_dir EXIT +ensure_tmp_dir # ensure that the variable has been set, even in subshells +# }}} + +tmp="$(mktmp)" + +curl https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt | + awk '!/^#/' | + awk '!/^[\s\t]*$/' | + awk -v s="'" '!/.*s.*/' | + + # This entry contains duplicated spaces, just ignore it + awk '!/Power/' | + iconv -c -f utf-8 -t ascii \ + >"$tmp" + +counter=0 + +cat <<EOF +// DO NOT EDIT +// This file is automatically generated by the 'update.sh' file, with data from: +// https://raw.githubusercontent.com/minimaxir/big-list-of-naughty-strings/master/blns.txt + +#[cfg(test)] +mod test { + use crate::Trinitry; +EOF + +while read -r name; do + tmp2="$(mktmp)" + printf "%s" "$name" >"$tmp2" + if rg '^[A-Za-z0-9_.-]+$' "$tmp2" -q; then + cat <<EOF + #[test] + fn parse_$counter() { + let p = Trinitry::new(r##"$name"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"$name"##, &p.to_string()); + } +EOF + elif rg '^[A-Za-z0-9_.-]+ [A-Za-z0-9_.(){}<>?!+^@&*~|=,/\\ -]*$' "$tmp2" -q; then + cat <<EOF + #[test] + fn parse_$counter() { + let p = Trinitry::new(r##"$name"##).unwrap_or_else(|e| { + panic!("{}", e); + }); + assert_eq!(r##"$name"##, &p.to_string()); + } +EOF + else + cat <<EOF + #[test] + fn parse_$counter() { + let p = Trinitry::new(r##"$name"##); + assert!(p.is_err()); + } +EOF + fi + counter=$((counter + 1)) +done <"$tmp" + +cat <<EOF +} +EOF + +# vim: ft=sh