diff --git a/src/lib.rs b/src/lib.rs index 4e52513..4d206f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -204,11 +204,17 @@ macro_rules! big_array { } )+ }; - ($name:ident;) => { + ($name:ident; + $($len:expr,)*) => { big_array! { $name; 40, 48, 50, 56, 64, 72, 96, 100, 128, 160, 192, 200, 224, 256, 384, 512, 768, 1024, 2048, 4096, 8192, 16384, 32768, 65536, + $($len,)* + } + }; + ($name:ident;) => { + big_array! { + $name; + } } } diff --git a/tests/plus.rs b/tests/plus.rs new file mode 100644 index 0000000..9e39fc9 --- /dev/null +++ b/tests/plus.rs @@ -0,0 +1,27 @@ +#![no_std] + +extern crate serde; +#[macro_use] +extern crate serde_derive; +extern crate serde_json; +#[macro_use] +extern crate serde_big_array; + +big_array! { BigArray; +127, } + +#[derive(Serialize, Deserialize)] +struct S { + #[serde(with = "BigArray")] + arr: [u8; 64], + #[serde(with = "BigArray")] + arr_2: [u8; 127], +} + +#[test] +fn test() { + let s = S { arr: [1; 64], arr_2: [1; 127] }; + let j = serde_json::to_string(&s).unwrap(); + let s_back = serde_json::from_str::(&j).unwrap(); + assert!(&s.arr[..] == &s_back.arr[..]); + assert!(&s.arr_2[..] == &s_back.arr_2[..]); +}