Complete encoder test code in case 4