• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PASS函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PASS函数的典型用法代码示例。如果您正苦于以下问题:C++ PASS函数的具体用法?C++ PASS怎么用?C++ PASS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PASS函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parg_getopt_long_optarg_missing

TEST parg_getopt_long_optarg_missing(void)
{
	struct parg_state ps;
	char *argv[] = { "app", "--optarg" };
	int li = -1;

	parg_init(&ps);

	ASSERT_EQ('o', parg_getopt_long(&ps, ARRAY_SIZE(argv), argv, ":", po_def, &li));
	ASSERT_EQ(1, li);
	ASSERT_EQ(NULL, ps.optarg);
	ASSERT_EQ(2, ps.optind);

	ASSERT_EQ(-1, parg_getopt_long(&ps, ARRAY_SIZE(argv), argv, ":", po_def, &li));
	ASSERT_EQ(NULL, ps.optarg);
	ASSERT_EQ(2, ps.optind);

	PASS();
}
开发者ID:WS-Libraries,项目名称:parg,代码行数:19,代码来源:test_parg.c


示例2: basic_test_sadd_sunion

TEST basic_test_sadd_sunion(int _commit)
{
	int retval;

	rlite *db = NULL;
	RL_CALL_VERBOSE(setup_db, RL_OK, &db, _commit, 1);
	unsigned char *key = UNSIGN("my key");
	long keylen = strlen((char *)key);
	unsigned char *key2 = UNSIGN("my key2");
	long key2len = strlen((char *)key2);
	unsigned char *datas[2] = {UNSIGN("my data"), UNSIGN("my data2")};
	long dataslen[2] = {strlen((char *)datas[0]), strlen((char *)datas[1]) };
	unsigned char *datas2[3] = {UNSIGN("other data2"), UNSIGN("yet another data"), UNSIGN("my data")};
	long datas2len[3] = {strlen((char *)datas2[0]), strlen((char *)datas2[1]), strlen((char *)datas2[2])};
	unsigned char *keys[2] = {key, key2};
	long keyslen[2] = {keylen, key2len};
	unsigned char **datasunion;
	long *datasunionlen, datasc, i;

	RL_CALL_VERBOSE(rl_sadd, RL_OK, db, key, keylen, 2, datas, dataslen, NULL);
	RL_BALANCED();
	RL_CALL_VERBOSE(rl_sadd, RL_OK, db, key2, key2len, 3, datas2, datas2len, NULL);
	RL_BALANCED();

	RL_CALL_VERBOSE(rl_sunion, RL_OK, db, 2, keys, keyslen, &datasc, &datasunion, &datasunionlen);
	EXPECT_LONG(datasc, 4);

	EXPECT_BYTES(datas[1], dataslen[1], datasunion[0], datasunionlen[0]);
	EXPECT_BYTES(datas[0], dataslen[0], datasunion[1], datasunionlen[1]);
	EXPECT_BYTES(datas2[1], datas2len[1], datasunion[2], datasunionlen[2]);
	EXPECT_BYTES(datas2[0], datas2len[0], datasunion[3], datasunionlen[3]);

	for (i = 0; i < datasc; i++) {
		rl_free(datasunion[i]);
	}
	rl_free(datasunion);
	rl_free(datasunionlen);


	rl_close(db);
	PASS();
}
开发者ID:jqk6,项目名称:rlite,代码行数:42,代码来源:type_set-test.c


示例3: test_build_identity

/*  -----------------------------------------------------------------------------------
 *  Test 6: Q(qr(A)).T * Q(qr(A)) == I 
 *    OK: ||I - Q.T*Q||_1 ~~ n*eps
 */
