MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / split

Method split

extern/libcds/test/unit/misc/split_bitstring.cpp:720–755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718 protected:
719 template <typename Int>
720 void split( Int const n )
721 {
722 cds::algo::number_splitter< Int > splitter( n );
723
724 // split by hex digit
725 for ( unsigned count = 4; count < sizeof( Int ) * 8; count += 4 ) {
726 EXPECT_EQ( splitter.cut( 4 ), static_cast<Int>( count / 4 - 1 ));
727 }
728
729 // random cut
730 for ( int i = 0; i < 100; ++i ) {
731 splitter.reset();
732 EXPECT_EQ( splitter.source(), n );
733 EXPECT_EQ( splitter.bit_offset(), 0u );
734 EXPECT_EQ( splitter.rest_count(), sizeof( Int ) * 8 );
735
736 unsigned total = 0;
737 Int result = 0;
738
739 while ( total < sizeof( Int ) * 8 ) {
740 unsigned count = std::rand() % 16;
741
742 unsigned shift = count;
743 if ( total + count > sizeof( Int ) * 8 )
744 shift = sizeof( Int ) * 8 - total;
745
746 result += splitter.safe_cut( count ) << total;
747 total += shift;
748 }
749
750 EXPECT_EQ( result, n );
751
752 EXPECT_EQ( splitter.bit_offset(), sizeof( Int ) * 8 );
753 EXPECT_EQ( splitter.rest_count(), 0u );
754 }
755 }
756 };
757
758

Callers 5

_URangeFunction · 0.45
ReadUnicodeTableFunction · 0.45
parse_re2_benchlogMethod · 0.45
read_hexFunction · 0.45
inprintFunction · 0.45

Calls 6

cutMethod · 0.45
resetMethod · 0.45
sourceMethod · 0.45
bit_offsetMethod · 0.45
rest_countMethod · 0.45
safe_cutMethod · 0.45

Tested by

no test coverage detected