int main() { SUITE("Publish"); test_publish(); test_publish_bytes(); test_publish_retained(); test_publish_not_connected(); test_publish_P(); FINISH }
int main(int argc, char* argv[]) { int ch, n = 1, conn_timeout = 10, rw_timeout = 0; acl::string addr("127.0.0.1:6379"), cmd; bool cluster_mode = false; while ((ch = getopt(argc, argv, "hs:n:C:I: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 'I': rw_timeout = atoi(optarg); break; case 'a': cmd = optarg; break; case 'c': cluster_mode = true; break; default: break; } } acl::acl_cpp_init(); acl::log::stdout_open(true); acl::redis_client_cluster cluster; cluster.set(addr.c_str(), 100, conn_timeout, rw_timeout); acl::redis_client client(addr.c_str(), conn_timeout, rw_timeout); acl::redis_pubsub redis; if (cluster_mode) redis.set_cluster(&cluster, 100); else redis.set_client(&client); bool ret; if (cmd == "subscribe") ret = test_subscribe(redis, n); else if (cmd == "publish") ret = test_publish(redis, n); 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; }