faker_rust/default/
dc_comics.rs1use crate::base::sample;
4use crate::locale::fetch_locale;
5
6pub fn hero() -> String {
8 fetch_locale("dc_comics.heroes", "en")
9 .map(|v| sample(&v))
10 .unwrap_or_else(|| sample(FALLBACK_HEROES).to_string())
11}
12
13pub fn villain() -> String {
15 fetch_locale("dc_comics.villains", "en")
16 .map(|v| sample(&v))
17 .unwrap_or_else(|| sample(FALLBACK_VILLAINS).to_string())
18}
19
20pub fn title() -> String {
22 fetch_locale("dc_comics.titles", "en")
23 .map(|v| sample(&v))
24 .unwrap_or_else(|| sample(FALLBACK_TITLES).to_string())
25}
26
27const FALLBACK_HEROES: &[&str] = &[
29 "Superman", "Batman", "Wonder Woman", "The Flash", "Green Lantern",
30 "Aquaman", "Cyborg", "Shazam", "Green Arrow", "Nightwing", "Batgirl",
31 "Supergirl", "Martian Manhunter", "Hawkman", "Hawkgirl", "Zatanna",
32 "Constantine", "Swamp Thing", "Doctor Fate", "The Atom", "Blue Beetle",
33];
34
35const FALLBACK_VILLAINS: &[&str] = &[
36 "Joker", "Lex Luthor", "Darkseid", "Brainiac", "Doomsday",
37 "Deathstroke", "Harley Quinn", "Catwoman", "Poison Ivy", "Bane",
38 "Penguin", "Riddler", "Two-Face", "Scarecrow", "Ra's al Ghul",
39 "Reverse-Flash", "Sinestro", "Black Manta", "General Zod", "Lobo",
40];
41
42const FALLBACK_TITLES: &[&str] = &[
43 "Action Comics", "Detective Comics", "Batman", "Superman", "Wonder Woman",
44 "The Flash", "Green Lantern", "Justice League", "Teen Titans", "Suicide Squad",
45 "Aquaman", "Shazam", "Swamp Thing", "Watchmen", "V for Vendetta",
46];
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_hero() {
54 assert!(!hero().is_empty());
55 }
56
57 #[test]
58 fn test_villain() {
59 assert!(!villain().is_empty());
60 }
61
62 #[test]
63 fn test_title() {
64 assert!(!title().is_empty());
65 }
66}