Add unit test of buf_* functions.