Skip to content

Instantly share code, notes, and snippets.

@lithiumhead
Last active January 31, 2018 17:13
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 lithiumhead/d821ea9b7632f65384f937a9be7eb0a3 to your computer and use it in GitHub Desktop.
Save lithiumhead/d821ea9b7632f65384f937a9be7eb0a3 to your computer and use it in GitHub Desktop.
TEST() and code in same file - Test Fail
#include <iostream>
#include <gtest/gtest.h>
double squareroot (double) {
return 0;
};
TEST (SquareRootTest, PositiveNos) {
EXPECT_EQ (18.0, squareroot (324.0));
EXPECT_EQ (25.4, squareroot (645.16));
EXPECT_EQ (50.332, squareroot (2533.310224));
}
TEST (SquareRootTest, ZeroAndNegativeNos) {
ASSERT_EQ (0.0, squareroot (0.0));
ASSERT_EQ (-1, squareroot (-22.0));
}
int main(int argc, char **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