Add a test for the link group.

This commit is contained in:
whitequark 2017-03-09 17:48:44 +00:00
parent 15f349049c
commit 7e2b1b1d8d
9 changed files with 25 additions and 1 deletions

View File

@ -261,7 +261,7 @@ bool SolveSpaceUI::SaveToFile(const std::string &filename) {
// will be exported. We reload the linked files because that rewrites
// the linkFileRel for our possibly-new filename.
SS.ScheduleShowTW();
SS.ReloadAllImported();
SS.ReloadAllImported(filename);
SS.GenerateAll(SolveSpaceUI::Generate::ALL);
fh = ssfopen(filename, "wb");

View File

@ -55,6 +55,7 @@ set(testsuite_SOURCES
request/datum_point/test.cpp
request/line_segment/test.cpp
request/ttf_text/test.cpp
group/link/test.cpp
group/translate_asy/test.cpp
group/translate_nd/test.cpp
)

BIN
test/group/link/normal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
test/group/link/normal.slvs Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

17
test/group/link/test.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "harness.h"
TEST_CASE(normal_roundtrip) {
CHECK_LOAD("normal.slvs");
CHECK_RENDER("normal.png");
CHECK_SAVE("normal.slvs");
}
TEST_CASE(normal_migrate_from_v20) {
CHECK_LOAD("normal_v20.slvs");
CHECK_SAVE("normal.slvs");
}
TEST_CASE(normal_migrate_from_v22) {
CHECK_LOAD("normal_v22.slvs");
CHECK_SAVE("normal.slvs");
}

View File

@ -116,6 +116,7 @@ static std::string PrepareSavefile(std::string data) {
if(eqPos < nextLineBegin) {
std::string key = data.substr(lineBegin, eqPos - lineBegin),
value = data.substr(eqPos + 1, nextLineBegin - eqPos - 2);
for(int i = 0; SolveSpaceUI::SAVED[i].type != 0; i++) {
if(SolveSpaceUI::SAVED[i].fmt != 'f') continue;
if(SolveSpaceUI::SAVED[i].desc != key) continue;
@ -126,6 +127,11 @@ static std::string PrepareSavefile(std::string data) {
std::copy(newValue.begin(), newValue.end(),
data.begin() + eqPos + 1);
}
if(key == "Group.impFile") {
data.erase(lineBegin, nextLineBegin - lineBegin);
nextLineBegin = lineBegin;
}
}
size_t spPos = data.find(' ', lineBegin);