void test_jaldb_xml_to_sys_metadata_works_with_cdata()
{
	struct jaldb_record *sys_meta;
	FILE *fd = fopen(GOOD_SYS_META_CDATA,"r");
	assert_not_equals(fd,NULL);
	assert_equals(fseek(fd, 0L, SEEK_END),0);
	long bufsize = ftell(fd);
	assert_not_equals(bufsize,-1);
	
	char *buf = jal_calloc(bufsize,sizeof(char));
	assert_not_equals(NULL,buf);
	assert_equals(fseek(fd,0L,SEEK_SET),0);
	assert_not_equals(fread(buf,sizeof(char),bufsize,fd),0);

	assert_equals(JAL_OK,jaldb_xml_to_sys_metadata((uint8_t *)buf,(size_t)bufsize,&sys_meta));
	assert_not_equals(sys_meta,NULL);
	assert_equals(sys_meta->pid,0);
	assert_equals(sys_meta->uid,0);
	assert_string_equals(sys_meta->hostname,"test.jalop.com");
	assert_string_equals(sys_meta->timestamp,"2011-11-10T04:09:55-05:00");
	assert_string_equals(sys_meta->username,"root");
	assert_string_equals(sys_meta->sec_lbl,"unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023");
	assert_equals(sys_meta->type,JALDB_RTYPE_JOURNAL);
	
	fclose(fd);
	free(buf);
}
void test_jalp_transform_append_other_return_list_with_transform_inserted_center()
{
	struct jalp_transform *frst_transform;
	struct jalp_transform *scnd_transform;
	struct jalp_transform *new_scnd;

	frst_transform = jalp_transform_append_other(NULL, "uri", "snippet");
	scnd_transform = jalp_transform_append_other(frst_transform, "uri2", "snippet2");
	new_scnd = jalp_transform_append_other(frst_transform, "uri1", "snippet1");

	assert_not_equals(NULL, frst_transform);
	assert_equals(JALP_TRANSFORM_OTHER, frst_transform->type);
	assert_not_equals(NULL, frst_transform->other_info);
	assert_not_equals(NULL, scnd_transform);
	assert_equals(JALP_TRANSFORM_OTHER, scnd_transform->type);
	assert_not_equals(NULL, scnd_transform->other_info);
	assert_not_equals(NULL, new_scnd);
	assert_equals(JALP_TRANSFORM_OTHER, new_scnd->type);
	assert_not_equals(NULL, new_scnd->other_info);
	assert_string_equals("uri", frst_transform->other_info->uri);
	assert_string_equals("snippet", frst_transform->other_info->xml);
	assert_string_equals("uri1", new_scnd->other_info->uri);
	assert_string_equals("snippet1", new_scnd->other_info->xml);
	assert_string_equals("uri2", scnd_transform->other_info->uri);
	assert_string_equals("snippet2", scnd_transform->other_info->xml);
	assert_string_equals("uri1", frst_transform->next->other_info->uri);
	assert_string_equals("snippet1", frst_transform->next->other_info->xml);
	assert_equals(frst_transform->next, new_scnd);
	assert_string_equals("uri2", new_scnd->next->other_info->uri);
	assert_string_equals("snippet2", new_scnd->next->other_info->xml);
	assert_equals(new_scnd->next, scnd_transform);

	jalp_transform_destroy(&frst_transform);
}
void test_jalp_transform_append_other_return_new_transform_when_prev_is_null()
{
	struct jalp_transform *transform;
	transform = jalp_transform_append_other(NULL, "uri", "snippet");

	assert_not_equals(NULL, transform);
	assert_equals(JALP_TRANSFORM_OTHER, transform->type);
	assert_not_equals(NULL, transform->other_info);
	assert_string_equals("uri", transform->other_info->uri);
	assert_string_equals("snippet", transform->other_info->xml);
	assert_equals((struct jalp_transform *)NULL, transform->next);

	jalp_transform_destroy(&transform);
}
Exemple #4
0
void test_string_char_source()
{
    const char *test = "this is a test";
    char temp[64];
    char_source *src = string_source(test);
    for (int i=0; (temp[i] = src->read()) != 0; i++);
    assert_string_equals(temp, test);
}
Exemple #5
0
void replace_when_new_null(void)
{
    char *string = "hello";
    char *sub = "hello";
    char *new = NULL;

    char *result = str_replace(string, sub, new);

    assert_string_equals("hello", result);
}
Exemple #6
0
void replace_one_substr_beginning(void)
{
    char *string = "it is a string";
    char *sub = "it";
    char *new = "that";

    char *result = str_replace(string, sub, new);

    assert_string_equals("that is a string", result);
}
Exemple #7
0
void replace_char(void)
{
    char *string = "some & a thing & something else";
    char *sub = "&";
    char *new = "&";

    char *result = str_replace(string, sub, new);

    assert_string_equals("some & a thing & something else", result);
}
Exemple #8
0
void replace_one_substr(void)
{
    char *string = "it is a string";
    char *sub = "is";
    char *new = "was";

    char *result = str_replace(string, sub, new);

    assert_string_equals("it was a string", result);
}
Exemple #9
0
void replace_when_none(void)
{
    char *string = "its another string";
    char *sub = "haha";
    char *new = "replaced";

    char *result = str_replace(string, sub, new);

    assert_string_equals("its another string", result);
}
Exemple #10
0
void replace_when_string_empty(void)
{
    char *string = "";
    char *sub = "hello";
    char *new = "goodbye";

    char *result = str_replace(string, sub, new);

    assert_string_equals("", result);
}
void test_digest_resp_info_create_works_with_valid_input_for_unknown()
{

	struct jaln_digest_resp_info *di = jaln_digest_resp_info_create(nonce, JALN_DIGEST_STATUS_UNKNOWN);
	assert_not_equals((void*)NULL, di);

	assert_not_equals((void*)NULL, di->nonce);
	assert_not_equals(nonce, di->nonce);
	assert_string_equals(nonce, di->nonce);

	assert_equals(JALN_DIGEST_STATUS_UNKNOWN, di->status);
	jaln_digest_resp_info_destroy(&di);
	assert_pointer_equals((void*) NULL, di);
}
void test_jalp_transform_append_xor_returns_list_when_prev_not_null()
{
	struct jalp_transform *transform = NULL;
	struct jalp_transform *new_transform = NULL;
	uint8_t key_buf[] = {0xAA, 0xBB, 0x11, 0x22};

	transform = jalp_transform_append_other(NULL, "http://www.fake.uri/", "<fake>fake</fake>");
	assert_not_equals(NULL, transform);
	assert_equals(JALP_TRANSFORM_OTHER, transform->type);
	assert_not_equals(NULL, transform->other_info);
	assert_string_equals("<fake>fake</fake>", transform->other_info->xml);
	assert_string_equals("http://www.fake.uri/", transform->other_info->uri);

	new_transform = jalp_transform_append_xor(transform, 0xAABB1122);
	assert_not_equals(NULL, transform->next);
	assert_not_equals(NULL, new_transform);
	assert_not_equals(NULL, new_transform->enc_info);
	assert_not_equals(NULL, new_transform->enc_info->key);
	assert_equals((void*)NULL, new_transform->enc_info->iv);
	assert_equals(transform->next, new_transform);
	assert_equals(JALP_TRANSFORM_XOR, new_transform->type);
	assert_equals(0, memcmp(key_buf, new_transform->enc_info->key, sizeof(key_buf)));
	jalp_transform_destroy(&transform);
}
Exemple #13
0
void test_change_prefix() {
  assert_string_equals("instrument: basoon", bar());
  set_printing_prefix("paint");
  assert_string_equals("paint: basoon", bar());
}
Exemple #14
0
void test_foo() {
  assert_string_equals("instrument: basoon", bar());
}
Exemple #15
0
void test_byte_to_str(void)
{
    assert_string_equals("00000000", byte_to_str((BYTE)0x00));    
    assert_string_equals("00000001", byte_to_str((BYTE)0x01));    
    assert_string_equals("00000010", byte_to_str((BYTE)0x02));    
    assert_string_equals("00000011", byte_to_str((BYTE)0x03));    
    assert_string_equals("00000100", byte_to_str((BYTE)0x04));    
    assert_string_equals("00000101", byte_to_str((BYTE)0x05));    
    assert_string_equals("00010101", byte_to_str((BYTE)0x15));    
    assert_string_equals("00011101", byte_to_str((BYTE)0x1D));    
    assert_string_equals("01111111", byte_to_str((BYTE)0x7F));    
    assert_string_equals("10000000", byte_to_str((BYTE)0x80));    
    assert_string_equals("10000001", byte_to_str((BYTE)0x81));    
    assert_string_equals("10101111", byte_to_str((BYTE)0xAF));    
    assert_string_equals("11111111", byte_to_str((BYTE)0xFF));    
}
Exemple #16
0
void test_stringify() {
  char *h = stringify('h');
  assert_string_equals("h", h);
  free(h);
}
Exemple #17
0
void test_stringify_cannot_malloc_returns_sane_result() {
  replace_function(&malloc, &always_failing_malloc);
  char *h = stringify('h');
  assert_string_equals("cannot_stringify", h);
}
Exemple #18
0
void test_fie() {
  assert_string_equals("instrument: trumpet", fie());
}
Exemple #19
0
static int
assert_log_buffer_equals(char * expected)
{
  return assert_string_equals(expected, log_buffer);
}