Play Google Open source C + + unit Test Framework one of the Google Test series (gtest) first knowledge gtest in Linux

Source: Internet
Author: User

Follow this article http://blog.csdn.net/calmreason/article/details/38488765 download source package: Gtest-1.3.0.zip, unzip

Go to Folder execution:

./configure

Make

Make install

You can use it properly after:

(1) include include directory-i/root/scp/gtest/gtest-1.3.0;

(2) contains the dynamic link library in Lib:-lgtest-l/root/scp/gtest/gtest-1.3.0/lib

Example code:

#include <gtest/gtest.h>int Foo (int a, int b) {    if (a = = 0 | | b = = 0)    {        throw "Don t do";    }    int c = a% B;    if (c = = 0)        return b;    Return Foo (b, c);} TEST (Footest, handlenonezeroinput) {    expect_eq (2, Foo (4, ten));    Expect_eq (6, Foo (30, 18));} int ace_tmain (int argc, ace_tchar* argv[]) {    testing::initgoogletest (&ARGC, argv);    return run_all_tests ();}

Output:



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.