add cpp test, takestp pattern