Tuesday, February 9, 2010

GoogleTest Assertions

SUCCEED(); // now output currently
FAIL();
ADD_FAILURE();

Fatal assertion:

ASSERT_THROW(statement, exception_type);
ASSERT_ANY_THROW(statement);
ASSERT_NO_THROW(statement);

Nonfatal assertion:

EXPECT_THROW(statement, exception_type);
EXPECT_ANY_THROW(statement);
EXPECT_NO_THROW(statement);

Examples:

ASSERT_THROW(Foo(5), bar_exception);

EXPECT_NO_THROW
(
  {
      int n= 5;
      Bar(&n);
  }
);

Predicate Assertions

ASSERT_PRED1(pred1, val1);
ASSERT_PRED2(pred2, val1, val2);

...
EXPECT_PRED1(pred1, val1);
...

Tuesday, December 8, 2009

Google Test

Download the install files from here:

http://code.google.com/p/googletest/

Unzip and started reading.

Using VS 2010.

Use the msvc folder.  Contains a solution, but not read me.

There are two sln files:  gtest.sln and gtest-md.sln

What is the md one for?

When I open gtest.sln, I am told that I need to convert the solution.

I seem to remember something about installing, but I don't see it now.

Moved main folder to top.  (C:\testing\gtest-1.4.0)