diff --git a/tests/unit/unittest/cppbaseprojectpartbuilder-test.cpp b/tests/unit/unittest/cppbaseprojectpartbuilder-test.cpp index ff834c1cc32..68cfd629c76 100644 --- a/tests/unit/unittest/cppbaseprojectpartbuilder-test.cpp +++ b/tests/unit/unittest/cppbaseprojectpartbuilder-test.cpp @@ -49,9 +49,22 @@ using CppTools::ToolChainInterface; using CppTools::ToolChainInterfacePtr; using testing::Eq; +using testing::UnorderedElementsAre; +using testing::PrintToString; namespace { +MATCHER_P2(IsProjectPart, languageVersion, fileKind, + std::string(negation ? "isn't" : "is") + + " project part with language version " + PrintToString(languageVersion) + + " and file kind " + PrintToString(fileKind)) +{ + const ProjectPart::Ptr &projectPart = arg; + + return projectPart->languageVersion == languageVersion + && projectPart->files.at(0).kind == fileKind; +} + class EditableToolChain : public CppTools::ToolChainInterface { public: @@ -195,16 +208,11 @@ TEST_F(BaseProjectPartBuilder, ProjectFileKindsMatchProjectPartVersion) builder.createProjectPartsForFiles(QStringList() << "foo.h"); - const QVector projectParts = projectInfo.projectParts(); - ASSERT_THAT(projectParts.size(), Eq(4)); - ASSERT_THAT(projectParts.at(0)->languageVersion, Eq(ProjectPart::LatestCxxVersion)); - ASSERT_THAT(projectParts.at(0)->files.at(0).kind, Eq(ProjectFile::CXXHeader)); - ASSERT_THAT(projectParts.at(1)->languageVersion, Eq(ProjectPart::LatestCxxVersion)); - ASSERT_THAT(projectParts.at(1)->files.at(0).kind, Eq(ProjectFile::ObjCXXHeader)); - ASSERT_THAT(projectParts.at(2)->languageVersion, Eq(ProjectPart::LatestCVersion)); - ASSERT_THAT(projectParts.at(2)->files.at(0).kind, Eq(ProjectFile::CHeader)); - ASSERT_THAT(projectParts.at(3)->languageVersion, Eq(ProjectPart::LatestCVersion)); - ASSERT_THAT(projectParts.at(3)->files.at(0).kind, Eq(ProjectFile::ObjCHeader)); + ASSERT_THAT(projectInfo.projectParts(), + UnorderedElementsAre(IsProjectPart(ProjectPart::LatestCVersion, ProjectFile::CHeader), + IsProjectPart(ProjectPart::LatestCVersion, ProjectFile::ObjCHeader), + IsProjectPart(ProjectPart::LatestCxxVersion, ProjectFile::CXXHeader), + IsProjectPart(ProjectPart::LatestCxxVersion, ProjectFile::ObjCXXHeader))); } void BaseProjectPartBuilder::SetUp()