proxygen
sample5_unittest.cc File Reference
#include <limits.h>
#include <time.h>
#include "sample3-inl.h"
#include "gtest/gtest.h"
#include "sample1.h"

Go to the source code of this file.

Classes

class  QuickTest
 
class  IntegerFunctionTest
 
class  QueueTest
 

Functions

 TEST_F (IntegerFunctionTest, Factorial)
 
 TEST_F (IntegerFunctionTest, IsPrime)
 
 TEST_F (QueueTest, DefaultConstructor)
 
 TEST_F (QueueTest, Dequeue)
 

Function Documentation

TEST_F ( IntegerFunctionTest  ,
Factorial   
)

Definition at line 100 of file sample5_unittest.cc.

References EXPECT_EQ, EXPECT_GT, and Factorial().

100  {
101  // Tests factorial of negative numbers.
102  EXPECT_EQ(1, Factorial(-5));
103  EXPECT_EQ(1, Factorial(-1));
104  EXPECT_GT(Factorial(-10), 0);
105 
106  // Tests factorial of 0.
107  EXPECT_EQ(1, Factorial(0));
108 
109  // Tests factorial of positive numbers.
110  EXPECT_EQ(1, Factorial(1));
111  EXPECT_EQ(2, Factorial(2));
112  EXPECT_EQ(6, Factorial(3));
113  EXPECT_EQ(40320, Factorial(8));
114 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
int Factorial(int n)
Definition: sample1.cc:37
#define EXPECT_GT(val1, val2)
Definition: gtest.h:1934
TEST_F ( IntegerFunctionTest  ,
IsPrime   
)

Definition at line 118 of file sample5_unittest.cc.

References EXPECT_FALSE, EXPECT_TRUE, and IsPrime().

118  {
119  // Tests negative input.
120  EXPECT_FALSE(IsPrime(-1));
121  EXPECT_FALSE(IsPrime(-2));
122  EXPECT_FALSE(IsPrime(INT_MIN));
123 
124  // Tests some trivial cases.
125  EXPECT_FALSE(IsPrime(0));
126  EXPECT_FALSE(IsPrime(1));
127  EXPECT_TRUE(IsPrime(2));
128  EXPECT_TRUE(IsPrime(3));
129 
130  // Tests positive input.
131  EXPECT_FALSE(IsPrime(4));
132  EXPECT_TRUE(IsPrime(5));
133  EXPECT_FALSE(IsPrime(6));
134  EXPECT_TRUE(IsPrime(23));
135 }
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
bool IsPrime(int n)
Definition: sample1.cc:47
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
TEST_F ( QueueTest  ,
DefaultConstructor   
)

Definition at line 173 of file sample5_unittest.cc.

References EXPECT_EQ.

173  {
174  EXPECT_EQ(0u, q0_.Size());
175 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
TEST_F ( QueueTest  ,
Dequeue   
)

Definition at line 178 of file sample5_unittest.cc.

References EXPECT_EQ, and EXPECT_TRUE.

178  {
179  int* n = q0_.Dequeue();
180  EXPECT_TRUE(n == NULL);
181 
182  n = q1_.Dequeue();
183  EXPECT_TRUE(n != NULL);
184  EXPECT_EQ(1, *n);
185  EXPECT_EQ(0u, q1_.Size());
186  delete n;
187 
188  n = q2_.Dequeue();
189  EXPECT_TRUE(n != NULL);
190  EXPECT_EQ(2, *n);
191  EXPECT_EQ(1u, q2_.Size());
192  delete n;
193 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859