示例#1
0
文件: bit.c 项目: postsql/tarantool
int
main(void)
{
	test_ctz_clz();
	test_count();
	test_rotl_rotr();
	test_bswap();
	test_index();
}
示例#2
0
void
TestSeg_Run_IMP(TestSegment *self, TestBatchRunner *runner) {
    TestBatchRunner_Plan(runner, (TestBatch*)self, 21);
    test_fields(runner);
    test_metadata_storage(runner);
    test_seg_name_and_num(runner);
    test_count(runner);
    test_Compare_To(runner);
    test_Write_File_and_Read_File(runner);
}
示例#3
0
static bool addr_count_test(void)
{
	bool success = true;

	success &= test_count(32, 1U);
	success &= test_count(31, 2U);
	success &= test_count(24, 0x100U);
	success &= test_count(16, 0x10000U);
	success &= test_count(8, 0x1000000U);
	success &= test_count(3, 0x20000000U);
	success &= test_count(2, 0x40000000U);
	success &= test_count(1, 0x80000000U);
	success &= test_count(0, 0x100000000U);

	return success;
}
示例#4
0
int main()
{
    int i = 40;
    int j = 55;
    
    system("clear");
    printf("begin run \n\n\n");
    printf("\n###INVERSION TEST###\n\n");
    run_test(0x00000001,4,3);
    run_test(0x01010101,5,4);
    run_test(0x00001000,4,3);
    printf("\n\n###SET BITS TEST###\n\n");
    test_count(0x00000001);
    test_count(0x10011001);
    test_count(0x8FF);
    printf("###CLEAR BITS TEST###\n\n");
    clear_test(0x1);
    clear_test(0x0);
    clear_test(0x85F);
    printf("####LOW BIT TEST#### \n\n");
    run_low_bits(0x00000001,2);
    run_low_bits(0xAC15,8);
    run_low_bits(0x0,1);
    printf("##########LOCAL SWAP TEST BELOW##########\n");
    swap(300000, 200000);
    printf("##########MAIN SWAP TEST BELOW##########\n");
    swap(i,j);
    printf("#########GLOBAL SWAP TEST BELOW##########\n");
    swap(i,j);
    printf("complete run \n\n\n");
    
    
    
    
    return 0;
    
}
示例#5
0
void
TestSeg_run_tests()
{
    TestBatch *batch = TestBatch_new(21);

    TestBatch_Plan(batch);
    test_fields(batch);
    test_metadata_storage(batch);
    test_seg_name_and_num(batch);
    test_count(batch);
    test_Compare_To(batch);
    test_Write_File_and_Read_File(batch);

    DECREF(batch);
}
int main(int argc, char **argv)
{
    int nerrors = 0;

    MPI_Init(&argc, &argv);
    /* baseline: this tiny value should pose no problems */
    nerrors += test_count(60);
    /* one with no next-to-high-bits set */
    nerrors += test_count(0x3654321f71234567);
    /* masking after shift can help the count_high, but count_low is still
     * wrong */
    nerrors += test_count(0x7654321f71234567);
    /* original problematic count reported by Artem Yalozo */
    nerrors += test_count(0x7654321ff1234567);

    if (nerrors != 0) {
        fprintf(stderr, "found %d errors\n", nerrors);
    }
    else {
        printf(" No Errors\n");
    }
    MPI_Finalize();
    return 0;
}
示例#7
0
文件: tests.c 项目: DownGoat/plstr
int main () {

    test_slice_positive_sub_str();
    test_slice_equal_offlim();
    test_slice_negative_offset();
    test_slice_negative_limit();
    test_slice_both_negative();
    test_slice_limit_oor();
    test_slice_offset_oor();
    test_slice_empty_string();
    test_strcpy_no_alloc();
    test_strcpy_pre_alloc();
    test_strcpy_not_empty();
    test_strcpy_empty_paras();
    test_strcat();
    test_strcat_empty_source();
    test_strcat_empty_destination();
    test_strcat_empty_params();
    test_split();
    test_split_multiple_delims();
    test_split_delim_not_found();
    test_split_empty_delim();
    test_split_single_delim();
    test_split_empty_paras();
    test_startswith();
    test_startwith_empy_string();
    test_startwith_empy_prefix();
    test_startwith_empty_params();
    test_endswith();
    test_endswith_empty_string();
    test_endswith_empty_postfix();
    test_endswith_empty_params();
    test_strip_no_chars();
    test_strip_with_chars();
    test_strip_empty_params();
    test_translate();
    test_translate_empty_params();
    test_splitlines();
    test_splitlines_keepends();
    test_splitlines_empty_params();
    test_count();
    test_count_empty_params();
    test_expandtabs();
    test_expandtabs_no_params();

    return 0;
}
示例#8
0
文件: main.cpp 项目: qzmfranklin/test
int main(int argc, char const* argv[])
{ 
	int n;
	struct test_t *w = test_create(n);

	//printf("test 1\n");
	//test_print(w);
	//printf("%d\n",test_count(w));

	//printf("\n\n");

	//printf("test 2\n");
	test_print(w+1);
	printf("%d\n",test_count(w+1));


	return 0;
}
示例#9
0
文件: tests.hpp 项目: msuchard/nt2
  inline bool test_ulp_tuple_eq( char const* x1
			   , char const* x2		
			   , char const* x3				
			   , int line
			   , char const * fn			
			   , T const & t
			   , U const & u			
			   , V const & v				
			   )						
  {									
    boost::dispatch::ignore_unused(fn);                                     \
    test_count()++;							
    volatile T tt(t);							
    volatile U uu(u);							
    volatile V vv(v);
    typedef typename boost::dispatch::meta::upgrade<T>::type TT;
    typedef typename boost::dispatch::meta::upgrade<U>::type UU;
    bool r =   nt2::ulpdist(boost::fusion::at_c<0>(u), boost::fusion::at_c<0>(t)) <= v;
    r &= nt2::ulpdist(boost::fusion::at_c<1>(u), boost::fusion::at_c<1>(t)) <= v; 
    if(r)					
    {									
      std::cout << " * Test `"					
                << "ulpdist(" << x1 << ", " <<  x2 << ") <= " << x3	
                << "` **passed**."					
                << " (" << line << ")"				
                << std::endl;
      return true; 
    }									
    else								
    {									
//    std::cout << " * Test `"					
//              << "ulpdist(" << x1 << ", " <<  x2 << ") <= " << x3	
//              << "` **failed** in function "			
//              << fn << " (" << line << ")"				
//              << "ulpdist(" << TT(t) << ", " <<  UU(u) << ") == "		
//              <<  nt2::ulpdist(tt, uu )				
//              << std::endl;						
      ++error_count();
      return false; 
    }									
  }
示例#10
0
文件: tests.hpp 项目: faldah/nt2
  inline bool test_ulp_eq( char const* x1
                           , char const* x2             
                           , char const* x3                             
                           , int line
                           , char const * fn                    
                           , T const & t
                           , U const & u                        
                           , V const & v                                
                           )                                            
  {                                                                     
    test_count()++;                                                     
    /*volatile*/ T tt(t);
    /*volatile*/ U uu(u);
    /*volatile*/ V vv(v);
//     typedef typename boost::dispatch::meta::upgrade<T>::type TT;
//     typedef typename boost::dispatch::meta::upgrade<U>::type UU;
       typedef T TT;
       typedef U UU; 
    typedef typename boost::dispatch::meta::call<nt2::tag::ulpdist_(T, U)>::type R;
    if( nt2::ulpdist(T(tt), U(uu) ) <= (R)vv)
    {                                                                   
      std::cout << " * Test `"                                  
                << "ulpdist(" << x1 << ", " <<  x2 << ") ( == " << nt2::ulpdist(T(tt), U(uu) ) << ") <= " << x3     
                << "` **passed**."                                      
                << " (" << line << ")"                          
                << std::endl;
      return true; 
    }                                                                   
    else                                                                
    {
      std::cout << " * Test `"                                  
                << "ulpdist(" << x1 << ", " <<  x2 << ") <= " << x3     
                << "` **failed** in function "                  
                << fn << " (" << line << ")"                            
                << "ulpdist(" << TT(tt) << ", " <<  UU(uu) << ") == "           
                <<  nt2::ulpdist(T(tt), U(uu) )
                << std::endl;                                           
      ++error_count();
      return false; 
    }
  }
示例#11
0
  inline bool test_ulp_eq( char const* x1
			   , char const* x2		
			   , char const* x3				
			   , int line
			   , char const * fn			
			   , T const & t
			   , U const & u			
			   , V const & v				
			   )						
  {									
    test_count()++;							
    volatile T tt(t);							
    volatile U uu(u);							
    volatile V vv(v);
    typedef typename nt2::meta::upgrade<T>::type TT;
    typedef typename nt2::meta::upgrade<U>::type UU;
    typedef typename boost::common_type<TT, UU>::type R;
    if( nt2::details::ulpdist(tt, uu ) <= (R)vv)
      {									
	std::cout << " * Test `"					
		  << "details::ulpdist(" << x1 << ", " <<  x2 << ") <= " << x3	
		  << "` **passed**."					
		  << " (" << line << ")"				
		  << std::endl;
	return true; 
      }									
    else								
      {									
	std::cout << " * Test `"					
		  << "details::ulpdist(" << x1 << ", " <<  x2 << ") <= " << x3	
		  << "` **failed** in function "			
		  << fn << " (" << line << ")"				
		  << "details::ulpdist(" << TT(tt) << ", " <<  UU(uu) << ") == "		
		  <<  nt2::details::ulpdist(tt, uu )				
		  << std::endl;						
	++error_count();
	return false; 
      }									
  }									
示例#12
0
/*===========================================================================
 * Main routine
 */
