|
4 | 4 | use crate::DscError; |
5 | 5 | use crate::configure::context::Context; |
6 | 6 | use crate::functions::{AcceptedArgKind, Function}; |
7 | | -use rt_format::{Format, FormatArgument, ParsedFormat, Specifier}; |
| 7 | +use rt_format::{Format as RtFormat, FormatArgument, ParsedFormat, Specifier}; |
8 | 8 | use rust_i18n::t; |
9 | 9 | use serde_json::Value; |
| 10 | +use std::fmt; |
10 | 11 | use std::fmt::{Error, Formatter, Write}; |
11 | 12 |
|
12 | 13 | impl FormatArgument for Value { |
@@ -108,51 +109,10 @@ mod tests { |
108 | 109 | } |
109 | 110 |
|
110 | 111 | #[test] |
111 | | - fn strings_with_spaces() { |
| 112 | + fn numbers_as_hex() { |
112 | 113 | let mut parser = Statement::new().unwrap(); |
113 | | - let result = parser.parse_and_execute("[concat('a ', ' ', ' b')]", &Context::new()).unwrap(); |
114 | | - assert_eq!(result, "a b"); |
| 114 | + let result = parser.parse_and_execute("[format('{0:x} {0:X}', 12, 13)]", &Context::new()).unwrap(); |
| 115 | + assert_eq!(result, "c D"); |
115 | 116 | } |
116 | 117 |
|
117 | | - #[test] |
118 | | - fn arrays() { |
119 | | - let mut parser = Statement::new().unwrap(); |
120 | | - let result = parser.parse_and_execute("[concat(createArray('a','b'), createArray('c','d'))]", &Context::new()).unwrap(); |
121 | | - assert_eq!(result.to_string(), r#"["a","b","c","d"]"#); |
122 | | - } |
123 | | - |
124 | | - #[test] |
125 | | - fn string_and_numbers() { |
126 | | - let mut parser = Statement::new().unwrap(); |
127 | | - let result = parser.parse_and_execute("[concat('a', 1)]", &Context::new()); |
128 | | - assert!(result.is_err()); |
129 | | - } |
130 | | - |
131 | | - #[test] |
132 | | - fn nested() { |
133 | | - let mut parser = Statement::new().unwrap(); |
134 | | - let result = parser.parse_and_execute("[concat('a', concat('b', 'c'), 'd')]", &Context::new()).unwrap(); |
135 | | - assert_eq!(result, "abcd"); |
136 | | - } |
137 | | - |
138 | | - #[test] |
139 | | - fn invalid_one_parameter() { |
140 | | - let mut parser = Statement::new().unwrap(); |
141 | | - let result = parser.parse_and_execute("[concat('a')]", &Context::new()); |
142 | | - assert!(result.is_err()); |
143 | | - } |
144 | | - |
145 | | - #[test] |
146 | | - fn string_and_array() { |
147 | | - let mut parser = Statement::new().unwrap(); |
148 | | - let result = parser.parse_and_execute("[concat('a', createArray('b','c'))]", &Context::new()); |
149 | | - assert!(result.is_err()); |
150 | | - } |
151 | | - |
152 | | - #[test] |
153 | | - fn array_and_string() { |
154 | | - let mut parser = Statement::new().unwrap(); |
155 | | - let result = parser.parse_and_execute("[concat(createArray('a','b'), 'c')]", &Context::new()); |
156 | | - assert!(result.is_err()); |
157 | | - } |
158 | 118 | } |
0 commit comments