Beispiel #1
0
#include "UnitTest.h"

#define CCHARP(str)           ((const char*)str)
#define STR_EQUAL(str1, str2) (strcmp(CCHARP(str1), CCHARP(str2)) == 0)

EDELIB_NS_USE

UT_FUNC(ThemeTestReader, "Test Theme reader")
{
	Theme t;
	UT_VERIFY( t.load("theme.et") == true );
	UT_VERIFY( t.loaded() == true );

	UT_VERIFY( t.author() && STR_EQUAL(t.author(), "John Foo <*****@*****.**>") );
	UT_VERIFY( t.name() && STR_EQUAL(t.name(), "Demo") );
	UT_VERIFY( t.sample_image() && STR_EQUAL(t.sample_image(), "img.jpg") );

	char buf[64];
	long lval;

	UT_VERIFY( t.get_item("test style", "item1", buf, sizeof(buf)) );
	UT_VERIFY( STR_EQUAL(buf, "value 1") );

	UT_VERIFY( t.get_item("test style", "item2", buf, sizeof(buf)) );
	UT_VERIFY( STR_EQUAL(buf, "value 2") );

	UT_VERIFY( t.get_item("test style", "item3", lval, 0) );
	UT_VERIFY( lval == 123 );

	/* return false if item wasn't found */
	UT_VERIFY( t.get_item("test style", "item-do-not-exists", lval, -1) == false );