add typeOf() and instanceOf()
This commit is contained in:
parent
dffbd936db
commit
6f6bb5b4e0
5 changed files with 69 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ void tearDown(void)
|
|||
return;
|
||||
}
|
||||
|
||||
extern void test_type(void);
|
||||
extern void test_iter(void);
|
||||
extern void test_invalid(void);
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
UNITY_BEGIN();
|
||||
|
||||
TEST(test_type);
|
||||
TEST(test_iter);
|
||||
TEST(test_invalid);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,21 @@ static typeinfo_t myintArray
|
|||
.reset = (iter_reset_fn_t)my_array_iter_reset,
|
||||
.destroy = (iter_destroy_fn_t)my_array_iter_destroy } } };
|
||||
|
||||
static void test_typeof(void)
|
||||
{
|
||||
var array = makeInstance(&myintArray, 5, 0, 1, 2, 3, 4);
|
||||
int rc;
|
||||
typeinfo_t* t = NULL;
|
||||
|
||||
t = typeOf(array);
|
||||
TEST_ASSERT_TRUE(t == &myintArray);
|
||||
|
||||
rc = instanceOf(array, &myintArray);
|
||||
TEST_ASSERT_TRUE(rc == 1);
|
||||
|
||||
destroy(array);
|
||||
}
|
||||
|
||||
static void test_array_iter(void)
|
||||
{
|
||||
var array = makeInstance(&myintArray, 5, 0, 1, 2, 3, 4);
|
||||
|
|
@ -147,6 +162,12 @@ static void test_array_iter(void)
|
|||
return;
|
||||
}
|
||||
|
||||
void test_type(void) {
|
||||
printf("\n type info test\n\n");
|
||||
|
||||
RUN_TEST(test_typeof);
|
||||
}
|
||||
|
||||
void test_iter(void)
|
||||
{
|
||||
printf("\n iterator test\n\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue