Skip to content

Instantly share code, notes, and snippets.

@hwada
Created February 29, 2012 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwada/1937329 to your computer and use it in GitHub Desktop.
Save hwada/1937329 to your computer and use it in GitHub Desktop.
#include "stdafx.h"
#include "gtest/gtest.h"
#pragma comment(lib, "gtestd.lib")
int Factorial(int n) {
int result = 1;
for (int i = 1; i <= n; i++) {
result *= i;
}
return result;
}
TEST(FactorialTest, Negative) {
EXPECT_EQ(1, Factorial(-5));
EXPECT_EQ(1, Factorial(-1));
EXPECT_GT(Factorial(-10), 0);
}
int _tmain(int argc, _TCHAR* argv[])
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment