mirror of
https://gitee.com/apaki/unicstl.git
synced 2026-05-28 22:54:19 +08:00
55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
/**
|
|
* @file test_unicstal.c
|
|
* @author wenjf (Orig5826@163.com)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2026-05-12
|
|
*
|
|
* @copyright Copyright (c) 2026
|
|
*
|
|
*/
|
|
#include "test.h"
|
|
|
|
void test_unicstl_version(void)
|
|
{
|
|
TEST_ASSERT_EQUAL_STRING("0.0.10", unicstl_version());
|
|
// TEST_ASSERT_GREATER_THAN( 0x000002L , UNICSTL_VERSION );
|
|
// TEST_ASSERT_LESS_THAN( 0x010000L , UNICSTL_VERSION );
|
|
}
|
|
|
|
void test_unicstl_capacity(void)
|
|
{
|
|
TEST_ASSERT_EQUAL_UINT32(UNICSTL_CAPACITY_INIT, unicstl_new_capacity(0));
|
|
|
|
TEST_ASSERT_EQUAL_UINT32(2, unicstl_new_capacity(1));
|
|
TEST_ASSERT_EQUAL_UINT32(6, unicstl_new_capacity(3));
|
|
TEST_ASSERT_EQUAL_UINT32(8, unicstl_new_capacity(4));
|
|
TEST_ASSERT_EQUAL_UINT32(16, unicstl_new_capacity(8));
|
|
TEST_ASSERT_EQUAL_UINT32(1024, unicstl_new_capacity(512));
|
|
|
|
TEST_ASSERT_EQUAL_UINT32(1152, unicstl_new_capacity(1024));
|
|
TEST_ASSERT_EQUAL_UINT32(1296, unicstl_new_capacity(1152));
|
|
|
|
TEST_ASSERT_EQUAL_UINT32(1125000, unicstl_new_capacity(1000000));
|
|
}
|
|
|
|
void test_unicstl_compare_obj(void)
|
|
{
|
|
int data[] = {1,2,3};
|
|
int obj_size = sizeof(int);
|
|
|
|
TEST_ASSERT_EQUAL_INT(0, compare_obj(data, 0, 0, obj_size, compare_int));
|
|
TEST_ASSERT_EQUAL_INT(1, compare_obj(data, 2, 1, obj_size, compare_int));
|
|
TEST_ASSERT_EQUAL_INT(-1, compare_obj(data, 0, 1, obj_size, compare_int));
|
|
}
|
|
|
|
void test_unicstl(void)
|
|
{
|
|
UnitySetTestFile(__FILE__);
|
|
|
|
RUN_TEST(test_unicstl_version);
|
|
RUN_TEST(test_unicstl_capacity);
|
|
|
|
RUN_TEST(test_unicstl_compare_obj);
|
|
}
|