Exemple #1
0
int main()
{
    test_trim();
    test_toupper_tolower();
    test_compare_icase();
    test_sstream();
    test_prefix_suffix();
    test_replace();
    test_split_ws();
    test_split();
    test_join();
    test_contains();
    test_extract_between();
    test_random();
    test_hexdump();
    test_base64();
    test_uri_decode();
    test_levenshtein();

#if HAVE_OPENSSL
    test_crypto_digest();
#endif

    return 0;
}
Exemple #2
0
  static void execute_test() {
    pasl::util::cmdline::argmap<thunk_t> c;
    c.add("push_pop_lifo",  [&]() { test_pushpop<lifo>(); });
    c.add("push_pop_fifo", [&]() { test_pushpop<fifo>(); });
    c.add("concat", [&]() { test_concat(); });
    c.add("split", [&]() { test_split(); });
    c.add("split_concat", [&]() { test_split_concat(); });
    pasl::util::cmdline::dispatch_by_argmap_with_default_all(c, "only");

  }
Exemple #3
0
int
main (int argc, char *argv[])
{
  test_split ();
  test_concat ();
  test_join ();
  test_validate_guid ();

  exit (EXIT_SUCCESS);
}
Exemple #4
0
int main(void)
{
	test_split();
	//test_reverse(7);
	//test_reverse(2);	
	//test_reverse(1);	
	//test_reverse(0);
	//test_reverse(100);
	
	//test_insert_into_sorted_list(10);
	
	return 0;
}
Exemple #5
0
int main()
{
    test_cpy();
    test_int();
    test_long();
    test_real();
    test_idx();
    test_trim();
    test_split();
    test_match();

    return 0;
}
Exemple #6
0
int
main (void) {

	test_new ();
	test_import ();
	test_split ();
	test_replace ();
	test_copy ();
	test_cut ();
	test_search ();
	test_tail_head ();
	return 0;
}
int main( int argc , char ** argv) {
  test_empty();
  test_char();
  test_join();
  test_reverse();
  test_iget_as_int();
  test_iget_as_bool();
  test_iget_as_double();
  test_split();
  test_matching();
  test_unique();
  test_predicate_matching();
  exit(0);
}
Exemple #8
0
int main(int, char**) {
  plan_tests(69);
  test_integrals();
  test_strings();
  test_pointers();
  test_double();
  test_concat();
  test_suffix();
  test_to();
  test_path_cat();
  test_basename_dirname();
  test_operator();
  test_split();

  return exit_status();
}
Exemple #9
0
int main () {

    test_slice_positive_sub_str();
    test_slice_equal_offlim();
    test_slice_negative_offset();
    test_slice_negative_limit();
    test_slice_both_negative();
    test_slice_limit_oor();
    test_slice_offset_oor();
    test_slice_empty_string();
    test_strcpy_no_alloc();
    test_strcpy_pre_alloc();
    test_strcpy_not_empty();
    test_strcpy_empty_paras();
    test_strcat();
    test_strcat_empty_source();
    test_strcat_empty_destination();
    test_strcat_empty_params();
    test_split();
    test_split_multiple_delims();
    test_split_delim_not_found();
    test_split_empty_delim();
    test_split_single_delim();
    test_split_empty_paras();
    test_startswith();
    test_startwith_empy_string();
    test_startwith_empy_prefix();
    test_startwith_empty_params();
    test_endswith();
    test_endswith_empty_string();
    test_endswith_empty_postfix();
    test_endswith_empty_params();
    test_strip_no_chars();
    test_strip_with_chars();
    test_strip_empty_params();
    test_translate();
    test_translate_empty_params();
    test_splitlines();
    test_splitlines_keepends();
    test_splitlines_empty_params();
    test_count();
    test_count_empty_params();
    test_expandtabs();
    test_expandtabs_no_params();

    return 0;
}
Exemple #10
0
int
main (int argc, char *argv[])
{
  test_split ();
  test_concat ();
  test_join ();
  test_validate_guid ();
  test_drive_name ();
  test_drive_index ();
  test_getumask ();
  test_command ();
  test_qemu_escape_param ();
  test_timeval_diff ();
  test_match ();
  test_stringsbuf ();

  exit (EXIT_SUCCESS);
}
int main(void) {
	assert(R_Type_BytesAllocated == 0);
	test_set_get();
	test_append_bytes();
	test_int_float_string();
	test_getSubString();
	test_setHex();
	test_json_formatting();
	test_shift();
	test_trim();
	test_split();
	test_base64();
	test_puts();
	test_is_same();

	assert(R_Type_BytesAllocated == 0);
	printf("Pass\n");
}
Exemple #12
0
int main()
{
	if (test_replace()==0 && test_replace_any()==0 &&
	test_trim_left()==0 && test_trim_right()==0 && test_trim()==0 &&
	test_str2hex()==0 &&
	test_split()==0 && test_split_first()==0 && test_split_second()==0 &&
	test_vexec()==0 &&
	test_json_set()==0 &&
	test_hash()==0 &&
	test_random()==0 &&
	test_local()==0
	)
	{
		std::cout << "Success" << std::endl;
		return EXIT_SUCCESS;
	} else {
		std::cerr << "Fail" << std::endl;
		return EXIT_FAILURE;
	}
}
Exemple #13
0
 void func()
 {
     test_splitn();
     test_interval();
     test_combine();
     test_extract();
     test_split();
     test_trim();
     test_urldecode();
     test_querystring();
     test_str_pat_match();
     test_munge();
     test_counter_filename();
     test_stripext();
     test_explode();
     test_sql_quote();
     test_js_quote();
     test_iso_8601_datetime();
     test_is_valid_settings_name();
 }
