Skip to content

Commit 480c24c

Browse files
committed
update crate
1 parent fab840b commit 480c24c

File tree

1 file changed

+5
-45
lines changed

1 file changed

+5
-45
lines changed

dsc_lib/src/functions/format.rs

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
use crate::DscError;
55
use crate::configure::context::Context;
66
use crate::functions::{AcceptedArgKind, Function};
7-
use rt_format::{Format, FormatArgument, ParsedFormat, Specifier};
7+
use rt_format::{Format as RtFormat, FormatArgument, ParsedFormat, Specifier};
88
use rust_i18n::t;
99
use serde_json::Value;
10+
use std::fmt;
1011
use std::fmt::{Error, Formatter, Write};
1112

1213
impl FormatArgument for Value {
@@ -108,51 +109,10 @@ mod tests {
108109
}
109110

110111
#[test]
111-
fn strings_with_spaces() {
112+
fn numbers_as_hex() {
112113
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");
115116
}
116117

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-
}
158118
}

0 commit comments

Comments
 (0)