Boost unit testing main function?

后端 未结 4 1947
[愿得一人]
[愿得一人] 2021-01-11 16:51

How do I define my own main() function when testing with boost?

Boost is using it\'s own main function, but I\'m using a custom memory manager and it ne

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-11 17:17

    You can define a static object and his constructor will execute before main:

    class Alloc_Setup {
       Alloc_Setup() {
           // Your init code
       }
       ~Alloc_Setup() {
           // Your cleanup
       }
    };
    Alloc_Setup setup;
    int main() {} // (generated by boost)
    

提交回复
热议问题