~ci-train-bot/location-service/location-service-ubuntu-yakkety-1895

« back to all changes in this revision

Viewing changes to tests/velocity_test.cpp

  • Committer: Thomas Voß
  • Date: 2013-05-28 14:20:45 UTC
  • Revision ID: thomas.voss@canonical.com-20130528142045-kq5umqdmm4o53vwk
Initial push.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "com/ubuntu/location/velocity.h"
 
2
 
 
3
#include <gtest/gtest.h>
 
4
 
 
5
TEST(Velocity, constructing_a_velocity_with_invalid_value_throws)
 
6
{
 
7
    std::default_random_engine rng;
 
8
    std::uniform_real_distribution<double> dist(
 
9
        -std::numeric_limits<double>::max(),
 
10
        com::ubuntu::location::Velocity::min().value() - std::numeric_limits<double>::min());
 
11
    double d = dist(rng);
 
12
    EXPECT_ANY_THROW(com::ubuntu::location::Velocity v {d*com::ubuntu::location::units::MetersPerSecond};);
 
13
}
 
14
 
 
15
TEST(Velocity, constructing_a_velocity_with_a_valid_value_does_not_throw)
 
16
{
 
17
    std::default_random_engine rng;
 
18
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Velocity::min().value(),
 
19
            com::ubuntu::location::Velocity::max().value());
 
20
 
 
21
    EXPECT_NO_THROW(com::ubuntu::location::Velocity v {dist(rng)*com::ubuntu::location::units::MetersPerSecond};);
 
22
}
 
23
 
 
24
TEST(Velocity, a_velocity_contains_value_passed_at_construction)
 
25
{
 
26
    std::default_random_engine rng;
 
27
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Velocity::min().value(),
 
28
            com::ubuntu::location::Velocity::max().value());
 
29
    double d = dist(rng);
 
30
    com::ubuntu::location::Velocity v {d* com::ubuntu::location::units::MetersPerSecond};
 
31
    EXPECT_EQ(d * com::ubuntu::location::units::MetersPerSecond, v.value);
 
32
}