当前位置: 首页>>代码示例>>C++>>正文


C++ BitString::bits_available方法代码示例

本文整理汇总了C++中BitString::bits_available方法的典型用法代码示例。如果您正苦于以下问题:C++ BitString::bits_available方法的具体用法?C++ BitString::bits_available怎么用?C++ BitString::bits_available使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitString的用法示例。


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

示例1: main

int main(int argc, const char** argv, char **envp, char **apple) {
    srand ( time(NULL) );
    ___invalidate___ = false;
    //unit tests
    BitString bitString0;
    GeneratorContext context;
   /*
    
    if(!bitString0.is_valid())
        cout << "is_valid failed\n";
    
    if(bitString0.get_bit_offset() != 0)
        cout << "get_bit_offset failed\n";
        
    if(bitString0.get_byte_index() != 0)
        cout << "get_byte_index failed\n";
        
    bitString0.set_byte(1);
    if(bitString0.peek_byte() != 1)
        cout << "set_byte / peek_byte failed\n";
        
    if(bitString0.is_cleared())
        cout << "is_cleared failed\n";
        
    bitString0.clear();
    
    if(bitString0.is_cleared() == false)
        cout << "clear failed!\n";
        
    bitString0.write_bit(true);
    bitString0.reset_index();
    if(bitString0.peek_bit() != true)
        cout << "set_byte / peek_bit failed\n";
        
    if(bitString0.read_bit() != true)
        cout << "set_byte / read_bit failed\n";
      
    
    bitString0.clear();
    
    
    int bits = 17;
    int value = 70000;
    int read_value = 0;
    
    
    bitString0.write_bits_from_int(bits, value);
    bitString0.rewind(bits);
    read_value = bitString0.read_bits_as_int(bits);
    
    if(read_value != value)
        cout << "write_bits/read_bits failed\n";

    


        
    bitString0.gen_valid(context);

    //need enough bits for the test
    if(bitString0.bits_available() > bits + 1) {
        cout << "Test Started\n";
        bitString0.write_bit(false);
        bitString0.rewind(1);
        if(bitString0.peek_bit() != false)
            cout << "set_byte / peek_bit failed\n";
        
        if(bitString0.read_bit() != false)
            cout << "set_byte / read_bit failed\n";

        
        bitString0.set_bit_index(4);
        
        bitString0.write_bits_from_int(bits, value);
        bitString0.rewind(bits);
        read_value = bitString0.read_bits_as_int(bits);
    
        if(read_value != value)
            cout << "write_bits/read_bits failed after gen_valid with value = " << value << " and read_value " << read_value << "\n";
    }

*/
    

    BitString bitString;
    bitString.gen_valid(context);
    
    test_long_write_read(16683730362329794560ULL, 64, bitString);
    
    
    for(int i = 0; i < 1000; i++) {
        cout << "*";
        
        bitString.gen_valid(context);
        //BitString original_bitstring(bitString);
        
        //add a byte and then make sure that index is correct
        
        int available_bits = bitString.bits_available();
        
//.........这里部分代码省略.........
开发者ID:jfischoff,项目名称:bitstring,代码行数:101,代码来源:BitString_Test.cpp


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