Jamoma API  0.6.0.a19
AngleDataspace.test.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup foundationDataspaceLib
4  *
5  * @brief Unit tests for the #AngleDataspace.
6  *
7  * @authors Trond Lossius, Tim Place, Nils Peters, ...
8  *
9  * @copyright Copyright © 2011 Trond Lossius @n
10  * This code is licensed under the terms of the "New BSD License" @n
11  * http://creativecommons.org/licenses/BSD/
12  */
13 
14 
15 // Dataspaces and Units employ C++ double-inheritance and are thus unsuitable for direct use
16 // through the usual TTObject API
17 #define TT_NO_DEPRECATION_WARNINGS
18 
19 #include "AngleDataspace.h"
20 
21 
22 TTErr AngleDataspace::test(TTValue& returnedTestInfo)
23 {
24  int errorCount = 0;
25  int testAssertionCount = 0;
26 
27  // Create dataspace object and set to angle
28  try {
29  TTObject myDataspace("dataspace");
30 
31  myDataspace.set(TT("dataspace"), TT("angle"));
32 
33  TTValue v;
34  TTValue expected;
35 
36  /************************************************/
37  /* */
38  /* Test conversions to neutral unit */
39  /* */
40  /************************************************/
41 
42 
43  // Radian => Radian
44 
45  myDataspace.set(TT("inputUnit"), TT("radian"));
46  myDataspace.set(TT("outputUnit"), TT("radian"));
47 
48  v = TTValue(kTTPi);
49  expected = TTValue(kTTPi);
50 
51  myDataspace.send(TT("convert"), v, v);
52 
53  TTTestAssertion("Radian to Radian",
54  TTTestFloatEquivalence(TTFloat64(v), TTFloat64(expected)),
55  testAssertionCount,
56  errorCount);
57 
58 
59 
60  // Degree => Radian
61 
62  myDataspace.set(TT("inputUnit"), TT("degree"));
63  myDataspace.set(TT("outputUnit"), TT("radian"));
64 
65  v = TTValue(180.);
66  expected = TTValue(kTTPi);
67 
68  myDataspace.send(TT("convert"), v, v);
69 
70  TTTestAssertion("Degree to Radian",
71  TTTestFloatEquivalence(TTFloat64(v), TTFloat64(expected)),
72  testAssertionCount,
73  errorCount);
74 
75 
76  /************************************************/
77  /* */
78  /* Test conversions from neutral unit */
79  /* */
80  /************************************************/
81 
82  // Radian => Degree
83  // Expected value according to Google search: "0 Celsius to Kelvin"
84 
85  myDataspace.set(TT("inputUnit"), TT("radian"));
86  myDataspace.set(TT("outputUnit"), TT("degree"));
87 
88  v = TTValue(kTTPi);
89  expected = TTValue(180.0);
90 
91  myDataspace.send(TT("convert"), v, v);
92 
93  TTTestAssertion("Radian to Degree",
94  TTTestFloatEquivalence(TTFloat64(v), TTFloat64(expected)),
95  testAssertionCount,
96  errorCount);
97 
98  }
99  catch (...) {
100  TTLogMessage("AngleDataspace::test TOTAL FAILURE");
101  errorCount = 1;
102  testAssertionCount = 1;
103  }
104 
105  return TTTestFinish(testAssertionCount, errorCount, returnedTestInfo);
106 }
The AngleDataspace converts between different measurement untis describing trigonometric angles...
Create and use Jamoma object instances.
Definition: TTObject.h:29
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
void set(const TTUInt16 index, const T &anElementValue)
DEPRECATED.
Definition: TTValue.h:569
void TTFOUNDATION_EXPORT TTLogMessage(TTImmutableCString message,...)
Platform and host independent method for posting log messages.
Definition: TTBase.cpp:534
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
TTFOUNDATION_EXPORT const TTFloat64 kTTPi
[doxygenAppendixC_constExample]
Definition: TTBase.cpp:23
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34