Using a friend class vs. adding accessors for unit testing in C++?

后端 未结 6 1795
予麋鹿
予麋鹿 2021-02-08 03:50

Is it better to add functions that return the internal state of an object for unit testing, as opposed to making the testing class a friend? - especially, when there is no use f

6条回答
  •  Happy的楠姐
    2021-02-08 04:33

    How about making internal state "protected"? And then do unittest using derived class.

提交回复
热议问题