C++ - Is it possible to implement memory leak testing in a unit test?

前端 未结 4 835
感动是毒
感动是毒 2020-12-25 14:25

I\'m trying to implement unit testing for my code and I\'m having a hard time doing it.

Ideally I would like to test some classes not only for good functionality but

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-25 14:54

    You can use Google's tcmalloc allocation library, which provides a heapchecker.

    (Note that heapchecking may add noticeable overhead to your program's performance, so you probably only want to enable it on debug builds or unit tests.)

    And you asked for example code, so here it is.

提交回复
热议问题