Implement tests for encoding and decoding