Skip to content

Commit

Permalink
Added FileList test (DOI-USGS#3168)
Browse files Browse the repository at this point in the history
* Added LineEqationTests.cpp

* Added FileListTests.cpp
Implemented an istream constructor in FileList.cpp to help with testing.

* added FileList tests. implemented istream constructor for FileList.cpp to help with testing.

* fixed whitespace issues in FileListTests.cpp

* Update FileListTests.cpp
  • Loading branch information
paarongiroux authored and scsides committed Mar 29, 2019
1 parent 02c6858 commit 6647b29
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 48 deletions.
9 changes: 9 additions & 0 deletions isis/src/base/objs/FileList/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ namespace Isis {
read(listFile);
}

/**
* Constructs a FileList from an istream.
*
* @param in the istream to read from
*/
FileList::FileList(std::istream &in) {
read(in);
}


/**
* Opens and loads the list of files from a file.
Expand Down
10 changes: 0 additions & 10 deletions isis/src/base/objs/FileList/FileList.truth

This file was deleted.

24 changes: 0 additions & 24 deletions isis/src/base/objs/FileList/unitTest.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions isis/src/base/objs/FileList/unitTest.list

This file was deleted.

47 changes: 47 additions & 0 deletions isis/tests/FileListTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <gtest/gtest.h>
#include <iostream>
#include "FileList.h"
#include "IException.h"

TEST(FileList, NonExistantFileConstructor)
{
try
{
Isis::FileList fl1(Isis::FileName("FakeFile"));
}
catch(Isis::IException &e)
{
EXPECT_TRUE(e.toString().toLatin1().contains("Unable to open [FakeFile]."))
<< e.toString().toStdString();
}
catch(...)
{
FAIL() << "Expected an IException\"Unable to open [FakeFile].\"";
}
}

TEST(FileList, FileNameConstructor)
{
std::istringstream input(
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.cpp\n"
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.h\n"
"#Comment\n"
"unitTest.cpp\n"
">This will not be comment ignored\n"
"\n"
"^is a blank line, this line will not be ignored as a comment\n"
" Makefile\n"
" //Testing comment with prepended spaces\n"
"\n"
"#Above and below are for testing multiple blank lines\n"
"\n"
"\n"
"FileList.h\n");
std::ostringstream output;
std::string expectedOutput = "/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.cpp\n"
"/usgs/pkgs/isis3/isis/src/base/objs/FileList/FileList.h\n"
"unitTest.cpp\n>This\n^is\nMakefile\nFileList.h\n";
Isis::FileList fl1(input);
fl1.write(output);
EXPECT_STREQ(expectedOutput.c_str(), output.str().c_str());
}

0 comments on commit 6647b29

Please sign in to comment.