Dear Bob,
Yes mate writing tests is indeed a great way to get familiar with code…
Also trying to refactor / comment existing code would also help both ways ( the tests would be improved and we might get to know about any missing coverage …. )
Discussing / changing code ( so called “scratch refactoring” ) would also help both ways…
Looking forward to yours tests …. I am sure they will be a valuable addition…
- -cheerio atul
Bob wrote:
Hallo everyone,
After reading some code, I started to do some unit test now, so that I can become familiar with the code.
Because I have worked in C for a long time, and I often “think in C”, when I started with the class NodeCache, I tried to test the internal functions. I considered the methods of a class as a “unit”. It led to the details of the implementation of the class and I did not concentrate in the usage of the class.
But in C++ the unit should be a class, and the behavior of the class should be tested. We need to look at the class from outside and try to use it in all possible cases. The internal methods should be kept hidden.This is my first experience of doing unit test in Calitko. I would like to share it with you. If you have any comments or suggestions, I am very glad to hear that.
I plan to do the unit test for classes in Gnutella first.
Best regards,Bo
