Skip to content

Commit

Permalink
Qt: ignore strings in Q_CLASSINFO and Q_MOC_INCLUDE
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Jun 15, 2024
1 parent 12787d8 commit fbc709e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/i18n_review.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ namespace i18n_check
// Qt
L"Q_ASSERT", L"Q_ASSERT_X", L"qSetMessagePattern", L"qmlRegisterUncreatableMetaObject",
L"addShaderFromSourceCode", L"QStandardPaths::findExecutable", L"QDateTime::fromString",
L"qCDebug", L"qDebug",
L"qCDebug", L"qDebug", L"Q_MOC_INCLUDE", L"Q_CLASSINFO",
// Catch2
L"TEST_CASE", L"BENCHMARK", L"TEMPLATE_TEST_CASE", L"SECTION", L"DYNAMIC_SECTION",
L"REQUIRE", L"REQUIRE_THROWS_WITH", L"REQUIRE_THAT", L"CHECK", L"CATCH_ENFORCE",
Expand Down
38 changes: 38 additions & 0 deletions tests/cpptests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,44 @@ QString test = QApplication::translate("SomeContext", "more source content");)";
}
}

TEST_CASE("Qt no-loc", "[cpp][i18n]")
{
SECTION("Q_MOC_INCLUDE")
{
cpp_i18n_review cpp;
cpp.set_min_words_for_classifying_unavailable_string(1);
const wchar_t* code = LR"(Q_MOC_INCLUDE("myheader"))"; // don't include extension
cpp(code, L"");
cpp.review_strings();
CHECK(cpp.get_localizable_strings().size() == 0);
CHECK(cpp.get_internal_strings().size() == 1);
CHECK(cpp.get_unsafe_localizable_strings().size() == 0);
}

SECTION("Q_CLASSINFO")
{
cpp_i18n_review cpp;
cpp.set_min_words_for_classifying_unavailable_string(1);
const wchar_t* code = LR"(class MyClass : public QObject
{
Q_OBJECT
Q_CLASSINFO("Author", "Joe Smith")
Q_CLASSINFO("URL", "http://www.my-organization.qc.ca")
public:)";
cpp(code, L"");
cpp.review_strings();
CHECK(cpp.get_localizable_strings().size() == 0);
CHECK(cpp.get_not_available_for_localization_strings().size() == 0);
REQUIRE(cpp.get_internal_strings().size() == 4);
CHECK(cpp.get_internal_strings()[0].m_string == L"Author");
CHECK(cpp.get_internal_strings()[1].m_string == L"Joe Smith");
CHECK(cpp.get_internal_strings()[2].m_string == L"URL");
CHECK(cpp.get_internal_strings()[3].m_string == L"http://www.my-organization.qc.ca");
CHECK(cpp.get_unsafe_localizable_strings().size() == 0);
}
}

TEST_CASE("Deprecated functions & macros", "[cpp][i18n]")
{
SECTION("Functions")
Expand Down

0 comments on commit fbc709e

Please sign in to comment.