macro_rules! test_encoding_enum_by_values {
($enum:path as $ty:ty; $( $item:path => $val:expr ),+) => { ... };
($se:ident => $enum:path as $ty:ty; $( $item:path => $val:expr ),+) => { ... };
}
👎 Deprecated since 1.6.1:
use strict_encoding_test crate instead
Expand description
Macro testing encodings of all enum variants for enums with assigned primitive integer values.
Macro expands into an expression of Result<(),
EnumEncodingTestFailure
>
type.
Macro extends functionality of test_encoding_enum
and should be used
whenever enum has assigned primitive integer values. If the primitive values
are of u8
type, test_encoding_enum_u8_exhaustive
should be used
instead of this macro.
Covered test cases
- Each enum variant must have a primitive value
- Primitive value representing enum variant must be equal to strict encoding
of the same variant. If a primitive enum value occupies of several bytes
(
u16
,u32
and other large integer types), strict encoding must match little-endian encoding of the value - Roundtrip encoding-decoding of the enum variant must result in the original value
- Each enum variant must be equal to itself
- Each enum variant must not be equal to any other enum variant
- Enum variants must be ordered according to their primitive values