synwire_core/output_parsers/
string.rs1use crate::error::SynwireError;
4use crate::output_parsers::OutputParser;
5
6pub struct StrOutputParser;
21
22impl OutputParser for StrOutputParser {
23 type Output = String;
24
25 fn parse(&self, text: &str) -> Result<String, SynwireError> {
26 Ok(text.to_string())
27 }
28}
29
30#[cfg(test)]
31#[allow(clippy::unwrap_used)]
32mod tests {
33 use super::*;
34
35 #[test]
36 fn test_str_parser_returns_unchanged() {
37 let parser = StrOutputParser;
38 let input = "Hello, world!";
39 let result = parser.parse(input).unwrap();
40 assert_eq!(result, input);
41 }
42
43 #[test]
44 fn test_str_parser_empty_string() {
45 let parser = StrOutputParser;
46 let result = parser.parse("").unwrap();
47 assert_eq!(result, "");
48 }
49
50 #[test]
51 fn test_str_parser_preserves_whitespace() {
52 let parser = StrOutputParser;
53 let input = " hello\n world ";
54 let result = parser.parse(input).unwrap();
55 assert_eq!(result, input);
56 }
57
58 #[test]
59 fn test_str_parser_format_instructions_empty() {
60 let parser = StrOutputParser;
61 assert!(parser.get_format_instructions().is_empty());
62 }
63}