UnitTests: More QString fixes

Change-Id: Id1c60dfa8b3ada2c855f43437a153042cfec9f63
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Marco Bubke
2019-04-04 15:50:11 +02:00
parent 51176c92ff
commit 71e6c40cc2
4 changed files with 69 additions and 64 deletions

View File

@@ -130,7 +130,7 @@ static QString tweakName(const Utf8String &oldName)
if (!oldName.contains('>')) if (!oldName.contains('>'))
return QString(); return QString();
QString fullName = QString(oldName).trimmed(); QString fullName = oldName.toString().trimmed();
if (!fullName.endsWith('>')) { if (!fullName.endsWith('>')) {
// This is the class<type>::method case - remove ::method part // This is the class<type>::method case - remove ::method part
if (!fullName.endsWith("create") || !fullName.contains("QSharedPointer")) if (!fullName.endsWith("create") || !fullName.contains("QSharedPointer"))

View File

@@ -361,8 +361,8 @@ SourceRangeContainer toRangeContainer(const UnsavedFile &file, CXSourceRange cxS
QTC_ASSERT(startLine == endLine, return SourceRangeContainer();); QTC_ASSERT(startLine == endLine, return SourceRangeContainer(););
const Utf8String lineText = file.lineRange(startLine, endLine); const Utf8String lineText = file.lineRange(startLine, endLine);
startColumn = QString(lineText.mid(0, startColumn - 1)).size() + 1; startColumn = lineText.mid(0, startColumn - 1).toString().size() + 1;
endColumn = QString(lineText.mid(0, endColumn - 1)).size() + 1; endColumn = lineText.mid(0, endColumn - 1).toString().size() + 1;
return SourceRangeContainer(SourceLocationContainer(file.filePath(), startLine, startColumn), return SourceRangeContainer(SourceLocationContainer(file.filePath(), startLine, startColumn),
SourceLocationContainer(file.filePath(), endLine, endColumn)); SourceLocationContainer(file.filePath(), endLine, endColumn));

View File

@@ -37,7 +37,7 @@ MATCHER_P(HasBuiltIn,
std::string(negation ? "isn't " : "is ") std::string(negation ? "isn't " : "is ")
+ PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::BuiltIn})) + PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::BuiltIn}))
{ {
return arg.path == path && arg.type == HeaderPathType::BuiltIn; return arg.path == QString(path) && arg.type == HeaderPathType::BuiltIn;
} }
MATCHER_P(HasSystem, MATCHER_P(HasSystem,
@@ -45,7 +45,7 @@ MATCHER_P(HasSystem,
std::string(negation ? "isn't " : "is ") std::string(negation ? "isn't " : "is ")
+ PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::System})) + PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::System}))
{ {
return arg.path == path && arg.type == HeaderPathType::System; return arg.path == QString(path) && arg.type == HeaderPathType::System;
} }
MATCHER_P(HasFramework, MATCHER_P(HasFramework,
@@ -53,7 +53,7 @@ MATCHER_P(HasFramework,
std::string(negation ? "isn't " : "is ") std::string(negation ? "isn't " : "is ")
+ PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::Framework})) + PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::Framework}))
{ {
return arg.path == path && arg.type == HeaderPathType::Framework; return arg.path == QString(path) && arg.type == HeaderPathType::Framework;
} }
MATCHER_P(HasUser, MATCHER_P(HasUser,
@@ -61,7 +61,7 @@ MATCHER_P(HasUser,
std::string(negation ? "isn't " : "is ") std::string(negation ? "isn't " : "is ")
+ PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::User})) + PrintToString(HeaderPath{QString::fromUtf8(path), HeaderPathType::User}))
{ {
return arg.path == path && arg.type == HeaderPathType::User; return arg.path == QString(path) && arg.type == HeaderPathType::User;
} }
class HeaderPathFilter : public testing::Test class HeaderPathFilter : public testing::Test

View File

