UnitTests: Refactor printing

Move standard printing functions to extra header.

Change-Id: Ib032047235297dfe3ac0bcdbd39c353493f3ae0d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2020-06-10 13:50:35 +02:00
committed by Tim Jenssen
parent 5a7a6cb02d
commit 50d3067bcd
8 changed files with 50 additions and 21 deletions

View File

@@ -62,6 +62,7 @@ add_qtc_test(unittest GTEST
gtest-creator-printing.cpp gtest-creator-printing.h
gtest-llvm-printing.h
gtest-qt-printing.cpp gtest-qt-printing.h
gtest-std-printing.h
headerpathfilter-test.cpp
highlightingresultreporter-test.cpp
lineprefixer-test.cpp

View File

@@ -38,9 +38,10 @@
#include "compare-operators.h"
#include "conditionally-disabled-tests.h"
#include "gtest-qt-printing.h"
#include "gtest-creator-printing.h"
#include "gtest-llvm-printing.h"
#include "gtest-qt-printing.h"
#include "gtest-std-printing.h"
#ifdef CLANG_UNIT_TESTS
# include "gtest-clang-printing.h"
#endif

View File

@@ -24,6 +24,7 @@
****************************************************************************/
#include "gtest-creator-printing.h"
#include "gtest-std-printing.h"
#ifdef CLANG_UNIT_TESTS
#include <clang/Basic/SourceLocation.h>

View File

@@ -24,6 +24,7 @@
****************************************************************************/
#include "gtest-creator-printing.h"
#include "gtest-std-printing.h"
#include "gtest-qt-printing.h"

View File

@@ -350,24 +350,4 @@ std::ostream &operator<<(std::ostream &out, const Diagnostic &diag);
} // namespace Internal
} // namespace CppTools
namespace std {
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &vector)
{
out << "[";
for (auto current = vector.begin(); current != vector.end(); ++current) {
out << *current;
if (std::next(current) != vector.end())
out << ", ";
}
out << "]";
return out;
}
} // namespace std
void setFilePathCache(ClangBackEnd::FilePathCaching *filePathCache);

View File

@@ -23,6 +23,9 @@
**
****************************************************************************/
#include "gtest-llvm-printing.h"
#include "gtest-std-printing.h"
#include <gtest/gtest-printers.h>
#include <utils/smallstringio.h>

View File

@@ -0,0 +1,41 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
****************************************************************************/
#pragma once
#include <ostream>
#include <vector>
namespace std {
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &vector)
{
out << "[";
for (auto current = vector.begin(); current != vector.end(); ++current) {
out << *current;
if (std::next(current) != vector.end())
out << ", ";
}
out << "]";
return out;
}
} // namespace std

View File

@@ -230,6 +230,7 @@ HEADERS += \
gtest-creator-printing.h \
gtest-llvm-printing.h \
gtest-qt-printing.h \
gtest-std-printing.h \
mimedatabase-utilities.h \
mockclangcodemodelclient.h \
mockclangcodemodelserver.h \