Beispiel #1
0
/* Returns true if SA contains at least one copy of STRING, otherwise false.

   This function runs in O(n) time in the number of strings in SA. */
bool
string_array_contains (const struct string_array *sa, const char *string)
{
  return string_array_find (sa, string) != SIZE_MAX;
}
Beispiel #2
0
int
main_initialize(void) {
	foundation_config_t config;
	application_t application;
	int ret;
	size_t iarg, asize;
	const string_const_t* cmdline = environment_command_line();

	_test_memory_tracker = true;
	for (iarg = 0, asize = array_size(cmdline); iarg < asize; ++iarg) {
		if (string_equal(STRING_ARGS(cmdline[iarg]), STRING_CONST("--no-memory-tracker")))
			_test_memory_tracker = false;
	}

	if (_test_memory_tracker)
		memory_set_tracker(memory_tracker_local());

	memset(&config, 0, sizeof(config));
#if BUILD_MONOLITHIC
	//For fs monitor test
	config.fs_monitor_max = 1;
	//For temporary allocator test, 256KiB
	config.temporary_memory = 256 * 1024;
	//For testing static hash store
	config.hash_store_size = 32 * 1024;
	//Test preallocation of random state buffers
	config.random_state_prealloc = 4;
#endif

	memset(&application, 0, sizeof(application));
	application.name = string_const(STRING_CONST("Foundation library test suite"));
	application.short_name = string_const(STRING_CONST("test_all"));
	application.company = string_const(STRING_CONST("Rampant Pixels"));
	application.version = foundation_version();
	application.flags = APPLICATION_UTILITY;
	application.exception_handler = test_exception_handler;

	log_set_suppress(0, ERRORLEVEL_INFO);

#if (FOUNDATION_PLATFORM_IOS || FOUNDATION_PLATFORM_ANDROID) && BUILD_ENABLE_LOG
	log_set_handler(test_log_handler);
#endif

#if !FOUNDATION_PLATFORM_IOS && !FOUNDATION_PLATFORM_ANDROID && !FOUNDATION_PLATFORM_PNACL

	_test_should_start = true;

#endif

	ret = foundation_initialize(memory_system_malloc(), application, config);

#if BUILD_MONOLITHIC
	//For monolithic process test
	if (string_array_find(cmdline, array_size(cmdline), STRING_CONST("wait for kill")) >= 0) {
		while (true)
			thread_sleep(100);
	}

	test_set_suitable_working_directory();
#endif
	return ret;
}