Skip to content

Commit cb49ef6

Browse files
committed
Add more tests for version changes
1 parent f627b8e commit cb49ef6

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

savefile-test/src/test_versioning.rs

+73
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,76 @@ fn test_change_type_of_field2() {
313313
1
314314
);
315315
}
316+
317+
318+
319+
320+
321+
#[derive(Debug, PartialEq, Savefile)]
322+
struct FastVersionA0 {
323+
a: u32,
324+
b: u32,
325+
c: u32
326+
}
327+
#[derive(Debug, PartialEq, Savefile)]
328+
struct FastVersionA1 {
329+
a: u32,
330+
#[savefile_versions = "0..0"]
331+
b: Removed<u32>,
332+
c: u32
333+
}
334+
335+
336+
337+
#[test]
338+
fn simple_vertest_a() {
339+
use ::assert_roundtrip_to_new_version;
340+
let _ver1:FastVersionA1 = assert_roundtrip_to_new_version(
341+
FastVersionA0 {
342+
a: 2,
343+
b: 3,
344+
c: 4
345+
},
346+
0,
347+
FastVersionA1 {
348+
a: 2,
349+
b: Removed::new(),
350+
c: 4,
351+
},
352+
1
353+
);
354+
}
355+
356+
357+
#[derive(Debug, PartialEq, Savefile)]
358+
struct FastVersionB0 {
359+
a: u32,
360+
b: u32,
361+
}
362+
#[derive(Debug, PartialEq, Savefile)]
363+
struct FastVersionB1 {
364+
a: u32,
365+
b: u32,
366+
#[savefile_versions = "1.."]
367+
c: u32,
368+
}
369+
370+
371+
372+
#[test]
373+
fn simple_vertest_b() {
374+
use ::assert_roundtrip_to_new_version;
375+
let _ver1:FastVersionB1 = assert_roundtrip_to_new_version(
376+
FastVersionB0 {
377+
a: 2,
378+
b: 3,
379+
},
380+
0,
381+
FastVersionB1 {
382+
a: 2,
383+
b: 3,
384+
c: 0,
385+
},
386+
1
387+
);
388+
}

0 commit comments

Comments
 (0)