macro_rules! test_encoding_enum_u8_exhaustive {
    ($enum:path; $( $item:path => $val:expr ),+) => { ... };
    ($enum:path as $ty:ty; $( $item:path => $val:expr ),+) => { ... };
    ($se:ident => $enum:path; $( $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 encoding of all possible enum values, covering full range of u8 values, including enum out-of-range values.

Macro expands into an expression of Result<(), EnumEncodingTestFailure> type.

Macro extends functionality of test_encoding_enum_by_values and should be used whenever enum with assigned primitive values is represented by u8 integers.

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
  • All 8-bit integers which do not match any of enum variants must not be decoded with strict decoder into a valid enum and their decoding must result in Error::EnumValueNotKnown error.