Skip to content

Commit 4a48b79

Browse files
committed
test: 补充测试用例
1 parent db12588 commit 4a48b79

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod tests {
105105

106106
#[test]
107107
fn test_valid_input() {
108-
let json_input = json!({"fonts":[],"keyframes":[],"medias":[],"styles":[{"declarations":[[22,293],[42,4278753764u32]],"media":0,"selector":["app"]},{"declarations":[[41,4294901760u32]],"media":0,"selector":["tit"]},{"declarations":[[29,24],[41,4291979550u32]],"media":0,"selector":["tit",2,"app"]},{"declarations":[[22,100],[25,100]],"media":0,"selector":["img"]}, {"declarations":[[79,"hello"]],"media":0,"pseudo":1,"selector":["hello"]},{"declarations":[[42,4294967264u32]],"media":0,"pseudo":5,"pseudo_key":[2,0,true],"pseudo_val":"2n","selector":["bbb"]}]}).to_string();
108+
let json_input = json!({"fonts":[],"keyframes":[],"medias":[],"styles":[{"declarations":[[22,293],[42,4278753764u32],[25, "var(--h)", 1]],"media":0,"selector":["app"]},{"declarations":[[41,4294901760u32]],"media":0,"selector":["tit"]},{"declarations":[[29,24],[41,4291979550u32]],"media":0,"selector":["tit",2,"app"]},{"declarations":[[22,100],[25,100]],"media":0,"selector":["img"]}, {"declarations":[[79,"hello"]],"media":0,"pseudo":1,"selector":["hello"]},{"declarations":[[42,4294967264u32]],"media":0,"pseudo":5,"pseudo_key":[2,0,true],"pseudo_val":"2n","selector":["bbb"]}]}).to_string();
109109

110110
let result = convert_json_to_flatbuffer(&json_input);
111111
assert!(result.is_ok());
@@ -126,7 +126,7 @@ mod tests {
126126
let styles = style_sheet.styles().unwrap();
127127
assert_eq!(styles.len(), 6); // 根据实际情况调整
128128
let first_style = styles.get(0);
129-
assert_eq!(first_style.declarations().unwrap().len(), 2);
129+
assert_eq!(first_style.declarations().unwrap().len(), 3);
130130

131131
let first_declaration = first_style.declarations().unwrap().get(0);
132132
assert_eq!(first_declaration.property_id(), 22);
@@ -137,6 +137,12 @@ mod tests {
137137
assert_eq!(second_declaration.property_id(), 42);
138138
assert!(second_declaration.value_as_integer().is_some());
139139
assert_eq!(second_declaration.value_as_integer().unwrap().value(), 4278753764);
140+
assert_eq!(second_declaration.flag(), 0);
141+
142+
let third_declaration = first_style.declarations().unwrap().get(2);
143+
assert_eq!(third_declaration.property_id(), 25);
144+
assert!(third_declaration.value_as_string().is_some());
145+
assert_eq!(third_declaration.flag(), 1);
140146

141147
let first_selector = first_style.selector().unwrap().get(0);
142148
assert_eq!(first_selector.string_value().unwrap(), "app");

0 commit comments

Comments
 (0)