1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub struct ParseOptions {
23 pub strict_boundary_check: bool,
34}
35
36impl Default for ParseOptions {
37 fn default() -> Self {
38 Self {
39 strict_boundary_check: true,
40 }
41 }
42}
43
44impl ParseOptions {
45 #[must_use]
47 pub const fn new() -> Self {
48 Self {
49 strict_boundary_check: true,
50 }
51 }
52
53 #[must_use]
59 pub const fn lenient() -> Self {
60 Self {
61 strict_boundary_check: false,
62 }
63 }
64}
65
66#[cfg(test)]
67mod tests {
68 use super::ParseOptions;
69
70 #[test]
72 fn test_parse_options_default() {
73 let options = ParseOptions::default();
74 assert!(options.strict_boundary_check);
75 }
76
77 #[test]
78 fn test_parse_options_new() {
79 let options = ParseOptions::new();
80 assert!(options.strict_boundary_check);
81 }
82
83 #[test]
84 fn test_parse_options_lenient() {
85 let options = ParseOptions::lenient();
86 assert!(!options.strict_boundary_check);
87 }
88
89 #[test]
90 fn test_parse_options_equality() {
91 let default1 = ParseOptions::default();
92 let default2 = ParseOptions::new();
93 assert_eq!(default1, default2);
94
95 let lenient1 = ParseOptions::lenient();
96 let lenient2 = ParseOptions::lenient();
97 assert_eq!(lenient1, lenient2);
98
99 assert_ne!(default1, lenient1);
100 }
101
102 #[test]
103 fn test_parse_options_clone() {
104 let original = ParseOptions::lenient();
105 let cloned = original;
106 assert_eq!(original, cloned);
107 assert!(!cloned.strict_boundary_check);
108 }
109
110 #[test]
111 fn test_parse_options_copy() {
112 let options = ParseOptions::new();
113 let copied = options; assert_eq!(options, copied); assert!(options.strict_boundary_check);
116 }
117
118 #[cfg(any(feature = "alloc", feature = "kernel"))]
120 mod tests_with_format {
121 use super::*;
122 #[cfg(any(feature = "alloc", feature = "kernel"))]
123 use alloc::format;
124
125 #[test]
126 fn test_parse_options_debug() {
127 let options = ParseOptions::default();
128 let debug_str = format!("{:?}", options);
129 assert!(debug_str.contains("ParseOptions"));
130 }
131 }
132}