#include <stdio.h> #include <errno.h> #include <kc.h> #include <kc_ut.h> #include <kc_assert.h> #include <kc_memory_mark.h> // プロトタイプ宣言 static void test_memory_mark_allocated(void); static void test_memory_mark_deleted(void); static void test_memory_mark_other(void); /** * memory_mark 単体テストスイート */ void suite_memory_mark(void) { KcUt *ut = KcUt_get_instance(); ut->add(ut, UT_TESTCASE, "memory_mark ALLOCATED", test_memory_mark_allocated); ut->add(ut, UT_TESTCASE, "memory_mark DELETED", test_memory_mark_deleted); ut->add(ut, UT_TESTCASE, "memory_mark OTHER", test_memory_mark_other); } /** * KcMemoryMark の文字列表現取得 (ALLOCATED) * * @process KC_MEMORY_ALLOCATED の文字列表現を取得する。 * @result 'alloc ' が取得されること。 */ static void test_memory_mark_allocated(void) { const char *res = KcMemoryMark_to_string(KC_MEMORY_ALLOCATED); assert_equals("alloc ", res); res = KcMemoryMark_to_string(KC_MEMORY_ALLOCATED_ALIGNED); assert_equals("alloca", res); } /** * KcMemoryMark の文字列表現取得 (ALLOCATED_DELETED) * * @process KC_MEMORY_DELETED の文字列表現を取得する。 * @result 'delete' が取得されること。 */ static void test_memory_mark_deleted(void) { const char *res = KcMemoryMark_to_string(KC_MEMORY_DELETED); assert_equals("delete", res); } /** * KcMemoryMark の文字列表現取得 (その他) * * @process 規定外の値を指定し、 KcMemoryMark_to_string を実行する。 * @result 'other ' が取得されること。 */ static void test_memory_mark_other(void) { const char *res = KcMemoryMark_to_string(0x12345678); assert_equals("other ", res); }