FTermBuffer unit test now also runs on older Linux distributions without multicolored emojis
This commit is contained in:
parent
a1107f96c7
commit
28f41f5d6c
|
@ -164,6 +164,7 @@ jobs:
|
|||
before_install:
|
||||
- uname -a
|
||||
- g++ --version
|
||||
- sudo pkg install -y autoconf-archive
|
||||
script:
|
||||
- autoreconf -v --install --force
|
||||
- ./configure --prefix=/usr
|
||||
|
|
|
@ -258,9 +258,8 @@ std::size_t FLabel::getAlignOffset (const std::size_t length) const
|
|||
if ( length < width )
|
||||
return (width - length) / 2;
|
||||
}
|
||||
else if ( alignment == Align::Right )
|
||||
else if ( alignment == Align::Right && length < width )
|
||||
{
|
||||
if ( length < width )
|
||||
return width - length;
|
||||
}
|
||||
|
||||
|
|
|
@ -1484,9 +1484,8 @@ std::size_t FListView::getAlignOffset ( const Align align
|
|||
if ( column_width < width )
|
||||
return (width - column_width) / 2;
|
||||
}
|
||||
else if ( align == Align::Right )
|
||||
else if ( align == Align::Right && column_width < width )
|
||||
{
|
||||
if ( column_width < width )
|
||||
return width - column_width;
|
||||
}
|
||||
|
||||
|
|
|
@ -1880,7 +1880,7 @@ void FVTerm::init_characterLengths()
|
|||
if ( clr_eol_length == 0 )
|
||||
clr_eol_length = INT_MAX;
|
||||
}
|
||||
#include <unistd.h>
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FVTerm::init_combined_character()
|
||||
{
|
||||
|
|
|
@ -178,10 +178,10 @@ class FString
|
|||
iterator end() noexcept;
|
||||
const_iterator begin() const noexcept;
|
||||
const_iterator end() const noexcept;
|
||||
reference front() noexcept;
|
||||
reference back() noexcept;
|
||||
const_reference front() const noexcept;
|
||||
const_reference back() const noexcept;
|
||||
reference front();
|
||||
reference back();
|
||||
const_reference front() const;
|
||||
const_reference back() const;
|
||||
|
||||
template <typename... Args>
|
||||
FString& sprintf (const FString&, Args&&...);
|
||||
|
@ -403,28 +403,28 @@ inline FString::const_iterator FString::end() const noexcept
|
|||
{ return string + length; }
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::front() noexcept
|
||||
inline FString::reference FString::front()
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::reference FString::back() noexcept
|
||||
inline FString::reference FString::back()
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return (*this)[length - 1];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::front() const noexcept
|
||||
inline FString::const_reference FString::front() const
|
||||
{
|
||||
assert ( ! isEmpty() );
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
inline FString::const_reference FString::back() const noexcept
|
||||
inline FString::const_reference FString::back() const
|
||||
{
|
||||
assert( ! isEmpty() );
|
||||
return (*this)[length - 1];
|
||||
|
|
|
@ -287,6 +287,7 @@ void FTermBufferTest::writeTest()
|
|||
}
|
||||
|
||||
// Write with style
|
||||
auto multi_color_emojis = bool( wcswidth(L"☕⛄🧸🦡", 4) == 8 );
|
||||
term_buf.clear();
|
||||
auto style = finalcut::FStyle(finalcut::Style::Italic | finalcut::Style::Reverse);
|
||||
term_buf.write (style);
|
||||
|
@ -339,20 +340,25 @@ void FTermBufferTest::writeTest()
|
|||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].encoded_char[2] == L'\0' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].encoded_char[3] == L'\0' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].encoded_char[4] == L'\0' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.byte[2] != 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.byte[3] == 0 );
|
||||
|
||||
if ( multi_color_emojis )
|
||||
{
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.byte[2] != 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.bit.char_width == 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
void FTermBufferTest::streamTest()
|
||||
{
|
||||
auto multi_color_emojis = bool( wcswidth(L"🚧🚀🚴", 3) == 6 );
|
||||
const auto& data = finalcut::FTerm::getFTermData();
|
||||
data->setTermEncoding (finalcut::Encoding::UTF8);
|
||||
finalcut::FTermBuffer::FCharVector fchar_vec = { finalcut::FChar{} };
|
||||
CPPUNIT_ASSERT ( fchar_vec.size() == 1 );
|
||||
fchar_vec.front().ch[0] = L'🥨';
|
||||
fchar_vec.front().ch[0] = L'🚧';
|
||||
fchar_vec.front().fg_color = finalcut::FColor::White;
|
||||
fchar_vec.front().bg_color = finalcut::FColor::Cyan;
|
||||
finalcut::addColumnWidth(fchar_vec.front());
|
||||
|
@ -365,7 +371,7 @@ void FTermBufferTest::streamTest()
|
|||
<< finalcut::UniChar::NF_Bullet
|
||||
<< finalcut::FStyle(finalcut::Style::Blink)
|
||||
<< fchar_vec
|
||||
<< std::string("🧭")
|
||||
<< std::string("🚀")
|
||||
<< finalcut::FStyle(finalcut::Style::None)
|
||||
<< finalcut::FStyle(finalcut::Style::DoubleUnderline)
|
||||
<< finalcut::FColorPair{finalcut::FColor::Black, finalcut::FColor::White}
|
||||
|
@ -394,28 +400,37 @@ void FTermBufferTest::streamTest()
|
|||
CPPUNIT_ASSERT ( term_buf.getBuffer()[2].attr.byte[0] != 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[2].attr.byte[1] == 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[2].attr.bit.char_width == 1 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].ch[0] == L'🥨' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].ch[0] == L'🚧' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].fg_color == finalcut::FColor::White );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].bg_color == finalcut::FColor::Cyan );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].attr.byte[0] == 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].attr.byte[1] == 0 );
|
||||
|
||||
if ( multi_color_emojis )
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[3].attr.bit.char_width == 2 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].ch[0] == L'🧭' );
|
||||
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].ch[0] == L'🚀' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].fg_color == finalcut::FColor::Cyan );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].bg_color == finalcut::FColor::White );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].attr.bit.dim == 1 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].attr.bit.blink == 1 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].attr.byte[0] != 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].attr.byte[1] == 0 );
|
||||
|
||||
if ( multi_color_emojis )
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[4].attr.bit.char_width == 2 );
|
||||
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].ch[0] == L'🚴' );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].fg_color == finalcut::FColor::Black );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].bg_color == finalcut::FColor::White );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].attr.bit.dbl_underline == 1 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].attr.byte[0] == 0 );
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].attr.byte[1] != 0 );
|
||||
|
||||
if ( multi_color_emojis )
|
||||
CPPUNIT_ASSERT ( term_buf.getBuffer()[5].attr.bit.char_width == 2 );
|
||||
CPPUNIT_ASSERT ( term_buf.toString() == "a1\U0000e1f9🥨🧭🚴" );
|
||||
|
||||
CPPUNIT_ASSERT ( term_buf.toString() == "a1\U0000e1f9🚧🚀🚴" );
|
||||
|
||||
for (std::size_t i{0}; i < 6; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue