int main()
{
  // 8 to 3 encoder test (using vec<bool>)
  std::vector<bool> vb_in(8,0);
  vb_in[4] = true; // 10000
  std::vector<bool> vb_out = encoder(vb_in);
  reverse_print_vector(vb_in);
  std::cout << " --> [encoder] --> ";
  reverse_print_vector(vb_out);
  std::cout << "\n\n";

  // 3 to 8 decoder test (using vec<bool>)
  std::vector<bool> vb_out2 = decoder(vb_out); // using output from encoder from last test
  reverse_print_vector(vb_out);
  std::cout << " --> [decoder] --> ";
  reverse_print_vector(vb_out2);
  std::cout << "\n\n";

  // 8 to 1 muxer test, using input from 8 to 3 encoder test
  std::vector<bool> sw(3,0); // switch input for muxer, set to 100
  sw[2] = true;

  std::vector<bool> muxer_out = mux(vb_in, sw);
  reverse_print_vector(vb_in);
  std::cout << " --- > +-----+ " << "\n";
  std::cout << "               | mux | --> "; 
  reverse_print_vector(muxer_out);
  std::cout << "\n";
  reverse_print_vector(sw);
  std::cout << "      --- > +-----+\n";
}
Ejemplo n.º 2
0
int t_vector()
{
    c_vector vt;
    __c_vector(&vt, int_comparer);
    

    printf("1.test create vector\n");
    create_with_push_back(&vt);
    print_vector(&vt);
    reverse_print_vector(&vt);
    clear_vector(&vt);
    
    printf("\n\n2.test vector assign\n");
    create_with_push_back(&vt);    
    vector_assign(&vt);
    clear_vector(&vt);
    
    printf("\n\n3.test erase vector\n");
    erase_vector();
    
    printf("\n\n4.test reserve vector\n");
    create_with_push_back(&vt);
    vector_reserve(&vt);
    clear_vector(&vt);
    
    printf("\n\n5.test front back\n");
    create_with_push_back(&vt);
    vector_front_back(&vt);
    clear_vector(&vt);

    printf("\n\n6.test swap\n");
    create_with_push_back(&vt);
    vector_swap(&vt);
    clear_vector(&vt);

    printf("\n\n7.test insert\n");
    vector_insert(&vt);
    clear_vector(&vt);    
    
    printf("\n\n8.test insert2\n");
    create_with_push_back(&vt);
    vector_insert2(&vt);
    clear_vector(&vt);
    
    printf("\n\n9.test fill insert\n");
    create_with_push_back(&vt);
    vector_fill_insert(&vt);
    clear_vector(&vt);
    
    printf("\n\n10.test resize\n");
    create_with_push_back(&vt);
    vector_resize(&vt);
    clear_vector(&vt);
        
    printf("\n\n11.test equal\n");
    create_with_push_back(&vt);
    vector_equal(&vt);
    clear_vector(&vt);
    
    printf("\n\n12.test less\n");
    create_with_push_back(&vt);
    vector_less(&vt);
    clear_vector(&vt);        
    
    __c_rotcev(&vt);
    printf("\n\nfinish testing vector!\n");
    return 0;
}