Esempio n. 1
0
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:
 *
 * Return:	Success:
 *
 *		Failure:
 *
 * Programmer:	Robb Matzke
 *              Tuesday, June 16, 1998
 *
 *-------------------------------------------------------------------------
 */
int
main(void)
{
    int	nerrors = 0;

    /*
     * Open the library explicitly.
     */
    H5open();

    nerrors += test_find() < 0 ? 1 : 0;
    nerrors += test_set() < 0 ? 1 : 0;
    nerrors += test_clear() < 0 ? 1 : 0;
    nerrors += test_copy() < 0 ? 1 : 0;
    nerrors += test_shift() < 0 ? 1 : 0;
    nerrors += test_increment() < 0 ? 1 : 0;
    nerrors += test_decrement() < 0 ? 1 : 0;
    nerrors += test_negate() < 0 ? 1 : 0;

    if(nerrors) {
        printf("***** %u FAILURE%s! *****\n",
               nerrors, 1 == nerrors ? "" : "S");
        exit(1);
    }
    printf("All bit tests passed.\n");

    H5close();

    return 0;
}
Esempio n. 2
0
/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:
 *
 * Return:	Success:
 *
 *		Failure:
 *
 * Programmer:	Robb Matzke
 *              Tuesday, June 16, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
main (void)
{
    int	nerrors=0;

    /*
     * Open the library explicitly for thread-safe builds, so per-thread
     * things are initialized correctly.
     */
#ifdef H5_HAVE_THREADSAFE
    H5open();
#endif  /* H5_HAVE_THREADSAFE */

    nerrors += test_find ()<0?1:0;
    nerrors += test_set  ()<0?1:0;
    nerrors += test_clear()<0?1:0;
    nerrors += test_copy ()<0?1:0;
    nerrors += test_shift()<0?1:0;
    nerrors += test_increment  ()<0?1:0;
    nerrors += test_decrement  ()<0?1:0;
    nerrors += test_negate  ()<0?1:0;

    if (nerrors) {
        printf("***** %u FAILURE%s! *****\n",
               nerrors, 1==nerrors?"":"S");
        exit(1);
    }
    printf("All bit tests passed.\n");

#ifdef H5_HAVE_THREADSAFE
    H5close();
#endif  /* H5_HAVE_THREADSAFE */
    return 0;
}
Esempio n. 3
0
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");
}
Esempio n. 4
0
int main()
{
	int failures = 0;
	printf("Starting linked list test...\n");
	failures += test_create();
	failures += test_append_element();
	failures += test_prepend_element();
	failures += test_prepend_five();
	failures += test_append_five();
	failures += test_add_many();
	failures += test_add_struct();
	failures += test_append_list();
	failures += test_append_list_empty();
	failures += test_prepend_list();
	failures += test_prepend_list_empty();
	failures += test_reverse();
	failures += test_shallow_copy();
	failures += test_shift();
	failures += test_reduce();
	failures += test_insert();
	failures += test_insert_at_head();
	failures += test_insert_at_tail();
	failures += test_delete();
	failures += test_delete_at_head();
	failures += test_delete_at_tail();
	failures += test_index();
	failures += test_destroy();
	failures += test_clear();
	failures += test_llist_index_of_f();
	failures += test_to_array();
	failures += test_delete_last();
	failures += test_delete_last_few();
	if (0 == failures) {
		printf("All tests ok.\n");
	} else {
		printf("%d test(s) FAILED.\n", failures);
		return 1;
	}

	return 0;
}
Esempio n. 5
0
int main(int argc, char **argv)
{
	struct bitvec bv;
	uint8_t i = 8, test[i];

	memset(test, 0, i);
	bv.data_len = i;
	bv.data = test;
	bv.cur_bit = 0;

	printf("test shifting...\n");

	bitvec_set_uint(&bv, 0x0E, 7);
	test_shift(&bv, 3);
	test_shift(&bv, 17);
	bitvec_set_uint(&bv, 0, 32);
	bitvec_set_uint(&bv, 0x0A, 7);
	test_shift(&bv, 24);

	printf("checking RL functions...\n");

	bitvec_zero(&bv);
	test_rl(&bv);
	bitvec_set_uint(&bv, 0x000F, 32);
	test_rl(&bv);
	bitvec_shiftl(&bv, 18);
	test_rl(&bv);
	bitvec_set_uint(&bv, 0x0F, 8);
	test_rl(&bv);
	bitvec_zero(&bv);
	bitvec_set_uint(&bv, 0xFF, 8);
	test_rl(&bv);
	bitvec_set_uint(&bv, 0xFE, 7);
	test_rl(&bv);
	bitvec_set_uint(&bv, 0, 17);
	test_rl(&bv);
	bitvec_shiftl(&bv, 18);
	test_rl(&bv);

	printf("probing bit access...\n");

	bitvec_zero(&bv);
	bitvec_set_uint(&bv, 0x3747817, 32);
	bitvec_shiftl(&bv, 10);

	test_get(&bv, 2);
	test_get(&bv, 7);
	test_get(&bv, 9);
	test_get(&bv, 13);
	test_get(&bv, 16);
	test_get(&bv, 42);

	printf("feeling bit fills...\n");

	test_set(&bv, ONE);
	test_fill(&bv, 3, ZERO);
	test_spare(&bv, 38);
	test_spare(&bv, 43);
	test_spare(&bv, 1);
	test_spare(&bv, 7);
	test_fill(&bv, 5, ONE);
	test_fill(&bv, 3, L);

	printf("byte me...\n");

	test_byte_ops();
	test_unhex("48282407a6a074227201000b2b2b2b2b2b2b2b2b2b2b2b");
	test_unhex("47240c00400000000000000079eb2ac9402b2b2b2b2b2b");
	test_unhex("47283c367513ba333004242b2b2b2b2b2b2b2b2b2b2b2b");
	test_unhex("DEADFACE000000000000000000000000000000BEEFFEED");
	test_unhex("FFFFFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB");

	printf("arrr...\n");

	test_array();

	printf("\nbitvec ok.\n");

	return 0;
}
Esempio n. 6
0
int main(void) {
  uint32_t i, j;
  uint64_t a, b;
  uint32_t x[2], y[2];

  printf("--- bit size = 5 ---\n");
  for (i=0; i<32; i++) {
    for (j=0; j<7; j++) {
      a = i;
      b = j;
      test_shift64(a, b, 5);
      x[0] = i; x[1] = 0;
      y[0] = j; y[1] = 0;
      test_shift(x, y, 5);
      printf("---\n");
    }
  }

  // more tests with size = 64bits
  a = 6;
  test_shift64(a << 4, 0, 64);
  test_shift64(a << 4, 1, 64);
  test_shift64(a << 4, 2, 64);
  test_shift64(a << 4, 3, 64);
  test_shift64(a << 4, 4, 64);
  test_shift64(a << 4, 5, 64);
  test_shift64(a << 4, 63, 64);
  test_shift64(a << 4, 64, 64);
  test_shift64(a << 4, 65, 64);

  a ^= ~((uint64_t) 0);
  test_shift64(a << 4, 0, 64);
  test_shift64(a << 4, 1, 64);
  test_shift64(a << 4, 2, 64);
  test_shift64(a << 4, 3, 64);
  test_shift64(a << 4, 4, 64);
  test_shift64(a << 4, 5, 64);
  test_shift64(a << 4, 63, 64);
  test_shift64(a << 4, 64, 64);
  test_shift64(a << 4, 65, 64);


  x[0] = 6 << 4;
  x[1] = 0;
  y[0] = 0;
  y[1] = 0;
  test_shift(x, y, 62);
  y[0] = 1;
  test_shift(x, y, 62);
  y[0] = 10;
  test_shift(x, y, 62);
  y[1] = 2;
  test_shift(x, y, 62);

  x[1] = 0xFF000000;
  x[0] = 0x55555555;
  y[0] = 0;
  y[1] = 0;
  test_shift(x, y, 64);
  y[0] = 1;
  test_shift(x, y, 64);
  y[0] = 10;
  test_shift(x, y, 64);
  y[1] = 2;
  test_shift(x, y, 64);

  return 0;
}
int main(int argc , char ** argv) {
  
  int_vector_type * int_vector = int_vector_alloc( 0 , 99);
  
  test_abort();
  test_assert_int_equal( -1 , int_vector_index(int_vector , 100));
  test_assert_int_equal( -1 , int_vector_index_sorted(int_vector , 100));

  test_assert_true( int_vector_is_instance( int_vector ));
  test_assert_false( double_vector_is_instance( int_vector ));
  int_vector_iset( int_vector , 2 , 0);       
  int_vector_insert( int_vector , 2 , 77 );   
  int_vector_iset( int_vector , 5 , -10);     
  
  assert_equal( int_vector_iget(int_vector , 0 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 1 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 2 ) == 77 );
  assert_equal( int_vector_iget(int_vector , 3 ) == 00 );
  assert_equal( int_vector_iget(int_vector , 4 ) == 99 );
  assert_equal( int_vector_iget(int_vector , 5 ) == -10 );
  
  {
    int N1 = 100000;
    int N2 = 10*N1;
    int_vector_type * v1 = int_vector_alloc( N1 , 0 );
    int_vector_type * v2;
    int * data1 = int_vector_get_ptr( v1 );
    int_vector_iset( v1 , N1 - 1, 99);

    int_vector_free_container( v1 );
    v2 = int_vector_alloc( N2 , 0 );
    int_vector_iset(v2 , N2 - 1, 77 );
    
    test_assert_int_equal(  data1[N1-1] , 99);
    int_vector_free( v2 );
    free( data1 );
  }                 
  
  
  test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) );
  test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100);
  test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215);
  test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330);
  test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445);
  test_assert_int_equal( int_vector_get_last( int_vector ) , 1000);
  
  test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) );
  test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100);
  test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215);
  test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330);
  test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445);
  test_assert_int_equal( int_vector_get_last( int_vector ) , 1000);

  {
    int_vector_type * v1 = int_vector_alloc(0,0);
    int_vector_type * v2 = int_vector_alloc(0,0);
    int_vector_append(v1 , 10);
    int_vector_append(v1 , 15);
    int_vector_append(v1 , 20);

    int_vector_append(v2 , 1);
    int_vector_append(v2 , 2);
    int_vector_append(v2 , 3);

    int_vector_append_vector( v1 , v2 );
    test_assert_int_equal( int_vector_size( v1 ) , 6 );
    test_assert_int_equal( int_vector_iget (v1 ,  0 ), 10 );
    test_assert_int_equal( int_vector_iget (v1 ,  1 ), 15 );
    test_assert_int_equal( int_vector_iget (v1 ,  2 ), 20 );
                                                               
    test_assert_int_equal( int_vector_iget (v1 ,  3 ), 1 );
    test_assert_int_equal( int_vector_iget (v1 ,  4 ), 2 );
    test_assert_int_equal( int_vector_iget (v1 ,  5 ), 3 );

    int_vector_free( v1 );
    int_vector_free( v2 );
  }
  test_contains();
  test_contains_sorted();
  test_shift();
  test_alloc();
  test_div();
  test_memcpy_from_data();
  test_idel_insert();
  test_del();
  test_range_fill();
  test_iset_block();
  test_resize();
  test_empty();
  test_insert_double();
  exit(0);
}