int test_build_identity(int M, int N, int K, int lb, int verbose)
{
  char *blk = lb > 0 ? "  blk" : "unblk";
  char ct = M == K ? 'M' : 'K';
  armas_x_dense_t A0, C0, tau0, D;
  int ok;
  DTYPE n0;
  armas_conf_t conf = *armas_conf_default();

  armas_x_init(&A0, M, N);
  armas_x_init(&C0, M, M);
  armas_x_init(&tau0, imin(M, N), 1);

  // set source data
  armas_x_set_values(&A0, unitrand, ARMAS_ANY);

  // factorize
  conf.lb = lb;
  armas_x_rqfactor(&A0, &tau0, &conf);

  // compute Q = buildQ(rq(A)), K first columns
  conf.lb = lb;
  if (armas_x_rqbuild(&A0, &tau0, K, &conf) < 0)
    printf("build error: %d\n", conf.error);

  // C0 = Q.T*Q - I
  armas_x_mult(0.0, &C0, 1.0, &A0, &A0, ARMAS_TRANSB, &conf);
  armas_x_diag(&D, &C0, 0);
  armas_x_add(&D, -1.0, &conf);

  n0 = armas_x_mnorm(&C0, ARMAS_NORM_ONE, &conf);

  ok = isOK(n0, N);
  printf("%s: %s Q(rq(A),%c).T * Q(rq(A),%c) == I\n", PASS(ok), blk, ct, ct);
  if (verbose > 0) {
    printf("  || rel error ||_1: %e [%d]\n", n0, ndigits(n0));
  }
  //armas_x_release(&A0);
  armas_x_release(&C0);
  armas_x_release(&tau0);
  return ok;
}
开发者ID:hrautila,项目名称:armas,代码行数:46,代码来源:rqbld.c


示例4: main

int main(int argc, char *argv[])
{
	void *fdt;
	int subnode1_offset, subnode2_offset;
	int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2;
	int ss12_off, ss21_off;

	test_init(argc, argv);
	fdt = load_blob_arg(argc, argv);

	subnode1_offset = check_subnode(fdt, 0, "[email protected]");
	subnode2_offset = check_subnode(fdt, 0, "[email protected]");

	if (subnode1_offset == subnode2_offset)
		FAIL("Different subnodes have same offset");

	check_property_cell(fdt, subnode1_offset, "prop-int", TEST_VALUE_1);
	check_property_cell(fdt, subnode2_offset, "prop-int", TEST_VALUE_2);

	subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode");
	subsubnode2_offset = check_subnode(fdt, subnode2_offset, "[email protected]");
	subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode");

	check_property_cell(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1);
	check_property_cell(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2);
	check_property_cell(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2);

	if (subsubnode2_offset != subsubnode2_offset2)
		FAIL("Different offsets with and without unit address");

	check_subnode(fdt, subnode1_offset, "ss1");
	ss21_off = fdt_subnode_offset(fdt, subnode2_offset, "ss1");
	if (ss21_off != -FDT_ERR_NOTFOUND)
		FAIL("Incorrectly found ss1 in subnode2");

	ss12_off = fdt_subnode_offset(fdt, subnode1_offset, "ss2");
	if (ss12_off != -FDT_ERR_NOTFOUND)
		FAIL("Incorrectly found ss2 in subnode1");
	check_subnode(fdt, subnode2_offset, "ss2");

	PASS();
}
开发者ID:ActionAdam,项目名称:osmc,代码行数:42,代码来源:subnode_offset.c


示例5: test_ascii_is_white_space

