TEST(ppb_url_request_info, ltrim)
{
    test_ltrim("", "");
    test_ltrim("hello", "hello");
    test_ltrim("   hello", "hello");
    test_ltrim(" \t  hello", "hello");
    test_ltrim("\n\nhello", "hello");
}
예제 #2
0
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();
}
예제 #3
0
파일: redis_list.cpp 프로젝트: nitsel88/acl
int main(int argc, char* argv[])
{
	int  ch, n = 50, conn_timeout = 10, rw_timeout = 10;
	acl::string addr("127.0.0.1:6379"), cmd("all");
	bool cluster_mode = false;

	acl::log::stdout_open(true);

	while ((ch = getopt(argc, argv, "hs:n:C:T:a:c")) > 0)
	{
		switch (ch)
		{
		case 'h':
			usage(argv[0]);
			return 0;
		case 's':
			addr = optarg;
			break;
		case 'n':
			n = atoi(optarg);
			break;
		case 'C':
			conn_timeout = atoi(optarg);
			break;
		case 'T':
			rw_timeout = atoi(optarg);
			break;
		case 'a':
			cmd = optarg;
			break;
		case 'c':
			cluster_mode = true;
			break;
		default:
			break;
		}
	}

	acl::acl_cpp_init();

	acl::redis_client_cluster cluster(conn_timeout, rw_timeout);
	cluster.set(addr.c_str(), 100);

	acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout);

	acl::redis_list redis(&client);
	
	if (cluster_mode)
		redis.set_cluster(&cluster, 100);
	else
		redis.set_client(&client);

	bool ret;

	if (cmd == "lpush")
	{
		ret = test_lpush(redis, n)
			&& test_lpush2(redis, n)
			&& test_lpush3(redis, n)
			&& test_lpush4(redis, n)
			&& test_lpush5(redis, n)
			&& test_lpush6(redis, n);
	}
	else if (cmd == "rpush")
		ret = test_rpush(redis, n)
			&& test_rpush2(redis, n)
			&& test_rpush3(redis, n)
			&& test_rpush4(redis, n)
			&& test_rpush5(redis, n)
			&& test_rpush6(redis, n);
	else if (cmd == "lpushx")
		ret = test_lpushx(redis, n) && test_lpushx2(redis, n);
	else if (cmd == "rpushx")
		ret = test_rpushx(redis, n) && test_rpushx2(redis, n);
	else if (cmd == "lrange")
		ret = test_lrange(redis);
	else if (cmd == "rpop")
		ret = test_rpop(redis, n);
	else if (cmd == "lpop")
		ret = test_lpop(redis, n);
	else if (cmd == "blpop")
		ret = test_blpop(redis, n);
	else if (cmd == "brpop")
		ret = test_brpop(redis, n);
	else if (cmd == "rpoplpush")
		ret = test_rpoplpush(redis, n);
	else if (cmd == "brpoplpush")
		ret = test_brpoplpush(redis, n);
	else if (cmd == "lrem")
		ret = test_lrem(redis, n);
	else if (cmd == "ltrim")
		ret = test_ltrim(redis, n);
	else if (cmd == "llen")
		ret = test_llen(redis, n);
	else if (cmd == "lindex")
		ret = test_lindex(redis, n);
	else if (cmd == "lset")
		ret = test_lset(redis, n);
	else if (cmd == "linsert_before")
		ret = test_linsert_before(redis,1);
	else if (cmd == "linsert_after")
		ret = test_linsert_after(redis,1);
	else
	{
		ret = false;
		printf("unknown cmd: %s\r\n", cmd.c_str());
	}

	if (ret == true)
		printf("test OK!\r\n");
	else
		printf("test failed!\r\n");
	
#ifdef WIN32
	printf("enter any key to exit\r\n");
	getchar();
#endif

	return 0;
}