- Timestamp:
- Mar 11, 2012, 9:19:47 PM (13 years ago)
- Location:
- code/branches/testing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/testing/src/libraries/util/Math.h
r8729 r9026 139 139 { 140 140 return x*x*x; 141 }142 143 /**144 @brief Rounds the value to the nearest integer.145 */146 template <typename T>147 inline int round(T x)148 {149 return static_cast<int>(x + 0.5);150 141 } 151 142 -
code/branches/testing/test/util/MathTest.cc
r9025 r9026 148 148 EXPECT_DOUBLE_EQ( -3.375, cube(-1.5)); 149 149 EXPECT_DOUBLE_EQ( -8.000, cube(-2.0)); 150 }151 152 /////////////153 // round() //154 /////////////155 TEST(round, Positive)156 {157 // int158 EXPECT_EQ( 5, round(5));159 EXPECT_EQ(10, round(10));160 161 // double162 EXPECT_EQ(4, round(4.499));163 EXPECT_EQ(5, round(4.500));164 EXPECT_EQ(5, round(4.999));165 EXPECT_EQ(5, round(5.000));166 EXPECT_EQ(5, round(5.001));167 EXPECT_EQ(5, round(5.499));168 EXPECT_EQ(6, round(5.500));169 }170 171 /////////////172 // round() //173 /////////////174 TEST(round, Negative)175 {176 // int177 EXPECT_EQ( -5, round(-5));178 EXPECT_EQ(-10, round(-10));179 180 // double181 EXPECT_EQ(-4, round(-4.499));182 EXPECT_EQ(-5, round(-4.500));183 EXPECT_EQ(-5, round(-4.999));184 EXPECT_EQ(-5, round(-5.000));185 EXPECT_EQ(-5, round(-5.001));186 EXPECT_EQ(-5, round(-5.499));187 EXPECT_EQ(-6, round(-5.500));188 150 } 189 151 … … 240 202 EXPECT_DOUBLE_EQ(0.0, zeroise<double>()); 241 203 EXPECT_EQ("", zeroise<std::string>()); 242 //EXPECT_EQ(Vector3::ZERO, zeroise<Vector3>());204 EXPECT_EQ(Vector3::ZERO, zeroise<Vector3>()); 243 205 } 244 206
Note: See TracChangeset
for help on using the changeset viewer.