bool test_ascii_is_white_space (Test *test)
{
	int i;

	TITLE ();
	for (i = SCHAR_MIN; i <= SCHAR_MAX; i++) {
		if ((char)i == ' ' ||
		    (char)i == '\f' ||
		    (char)i == '\n' ||
		    (char)i == '\r' ||
		    (char)i == '\t' ||
		    (char)i == '\v') {
			CATCH (!ascii_is_white_space ((char)i));
		}
		else {
			CATCH (ascii_is_white_space ((char)i));
		}
	}
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,代码来源:test-ascii.c


示例6: main

int main(int argc, const char* argv[])
{
	// tell dyld we want to know when images are mapped
	dyld_register_image_state_change_handler(dyld_image_state_dependents_mapped, true, batchMappedHandler);
	dyld_register_image_state_change_handler(dyld_image_state_mapped, false, singleMappedHandler);
	dyld_register_image_state_change_handler(dyld_image_state_terminated, false, singleUnmappedHandler);
	// with batch mode we get notified of existing images, but not with single mode, so re-sync counts
	batchMappedCount=0;
	
	loadAndUnLoad();

	loadAndUnLoad();
	
	if ( (singleMappedCount == batchMappedCount) && (singleMappedCount == singleUnMappedCount) )
		PASS("image-state-change");
	else
		FAIL("image-state-change: batch count=%d, single count=%d", batchMappedCount, singleMappedCount);
		
	return EXIT_SUCCESS;
}
开发者ID:Apple-FOSS-Mirror,项目名称:dyld,代码行数:20,代码来源:main.c


示例7: test_file_writer_write_args_invalid_argument_2

bool test_file_writer_write_args_invalid_argument_2 (Test *test)
{
        FileWriter *writer;
        char *path;

        TITLE ();
        CATCH (!(path = directory_current_path ()));
        CATCH (!string_append (&path, "/stage/file_writer/args"));
        if (file_exists (path)) {
                CATCH (!file_remove (path));
        }
        CATCH (!(writer = file_writer_create (path, FileWriterModeTruncate)));
        CATCH (file_writer_write_args (writer, NULL, "test"));
        CATCH (error_count () == 0);
        CATCH (error_at (0).error != ErrorInvalidArgument);
        CATCH (error_at (0).code != 2);
        file_writer_destroy (writer);
        string_destroy (path);
        PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,代码来源:test-file-writer.c


示例8: test_substr

TEST test_substr(long strsize, long start, long stop, long startindex, long expectedsize)
{
	int retval;
	unsigned char *data = malloc(sizeof(unsigned char) * strsize), *data2;
	rlite *db = NULL;
	RL_CALL_VERBOSE(rl_open, RL_OK, ":memory:", &db, RLITE_OPEN_READWRITE | RLITE_OPEN_CREATE);

	long page, i, size2;
	for (i = 0; i < strsize; i++) {
		data[i] = i % 123;
	}

	RL_CALL_VERBOSE(rl_multi_string_set, RL_OK, db, &page, data, strsize);
	RL_CALL_VERBOSE(rl_multi_string_getrange, RL_OK, db, page, &data2, &size2, start, stop);
	EXPECT_BYTES(&data[startindex], size2, data2, expectedsize);
	rl_free(data2);
	free(data);
	rl_close(db);
	PASS();
}
开发者ID:jqk6,项目名称:rlite,代码行数:20,代码来源:multi_string-test.c


示例9: test_file_remove

bool test_file_remove (Test *test)
{
	char *path;
	FILE *file;

	TITLE ();
	CATCH (file_remove (NULL));
	CATCH (file_remove ("badpathformat"));
	CATCH (!(path = directory_current_path ()));
	CATCH (!string_append (&path, "/stage/remove/file"));
        /* d stage/remove */
	if (!file_exists (path)) {
		CATCH (!(file = fopen (path, "ab+")));
		fclose (file);
	}
	CATCH (!file_remove (path));
	CATCH (file_exists (path));
	string_destroy (path);
	PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,代码来源:test-file.c


示例10: decoder_poll_should_expand_short_literal

TEST decoder_poll_should_expand_short_literal() {
    uint8_t input[] = {0xb3, 0x5b, 0xed, 0xe0 }; //"foo"
    uint8_t output[4];
    heatshrink_decoder *hsd = heatshrink_decoder_alloc(256, 7, 3);
    uint16_t count = 0;

    HSD_sink_res sres = heatshrink_decoder_sink(hsd, input, sizeof(input), &count);
    ASSERT_EQ(HSDR_SINK_OK, sres);

    uint16_t out_sz = 0;
    HSD_poll_res pres = heatshrink_decoder_poll(hsd, output, 4, &out_sz);
    ASSERT_EQ(HSDR_POLL_EMPTY, pres);
    ASSERT_EQ(3, out_sz);
    ASSERT_EQ('f', output[0]);
    ASSERT_EQ('o', output[1]);
    ASSERT_EQ('o', output[2]);

    heatshrink_decoder_free(hsd);
    PASS();
}
开发者ID:alepharchives,项目名称:heatshrink,代码行数:20,代码来源:test_heatshrink_dynamic.c


示例11: test_big_int_mul_function_call_3

bool test_big_int_mul_function_call_3 (Test *test)
{
        BigInt *a, *b, *to;

        TITLE ();
        CATCH (!(a = big_int_create (10000000000000000000ULL)));
        CATCH (!(b = big_int_create (10000000000000000000ULL)));
        CATCH (!(to = big_int_create (0)));
        memory_commit_limit (memory_commit_size () +
                             sizeof (size_t) + sizeof (BigInt) + sizeof (size_t) + 32 +
                             sizeof (size_t) + sizeof (BigInt) + sizeof (size_t) + 32 +
                             sizeof (size_t) + sizeof (BigInt) + sizeof (size_t) + 32 - 1);
        CATCH (big_int_mul (a, b, to));
        CATCH (error_at (0).error != ErrorFunctionCall);
        CATCH (error_at (0).code != 3);
        big_int_destroy (a);
        big_int_destroy (b);
        big_int_destroy (to);
        PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:20,代码来源:test-big-int.c


示例12: parg_reorder_long

TEST parg_reorder_long(void)
{
	char *argv[] = {
		"app", "first", "--reqarg", "--", "foo", "--unknown", "bar",
		"--optarg", "--", "--noarg", "last"
	};
	char *argv_expected[] = {
		"app", "--reqarg", "--", "--unknown", "--optarg", "--",
		"first", "foo", "bar", "--noarg", "last"
	};
	size_t i;

	ASSERT_EQ(6, parg_reorder(ARRAY_SIZE(argv), argv, "", po_def));

	for (i = 0; i < ARRAY_SIZE(argv); ++i) {
		ASSERT_STR_EQ(argv_expected[i], argv[i]);
	}

	PASS();
}
开发者ID:WS-Libraries,项目名称:parg,代码行数:20,代码来源:test_parg.c


示例13: parg_reorder_short

TEST parg_reorder_short(void)
{
	char *argv[] = {
		"app", "first", "-r", "--", "foo", "-u", "bar", "-o", "--",
		"-n", "last"
	};
	char *argv_expected[] = {
		"app", "-r", "--", "-u", "-o", "--", "first", "foo", "bar",
		"-n", "last"
	};
	size_t i;

	ASSERT_EQ(6, parg_reorder(ARRAY_SIZE(argv), argv, os_def, NULL));

	for (i = 0; i < ARRAY_SIZE(argv); ++i) {
		ASSERT_STR_EQ(argv_expected[i], argv[i]);
	}

	PASS();
}
开发者ID:WS-Libraries,项目名称:parg,代码行数:20,代码来源:test_parg.c


示例14: update_float32_decimals

TEST update_float32_decimals()
{
  TM_msg dummy;
  char topic[128] = "float32_decimals";
  float buf = -64.1235;
  dummy.type = TM_float32;
  dummy.buffer = (void *)&buf;
  dummy.size = 1;
  dummy.topic = topic;

  float destination;

  if(!update_f32(&dummy, "float32_decimals",  &destination))
  {
    FAIL();
  }
  ASSERT_EQ_FMT(buf, destination,"%u");

  PASS();
}
开发者ID:Overdrivr,项目名称:Telemetry,代码行数:20,代码来源:update_float_suite.c


示例15: parg_getopt_long_noarg_inline

TEST parg_getopt_long_noarg_inline(void)
{
	struct parg_state ps;
	char *argv[] = { "app", "--noarg=arg" };
	int li = -1;

	parg_init(&ps);

	ASSERT_EQ(':', parg_getopt_long(&ps, ARRAY_SIZE(argv), argv, ":", po_def, &li));
	ASSERT_EQ(0, li);
	ASSERT_EQ(NULL, ps.optarg);
	ASSERT_EQ('n', ps.optopt);
	ASSERT_EQ(2, ps.optind);

	ASSERT_EQ(-1, parg_getopt_long(&ps, ARRAY_SIZE(argv), argv, ":", po_def, &li));
	ASSERT_EQ(NULL, ps.optarg);
	ASSERT_EQ(2, ps.optind);

	PASS();
}
开发者ID:WS-Libraries,项目名称:parg,代码行数:20,代码来源:test_parg.c


示例16: basic_test_sadd_smove

TEST basic_test_sadd_smove(int _commit)
{
	int retval;

	rlite *db = NULL;
	RL_CALL_VERBOSE(setup_db, RL_OK, &db, _commit, 1);
	unsigned char *key = UNSIGN("my key");
	long keylen = strlen((char *)key);
	unsigned char *key2 = UNSIGN("my key2");
	long key2len = strlen((char *)key2);
	unsigned char *data = UNSIGN("my data");
	long datalen = strlen((char *)data);
	unsigned char *data2 = UNSIGN("other data2");
	long data2len = strlen((char *)data2);
	unsigned char *datas[2] = {data, data2};
	long dataslen[2] = {datalen, data2len};

	RL_CALL_VERBOSE(rl_sadd, RL_OK, db, key, keylen, 2, datas, dataslen, NULL);
	RL_BALANCED();

	RL_CALL_VERBOSE(rl_smove, RL_NOT_FOUND, db, key, keylen, key2, key2len, (unsigned char *)"new data", 8);
	RL_BALANCED();

	RL_CALL_VERBOSE(rl_smove, RL_OK, db, key, keylen, key2, key2len, data, datalen);
	RL_BALANCED();

	RL_CALL_VERBOSE(rl_sismember, RL_NOT_FOUND, db, key, keylen, data, datalen);
	RL_CALL_VERBOSE(rl_sismember, RL_FOUND, db, key2, key2len, data, datalen);

	RL_CALL_VERBOSE(rl_smove, RL_OK, db, key, keylen, key2, key2len, data2, data2len);
	RL_BALANCED();

	RL_CALL_VERBOSE(rl_sismember, RL_NOT_FOUND, db, key, keylen, data2, data2len);
	RL_CALL_VERBOSE(rl_sismember, RL_FOUND, db, key2, key2len, data2, data2len);

	RL_CALL_VERBOSE(rl_smove, RL_NOT_FOUND, db, key, keylen, key2, key2len, data, datalen);
	RL_CALL_VERBOSE(rl_key_get, RL_NOT_FOUND, db, key, keylen, NULL, NULL, NULL, NULL, NULL);

	rl_close(db);
	PASS();
}
开发者ID:jqk6,项目名称:rlite,代码行数:41,代码来源:type_set-test.c


示例17: test_boot_disk_cputrace

TEST test_boot_disk_cputrace() {
    const char *homedir = HOMEDIR;
    char *output = NULL;
    asprintf(&output, "%s/a2_cputrace.txt", homedir);
    if (output) {
        unlink(output);
        cpu65_trace_begin(output);
    }

    srandom(0);
    BOOT_TO_DOS();

    cpu65_trace_end();
    disk6_eject(0);

    do {
        uint8_t md[SHA_DIGEST_LENGTH];
        char mdstr0[(SHA_DIGEST_LENGTH*2)+1];

        FILE *fp = fopen(output, "r");
        fseek(fp, 0, SEEK_END);
        long expectedSize = ftell(fp);
        ASSERT(expectedSize == EXPECTED_CPU_TRACE_FILE_SIZE);
        fseek(fp, 0, SEEK_SET);
        unsigned char *buf = malloc(EXPECTED_CPU_TRACE_FILE_SIZE);
        if (fread(buf, 1, EXPECTED_CPU_TRACE_FILE_SIZE, fp) != EXPECTED_CPU_TRACE_FILE_SIZE) {
            ASSERT(false);
        }
        fclose(fp); fp = NULL;
        SHA1(buf, EXPECTED_CPU_TRACE_FILE_SIZE, md);
        FREE(buf);

        sha1_to_str(md, mdstr0);
        ASSERT(strcmp(mdstr0, EXPECTED_CPU_TRACE_SHA) == 0);
    } while(0);

    unlink(output);
    FREE(output);

    PASS();
}
开发者ID:jvernet,项目名称:apple2,代码行数:41,代码来源:testtrace.c


示例18: test_poll_close_2

bool test_poll_close_2 (Test *test)
{
        NetPoll *poll;
        NetServer *server;
        NetClientConnection connection;
        NetClient *client;

        TITLE ();
        monitor_success = false;
        close_success = false;
        poll_connection.closed = false;
        poll_connection.socket = 0;
        poll_connection.tag = NULL;
        CATCH (!(server = net_server_create ("127.0.0.1", 8888,
                                             &server_on_connect,
                                             &server_on_error,
                                             NULL)));
        CATCH (!(client = net_client_create (&client_on_connect,
                                             &client_on_connect_error,
                                             &client_on_error,
                                             NULL)));
        connection.ip = "127.0.0.1";
        connection.port = 8888;
        net_client_connect (client, &connection);
        thread_signal_wait (&server_signal);
        CATCH (!(poll = net_poll_create (&on_monitor, &on_close, NULL, NULL)));
        poll_connection.socket = server_socket;
        CATCH (!net_poll_monitor (poll, &poll_connection));
        thread_signal_wait (&monitor_signal);
        CATCH (!monitor_success);
        CATCH (!net_poll_close (poll, &poll_connection));
        thread_signal_wait (&close_signal);
        CATCH (!close_success);
        net_poll_destroy (poll);
        close (server_socket);
        close (client_socket);
        net_server_destroy (server);
        net_client_destroy (client);
        CATCH (error_count () != 0);
        PASS ();
}
开发者ID:jimmy-zhao-tainio,项目名称:project.m,代码行数:41,代码来源:test-poll-close-2.c


示例19: row_activated_cb

/** \brief Signal handler for managing double clicks in multi-pass dialog.
  * \param view Pointer to the GtkTreeView object.
  * \param path The path of the row that was activated.
  * \param column The column where the activation occured.
  * \param data Pointer to the toplevel window.
  *
  * This function is called when the user double clicks on a pass in the
  * multi-pass dialog. This will cause the pass details to be shown.
  */
static void row_activated_cb (GtkTreeView *treeview, GtkTreePath *path,
                              GtkTreeViewColumn *column, gpointer data)
{
    GtkTreeSelection *selection;
    GtkTreeModel     *model;
    GtkTreeIter       iter;
    GtkWidget        *toplevel = GTK_WIDGET (data);
    guint             rownum = 0;
    GSList           *passes = NULL;
    pass_t           *pass = NULL;
    qth_t            *qth;

    (void) path; /* avoid unused parameter compiler warning */
    (void) column; /* avoid unused parameter compiler warning */

    /* get selected satellite */
    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));

    if (gtk_tree_selection_get_selected (selection, &model, &iter))  {

        /* get data */
        passes = (GSList *) g_object_get_data (G_OBJECT (treeview), "passes");
        qth = (qth_t *) g_object_get_data (G_OBJECT (treeview), "qth");

        gtk_tree_model_get (model, &iter,
                            MULTI_PASS_COL_NUMBER, &rownum,
                            -1);

        /* get selected pass */
        pass = copy_pass (PASS (g_slist_nth_data (passes, rownum)));

        show_pass (pass->satname, qth, pass, toplevel);

    }
    else {
        sat_log_log (SAT_LOG_LEVEL_ERROR,
                     _("%s:%d: There is no selection; skip popup."),
                     __FILE__, __LINE__);
    }

}
开发者ID:kopaniapawel,项目名称:gpredict-1,代码行数:50,代码来源:sat-pass-dialogs.c


示例20: data_with_simple_repetition_should_match_with_absurdly_tiny_buffers

TEST data_with_simple_repetition_should_match_with_absurdly_tiny_buffers() {
    heatshrink_encoder *hse = heatshrink_encoder_alloc(8, 3);
    heatshrink_decoder *hsd = heatshrink_decoder_alloc(256, 8, 3);
    uint8_t input[] = {'a', 'b', 'c', 'a', 'b', 'c', 'd', 'a', 'b',
                       'c', 'd', 'e', 'a', 'b', 'c', 'd', 'e', 'f',
                       'a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b',
                       'c', 'd', 'e', 'f', 'g', 'h'};
    uint8_t comp[60];
    uint8_t decomp[60];
    uint16_t count = 0;
    int log = 0;

    if (log) dump_buf("input", input, sizeof(input));
    for (int i=0; i<sizeof(input); i++) {
        ASSERT(heatshrink_encoder_sink(hse, &input[i], 1, &count) >= 0);
    }
    ASSERT_EQ(HSER_FINISH_MORE, heatshrink_encoder_finish(hse));

    uint16_t packed_count = 0;
    do {
        ASSERT(heatshrink_encoder_poll(hse, &comp[packed_count], 1, &count) >= 0);
        packed_count += count;
    } while (heatshrink_encoder_finish(hse) == HSER_FINISH_MORE);

    if (log) dump_buf("comp", comp, packed_count);
    for (int i=0; i<packed_count; i++) {
        HSD_sink_res sres = heatshrink_decoder_sink(hsd, &comp[i], 1, &count);
        //printf("sres is %d\n", sres);
        ASSERT(sres >= 0);
    }

    for (int i=0; i<sizeof(input); i++) {
        ASSERT(heatshrink_decoder_poll(hsd, &decomp[i], 1, &count) >= 0);
    }

    if (log) dump_buf("decomp", decomp, sizeof(input));
    for (int i=0; i<sizeof(input); i++) ASSERT_EQ(input[i], decomp[i]);
    heatshrink_encoder_free(hse);
    heatshrink_decoder_free(hsd);
    PASS();
}
开发者ID:alepharchives,项目名称:heatshrink,代码行数:41,代码来源:test_heatshrink_dynamic.c



注:本文中的PASS函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PASSED函数代码示例发布时间:2022-05-30
下一篇:
C++ PARSE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap