Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9026 for code


Ignore:
Timestamp:
Mar 11, 2012, 9:19:47 PM (13 years ago)
Author:
landauf
Message:

removed obsolete (and wrong for negative values) round() function (exists also in cmath)

Location:
code/branches/testing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/Math.h

    r8729 r9026  
    139139    {
    140140        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);
    150141    }
    151142
  • code/branches/testing/test/util/MathTest.cc

    r9025 r9026  
    148148        EXPECT_DOUBLE_EQ( -3.375, cube(-1.5));
    149149        EXPECT_DOUBLE_EQ( -8.000, cube(-2.0));
    150     }
    151 
    152     /////////////
    153     // round() //
    154     /////////////
    155     TEST(round, Positive)
    156     {
    157         // int
    158         EXPECT_EQ( 5, round(5));
    159         EXPECT_EQ(10, round(10));
    160 
    161         // double
    162         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         // int
    177         EXPECT_EQ( -5, round(-5));
    178         EXPECT_EQ(-10, round(-10));
    179 
    180         // double
    181         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));
    188150    }
    189151
     
    240202        EXPECT_DOUBLE_EQ(0.0, zeroise<double>());
    241203        EXPECT_EQ("", zeroise<std::string>());
    242 //        EXPECT_EQ(Vector3::ZERO, zeroise<Vector3>());
     204        EXPECT_EQ(Vector3::ZERO, zeroise<Vector3>());
    243205    }
    244206
Note: See TracChangeset for help on using the changeset viewer.