Nobita/015.cppunitでテストを書く


Top / Nobita / 015.cppunitでテストを書く

これは何か

こんな感じで。

	#include "FileServerTest.h"
	#include "Message.h"
	#include "monapi/messages.h"
		
	CPPUNIT_TEST_SUITE_REGISTRATION(FileServerTest);
		
	using namespace MonAPI;
		
	void FileServerTest::setUp()
	{
	    Message::initialize();
	}
		
	void FileServerTest::tearDown()
	{
	}
		
	void FileServerTest::testReadDirectory()
	{
	    monapi_cmemoryinfo* mi = monapi_call_file_read_directory("/SERVERS", MONAPI_FALSE);
	    monapi_directoryinfo* p = (monapi_directoryinfo*)&mi->Data[sizeof(int)];
	    int size = *(int*)mi->Data;
		
	    CPPUNIT_ASSERT_EQUAL_MESSAGE("entry count", 7, size);
	    CPPUNIT_ASSERT_MESSAGE("file . exist?", strcmp((&p[0])->name, ".") == 0);
	    CPPUNIT_ASSERT_MESSAGE("file .. exist?", strcmp((&p[1])->name, "..") == 0);
	    CPPUNIT_ASSERT_MESSAGE("file SHELL.EX5 exist?", strcmp((&p[6])->name, "SHELL.EX5") == 0);
	    monapi_cmemoryinfo_dispose(mi);
	    monapi_cmemoryinfo_delete(mi);
	}
		
	void FileServerTest::testReadFile()
	{
	    monapi_cmemoryinfo* mi = monapi_call_file_read_data("/MONA.CFG", MONAPI_FALSE);
		
	    CPPUNIT_ASSERT_MESSAGE("file /MONA.CFG found?", NULL != mi);
	    CPPUNIT_ASSERT_EQUAL_MESSAGE("file size == 200byte", 200, (int)mi->Size);
	    CPPUNIT_ASSERT_MESSAGE("strncmp", strncmp("# 1600(x1200), 1280(x1024), 1024", (char*)mi->Data, 32) == 0);
		
	    monapi_cmemoryinfo_dispose(mi);
	    monapi_cmemoryinfo_delete(mi);
	}
		
	void FileServerTest::testFileSize()
	{
	    dword id = monapi_call_file_open("/MONA.CFG");
	    dword size = monapi_call_file_get_file_size(id);
	    CPPUNIT_ASSERT_EQUAL_MESSAGE("file size == 200byte", 200, (int)size);
	    monapi_call_file_close(id);
	}
		

コメント

コメントはありません。 コメント/Nobita/015.cppunitでテストを書く?

お名前:

MENU

now: 1

リンク


最新の20件
2018-05-03 2017-09-29 2017-04-25 2017-01-10 2016-12-11 2016-10-04 2016-08-14 2016-06-05 2016-05-29 2016-04-15 2015-12-28 2013-02-25 2013-02-21 2013-02-20 2013-02-12 2013-02-11 2013-02-10
最新の20件
2010-02-01 2010-01-31 2010-01-30 2010-01-29 2010-01-16

Counter: 3504, today: 2, yesterday: 0

リロード   新規 編集 凍結 差分 添付 複製 改名   トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Last-modified: 2008-03-28 (金) 15:47:55 (3794d);  Modified by mona
PukiWiki 1.4.6 Copyright © 2001-2005 PukiWiki Developers Team. License is GPL.
Based on "PukiWiki" 1.3 by yu-ji
Powered by PHP 5.2.17
HTML convert time to 0.022 sec.