faker_rust/default/
quote.rs1use crate::base::sample;
4use crate::locale::fetch_locale;
5
6pub fn famous() -> String {
8 fetch_locale("quote.famous", "en")
9 .map(|v| sample(&v))
10 .unwrap_or_else(|| "I think, therefore I am.".to_string())
11}
12
13pub fn matz() -> String {
15 fetch_locale("quote.matz", "en")
16 .map(|v| sample(&v))
17 .unwrap_or_else(|| "Ruby is designed to make programmers happy.".to_string())
18}
19
20pub fn robin() -> String {
22 fetch_locale("quote.robin", "en")
23 .map(|v| sample(&v))
24 .unwrap_or_else(|| {
25 "No matter what people tell you, words and ideas can change the world.".to_string()
26 })
27}
28
29pub fn jack_handey() -> String {
31 fetch_locale("quote.jack_handey", "en")
32 .map(|v| sample(&v))
33 .unwrap_or_else(|| "I hope if dogs ever take over the world, and they chose a king, they don't just go by size, because I bet there are some Lincoln Terrier-sized dogs with a lot of good ideas.".to_string())
34}
35
36pub fn yiddish() -> String {
38 fetch_locale("quote.yiddish", "en")
39 .map(|v| sample(&v))
40 .unwrap_or_else(|| "A bad peace is better than a good war.".to_string())
41}
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_quote_generation() {
49 assert!(!famous().is_empty());
50 assert!(!matz().is_empty());
51 assert!(!robin().is_empty());
52 assert!(!jack_handey().is_empty());
53 assert!(!yiddish().is_empty());
54 }
55}