void CommonTestsSuite::Run() {
	test_Endianess();
	test_isNumeric();
	test_lowerCase();
	test_upperCase();
	test_ltrim();
	test_rtrim();
	test_trim();
	test_replace();
	test_split();
	test_mapping();
	test_format();
	test_splitFileName();
	test_generateRandomString();
	test_GetHostByName();
	test_md5();
	test_HMACsha256();
	test_b64();
	test_unb64();
	test_unhex();
	test_ParseURL();
	test_setFdOptions();
}
Exemple #15
0
int
main(int argc, char *argv[])
{
	char buf[32];
	SQLINTEGER int_buf;
	SQLLEN len;
	SQLRETURN rc;

	odbc_connect();

	lc = 1;
	type = SQL_C_CHAR;
	test_split("");

	lc = sizeof(SQLWCHAR);
	type = SQL_C_WCHAR;
	test_split("");

	if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x07000000u) {
		lc = 1;
		type = SQL_C_CHAR;
		test_split("N");

		lc = sizeof(SQLWCHAR);
		type = SQL_C_WCHAR;
		test_split("N");
	}

	/* test with fixed length */
	odbc_command("SELECT CONVERT(INT, 12345)");

	CHKFetch("S");

	int_buf = 0xdeadbeef;
	CHKGetData(1, SQL_C_SLONG, &int_buf, 0, NULL, "S");
	if (int_buf != 12345) {
		printf("Wrong data result\n");
		exit(1);
	}

	CHKGetData(1, SQL_C_SLONG, &int_buf, 0, NULL, "No");
	if (int_buf != 12345) {
		printf("Wrong data result 2 res = %d\n", (int) int_buf);
		exit(1);
	}

	odbc_reset_statement();

	/* test with numeric */
	odbc_command("SELECT CONVERT(NUMERIC(18,5), 1850000000000)");

	CHKFetch("S");

	memset(buf, 'x', sizeof(buf));
	CHKGetData(1, SQL_C_CHAR, buf, 14, NULL, "S");
	buf[sizeof(buf)-1] = 0;
	if (strcmp(buf, "1850000000000") != 0) {
		printf("Wrong data result: %s\n", buf);
		exit(1);
	}

	/* should give NO DATA */
	CHKGetData(1, SQL_C_CHAR, buf, 14, NULL, "No");
	buf[sizeof(buf)-1] = 0;
	if (strcmp(buf, "1850000000000") != 0) {
		printf("Wrong data result 3 res = %s\n", buf);
		exit(1);
	}

	odbc_reset_statement();


	/* test int to truncated string */
	odbc_command("SELECT CONVERT(INTEGER, 12345)");
	CHKFetch("S");

	/* error 22003 */
	memset(buf, 'x', sizeof(buf));
	CHKGetData(1, SQL_C_CHAR, buf, 4, NULL, "E");
