Skip to main content

faker_rust/default/
house.rs

1//! House generator - generates house-related data
2
3use crate::base::sample;
4use crate::locale::fetch_locale;
5
6/// Generate a random house furniture
7pub fn furniture() -> String {
8    fetch_locale("house.furniture", "en")
9        .map(|v| sample(&v))
10        .unwrap_or_else(|| sample(FALLBACK_FURNITURE).to_string())
11}
12
13/// Generate a random house room
14pub fn room() -> String {
15    fetch_locale("house.rooms", "en")
16        .map(|v| sample(&v))
17        .unwrap_or_else(|| sample(FALLBACK_ROOMS).to_string())
18}
19
20// Fallback data
21const FALLBACK_FURNITURE: &[&str] = &[
22    "Sofa", "Armchair", "Coffee Table", "Dining Table", "Bed", "Wardrobe",
23    "Dresser", "Nightstand", "Bookshelf", "Desk", "Office Chair", "TV Stand",
24    "Cabinet", "Sideboard", "Console Table", "Ottoman", "Bench", "Stool",
25    "Bookcase", "Chest of Drawers", "Futon", "Bunk Bed", "Loft Bed", "Headboard",
26];
27
28const FALLBACK_ROOMS: &[&str] = &[
29    "Living Room", "Bedroom", "Kitchen", "Bathroom", "Dining Room",
30    "Office", "Study", "Guest Room", "Nursery", "Playroom", "Laundry Room",
31    "Garage", "Basement", "Attic", "Pantry", "Closet", "Hallway",
32    "Entryway", "Sunroom", "Library", "Home Theater", "Gym", "Game Room",
33];
34
35#[cfg(test)]
36mod tests {
37    use super::*;
38
39    #[test]
40    fn test_furniture() {
41        assert!(!furniture().is_empty());
42    }
43
44    #[test]
45    fn test_room() {
46        assert!(!room().is_empty());
47    }
48}