unit test for patch.c