MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / test_SaveAlreadyExistingFile

Method test_SaveAlreadyExistingFile

tests/INIFile_test.cpp:78–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 }
77
78 void test_SaveAlreadyExistingFile()
79 {
80 QString fileContent = R"(InstanceType=OneSix
81iconKey=vanillia_icon
82name=Minecraft Vanillia
83OverrideCommands=true
84PreLaunchCommand="$INST_JAVA" -jar packwiz-installer-bootstrap.jar link
85Wrapperommand=)";
86 fileContent += "\"";
87 fileContent += +R"(\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =)";
88 fileContent += "\"\n";
89#if defined(Q_OS_WIN)
90 QString fileName = "test_SaveAlreadyExistingFile.ini";
91 QFile file(fileName);
92 QCOMPARE(file.open(QFile::WriteOnly | QFile::Text), true);
93#else
94 QTemporaryFile file;
95 QCOMPARE(file.open(), true);
96 QCOMPARE(file.fileName().isEmpty(), false);
97 QString fileName = file.fileName();
98#endif
99 QTextStream stream(&file);
100 stream << fileContent;
101 file.close();
102
103 // load
104 INIFile f1;
105 f1.loadFile(fileName);
106 QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link");
107 QCOMPARE(f1.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =");
108 f1.saveFile(fileName);
109 INIFile f2;
110 f2.loadFile(fileName);
111 QCOMPARE(f2.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link");
112 QCOMPARE(f2.get("Wrapperommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link =");
113 QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.2");
114#if defined(Q_OS_WIN)
115 FS::deletePath(fileName);
116#endif
117 }
118
119 void test_SaveAlreadyExistingFileWithSpecialChars()
120 {

Callers

nothing calls this directly

Calls 8

deletePathFunction · 0.85
openMethod · 0.80
closeMethod · 0.80
loadFileMethod · 0.80
saveFileMethod · 0.80
isEmptyMethod · 0.45
toStringMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected