utExport.cpp 1.8 KB
Newer Older
wester committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
 
#include "UnitTestPCH.h"
#include "utExport.h"

#ifndef ASSIMP_BUILD_NO_EXPORT

CPPUNIT_TEST_SUITE_REGISTRATION (ExporterTest);

void ExporterTest :: setUp (void)
{
	
	ex = new Assimp::Exporter();
	im = new Assimp::Importer();

	pTest = im->ReadFile("../../test/models/X/test.x",0);
}


void ExporterTest :: tearDown (void)
{
	delete ex;
	delete im;
}


void  ExporterTest :: testExportToFile (void)
{
	const char* file = "unittest_output.dae";
	CPPUNIT_ASSERT_EQUAL(AI_SUCCESS,ex->Export(pTest,"collada",file));

	// check if we can read it again
	CPPUNIT_ASSERT(im->ReadFile(file,0));
}


void  ExporterTest :: testExportToBlob (void)
{
	const aiExportDataBlob* blob = ex->ExportToBlob(pTest,"collada");
	CPPUNIT_ASSERT(blob);
	CPPUNIT_ASSERT(blob->data);
	CPPUNIT_ASSERT(blob->size > 0);
	CPPUNIT_ASSERT(!blob->name.length); 

	// XXX test chained blobs (i.e. obj file with accompanying mtl script)

	// check if we can read it again
	CPPUNIT_ASSERT(im->ReadFileFromMemory(blob->data,blob->size,0,"dae"));
}


void  ExporterTest :: testCppExportInterface (void)
{
	CPPUNIT_ASSERT(ex->GetExportFormatCount() > 0);
	for(size_t i = 0; i < ex->GetExportFormatCount(); ++i) {
		const aiExportFormatDesc* const desc = ex->GetExportFormatDescription(i);
		CPPUNIT_ASSERT(desc);
		CPPUNIT_ASSERT(desc->description && strlen(desc->description));
		CPPUNIT_ASSERT(desc->fileExtension && strlen(desc->fileExtension));
		CPPUNIT_ASSERT(desc->id && strlen(desc->id));
	}

	CPPUNIT_ASSERT(ex->IsDefaultIOHandler());
}


void  ExporterTest :: testCExportInterface (void)
{
	CPPUNIT_ASSERT(aiGetExportFormatCount() > 0);
	for(size_t i = 0; i < aiGetExportFormatCount(); ++i) {
		const aiExportFormatDesc* const desc = aiGetExportFormatDescription(i);
		CPPUNIT_ASSERT(desc);
		// rest has aleady been validated by testCppExportInterface
	}
}

#endif