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_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, ""); }
void wi_test_runtime_invalid(void) { WI_TEST_ASSERT_NULL(wi_runtime_class_with_name(WI_STR("foo")), ""); WI_TEST_ASSERT_NULL(wi_runtime_class_with_id(1337), ""); WI_TEST_ASSERT_EQUALS(wi_runtime_id_for_class(NULL), WI_RUNTIME_ID_NULL, ""); WI_TEST_ASSERT_NULL(wi_runtime_class("foo"), ""); WI_TEST_ASSERT_NULL(wi_runtime_class_name("foo"), ""); WI_TEST_ASSERT_EQUALS(wi_runtime_id("foo"), WI_RUNTIME_ID_NULL, ""); WI_TEST_ASSERT_NULL(wi_retain(NULL), ""); WI_TEST_ASSERT_EQUALS(wi_retain_count(NULL), 0U, ""); WI_TEST_ASSERT_NULL(wi_copy(NULL), ""); WI_TEST_ASSERT_NULL(wi_mutable_copy(NULL), ""); WI_TEST_ASSERT_TRUE(wi_is_equal(NULL, NULL), ""); WI_TEST_ASSERT_FALSE(wi_is_equal(NULL, "foo"), ""); WI_TEST_ASSERT_FALSE(wi_is_equal(wi_array(), wi_dictionary()), ""); WI_TEST_ASSERT_NULL(wi_description(NULL), ""); WI_TEST_ASSERT_EQUALS(wi_hash(NULL), 0U, ""); }