void wi_test_runtime_pool(void) { wi_pool_t *pool, *pool2; _wi_runtimetest_t *runtimetest, *runtimetest2; _wi_runtimetest_deallocs = 0; pool = wi_pool_init(wi_pool_alloc()); runtimetest = wi_retain(wi_autorelease(_wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42))); wi_release(pool); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 1U, ""); wi_release(runtimetest); pool = wi_pool_init(wi_pool_alloc()); runtimetest = wi_retain(wi_autorelease(_wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42))); wi_pool_drain(pool); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 1U, ""); wi_release(pool); wi_release(runtimetest); pool = wi_pool_init(wi_pool_alloc()); runtimetest = wi_retain(wi_autorelease(_wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42))); pool2 = wi_pool_init(wi_pool_alloc()); runtimetest2 = wi_retain(wi_autorelease(_wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42))); wi_release(pool2); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest2), 1U, ""); wi_release(pool); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 1U, ""); wi_release(runtimetest); wi_release(runtimetest2); }
void wi_test_runtime_functions(void) { _wi_runtimetest_t *runtimetest1, *runtimetest2; _wi_mutable_runtimetest_t *runtimetest3; _wi_runtimetest_deallocs = 0; runtimetest1 = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42); runtimetest2 = wi_copy(runtimetest1); WI_TEST_ASSERT_TRUE(runtimetest1 == runtimetest2, ""); wi_release(runtimetest2); runtimetest3 = wi_mutable_copy(runtimetest1); WI_TEST_ASSERT_TRUE(runtimetest1 != runtimetest3, ""); WI_TEST_ASSERT_EQUALS(runtimetest1->value, runtimetest3->value, ""); WI_TEST_ASSERT_TRUE(wi_is_equal(runtimetest1, runtimetest3), ""); runtimetest3->value++; WI_TEST_ASSERT_FALSE(wi_is_equal(runtimetest1, runtimetest3), ""); wi_release(runtimetest3); WI_TEST_ASSERT_EQUALS(_wi_runtimetest_deallocs, 1U, ""); WI_TEST_ASSERT_EQUAL_INSTANCES(wi_description(runtimetest1), WI_STR("value=42"), ""); WI_TEST_ASSERT_EQUALS(wi_hash(runtimetest1), 42U, ""); wi_release(runtimetest1); }
void wi_test_runtime_info(void) { _wi_runtimetest_t *runtimetest; WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_name(WI_STR("_wi_runtimetest_t")), &_wi_runtimetest_runtime_class, ""); WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_id(_wi_runtimetest_runtime_id), &_wi_runtimetest_runtime_class, ""); runtimetest = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42); WI_TEST_ASSERT_EQUALS(wi_runtime_id(runtimetest), _wi_runtimetest_runtime_id, ""); WI_TEST_ASSERT_EQUALS(wi_runtime_class(runtimetest), &_wi_runtimetest_runtime_class, ""); WI_TEST_ASSERT_EQUAL_INSTANCES(wi_runtime_class_name(runtimetest), wi_string_with_cstring(_wi_runtimetest_runtime_class.name), ""); wi_release(runtimetest); }
void wi_test_runtime_info(void) { _wi_runtimetest_t *runtimetest; WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_name(WI_STR("_wi_runtimetest_t")), &_wi_runtimetest_runtime_class, ""); WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_id(_wi_runtimetest_runtime_id), &_wi_runtimetest_runtime_class, ""); WI_TEST_ASSERT_EQUALS(wi_runtime_id_for_class(&_wi_runtimetest_runtime_class), _wi_runtimetest_runtime_id, ""); runtimetest = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42); WI_TEST_ASSERT_EQUALS(wi_runtime_class(runtimetest), &_wi_runtimetest_runtime_class, ""); WI_TEST_ASSERT_EQUAL_INSTANCES(wi_runtime_class_name(runtimetest), wi_string_with_utf8_string(_wi_runtimetest_runtime_class.name), ""); WI_TEST_ASSERT_EQUALS(wi_runtime_id(runtimetest), _wi_runtimetest_runtime_id, ""); WI_TEST_ASSERT_EQUALS(wi_runtime_options(runtimetest), WI_RUNTIME_OPTION_IMMUTABLE, ""); wi_release(runtimetest); }
void wi_test_runtime_retain(void) { _wi_runtimetest_t *runtimetest, *runtimetest2; _wi_runtimetest_deallocs = 0; runtimetest = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 1U, ""); runtimetest2 = wi_retain(runtimetest); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 2U, ""); WI_TEST_ASSERT_EQUALS(runtimetest, runtimetest2, ""); wi_release(runtimetest); WI_TEST_ASSERT_EQUALS(wi_retain_count(runtimetest), 1U, ""); wi_release(runtimetest); WI_TEST_ASSERT_EQUALS(_wi_runtimetest_deallocs, 1U, ""); }
static wi_runtime_instance_t * _wi_runtimetest_copy(wi_runtime_instance_t *instance) { _wi_runtimetest_t *runtimetest = instance; return _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), runtimetest->value); }