forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "gtest-creator-printing.h"
|
||||
#include "gtest-std-printing.h"
|
||||
|
||||
#ifdef CLANG_UNIT_TESTS
|
||||
#include <clang/Basic/SourceLocation.h>
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "gtest-creator-printing.h"
|
||||
#include "gtest-std-printing.h"
|
||||
|
||||
#include "gtest-qt-printing.h"
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "gtest-llvm-printing.h"
|
||||
#include "gtest-std-printing.h"
|
||||
|
||||
#include <gtest/gtest-printers.h>
|
||||
|
||||
#include <utils/smallstringio.h>
|
||||
|
||||
41
tests/unit/unittest/gtest-std-printing.h
Normal file
41
tests/unit/unittest/gtest-std-printing.h
Normal 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
|
||||
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user