Protocol: tests for all functions of encode