Add lifetime test for cpp.