~sil2100/location-service/gps-arm64

« back to all changes in this revision

Viewing changes to tests/heading_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/heading.h"
 
2
 
 
3
#include <gtest/gtest.h>
 
4
 
 
5
TEST(Heading, constructing_a_heading_with_invalid_value_throws)
 
6
{
 
7
    EXPECT_ANY_THROW(com::ubuntu::location::Heading h {-std::numeric_limits<double>::min()*com::ubuntu::location::units::Degrees};);
 
8
    EXPECT_ANY_THROW(com::ubuntu::location::Heading h {361.*com::ubuntu::location::units::Degrees};);
 
9
}
 
10
 
 
11
TEST(Heading, constructing_a_heading_with_a_valid_value_does_not_throw)
 
12
{
 
13
    std::default_random_engine rng;
 
14
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Heading::min().value(),
 
15
            com::ubuntu::location::Heading::max().value());
 
16
 
 
17
    EXPECT_NO_THROW(com::ubuntu::location::Heading h {dist(rng)*com::ubuntu::location::units::Degrees};);
 
18
}
 
19
 
 
20
TEST(Heading, a_heading_contains_value_passed_at_construction)
 
21
{
 
22
    std::default_random_engine rng;
 
23
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Heading::min().value(),
 
24
            com::ubuntu::location::Heading::max().value());
 
25
    double d = dist(rng);
 
26
    com::ubuntu::location::Heading h {d* com::ubuntu::location::units::Degrees};
 
27
    EXPECT_EQ(d * com::ubuntu::location::units::Degrees, h.value);
 
28
}