TsUnitOfMeasure.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/common/UnitOfMeasure.cpp
22 
23  \brief A class for representing a unit of measure.
24 */
25 
26 #include "../../src/terralib/common/UnitOfMeasure.h"
27 #include "TsUnitOfMeasure.h"
28 
30 
32 {
33  uomA = new te::common::UnitOfMeasure(9030, "NAUTICAL MILE", "TestSymbolA", te::common::Length, 9001, 1852, 0, 0, 1, "TestDescriptionA");
34  uomB = new te::common::UnitOfMeasure(9101, "RADIAN", "TestSymbolB", te::common::Angle, 9101, 1, 0, 0, 1, "TestDescriptionB");
35  uomC = new te::common::UnitOfMeasure(9102, "DEGREE", "TestSymbolC", te::common::Angle, 9101, 3.14159265358979, 0, 0, 180, "TestDescriptionC");
36  uomD = new te::common::UnitOfMeasure(9201, "UNITY", "TesSymbolD", te::common::Scale, 9201, 1, 0, 0, 1, "TestDescriptionD");
37 }
38 
40 {
41  delete uomA;
42  delete uomB;
43  delete uomC;
44  delete uomD;
45 }
46 
48 {
49  CPPUNIT_ASSERT(uomA->getId() == 9030);
50 }
51 
53 {
54  CPPUNIT_ASSERT(uomB->getName() == "RADIAN");
55 }
56 
58 {
59  CPPUNIT_ASSERT(uomC->getDescription() == "TestDescriptionC");
60 }
61 
63 {
64  CPPUNIT_ASSERT(uomD->getSymbol() == "TesSymbolD");
65 }
66 
68 {
69  CPPUNIT_ASSERT(uomA->getType() == te::common::Length);
70 }
71 
73 {
74  CPPUNIT_ASSERT(uomB->isBaseUnit() == true);
75  CPPUNIT_ASSERT(uomC->isBaseUnit() == false);
76 }
77 
79 {
80  CPPUNIT_ASSERT(uomD->getBaseUnitId() == 9201);
81 }
82 
84 {
85  double a, b, c, d;
86  uomA->getConversionFactors(a, b, c, d);
87 
88  CPPUNIT_ASSERT(a == 1852);
89  CPPUNIT_ASSERT(b == 0);
90  CPPUNIT_ASSERT(c == 0);
91  CPPUNIT_ASSERT(d == 1);
92 }
93 
95 {
96  CPPUNIT_ASSERT(uomA->getConversionValue() == 1852);
97  CPPUNIT_ASSERT(uomB->getConversionValue() == 1);
98 }
CPPUNIT_TEST_SUITE_REGISTRATION(TsUnitOfMeasure)
te::common::UnitOfMeasure * uomB
void tcIsBaseUnit()
Test Case: Checks if it is returning true for a base unit and false for non-base units.
MeasureType getType() const
Returns the unit of measure type.
void getConversionFactors(double &A, double &B, double &C, double &D) const
Returns the conversion factors to convert the unit to its base unit.
unsigned int getId() const
Returns the unit of measure identification.
void tcGetName()
Test Case: Checks the unit of measure name.
const std::string & getDescription() const
Returns the unit of measure description.
const std::string & getName() const
Returns the unit of measure oficial name.
int b
Definition: TsRtree.cpp:32
void tcGetDescription()
Test Case: Checks the unit of measure description.
void tcGetBaseUnitId()
Test Case: Checks the base unit id from which this unit derives of.
void tcGetConversionFactors()
Test Case: Checks if the conversion factors to convert the unit to its base unit are correct...
void tcGetType()
Test Case: Checks the unit of measure type.
void tcGetSymbol()
Test Case: Checks the unit of measure symbol.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
te::common::UnitOfMeasure * uomA
const std::string & getSymbol() const
Returns the unit of measure symbol.
A class to represent units of measure.
Definition: UnitOfMeasure.h:74
void tcGetId()
Test Case: Checks the unit of measure identification.
te::common::UnitOfMeasure * uomC
double getConversionValue() const
Returns a multiplicative value to convert the unit to its base unit.
void tcGetConversionValue()
Test Case: Checks the multiplicative value to convert the unit to its base unit.
const unsigned int getBaseUnitId() const
Returns the base unit id from which this unit derives of.
te::common::UnitOfMeasure * uomD
bool isBaseUnit() const
Returns true if this is a base unit; otherwise returns false.