amethyst / amethyst/serde-diff

Incorrect handling of map like structures

未關閉
#39 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
127
分支
21
PR 合併指標
30 天內沒有已合併 PR

描述

See the applied test where "map" like structure is tested.

```
running 4 tests
test tests::test_targeted ... ok
test tests::test_array ... ok
test tests::test_tuple ... ok
test tests::test_option ... FAILED

failures:

---- tests::test_option stdout ----
thread 'tests::test_option' panicked at 'unexpected DiffCommand Value or Remove', src/apply.rs:96:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
tests::test_option

test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'
```

```diff
diff --git a/src/tests.rs b/src/tests.rs
index 082846b..83d117c 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -1,7 +1,9 @@
use crate as serde_diff;
use crate::{Apply, Diff, SerdeDiff};
use serde::{Deserialize, Serialize};
+use std::collections::HashMap;
use std::fmt::Debug;
+use std::iter::FromIterator;

#[derive(SerdeDiff, Serialize, Deserialize, PartialEq, Debug, Copy, Clone)]
struct TestStruct {
@@ -59,6 +61,18 @@ fn test_option() {
Some(TestStruct { a: 52, b: 32. }),
Some(TestStruct { a: 42, b: 12. }),
);
+ roundtrip(
+ HashMap::from_iter([
+ (1, TestStruct { a: 1, b: 1. }),
+ (2, TestStruct { a: 2, b: 2. }),
+ (3, TestStruct { a: 3, b: 3. }),
+ ]),
+ HashMap::from_iter([
+ (1, TestStruct { a: 1, b: 1. }),
+ (3, TestStruct { a: 4, b: 4. }),
+ (4, TestStruct { a: 1, b: 1. }),
+ ]),
+ );

partial(
Some(TestStruct { a: 5, b: 2. }),
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。