/**************************************************************************** ** ** Copyright (C) 2016 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. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3 as published by the Free Software ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ****************************************************************************/ #include "simplifytype.h" #include #include using namespace Debugger; using namespace Internal; const char *description[] = { "g++_short", "g++_stdstring", "g++_stdwstring", "g++_5stdstring", "g++_5stdwstring", "g++_stringmap", "g++_wstringmap", "g++_stringlist", "g++_stringset", "g++_stringvector", "g++_wstringvector", "g++_unordered_set", "g++_unordered_multiset", "g++_unordered_map", "g++_unordered_multimap", "g++_stdvector_int_ptr", "g++_stdmap_char_ptr", "g++_stdmap_short_string", "libc++_stringvector", "libc++_unordered_map", "libc++_hash_node", "msvc_stdstring", "msvc_stdwstring", "msvc_stringmap", "msvc_wstringmap", "msvc_stringlist", "msvc_stringset", "msvc_stringvector", "msvc_wstringvector", "std_shared_ptr", "boost_shared_ptr", "boost_unordered_set", }; const char *input[] = { // g++ "short int", "std::string", "std::wstring", "std::__cxx11::basic_string, std::allocator >", "std::__cxx11::basic_string, std::allocator >", "std::map, std::allocator >, std::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::basic_string, std::allocator > > > >", "std::map, std::allocator >, std::basic_string, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > const, std::basic_string, std::allocator > > > >", "std::list, std::allocator >, std::allocator, std::allocator > > >", "std::set, std::allocator >, std::less, std::allocator > >, std::allocator, std::allocator > > >", "std::vector, std::allocator >, std::allocator, std::allocator > > >", "std::vector, std::allocator >, std::allocator, std::allocator > > >", "std::unordered_set, std::equal_to, std::allocator >", "std::unordered_multiset, std::equal_to, std::allocator >", "std::unordered_map, std::equal_to, std::allocator > >", "std::unordered_multimap, std::equal_to, std::allocator > >", "std::vector >", "std::map, std::allocator > >", "std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >", // libc++ "std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >", "std::__1::unordered_map, std::__1::allocator >, float, std::__1::hash, std::__1::allocator >, std::__1::equal_to, std::__1::allocator > >, std::__1::allocator, std::__1::allocator >, float> > >", "std::__1::__hash_node::value_type", // MSVC "class std::basic_string,std::allocator >", "class std::basic_string,std::allocator >", "class std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > >", "class std::map,std::allocator >,std::basic_string,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > const ,std::basic_string,std::allocator > > > >", "class std::list,std::allocator >,std::allocator,std::allocator > > >", "class std::set,std::allocator >,std::less,std::allocator > >,std::allocator,std::allocator > > >", "class std::vector,std::allocator >,std::allocator,std::allocator > > >", "class std::vector,std::allocator >,std::allocator,std::allocator > > >", // std "std::shared_ptr::element_type", // boost "boost::shared_ptr::element_type", "boost::unordered_set, std::equal_to, std::allocator >", }; const char *output[] = { // Gcc "short", "std::string", "std::wstring", "std::string", "std::wstring", "std::map", "std::map", "std::list", "std::set", "std::vector", "std::vector", "std::unordered_set", "std::unordered_multiset", "std::unordered_map", "std::unordered_multimap", "std::vector", "std::map", "std::map", // libc++ "std::vector", "std::unordered_map", "int", // MSVC "std::string", "std::wstring", "std::map", "std::map", "std::list", "std::set", "std::vector", "std::vector", // std "int", // boost "int", "boost::unordered_set", }; class SimplifyTypesTest : public QObject { Q_OBJECT public: SimplifyTypesTest(); private Q_SLOTS: void test(); void test_data(); }; SimplifyTypesTest::SimplifyTypesTest() { } void SimplifyTypesTest::test() { QFETCH(QString, input); QFETCH(QString, expected); const QString output = simplifyType(input); QCOMPARE(output, expected); } void SimplifyTypesTest::test_data() { QTest::addColumn("input"); QTest::addColumn("expected"); const size_t count = sizeof(input)/sizeof(const char *); for (size_t i = 0; i < count; i++ ) QTest::newRow(description[i]) << QString::fromLatin1(input[i]) << QString::fromLatin1(output[i]); } QTEST_APPLESS_MAIN(SimplifyTypesTest); #include "tst_simplifytypes.moc"