forma_test 0.1.0

Token-based test serializer/deserializer for forma_core.
Documentation

forma_test

Token-based testing framework for validating Serialize and Deserialize implementations in the forma serialization framework.

Overview

forma_test provides a token-recording serializer and a token-replaying deserializer. You describe the expected serialized form as a sequence of Token values (30 variants matching the forma data model), then assert that serialization produces exactly those tokens and that deserialization from those tokens reconstructs the original value.

This crate is primarily intended for format authors and contributors testing their Serialize/Deserialize impls -- not for end users.

Usage

use forma_test::{assert_tokens, Token};
use forma_derive::{Serialize, Deserialize};

#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Point { x: i32, y: i32 }

assert_tokens(&Point { x: 1, y: 2 }, &[
    Token::Struct { name: "Point", len: 2 },
    Token::Str("x"), Token::I32(1),
    Token::Str("y"), Token::I32(2),
    Token::StructEnd,
]);

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.