Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91607611
test_test.cc
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 12, 16:13
Size
412 B
Mime Type
text/x-c
Expires
Thu, Nov 14, 16:13 (2 d)
Engine
blob
Format
Raw Data
Handle
22292206
Attached To
R7571 SP4E-TB-TL-FR
test_test.cc
View Options
#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
Log In to Comment