mirror of
https://github.com/catchorg/Catch2.git
synced 2025-06-07 16:01:13 +00:00
Report benchmark durations in natural units
(and extended StringRef to be able to report utf8 char lengths
This commit is contained in:
parent
4421672fb8
commit
519db85758
5 changed files with 106 additions and 8 deletions
|
@ -136,7 +136,23 @@ namespace Catch {
|
|||
auto StringRef::size() const noexcept -> size_type {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
auto StringRef::numberOfCharacters() const noexcept -> size_type {
|
||||
size_type noChars = m_size;
|
||||
// Make adjustments for uft encodings
|
||||
for( size_type i=0; i < m_size; ++i ) {
|
||||
char c = m_start[i];
|
||||
if( ( c & 0b11000000 ) == 0b11000000 ) {
|
||||
if( ( c & 0b11100000 ) == 0b11000000 )
|
||||
noChars--;
|
||||
else if( ( c & 0b11110000 ) == 0b11100000 )
|
||||
noChars-=2;
|
||||
else if( ( c & 0b11111000 ) == 0b11110000 )
|
||||
noChars-=3;
|
||||
}
|
||||
}
|
||||
return noChars;
|
||||
}
|
||||
|
||||
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> String {
|
||||
StringBuilder buf;
|
||||
buf.reserve( lhs.size() + rhs.size() );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue