Your privacy is important to us. We will never share your data.
Thank you!
Your message is highly valuable for us. One of our experts will follow up with you within 1-2 business days to discuss your request or to inquire for additional information if needed.
In the meantime, you might be interested in learning more about the following:
Our Blog
Check out new ideas and best practices for the IT world. Read more >
* Required fields
Your privacy is important to us. We will never share your data.
Thank you!
Dear %name%,
Thank you for your interest in our vacancies. You will receive weekly notifications based on your career preferences. We are looking forward to getting in touch with you.
Best regards, Recruiting Team
* Required fields
Your privacy is important to us. We will never share your data.
Thank you!
You are now subscribed to Infopulse Newsletter. Please look out for our email occasionally (and don’t forget to check your junk folder).
In the meantime, you might be interested in the following:
Google Test is a framework from Google for unit-testing of C++ code. Its overall architecture somewhat resembles conventional boost::test and CppUnit, however, it’s slightly different in details (I think for to its advantage). I’ll describe briefly Hello world in Google Test, pointing out some potential issues you can face while using Google Test in developing for Visual Studio.
There are two files gtest.sln and gtest-md.sln in folder guest -1.6.0/msvc. These are Solution Visual Studio files. They differ in compilation options: gtest.sln compiles a code with an /MT key, and gtest-md.sln with an /MD key. If you don’t know what these keys are used for, you can read, for example, here or here. You should compile the same variant as in the project you are going to test. It is important lest you have a lot of odd linker errors. You can check the keys used in your project here:
Google Test code can be successfully compiled with Visual Studio 2008/2010 (I haven’t tried any other versions). At the end you get files gtestd.lib\gtest.lib (for debug and release configurations). That’s the whole compilation.
Hello world
Open Solutions you are going to test. Add a new project (C++console application).
Add to this project a dependency on libraries compiled on the second stage gtestd.lib\gtest.lib, the path to Google Test include-folder, dependencies for the projects in you solution that you are going to test.
Write the following code in the main file of testing project:
Here, we test a rectangular for the accuracy of circumference calculation. Notice how convenient it is: there is no need both to register each test in the main function and write testing methods in include files.
4. Start the testing project. Observe the following:
Problems:
Number 1
Don’t go wrong selecting the solution to be compiled in stage two. If you make an error and forget, then it will be practically impossible to find the error.
Number 2
If you plan to place the main testing application in different projects, you will face one tricky issue. The point is that Google unit tests are in fact compile-time classes and Visual C++ compiler with a bug inside will simply exclude these classes in the course of compilation. To avoid the bug, use the method described here.
Number 3
Remember to add the tested compile-class libraries not only to Dependencies of the tested project, but also to References, otherwise there will be linking errors.