D17317: match and tc setting

Jan Grulich noreply at phabricator.kde.org
Mon Dec 3 07:18:23 GMT 2018


jgrulich added inline comments.

INLINE COMMENTS

> tcsettingtest.cpp:74
> +    while (it != map.constEnd()) {
> +        QCOMPARE(it.value(), map1.value(it.key()));
> +        ++it;

Something like:

  NMVariantMapList list = it.value();
  NMVariantMapList list1 = map1.value(it.key());
  QCOMPARE(list.count(), list1.count());
  
  int comparedMaps = 0;
  NMVariantMapList::const_iterator listIt = list.constBegin();
  while (listIt != list.constEnd() {
      NMVariantMapList::const_iterator list1It = list1.constBegin();
      while (list1it != list1.constEnd()) {
           QVariantMap listMap = listIt.value();
           QVariantMap1 listMap1 = list1It.value();
           // Test if keys do match, because the list can be in different order
           QStringList listMapKeys = listMap.keys();
           QStringList listMapKeys1 = listMap1.keys();
           listMapKeys.sort();
           listMapKeys1.sort();
           if (listMapKeys.join(QChar(' ')) ==  listMapKeys1.join(QChar(' '))) {
                 // Here the maps should have same keys so compare QVariantMaps as we do now
                 .........
                 ++comparedMaps;
           }
           ++list1it;  
       }
       ++listIt;
  }
  
  // Test if we compared all maps, if not, then probably they didn't match
  QCOMPARE(comparedMaps, list.count();

> pranavgade wrote in tcsettingtest.cpp:69
> So..how should I do it?

See below, it's ugly, but problem is that give it's a QList, the maps can be in different order so you first have to identify you compare correct QVariantMaps. I do that by comparing keys.

REPOSITORY
  R282 NetworkManagerQt

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/20181203/fb146e22/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list