#ifdef ENABLE_DEVELOPING
	buf[4] = 0;
	if (strcmp(buf, "xxxx") != 0) {
		fprintf(stderr, "Wrong buffer result buf = %s\n", buf);
		exit(1);
	}
#endif
	odbc_read_error();
	if (strcmp(odbc_sqlstate, "22003") != 0) {
		fprintf(stderr, "Unexpected sql state %s returned\n", odbc_sqlstate);
		odbc_disconnect();
		exit(1);
	}
	CHKGetData(1, SQL_C_CHAR, buf, 2, NULL, "No");
	odbc_reset_statement();

	/* test unique identifier to truncated string */
	rc = odbc_command2("SELECT CONVERT(UNIQUEIDENTIFIER, 'AA7DF450-F119-11CD-8465-00AA00425D90')", "SENo");
	if (rc != SQL_ERROR) {
		CHKFetch("S");

		/* error 22003 */
		CHKGetData(1, SQL_C_CHAR, buf, 17, NULL, "E");
		odbc_read_error();
		if (strcmp(odbc_sqlstate, "22003") != 0) {
			fprintf(stderr, "Unexpected sql state %s returned\n", odbc_sqlstate);
			odbc_disconnect();
			exit(1);
		}
		CHKGetData(1, SQL_C_CHAR, buf, 2, NULL, "No");
	}
	odbc_reset_statement();


	odbc_disconnect();

	odbc_use_version3 = 1;
	odbc_connect();

	/* test error from SQLGetData */
	/* wrong constant, SQL_VARCHAR is invalid as C type */
	test_err("prova 123",           SQL_VARCHAR,     "HY003");
	/* use ARD but no ARD data column */
	test_err("prova 123",           SQL_ARD_TYPE,    "07009");
	/* wrong conversion, int */
	test_err("prova 123",           SQL_C_LONG,      "22018");
	/* wrong conversion, date */
	test_err("prova 123",           SQL_C_TIMESTAMP, "22018");
	/* overflow */
	test_err("1234567890123456789", SQL_C_LONG,      "22003");

	/* test for empty string from mssql */
	if (odbc_db_is_microsoft()) {
		lc = 1;
		type = SQL_C_CHAR;

		for (;;) {
			void *buf = ODBC_GET(lc);

			odbc_command("SELECT CONVERT(TEXT,'')");

			CHKFetch("S");

			len = 1234;
			CHKGetData(1, type, buf, lc, &len, "S");

			if (len != 0) {
				fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len);
				return 1;
			}

			CHKGetData(1, type, buf, lc, NULL, "No");
			odbc_reset_statement();
			ODBC_FREE();

			buf = ODBC_GET(4096*lc);

			odbc_command("SELECT CONVERT(TEXT,'')");

			CHKFetch("S");

			len = 1234;
			CHKGetData(1, type, buf, lc*4096, &len, "S");

			if (len != 0) {
				fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len);
				return 1;
			}

			CHKGetData(1, type, buf, lc*4096, NULL, "No");
			odbc_reset_statement();
			ODBC_FREE();

			if (type != SQL_C_CHAR)
				break;
			lc = sizeof(SQLWCHAR);
			type = SQL_C_WCHAR;
		}	

		odbc_command("SELECT CONVERT(TEXT,'')");

		CHKFetch("S");

		len = 1234;
		CHKGetData(1, SQL_C_BINARY, buf, 1, &len, "S");

		if (len != 0) {
			fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len);
			return 1;
		}

		CHKGetData(1, SQL_C_BINARY, buf, 1, NULL, "No");
	}

	odbc_disconnect();

	printf("Done.\n");
	return 0;
}
TEST(space_splitter, empty) {
  std::vector<std::pair<size_t, size_t> > empty;
  test_split("", empty);
  test_split("   ", empty);
  test_split("\n\t", empty);
}
Exemple #17
0
int
main()
{
    cu_init();

    test_path("", NULL);
    test_path("/", "/");
    test_path(".", ".");
    test_path("./", ".");
    test_path("/.", "/");
    test_path("..", "..");
    test_path("../", "..");
    test_path("/..", NULL);
    test_path("../..", "../..");
    test_path(".//./", ".");
    test_path("..///.", "..");
    test_path("../..///", "../..");
    test_path("a", "a");
    test_path("a/", "a");
    test_path("/a", "/a");
    test_path("./a", "a");
    test_path("././a/.", "a");
    test_path("a/b", "a/b");
    test_path("/a/b/", "/a/b");
    test_path("//a//b//.", "/a/b");
    test_path("a/./b/./../.", "a");
    test_path("a/b/../..", ".");
    test_path("a/b/..//../../..", "../..");
    test_path("a/.././b", "b");
    test_path("a/../../b/..", "..");
    test_path("bla/blaa/", "bla/blaa");
    test_path("bla/blaa//", "bla/blaa");
    test_path("/bla", "/bla");
    test_path("//bla", "/bla");
    test_path("test/./bla", "test/bla");
    test_path("test/../bla", "bla");
    test_path("test/../../bla", "../bla");
    test_path("test/../../bla/be/../../..", "../..");
    test_split_join();

    test_join(".", "..", "..");
    test_join("a/b", "..", "a");
    test_join("a/b", "../..", ".");
    test_join("a/b", "../../..", "..");
    test_join("../a", "..", "..");
    test_join("../a", "../..", "../..");
    test_join(".", ".", ".");

    test_split("/", 0, ".", "/");
    test_split("/", 1, "/", ".");
    test_split(".", 0, ".", ".");
    test_split("a", 0, ".", "a");
    test_split("a", 1, "a", ".");
    test_split("a", -1, ".", "a");
    test_split("/a", 0, ".", "/a");
    test_split("/a", 1, "/", "a");
    test_split("/a", 2, "/a", ".");
    test_split("/a", -1, "/", "a");
    test_split("/a", -2, ".", "/a");
    test_split("../vu", 0, ".", "../vu");
    test_split("../vu", 1, "..", "vu");
    test_split("../vu", 2, "../vu", ".");
    test_split("../vu", -1, "..", "vu");
    test_split("../vu", -2, ".", "../vu");

    test_depth(".", 0, 0);
    test_depth("/", 1, 1);
    test_depth("a", 1, 1);
    test_depth("a/b", 2, 2);
    test_depth("..", -1, 1);
    test_depth("../..", -2, 2);
    test_depth("../a/b", 1, 3);
    test_depth("/al", 2, 2);

    return errors != 0;
}
TEST(space_splitter, trivial) {
  std::vector<std::pair<size_t, size_t> > bounds;
  bounds.push_back(std::make_pair(0, 4));

  test_split("hoge", bounds);
  test_split("hoge ", bounds);
  test_split("hoge\n", bounds);
  test_split("hoge\t", bounds);

  bounds.clear();
  bounds.push_back(std::make_pair(1, 4));
  test_split(" hoge", bounds);
  test_split(" hoge ", bounds);
  test_split("\nhoge\n", bounds);
  test_split("\thoge\t", bounds);

  bounds.clear();
  bounds.push_back(std::make_pair(2, 4));
  test_split("  hoge", bounds);
  test_split("  hoge  ", bounds);

  bounds.clear();
  bounds.push_back(std::make_pair(2, 4));
  bounds.push_back(std::make_pair(8, 4));
  bounds.push_back(std::make_pair(14, 4));
  test_split("  hoge  hoge  hoge  ", bounds);

  bounds.clear();
  bounds.push_back(std::make_pair(2, 1));
  bounds.push_back(std::make_pair(5, 1));
  test_split("  .  .", bounds);
}