porting code from test cpp to main framework