コード例 #1
0
ファイル: map_test.c プロジェクト: kragniz/mushroom
TEST test_large_map(void)
{
	struct mushroom_map *map = mushroom_map_new();
	ASSERT_EQ_FMT((size_t)0, mushroom_map_get_count(map), "%zu");

	int key_number = 300;

	for (int i = 0; i < key_number; i++) {
		char key[10];
		sprintf(key, "key-%d", i);
		mushroom_map_put(map, key, key);
	}

	char *value = mushroom_map_get(map, "key-9");
	ASSERT(value != NULL);
	ASSERT_STR_EQ("key-9", value);

	for (int i = 0; i < key_number; i++) {
		char key[10];
		sprintf(key, "key-%d", i);
		mushroom_map_put(map, key, key);
		value = mushroom_map_get(map, key);
		ASSERT(value != NULL);
		ASSERT_STR_EQ(key, value);
	}

	value = mushroom_map_get(map, "key-9");
	ASSERT(value != NULL);
	ASSERT_STR_EQ("key-9", value);
	ASSERT_EQ_FMT((size_t)300, mushroom_map_get_count(map), "%zu");

	mushroom_map_free(map);

	PASS();
}
コード例 #2
0
TEST test_inter_recon_bipred()
{


	memcpy(result.rec.y, lcu1.rec.y, sizeof(kvz_pixel) * 64 * 64);
	memcpy(result.rec.u, lcu1.rec.u, sizeof(kvz_pixel) * 32 * 32);
	memcpy(result.rec.v, lcu1.rec.v, sizeof(kvz_pixel) * 32 * 32);

	
	kvz_inter_recon_bipred_blend(hi_prec_luma_rec0, hi_prec_luma_rec1, hi_prec_chroma_rec0, hi_prec_chroma_rec1, width, height, xpos, ypos, high_precision_rec0, high_precision_rec1, &result, temp_lcu_y, temp_lcu_u, temp_lcu_v); 
 
 for (temp_y = 0; temp_y < height; ++temp_y) {
  int y_in_lcu = ((ypos + temp_y) & ((LCU_WIDTH)-1));
  for (temp_x = 0; temp_x < width; temp_x += 1) {
   int x_in_lcu = ((xpos + temp_x) & ((LCU_WIDTH)-1));
   printf("%d ", result.rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu]);
  }
 }
 printf("\n");
 
 /*
 for (temp_y = 0; temp_y < height >> 1; ++temp_y) {
  int y_in_lcu = (((ypos >> 1) + temp_y) & (LCU_WIDTH_C - 1));
  for (temp_x = 0; temp_x < width >> 1; ++temp_x) {
   int x_in_lcu = (((xpos >> 1) + temp_x) & (LCU_WIDTH_C - 1));
   printf("%d ", result.rec.u[y_in_lcu * LCU_WIDTH_C + x_in_lcu]);
  }
 }
 printf("\n");
 */

	for (temp_y = 0; temp_y < height; ++temp_y) {
		int y_in_lcu = ((ypos + temp_y) & ((LCU_WIDTH)-1));
		for (temp_x = 0; temp_x < width; temp_x+=1) {
			int x_in_lcu = ((xpos + temp_x) & ((LCU_WIDTH)-1));
			ASSERT_EQ_FMT(expected_test_result.rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu], result.rec.y[y_in_lcu * LCU_WIDTH + x_in_lcu], "%d");
		}
	}

	for (temp_y = 0; temp_y < height >> 1; ++temp_y) {
		int y_in_lcu = (((ypos >> 1) + temp_y) & (LCU_WIDTH_C - 1));
		for (temp_x = 0; temp_x < width >> 1; ++temp_x) {
			int x_in_lcu = (((xpos >> 1) + temp_x) & (LCU_WIDTH_C - 1));
			ASSERT_EQ_FMT(expected_test_result.rec.u[y_in_lcu * LCU_WIDTH_C + x_in_lcu], result.rec.u[y_in_lcu * LCU_WIDTH_C + x_in_lcu], "%d");
			ASSERT_EQ_FMT(expected_test_result.rec.v[y_in_lcu * LCU_WIDTH_C + x_in_lcu], result.rec.v[y_in_lcu * LCU_WIDTH_C + x_in_lcu], "%d");
		}
	}
	
	PASS();
}
コード例 #3
0
ファイル: manual_test.c プロジェクト: pteichman/roto
// The tonewheel oscillator block expects these volumes to be
// Q19. This test ensures we never overflow that range.
TEST test_manual_volume_overflow() {
    uint8_t keys[62] = {0};
    uint8_t drawbars[10] = {0};
    uint16_t ret[92] = {0};

    // Hold down all the keys on this manual.
    for (int i = 0; i < 62; i++) {
        keys[i] = 1;
    }

    // Pull out all the stops.
    for (int i = 0; i < 10; i++) {
        drawbars[i] = 8;
    }

    uint32_t total = manual_fill_volumes(keys, drawbars, ret);

    // The total volumes here cannot overflow the expected Q19 range.
    uint32_t sum = total_volume(ret);
    ASSERT_EQ_FMT(total, sum, "%d");

    if (sum > (1 << 19)) {
        char *msg = calloc(128, 1);
        snprintf(msg, 128, "overflow volume=%d (limit %d)", sum, (1 << 19));
        FAILm(msg);
        free(msg);
    }

    PASS();
}
コード例 #4
0
ファイル: manual_test.c プロジェクト: pteichman/roto
// test_manual_drawbar_incr ensures one tonewheel gets louder as its
// drawbar is extended.
TEST test_manual_drawbar_incr() {
    uint8_t keys[62] = {0};
    uint8_t drawbars[10] = {0};
    uint16_t ret[92] = {0};

    // Hold down key 30.
    keys[30] = 1;

    for (int d = 1; d < 10; d++) {
        int steps = 0;
        uint32_t prevsum = 0;

        for (int v = 0; v < 128; v++) {
            drawbars[d] = manual_quantize_drawbar(v);
            manual_fill_volumes(keys, drawbars, ret);

            uint32_t sum = total_volume(ret);
            if (sum != prevsum) {
                steps++;
            }

            prevsum = sum;
            drawbars[d] = 0;
        }

        ASSERT_EQ_FMT(8, steps, "%d");
    }

    PASS();
}
コード例 #5
0
TEST decoder_poll_should_expand_short_literal_and_backref(void) {
    uint8_t input[] = {0xb3, 0x5b, 0xed, 0xe0, 0x41, 0x00}; //"foofoo"
    uint8_t output[6];
    heatshrink_decoder *hsd = heatshrink_decoder_alloc(256, 7, 6);
    memset(output, 0, sizeof(*output));
    size_t count = 0;
    
    HSD_sink_res sres = heatshrink_decoder_sink(hsd, input, sizeof(input), &count);
    ASSERT_EQ(HSDR_SINK_OK, sres);

    size_t out_sz = 0;
    (void)heatshrink_decoder_poll(hsd, output, 6, &out_sz);

    if (0) dump_buf("output", output, out_sz);
    ASSERT_EQ_FMT(6, out_sz, "%d");
    ASSERT_EQ('f', output[0]);
    ASSERT_EQ('o', output[1]);
    ASSERT_EQ('o', output[2]);
    ASSERT_EQ('f', output[3]);
    ASSERT_EQ('o', output[4]);
    ASSERT_EQ('o', output[5]);

    heatshrink_decoder_free(hsd);
    PASS();
}
コード例 #6
0
ファイル: manual_test.c プロジェクト: pteichman/roto
// test_manual_tonewheel ensures each key+drawbar combination is
// connected to the correct tonewheel.
TEST test_manual_tonewheel() {
    // key 1 drawbar 1 -> tonewheel 13 (foldback)
    ASSERT_EQ_FMT(13, tonewheel(1, 1), "%d");
    ASSERT_EQ_FMT(20, tonewheel(1, 2), "%d");
    ASSERT_EQ_FMT(13, tonewheel(1, 3), "%d");
    ASSERT_EQ_FMT(25, tonewheel(1, 4), "%d");
    ASSERT_EQ_FMT(32, tonewheel(1, 5), "%d");
    ASSERT_EQ_FMT(37, tonewheel(1, 6), "%d");
    ASSERT_EQ_FMT(41, tonewheel(1, 7), "%d");
    ASSERT_EQ_FMT(44, tonewheel(1, 8), "%d");
    ASSERT_EQ_FMT(49, tonewheel(1, 9), "%d");

    PASS();
}
コード例 #7
0
TEST framing_simple_frame()
{
  uint8_t outgoingBuffer[12] = {0};

  initialize_framing();
  outgoing_storage(outgoingBuffer,12);

  begin();
  append(0xFF);
  uint32_t amount = end();

  ASSERT_EQ_FMT(3,amount,"%d");

  uint8_t expected[] = {0xF7, 0xFF, 0x7F};
  uint16_t range = amount > 3 ? 3 : amount;
  for(uint16_t i = 0 ; i < range ; i++)
  {
    ASSERT_EQ_FMT(expected[i],outgoingBuffer[i],"%x");
  }

  PASS();
}
コード例 #8
0
ファイル: manual_test.c プロジェクト: pteichman/roto
TEST test_manual_foldback() {
    // Lower foldback: wrap tonewheels < 13 back into the 13..92 range.
    for (int i = 1; i < 13; i++) {
        ASSERT_EQ_FMT(i + 12, foldback(i), "%d");
    }

    // No foldback applied up through tonewheel 92.
    for (int i = 13; i < 92; i++) {
        ASSERT_EQ_FMT(i, foldback(i), "%d");
    }

    // Upper foldback: the first octave above 91 is mapped down one octave.
    for (int i = 92; i < 104; i++) {
        ASSERT_EQ_FMT(i - 12, foldback(i), "%d");
    }

    // Upper foldback: the next octave is mapped down two octaves.
    for (int i = 104; i < 116; i++) {
        ASSERT_EQ_FMT(i - 24, foldback(i), "%d");
    }

    PASS();
}
コード例 #9
0
ファイル: map_test.c プロジェクト: kragniz/mushroom
TEST test_weird_string_map(void)
{
	struct mushroom_map *map = mushroom_map_new();
	char key[] = { '\x80', '\0' };
	char value[] = { '\x06', '\0' };
	mushroom_map_put(map, key, value);
	char *v = mushroom_map_get(map, key);
	ASSERT(v != NULL);
	ASSERT_STR_EQ(value, v);
	ASSERT_EQ_FMT((size_t)1, mushroom_map_get_count(map), "%zu");

	mushroom_map_free(map);

	PASS();
}
コード例 #10
0
TEST framing_overflow()
{
  uint8_t outgoingBuffer[3] = {0};

  initialize_framing();
  outgoing_storage(outgoingBuffer,3);

  begin();
  append(0xFF);
  append(0xFF);
  uint32_t amount = end();

  ASSERT_EQ_FMT(0,amount,"%d");

  PASS();
}
コード例 #11
0
ファイル: map_test.c プロジェクト: kragniz/mushroom
TEST test_map_for_each_key(void)
{
	struct mushroom_map *map = mushroom_map_new();

	for (int i = 0; i < 15; i++) {
		char key[10];
		sprintf(key, "key-%d", i);
		mushroom_map_put(map, key, key);
	}

	/* count the number of times the function was called */
	for_item_count = 0;
	mushroom_map_for_each_key(map, &for_item);
	ASSERT_EQ_FMT(15, for_item_count, "%i");

	mushroom_map_free(map);

	PASS();
}
コード例 #12
0
TEST emplace_int8_neg()
{
    TM_msg dummy;
    int8_t buf = -64;
    dummy.type = TM_int8;
    dummy.buffer = (void *)&buf;
    dummy.size = 1;

    int8_t destination;

    if(!emplace_i8(&dummy, &destination))
    {
        FAIL();
    }

    ASSERT_EQ_FMT(buf, destination,"%u");

    PASS();
}
コード例 #13
0
TEST emplace_int32()
{
    TM_msg dummy;
    int32_t buf = 64;
    dummy.type = TM_int32;
    dummy.buffer = (void *)&buf;
    dummy.size = 1;

    int32_t destination;

    if(!emplace_i32(&dummy, &destination))
    {
        FAIL();
    }

    ASSERT_EQ_FMT(buf, destination,"%d");

    PASS();
}
コード例 #14
0
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();
}
コード例 #15
0
ファイル: pub_sub_int_suite.c プロジェクト: klenov/Telemetry
TEST publish_int8()
{
  TM_state state;
  uint16_t i;
  for(i = 0 ; i < OUTGOING_BUFFER_SIZE ; i++)
  {
    endBuffer[i] = 0;
    state.rcvTopic[i] = 0;
  }
  sizeWritten = 0;
  sizeRead = 0;
  state.rcvInt8 = 0;
  state.called = 0;

  TM_transport transport;
  transport.read = read_int;
  transport.write = write_int;
  transport.readable = readable_int;
  transport.writeable = writeable_int;

  char topic[] = "topic";
  int8_t value = 127;

  init_telemetry(&transport);

  subscribe(callback_int,&state);

  publish_i8(topic, value);

  update_telemetry(0);

  ASSERT_EQ(state.called, 1);
  ASSERT_STR_EQ(topic,state.rcvTopic);
  ASSERT_EQ_FMT(value,state.rcvInt8,"%d");

  PASS();
}
コード例 #16
0
ファイル: map_test.c プロジェクト: kragniz/mushroom
TEST test_map(void)
{
	struct mushroom_map *map = mushroom_map_new();
	ASSERT_EQ_FMT((size_t)0, mushroom_map_get_count(map), "%zu");

	/* try to get some key that doesn't exist */
	char *value = mushroom_map_get(map, "key-doesn't-exist");
	ASSERT_EQ_FMT(NULL, (void *)value, "%p");

	/* store a value */
	mushroom_map_put(map, "key", "value");
	value = mushroom_map_get(map, "key");
	ASSERT_STR_EQ("value", value);
	ASSERT_EQ_FMT((size_t)1, mushroom_map_get_count(map), "%zu");

	/* update the value to something else */
	mushroom_map_put(map, "key", "value-2");
	value = mushroom_map_get(map, "key");
	ASSERT_STR_EQ("value-2", value);
	ASSERT_EQ_FMT((size_t)1, mushroom_map_get_count(map), "%zu");

	/* delete the item */
	mushroom_map_delete(map, "key");
	value = mushroom_map_get(map, "key");
	ASSERT_EQ_FMT(NULL, (void *)value, "%p");
	ASSERT_EQ_FMT((size_t)0, mushroom_map_get_count(map), "%zu");

	/* write again */
	mushroom_map_put(map, "key", "value-1");
	value = mushroom_map_get(map, "key");
	ASSERT_STR_EQ("value-1", value);
	ASSERT_EQ_FMT((size_t)1, mushroom_map_get_count(map), "%zu");

	mushroom_map_free(map);

	PASS();
}
コード例 #17
0
ファイル: example.c プロジェクト: Bloodknight/SmallLibraries
TEST expect_int_equal_printing_hex(void) {
    int a = 0xba5eba11;
    int b = 0xf005ba11;
    ASSERT_EQ_FMT(a, b, "0x%08x");
    PASS();
}