|
1 | | -use binrw::{binrw, NullString}; |
2 | 1 | use binrw::binrw; |
3 | 2 |
|
4 | 3 | use crate::utils::{nullstr_read, nullstr_write}; |
@@ -40,59 +39,27 @@ impl ModpkgLicense { |
40 | 39 | } |
41 | 40 | } |
42 | 41 |
|
43 | | -// TODO: use proptest here |
44 | 42 | #[cfg(test)] |
45 | 43 | mod tests { |
46 | 44 | use std::io::Cursor; |
47 | 45 |
|
48 | 46 | use binrw::BinWrite; |
49 | 47 |
|
50 | 48 | use super::*; |
51 | | - |
52 | | - #[test] |
53 | | - fn test_none_size() { |
54 | | - let license = ModpkgLicense::default(); |
55 | | - let mut buf = Cursor::new(Vec::with_capacity(license.size() + 512)); |
56 | | - license.write(&mut buf).unwrap(); |
57 | | - println!("{:x?}", buf.clone().into_inner()); |
58 | | - |
59 | | - assert_eq!( |
60 | | - license.size(), |
61 | | - buf.into_inner().len(), |
62 | | - "comparing reported size with real size" |
63 | | - ); |
64 | | - } |
65 | | - |
| 49 | + use proptest::prelude::*; |
| 50 | + proptest! { |
66 | 51 | #[test] |
67 | | - fn test_spdx_size() { |
68 | | - let license = ModpkgLicense::Spdx { |
69 | | - spdx_id: "test".to_string().into(), |
70 | | - }; |
| 52 | + fn test_license_size(license: ModpkgLicense) { |
| 53 | + let mut buf = Cursor::new(Vec::with_capacity(license.size() + 64)); |
| 54 | + license.write(&mut buf).unwrap(); |
71 | 55 |
|
72 | | - let mut buf = Cursor::new(Vec::with_capacity(license.size() + 512)); |
73 | | - license.write(&mut buf).unwrap(); |
| 56 | + println!("{:x?}", buf.clone().into_inner()); |
74 | 57 |
|
75 | | - assert_eq!( |
76 | | - license.size(), |
77 | | - buf.into_inner().len(), |
78 | | - "comparing reported size with real size" |
79 | | - ); |
80 | | - } |
81 | | - #[test] |
82 | | - fn test_custom_size() { |
83 | | - let license = ModpkgLicense::Custom { |
84 | | - name: "customName".into(), |
85 | | - url: "http://fake.url/".into(), |
86 | | - }; |
87 | | - let mut buf = Cursor::new(Vec::with_capacity(license.size() + 512)); |
88 | | - license.write(&mut buf).unwrap(); |
89 | | - |
90 | | - println!("{:x?}", buf.clone().into_inner()); |
91 | | - |
92 | | - assert_eq!( |
93 | | - license.size(), |
94 | | - buf.into_inner().len(), |
95 | | - "comparing reported size with real size" |
96 | | - ); |
| 58 | + assert_eq!( |
| 59 | + license.size(), |
| 60 | + buf.into_inner().len(), |
| 61 | + "comparing reported size with real size" |
| 62 | + ); |
| 63 | + } |
97 | 64 | } |
98 | 65 | } |
0 commit comments