Jamoma API  0.6.0.a19
DSP/extensions/FunctionLib/test.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup dspFunctionLib
4  *
5  * @brief Generalized Function Wrapper for Jamoma DSP
6  *
7  * @details When copying to other projects, be sure to customize the lines indicated.
8  * This file will find all classes with a common tag and run any "test" methods present in those classes.
9  * If running any test fails, the build of the project will either fail or complete with errors.
10  * If not test method is found, the terminal output will suggest that you should create a test.
11  *
12  * @authors Nathan Wolek, Trond Lossius
13  *
14  * @copyright Copyright © 2013 by Nathan Wolek @n
15  * This code is licensed under the terms of the "New BSD License" @n
16  * http://creativecommons.org/licenses/BSD/
17  */
18 
19 
20 
21 #include <iostream>
22 #include "TTFoundationAPI.h"
23 
24 extern "C" TTErr TTLoadJamomaExtension_FunctionLib(void); // CUSTOMIZE
25 
26 int main(int argc, const char * argv[])
27 {
28  std::cout << "BEGIN testing for FunctionLib...\n"; // CUSTOMIZE
29  TTLoadJamomaExtension_FunctionLib(); // CUSTOMIZE
30 
31  TTValue classNames;
32 
33  // if the follow group tag is present within the thisTTClassTags definition, the class will be tested
34  TTValue testClassesWithTheseTags(TT("dspFunctionLib")); // CUSTOMIZE
35  TTObject::GetRegisteredClassNamesForTags(classNames, testClassesWithTheseTags);
36 
37  for (int i=0; i<classNames.size(); i++) {
38  TTSymbol name = classNames[i];
39 
40  try {
41  TTObject obj(name);
42  std::cout << "TESTING " << name.string() << std::endl;
43  obj.send("test");
44  }
45  catch (...) {
46  TTLogMessage("UnitTest Failure to instantiate object of class %s! \n", name.c_str());
47  continue;
48  }
49  }
50 
51  std::cout << "END testing of FunctionLib!\n"; // CUSTOMIZE
52  return 0;
53 }
Create and use Jamoma object instances.
Definition: TTObject.h:29
size_type size() const noexcept
Return the number of elements.
static TTErr GetRegisteredClassNamesForTags(TTValue &classNames, const TTValue &searchTags)
Query TTEnvironment for names of all registered TTObjectBase classes that share specific tags...
Definition: TTObject.cpp:78
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
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
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34