int main(int argc, char **argv)
{
        unsigned int short_count = 0x1000;
        unsigned int long_count = 0x9000;
        int long_fd, short_fd, nfds, tics, expected_interrupts, c;
	int rate = 1000;
        int result;
        fd_set fds;

        while (-1 != (c = getopt(argc, argv, "hs:l:"))) {
                switch (c) {
                case 's':
                        short_count = strtol(optarg, NULL, 0);
                        break;
                case 'l':
                        long_count = strtol(optarg, NULL, 0);
                        break;
                case 'h':
                default:
                        fprintf(stderr,
                                "USAGE: tmr_read_test [-h]"
                                "[-s short interval timer count]"
                                "[-l long interval timer count]");
                        return -1;
                }
        }

        nfds = long_fd = open("/dev/timer3", O_RDWR);
        write(long_fd, &long_count, sizeof (long_count));
        ioctl(long_fd, TIMER_INTERRUPT_ENABLE);

        short_fd = open("/dev/timer1", O_RDWR);
        if (short_fd > nfds)
                nfds = short_fd;
        write(short_fd, &short_count, sizeof (short_count));
        ioctl(short_fd, TIMER_INTERRUPT_ENABLE);

        ioctl(long_fd, TIMER_RATE_SET, &rate);
        ioctl(short_fd, TIMER_RATE_SET, &rate);

        ioctl(long_fd, TIMER_START);
        ioctl(short_fd, TIMER_START);

        tics = 0;
        expected_interrupts = long_count / (short_count + 1);
        while (1) {
                FD_ZERO(&fds);
                FD_SET(long_fd, &fds);
                FD_SET(short_fd, &fds);

                select(nfds + 1, NULL, NULL, &fds, NULL);

                if (FD_ISSET(long_fd, &fds)) {
                        break;
                }

                if (FD_ISSET(short_fd, &fds)) {
                        ++tics;
                        result = test_count(long_fd, &long_count);
                        if (result) {
                                goto error;
                        }
                }
        }

        if (tics != expected_interrupts) {
                fprintf(stderr,
                        "Expected %d interrupts, received %d interrupts\n",
                        expected_interrupts, tics);
                result = -1;
        }

      error:
        printf("Test for correct timer readback: %s\n",
               (result) ? "FAIL" : "PASS");

        ioctl(short_fd, TIMER_INTERRUPT_DISABLE);
        ioctl(short_fd, TIMER_STOP);
        close(short_fd);

        ioctl(long_fd, TIMER_INTERRUPT_DISABLE);
        ioctl(long_fd, TIMER_STOP);
        close(long_fd);

        return result;
}
示例#13
0
TEST(Counter_symbol, test_input)
{
  std::string file_name("test//test_input.txt");
  counter test_count(file_name);
  EXPECT_EQ (43, test_count.symbol());
}
示例#14
0
TEST(Counter_line, test_input)
{
  std::string file_name("test//test_input.txt");
  counter test_count(file_name);
  EXPECT_EQ (4, test_count.line());
}
示例#15
0
TEST(Counter_word, test_input)
{
  std::string file_name("test//test_input.txt");
  counter test_count(file_name);
  EXPECT_EQ (10,test_count.word());
}
示例#16
0
int t_map()
{
	c_map map;

	c_map_create(&map, int_comparer);

	
	assert(__c_rb_tree_verify(map._l));
	printf("0. test create with insert unique\n");
	create_with_insert_unique(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n1. test clear\n");
	test_clear(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n2. test size and empty\n");
	test_size_empty(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n3. test create with insert equal\n");
	c_map_clear(&map);
	create_with_insert_equal(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n4. test swap\n");
	create_with_insert_unique(&map);
	test_swap(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n5. test create with insert unique1\n");
	create_with_insert_unique1(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n6. test create with insert equal1\n");
	c_map_clear(&map);
	create_with_insert_equal1(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n7. test create with insert unique2\n");
	c_map_clear(&map);
	create_with_insert_unique2(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n8. test create with insert equal2\n");
	c_map_clear(&map);
	create_with_insert_equal2(&map);
	print_map(&map);
	rprint_map(&map);
	assert(__c_rb_tree_verify(map._l));
	
	printf("\n\n9. test erase\n");
	c_map_clear(&map);
	create_with_insert_unique(&map);
	test_erase(&map);
	create_with_insert_unique(&map);	
	test_reverse_erase(&map);	
	print_map(&map);
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n10. test find and erase\n");
	c_map_clear(&map);
	printf("* test_find_erase:\n");
	create_with_insert_unique(&map);
	print_map(&map);	
	test_find_erase(&map);
	print_map(&map);	
	printf("* test_reverse_find_erase:\n");
	create_with_insert_unique(&map);
	print_map(&map);	
	test_reverse_find_erase(&map);
	print_map(&map);	
	assert(__c_rb_tree_verify(map._l));

	printf("\n\n11. test count:\n"); // 'lower_bound' 'upper_bound' 'equal_range' used	
	create_with_insert_unique(&map);
	test_count(&map);

	printf("\n\n12. test less:\n");
	test_less();

	printf("\n\n13. test equal:\n");
	test_equal();

	printf("\n\n14. test at:\n");
	test_at();
	
	c_map_destroy(&map);
	printf("\n\nfinish testing map!\n");
	return 0;
}