Example #1
0
void test_m_pointer(CuTest *tc)
{
  struct TestData dat = {1}; // inc
  MObject *obj = m_pointer_new(&dat, fake_ptr_copy, fake_ptr_free);
  MPointer *p = M_POINTER(obj);
  MPointer *p2;

  // Test getting and setting the pointer and NULL
  CuAssertTrue(tc, M_IS_POINTER(obj));
  CuAssertPtrEquals(tc, &dat, m_pointer_get(p));
  m_pointer_set(p, NULL);
  CuAssertPtrNull(tc, m_pointer_get(p));
  m_pointer_set(p, &dat);
  CuAssertPtrEquals(tc, &dat, m_pointer_get(p));

  // Test copy
  p2 = M_POINTER(m_object_copy(M_OBJECT(obj))); // inc
  CuAssertTrue(tc, M_IS_POINTER(obj));
  CuAssertPtrEquals(tc, &dat, m_pointer_get(p2));
  CuAssertIntEquals(tc, 2, dat.count);

  // Test free
  m_object_unref(M_OBJECT(p2)); // dec
  CuAssertIntEquals(tc, 1, dat.count);
  m_object_unref(M_OBJECT(p)); // dec
  CuAssertIntEquals(tc, 0, dat.count);
}
Example #2
0
static void hacf_param_list_collision_test(CuTest *tc) {
	hacf_param_list_t *list = create_hacf_param_list(p);
	hacf_param_t *key1 = create_hacf_param(p, KEY1, HASH1);
	CuAssertIntEquals(tc, 0, add_hacf_param(list, key1));
	CuAssertPtrNotNull(tc, list->first);
	hacf_param_t *key2 = create_hacf_param(p, KEY2, HASH2);
	CuAssertIntEquals(tc, 1, add_hacf_param(list, key2));
	CuAssertPtrNull(tc, list->first->next);
}
Example #3
0
static void hacf_param_list_multivalue_test(CuTest *tc) {
	hacf_param_list_t *list = create_hacf_param_list(p);
	hacf_param_t *key11 = create_hacf_param(p, KEY1, HASH1);
	CuAssertIntEquals(tc, 0, add_hacf_param(list, key11));
	CuAssertPtrNotNull(tc, list->first);
	hacf_param_t *key12 = create_hacf_param(p, KEY1, HASH1);
	CuAssertIntEquals(tc, 0, add_hacf_param(list, key12));
	CuAssertPtrNull(tc, list->first->next);
}
Example #4
0
void test_do_not_find_entry_scope(CuTest *tc) {
  scope_new();
  
  CuAssertIntEquals(tc, 1, scope_numbers());
  CuAssertFalse(tc, is_identifier_declared("a"));
  CuAssertPtrNull(tc, scope_search_identifier("a"));
  
  scope_reset();
}