@@ -339,7 +339,12 @@ TEST_F(ProjectUpdater, ToolChainArguments)
auto arguments = updater.toolChainArguments(&projectPart); auto arguments = updater.toolChainArguments(&projectPart);
ASSERT_THAT(arguments, ASSERT_THAT(arguments,
ElementsAre("-m32", "-fPIC", "--target=target", "extraflags", "-include", "config.h")); ElementsAre(QString{"-m32"},
QString{"-fPIC"},
QString{"--target=target"},
QString{"extraflags"},
QString{"-include"},
QString{"config.h"}));
} }
TEST_F(ProjectUpdater, ToolChainArgumentsMSVC) TEST_F(ProjectUpdater, ToolChainArgumentsMSVC)
@@ -352,61 +357,61 @@ TEST_F(ProjectUpdater, ToolChainArgumentsMSVC)
auto arguments = updater.toolChainArguments(&projectPart); auto arguments = updater.toolChainArguments(&projectPart);
ASSERT_THAT(arguments, ASSERT_THAT(arguments,
ElementsAre("-m32", ElementsAre(QString{"-m32"},
"--target=target", QString{"--target=target"},
"extraflags", QString{"extraflags"},
"-U__clang__", QString{"-U__clang__"},
"-U__clang_major__", QString{"-U__clang_major__"},
"-U__clang_minor__", QString{"-U__clang_minor__"},
"-U__clang_patchlevel__", QString{"-U__clang_patchlevel__"},
"-U__clang_version__", QString{"-U__clang_version__"},
"-U__cpp_aggregate_bases", QString{"-U__cpp_aggregate_bases"},
"-U__cpp_aggregate_nsdmi", QString{"-U__cpp_aggregate_nsdmi"},
"-U__cpp_alias_templates", QString{"-U__cpp_alias_templates"},
"-U__cpp_aligned_new", QString{"-U__cpp_aligned_new"},
"-U__cpp_attributes", QString{"-U__cpp_attributes"},
"-U__cpp_binary_literals", QString{"-U__cpp_binary_literals"},
"-U__cpp_capture_star_this", QString{"-U__cpp_capture_star_this"},
"-U__cpp_constexpr", QString{"-U__cpp_constexpr"},
"-U__cpp_decltype", QString{"-U__cpp_decltype"},
"-U__cpp_decltype_auto", QString{"-U__cpp_decltype_auto"},
"-U__cpp_deduction_guides", QString{"-U__cpp_deduction_guides"},
"-U__cpp_delegating_constructors", QString{"-U__cpp_delegating_constructors"},
"-U__cpp_digit_separators", QString{"-U__cpp_digit_separators"},
"-U__cpp_enumerator_attributes", QString{"-U__cpp_enumerator_attributes"},
"-U__cpp_exceptions", QString{"-U__cpp_exceptions"},
"-U__cpp_fold_expressions", QString{"-U__cpp_fold_expressions"},
"-U__cpp_generic_lambdas", QString{"-U__cpp_generic_lambdas"},
"-U__cpp_guaranteed_copy_elision", QString{"-U__cpp_guaranteed_copy_elision"},
"-U__cpp_hex_float", QString{"-U__cpp_hex_float"},
"-U__cpp_if_constexpr", QString{"-U__cpp_if_constexpr"},
"-U__cpp_inheriting_constructors", QString{"-U__cpp_inheriting_constructors"},
"-U__cpp_init_captures", QString{"-U__cpp_init_captures"},
"-U__cpp_initializer_lists", QString{"-U__cpp_initializer_lists"},
"-U__cpp_inline_variables", QString{"-U__cpp_inline_variables"},
"-U__cpp_lambdas", QString{"-U__cpp_lambdas"},
"-U__cpp_namespace_attributes", QString{"-U__cpp_namespace_attributes"},
"-U__cpp_nested_namespace_definitions", QString{"-U__cpp_nested_namespace_definitions"},
"-U__cpp_noexcept_function_type", QString{"-U__cpp_noexcept_function_type"},
"-U__cpp_nontype_template_args", QString{"-U__cpp_nontype_template_args"},
"-U__cpp_nontype_template_parameter_auto", QString{"-U__cpp_nontype_template_parameter_auto"},
"-U__cpp_nsdmi", QString{"-U__cpp_nsdmi"},
"-U__cpp_range_based_for", QString{"-U__cpp_range_based_for"},
"-U__cpp_raw_strings", QString{"-U__cpp_raw_strings"},
"-U__cpp_ref_qualifiers", QString{"-U__cpp_ref_qualifiers"},
"-U__cpp_return_type_deduction", QString{"-U__cpp_return_type_deduction"},
"-U__cpp_rtti", QString{"-U__cpp_rtti"},
"-U__cpp_rvalue_references", QString{"-U__cpp_rvalue_references"},
"-U__cpp_static_assert", QString{"-U__cpp_static_assert"},
"-U__cpp_structured_bindings", QString{"-U__cpp_structured_bindings"},
"-U__cpp_template_auto", QString{"-U__cpp_template_auto"},
"-U__cpp_threadsafe_static_init", QString{"-U__cpp_threadsafe_static_init"},
"-U__cpp_unicode_characters", QString{"-U__cpp_unicode_characters"},
"-U__cpp_unicode_literals", QString{"-U__cpp_unicode_literals"},
"-U__cpp_user_defined_literals", QString{"-U__cpp_user_defined_literals"},
"-U__cpp_variable_templates", QString{"-U__cpp_variable_templates"},
"-U__cpp_variadic_templates", QString{"-U__cpp_variadic_templates"},
"-U__cpp_variadic_using")); QString{"-U__cpp_variadic_using"}));
} }
TEST_F(ProjectUpdater, FetchProjectPartName) TEST_F(ProjectUpdater, FetchProjectPartName)
@@ -415,7 +420,7 @@ TEST_F(ProjectUpdater, FetchProjectPartName)
auto projectPartName = updater.fetchProjectPartName(1); auto projectPartName = updater.fetchProjectPartName(1);
ASSERT_THAT(projectPartName, Eq(" projectb")); ASSERT_THAT(projectPartName, Eq(QString{" projectb"}));
} }
// test for update many time and get the same id // test for update many time and get the same id