| 47 | } |
| 48 | |
| 49 | void test_SaveLoadLists() |
| 50 | { |
| 51 | QString slist_strings = "(\"a\",\"b\",\"c\")"; |
| 52 | QStringList list_strings = { "a", "b", "c" }; |
| 53 | |
| 54 | QString slist_numbers = "(1,2,3,10)"; |
| 55 | QList<int> list_numbers = { 1, 2, 3, 10 }; |
| 56 | |
| 57 | QString filename = "test_SaveLoadLists.ini"; |
| 58 | |
| 59 | INIFile f; |
| 60 | f.set("list_strings", list_strings); |
| 61 | f.set("list_numbers", QVariantUtils::fromList(list_numbers)); |
| 62 | f.saveFile(filename); |
| 63 | |
| 64 | // load |
| 65 | INIFile f2; |
| 66 | f2.loadFile(filename); |
| 67 | |
| 68 | QStringList out_list_strings = f2.get("list_strings", QStringList()).toStringList(); |
| 69 | qDebug() << "OutStringList" << out_list_strings; |
| 70 | |
| 71 | QList<int> out_list_numbers = QVariantUtils::toList<int>(f2.get("list_numbers", QVariantUtils::fromList(QList<int>()))); |
| 72 | qDebug() << "OutNumbersList" << out_list_numbers; |
| 73 | |
| 74 | QCOMPARE(out_list_strings, list_strings); |
| 75 | QCOMPARE(out_list_numbers, list_numbers); |
| 76 | } |
| 77 | |
| 78 | void test_SaveAlreadyExistingFile() |
| 79 | { |