The smokesignal.events web application
at main 46 lines 1.2 kB view raw
1//! LFG form constants and validation utilities. 2//! 3//! This module provides constants for the Looking For Group (LFG) feature. 4 5/// Allowed duration options in hours for LFG records. 6pub(crate) const ALLOWED_DURATIONS: [u32; 5] = [6, 12, 24, 48, 72]; 7 8/// Default duration in hours for new LFG records. 9pub(crate) const DEFAULT_DURATION_HOURS: u32 = 48; 10 11/// Maximum number of tags allowed per LFG record. 12pub(crate) const MAX_TAGS: usize = 10; 13 14/// Maximum length of a single tag. 15pub(crate) const MAX_TAG_LENGTH: usize = 64; 16 17#[cfg(test)] 18mod tests { 19 use super::*; 20 21 #[test] 22 fn test_allowed_durations() { 23 assert!(ALLOWED_DURATIONS.contains(&6)); 24 assert!(ALLOWED_DURATIONS.contains(&12)); 25 assert!(ALLOWED_DURATIONS.contains(&24)); 26 assert!(ALLOWED_DURATIONS.contains(&48)); 27 assert!(ALLOWED_DURATIONS.contains(&72)); 28 assert!(!ALLOWED_DURATIONS.contains(&1)); 29 assert!(!ALLOWED_DURATIONS.contains(&100)); 30 } 31 32 #[test] 33 fn test_default_duration() { 34 assert_eq!(DEFAULT_DURATION_HOURS, 48); 35 } 36 37 #[test] 38 fn test_max_tags() { 39 assert_eq!(MAX_TAGS, 10); 40 } 41 42 #[test] 43 fn test_max_tag_length() { 44 assert_eq!(MAX_TAG_LENGTH, 64); 45 } 46}