Skip to content

Commit

Permalink
Fix boundary issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed May 15, 2024
1 parent 2c5be72 commit 9abd74d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/i18n_review.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,11 @@ namespace i18n_check
{
return std::wstring_view{};
}
for (int64_t i = str.length() - 2; i >= 0; --i)
if (str.length() == 1)
{
return is_valid_name_char(str[0]) ? str : std::wstring_view{};
}
for (int64_t i = str.length() - 1; i >= 0; --i)
{
if (!is_valid_name_char(str[static_cast<size_t>(i)]))
{
Expand Down
8 changes: 6 additions & 2 deletions tests/cpptests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ MyWindow::MyWindow()
{
QLabel *senderLabel = new QLabel(tr("Name:"));
QLabel *recipientLabel = new QLabel(tr("Name:", "recipient"));
})";
}
QLabel *label = new QLabel(
s("Password:"), logwid);
)";
cpp(code, L"");
cpp.review_strings();
REQUIRE(cpp.get_localizable_strings().size() == 4);
Expand All @@ -404,10 +407,11 @@ MyWindow::MyWindow()
CHECK(cpp.get_localizable_strings()[2].m_string == L"Name:");
CHECK(cpp.get_localizable_strings()[3].m_string == L"Name:");
CHECK(cpp.get_not_available_for_localization_strings().size() == 0);
REQUIRE(cpp.get_internal_strings().size() == 2);
REQUIRE(cpp.get_internal_strings().size() == 3);
// context portion of translate() and tr()
CHECK(cpp.get_internal_strings()[0].m_string == L"LoginWidget");
CHECK(cpp.get_internal_strings()[1].m_string == L"recipient");
CHECK(cpp.get_internal_strings()[2].m_string == L"Password:");
CHECK(cpp.get_unsafe_localizable_strings().size() == 0);
}

Expand Down

0 comments on commit 9abd74d

Please sign in to comment.