D17317: match and tc setting

Jan Grulich noreply at phabricator.kde.org
Tue Dec 4 08:48:49 GMT 2018


jgrulich added a comment.


  In D17317#371010 <https://phabricator.kde.org/D17317#371010>, @pranavgade wrote:
  
  > In D17317#371009 <https://phabricator.kde.org/D17317#371009>, @jgrulich wrote:
  >
  > > The tcsettingtest is failing.
  >
  >
  > Why, exactly?
  
  
  Because it's broken in numerous ways :).
  
    void TcSettingTest::testSetting()
    {
        QFETCH(NMVariantMapList, tfilters);
        QFETCH(NMVariantMapList, qdiscs);
    
        QVariantMap map;
    
        map.insert(QLatin1String(NM_SETTING_TC_CONFIG_TFILTERS), QVariant::fromValue(tfilters));
        map.insert(QLatin1String(NM_SETTING_TC_CONFIG_QDISCS), QVariant::fromValue(qdiscs));
    
        NetworkManager::TcSetting setting;
        setting.fromMap(map);
    
        QVariantMap map1 = setting.toMap();
    
        QVariantMap::const_iterator it = map.constBegin();
        while (it != map.constEnd()) {
            NMVariantMapList list = it.value().value<NMVariantMapList>();
            NMVariantMapList list1 = map1.value(it.key()).value<NMVariantMapList>();
    
            QCOMPARE(list.count(), list1.count());
    
            int comparedMaps = 0;
            for (int i = 0; i < list.size(); ++i) {
                QVariantMap varMap = list.at(i);
                for (int j = 0; j < list1.size(); ++j) {
                    QVariantMap varMap1 = list1.at(i);
                    QVariantMap::const_iterator ite = varMap.constBegin();
                    int comparedvals = 0;
                    while (ite != varMap.constEnd()) {
                        QVariantMap::const_iterator val1 = varMap1.constFind(ite.key());
                        if (val1 != varMap1.constEnd()) {
                            if (varMap.value(ite.key()) == val1.value()) {
                                ++comparedvals;
                            }
                        }
                        ++ite;
                    }
                    if (comparedvals == varMap.size()) {
                        comparedMaps++;
                    }
                }
            }
            ++it;
            QCOMPARE(comparedMaps, list.count());
        }
    }
  
  It should be like this.

REVISION DETAIL
  https://phabricator.kde.org/D17317

To: pranavgade, jgrulich
Cc: kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20181204/45a95f0a/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list