Preallocated function and junit test cases