mirror of
https://github.com/openharmony/commonlibrary_rust_ylong_json.git
synced 2026-06-30 22:08:36 -04:00
@@ -23,10 +23,18 @@ ohos_rust_shared_library("lib") {
|
||||
part_name = "ylong_json"
|
||||
|
||||
sources = [ "src/lib.rs" ]
|
||||
|
||||
deps = [
|
||||
"//third_party/rust/crates/libc:lib",
|
||||
"//third_party/rust/crates/serde/serde:lib",
|
||||
]
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.third_party_rust_libc)) {
|
||||
deps += [ "//third_party/rust/crates/libc:lib" ]
|
||||
} else {
|
||||
external_deps += [ "rust_libc:lib" ]
|
||||
}
|
||||
|
||||
features = [
|
||||
"default",
|
||||
"vec_array",
|
||||
@@ -36,14 +44,27 @@ ohos_rust_shared_library("lib") {
|
||||
}
|
||||
|
||||
ohos_rust_unittest("rust_ylong_json_unit_test") {
|
||||
module_out_path = "commonlibrary/rust/ylong_json"
|
||||
module_out_path = "ylong_json/ylong_json"
|
||||
sources = [ "src/lib.rs" ]
|
||||
deps = [
|
||||
":lib",
|
||||
"//third_party/rust/crates/libc:lib",
|
||||
"//third_party/rust/crates/serde/serde:lib",
|
||||
]
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.third_party_rust_libc)) {
|
||||
deps += [ "//third_party/rust/crates/libc:lib" ]
|
||||
} else {
|
||||
external_deps += [ "rust_libc:lib" ]
|
||||
}
|
||||
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.third_party_rust_serde)) {
|
||||
deps += [ "//third_party/rust/crates/serde/serde:lib" ]
|
||||
} else {
|
||||
external_deps += [ "rust_serde:lib" ]
|
||||
}
|
||||
|
||||
rustflags = [
|
||||
"--cfg=feature=\"default\"",
|
||||
"--cfg=feature=\"vec_array\"",
|
||||
@@ -51,3 +72,11 @@ ohos_rust_unittest("rust_ylong_json_unit_test") {
|
||||
"--cfg=feature=\"ascii_only\"",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
if (!use_clang_coverage) {
|
||||
deps += [ ":rust_ylong_json_unit_test" ]
|
||||
}
|
||||
}
|
||||
+9
-2
@@ -25,7 +25,12 @@
|
||||
],
|
||||
"rom": "200KB",
|
||||
"ram": "~200KB",
|
||||
"deps": {},
|
||||
"deps": {
|
||||
"components": [
|
||||
"rust_libc"
|
||||
],
|
||||
"third_party": []
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [],
|
||||
"inner_kits": [
|
||||
@@ -37,7 +42,9 @@
|
||||
"name": "//commonlibrary/rust/ylong_json:lib"
|
||||
}
|
||||
],
|
||||
"test": []
|
||||
"test": [
|
||||
"//commonlibrary/rust/ylong_json:unittest"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -922,10 +922,10 @@ mod ut_test_for_deserializer {
|
||||
|
||||
let slice_map = r#"{ "apple" : 3 }"#.as_bytes();
|
||||
let mut expected = HashMap::new();
|
||||
expected.insert("appple", 3);
|
||||
expected.insert(String::from("apple"), 3);
|
||||
assert_eq!(
|
||||
expected,
|
||||
crate::from_slice::<HashMap<&str, i32>>(slice_map).unwrap()
|
||||
crate::from_slice::<HashMap<String, i32>>(slice_map).unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -800,20 +800,20 @@ mod ut_states {
|
||||
assert!(parse_string(&mut deserializer).is_err());
|
||||
|
||||
// 3.A backslash is followed by a terminator.
|
||||
let str = r#"\"#;
|
||||
let str = r"\";
|
||||
let mut deserializer = Deserializer::new_from_slice(str.as_bytes());
|
||||
assert!(parse_string(&mut deserializer).is_err());
|
||||
|
||||
// 4.Illegal unicode characters.
|
||||
let str = r#"\uBEEF"#;
|
||||
let str = r"\uBEEF";
|
||||
let mut deserializer = Deserializer::new_from_slice(str.as_bytes());
|
||||
assert!(parse_string(&mut deserializer).is_err());
|
||||
|
||||
let str = r#"\uZ000"#;
|
||||
let str = r"\uZ000";
|
||||
let mut deserializer = Deserializer::new_from_slice(str.as_bytes());
|
||||
assert!(parse_string(&mut deserializer).is_err());
|
||||
|
||||
let str = r#"\u"#;
|
||||
let str = r"\u";
|
||||
let mut deserializer = Deserializer::new_from_slice(str.as_bytes());
|
||||
assert!(parse_string(&mut deserializer).is_err());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user