示例#1
0
int test_strings_new()
{
	/// 
	{
		//
		char *src = "This is a string..";
		char *str = strings_new(src);

		//
		char *assert_message = "Testing strings copy for regular string..";
		int assert_result = (strcmp(str, src) == 0) ? TRUE : FALSE;
		ctest_assert_true(assert_result, assert_message);

		//
		strings_free(str);
	}

	/// 
	{
		//
		char *src = "";
		char *str = strings_new(src);

		//
		char *assert_message = "Testing string copy for empty string..";
		int assert_result = (strcmp(str, src) == 0) ? TRUE : FALSE;
		ctest_assert_true(assert_result, assert_message);

		//
		strings_free(str);
	}

	/// 
	{
		//
		char *src = NULL;
		char *str = strings_new(src);

		//
		char *assert_message = "Testing string copy for NULL..";
		int assert_result = (str == NULL) ? TRUE : FALSE;
		ctest_assert_true(assert_result, assert_message);

		//
		strings_free(str);
	}


	//
	return 0;
}
示例#2
0
void mapparse_file(
	const struct mapparse_callbacks *callbacks,
	const char *path,
	FILE *file)
{
	int type;
	struct strings strings = { 0, 0, NULL };

	assert(callbacks);
	assert(path);
	assert(file);

	for (;;) {
		type = getc(file);
		switch (type) {
		case MAPFILE_STRING:
			process_record_string(file, &strings);
			break;
		case MAPFILE_FUNCTION:
			process_record_function(callbacks, file, &strings);
			break;
		case MAPFILE_BASIC_BLOCK:
			process_record_basic_block(callbacks);
			break;
		case MAPFILE_INSTRUCTION:
			process_record_instruction(callbacks);
			break;
		case MAPFILE_DINSTRUCTION:
			process_record_dinstruction(callbacks, file, &strings);
			break;
		case MAPFILE_FAULT_CANDIDATE:
			process_record_fault_candidate(callbacks, file, &strings);
			break;
		case MAPFILE_FAULT_INJECTED:
			process_record_fault_injected(callbacks, file, &strings);
			break;
		case MAPFILE_MODULE_NAME:
			process_record_module_name(callbacks, file, &strings);
			break;
		case EOF: goto done;
		default:
			fprintf(stderr, "error: unknown record type %d in file %s at position %ld\n", type, path, ftell(file));
			exit(-1);
		}
	}
done:
	process_done(callbacks);
	strings_free(&strings);
}
示例#3
0
int test_strings_free()
{
	/// 
	{
		//
		char *src = NULL;
		int result = strings_free(src);

		//
		char *assert_message = "Testing strings free for NULL..";
		int assert_result = (result == 0) ? TRUE : FALSE;
		ctest_assert_true(assert_result, assert_message);
	}

	//
	return 0;
}