Skip to content

Instantly share code, notes, and snippets.

@pghalliday
Created June 27, 2012 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pghalliday/3004047 to your computer and use it in GitHub Desktop.
Save pghalliday/3004047 to your computer and use it in GitHub Desktop.
Blog - OOOCode - Part 2
#ifndef IMYINTERFACE_H_
#define IMYINTERFACE_H_
#include "OOOCode.h"
#define OOOInterface IMyInterface
OOOVirtuals
OOOVirtual(int, getData);
OOOVirtualsEnd
#undef OOOInterface
#endif
#include "opentv.h"
#include "assert.h"
#include "OOOUnitTestsRun.h"
void main(void)
{
size_t uMemory = O_heap_available();
OOODebug * pDebug = OOOConstruct(OOODebug);
OOODebugReporter * pReporter = OOOConstruct(OOODebugReporter, OOOCast(OOOIDebug, pDebug));
OOOUnitTestsRun(OOOCast(OOOIReporter, pReporter));
OOODestroy(pReporter);
OOODestroy(pDebug);
assert(O_heap_available() == uMemory);
/* Stick around so the VSTB does not exit and we know we ran everything */
while (TRUE)
{
o_message tMessage;
O_ui_get_event_wait(&tMessage);
if (O_msg_class(&tMessage) == MSG_CLASS_CONTROL)
{
if (O_msg_type(&tMessage) == MSG_TYPE_QUIT)
{
O_exit();
}
}
}
}
#include "MyClass.h"
#define OOOClass MyClass
OOOPrivateData
int nMyField;
OOOPrivateDataEnd
OOODestructor
{
}
OOODestructorEnd
OOOMethod(int, getMyField)
{
return OOOF(nMyField);
}
OOOMethodEnd
OOOConstructor(int nMyField)
{
OOOMapMethods
OOOMethodMapping(getMyField)
OOOMapMethodsEnd
OOOF(nMyField) = nMyField;
}
OOOConstructorEnd
#undef OOOClass
#ifndef MYCLASS_H_
#define MYCLASS_H_
#include "OOOCode.h"
#define OOOClass MyClass
OOODeclare(int nMyField)
OOOImplements
OOOImplementsEnd
OOOExports
OOOExport(int, getMyField);
OOOExportsEnd
OOODeclareEnd
#undef OOOClass
#endif
#include "OOOUnitTestDefines.h"
OOOTest(MyClass)
{
OOOInfo("MyClass test");
}
OOOTest(MyClass)
#include "OOOUnitTestDefines.h"
#include "MyClass.h"
OOOTest(MyClass)
{
MyClass * pMyClass = OOOConstruct(MyClass, 5);
/* Check stuff here */
OOOCheck(OOOCall(pMyClass, getMyField) == 5);
OOOCheck(OOOICall(OOOCast(IMyInterface, pMyClass), getData) == 5);
OOODestroy(pMyClass);
}
#include "OOOUnitTestDefines.h"
#include "MyClass.h"
OOOTest(MyClass)
{
MyClass * pMyClass = OOOConstruct(MyClass, 5);
/* Check stuff here */
OOOCheck(OOOCall(pMyClass, getMyField) == 5);
OOODestroy(pMyClass);
}
/* include test headers here */
#include "MyClass.Test.h"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment