mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 06:19:02 -06:00
Add some more fixes
This commit is contained in:
@@ -93,18 +93,6 @@ public:
|
||||
*/
|
||||
ProfileFile(std::string filename);
|
||||
|
||||
/**
|
||||
* Constructor with alternative method of populating the object by reading the lines
|
||||
* from a profile file. This is mainly intended for testing purposes, but it can be
|
||||
* used to provide the profile file contents from another source (the function
|
||||
* readFromFile() provides its own ifstream source).
|
||||
* \param reader A std::function object that accepts a string reference which will
|
||||
* be populated with a single line of content. This function returns
|
||||
* true if a single line was read successfully, or false if not to
|
||||
* indicate that the end of the content has been reached.
|
||||
*/
|
||||
ProfileFile(std::function<bool(std::string&)> reader);
|
||||
|
||||
/**
|
||||
* Reads the contents of a profile file and populates vector containers for all
|
||||
* sections. This only pulls individual line entries into their proper sections;
|
||||
|
||||
@@ -548,14 +548,14 @@ std::string Profile::convertToScene_camera(ProfileFile& pf) {
|
||||
result += "})\n";
|
||||
}
|
||||
else if (fields[cameraFieldType] == "goToGeo") {
|
||||
result += " openspace.globebrowsing.goToGeo({ ";
|
||||
result += " openspace.globebrowsing.goToGeo(";
|
||||
if (!fields[cameraGeoFieldAnchor].empty()) {
|
||||
result += fields[cameraGeoFieldAnchor] + ", ";
|
||||
}
|
||||
result += fields[cameraGeoFieldLatitude] + ", ";
|
||||
result += fields[cameraGeoFieldLongitude] + ", ";
|
||||
result += fields[cameraGeoFieldLongitude];
|
||||
if (!fields[cameraGeoFieldAltitude].empty()) {
|
||||
result += fields[cameraGeoFieldAltitude] + ", ";
|
||||
result += + ", " + fields[cameraGeoFieldAltitude];
|
||||
}
|
||||
result += ")\n";
|
||||
}
|
||||
|
||||
@@ -56,10 +56,6 @@ ProfileFile::ProfileFile(std::string filename) {
|
||||
readIn(filename);
|
||||
}
|
||||
|
||||
ProfileFile::ProfileFile(std::function<bool(std::string&)> reader) {
|
||||
readIn(reader);
|
||||
}
|
||||
|
||||
void ProfileFile::readIn(std::string filename) {
|
||||
clearAllFields();
|
||||
std::ifstream inFile;
|
||||
|
||||
@@ -38,15 +38,14 @@ namespace {
|
||||
|
||||
TEST_CASE("profileFile: Simple read and verify", "[profileFile]") {
|
||||
testProfileFormat test = buildTestProfile1();
|
||||
std::string testFull_string = stringFromTestProfileFormat(test);
|
||||
std::istringstream iss(testFull_string);
|
||||
std::string testFile = absPath("${TEMPORARY}/profile-test-simple");
|
||||
{
|
||||
std::string testFull_string = stringFromTestProfileFormat(test);
|
||||
std::ofstream f(testFile);
|
||||
f << testFull_string;
|
||||
}
|
||||
|
||||
ProfileFile pf([&iss](std::string& line) {
|
||||
if (getline(iss, line))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
});
|
||||
ProfileFile pf(testFile);
|
||||
|
||||
std::vector<std::string> tVect;
|
||||
|
||||
@@ -200,15 +199,14 @@ TEST_CASE("profileFile: Required field missing", "[profileFile]") {
|
||||
|
||||
TEST_CASE("profileFile: Write test", "[profileFile]") {
|
||||
testProfileFormat test = buildTestProfile1();
|
||||
std::string testFile = absPath("${TEMPORARY}/profile-test-write-test");
|
||||
std::string testFull_string = stringFromTestProfileFormat(test);
|
||||
std::istringstream iss(testFull_string);
|
||||
ProfileFile pf([&iss](std::string& line) {
|
||||
if (getline(iss, line))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
);
|
||||
{
|
||||
std::ofstream f(testFile);
|
||||
f << testFull_string;
|
||||
}
|
||||
|
||||
ProfileFile pf(testFile);
|
||||
|
||||
std::string result = pf.writeToString();
|
||||
REQUIRE(testFull_string == result);
|
||||
|
||||
Reference in New Issue
Block a user