Unit test accessing private variables

前端 未结 6 1477
无人及你
无人及你 2021-01-05 04:55

I have a unit test class Tester; I want it to access private fields of a Working class.

class Working {
    // ...
    private:
            


        
6条回答
  •  不知归路
    2021-01-05 05:41

    -fno-access-control

    If you're only using GCC, you can use the compiler option -fno-access-control while compiling your unit tests. This will cause GCC to skip all access checks, but still keep the class layout the same. I don't know if there is a similar option for other compilers, so this isn't a general solution.

提交回复
热议问题