Use gtest in

Source: Internet
Author: User
* Use gtest in

: Properties:
: Date: <on Monday>
: By: yafeilee
: End:
** Prepare the gtest framework
1.download gtest-1.6.0.zip
2. decompress the package and enter the gtest-1.6.0/msvc directory
3. Open the gtest project Compilation
4. Put the compiled gtest. lib and gtestd. Lib into the gtest-1.6.0/lib.

** Create a test project
1. Create a Win32 console application
2. Set the path of the gtest header file (addtional include directories)
3. Set the gtest. Lib path (additional dependencies)
4. Set the Runtime Library to/Mt or/MTD.
5. After gtest_main.lib is added, you do not need to write the _ tmain function.
6. Set "$ (targetdir) $ (targetfilename)" in the later generation event to automatically execute the unit test after generation.

** Test demo
# Include "stdafx. H"
# Include

Int add (int A, int B)
{
Return A + B;
}

Test (addtest, handlezeroinput)
{
Expect_eq (3, add (1, 2 ));
}

Int _ tmain (INT argc, _ tchar * argv [])
{
Testing: initgoogletest (& argc, argv );
Return run_all_tests ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.