Page MenuHomec4science

test_test.cc
No OneTemporary

File Metadata

Created
Tue, Nov 12, 16:13

test_test.cc

#include <cmath>
#include <exception>
#include <gtest/gtest.h>
struct NegativeException : public std::exception {};
double mysqrt(double x) {
if (x < 0.)
throw NegativeException();
return std::sqrt(x);
}
// MACRO function "TEST" from Google Test
// defines a test and a context
TEST(MysqrtTest, positive_integers) {
EXPECT_EQ(2, mysqrt(4));
EXPECT_EQ(4, mysqrt(16));
EXPECT_EQ(3, mysqrt(9));
}

Event Timeline