Skip to content
Snippets Groups Projects
Commit 8a366788 authored by Bienchen's avatar Bienchen
Browse files

Added negative test for missing data_ construct to the star parser.

parent 63670d02
Branches
Tags
No related merge requests found
......@@ -331,6 +331,7 @@ void StarParser::ParseGlobal()
void StarParser::Parse()
{
StringRef line;
std::stringstream ss;
while (this->GetLine(line)) {
StringRef tline=line.rtrim();
if (tline.empty()) {
......@@ -353,8 +354,8 @@ void StarParser::Parse()
this->ConsumeLine();
break;
default:
std::cout << "ERROR:" << line_num_ << ":" << tline << std::endl;
assert(0 && "unhandled top-level construct in StarParser::Parse()");
ss << "Missing 'data_' control structure." << std::endl;
throw IOException(ss.str());
break;
}
}
......
......@@ -21,6 +21,7 @@
*/
#include <fstream>
#include <ost/mol/mol.hh>
#include <ost/io/io_exception.hh>
#include <ost/io/mol/star_parser.hh>
#define BOOST_AUTO_TEST_DYN_LINK
......@@ -179,5 +180,12 @@ BOOST_AUTO_TEST_CASE(star_loop)
BOOST_CHECK_EQUAL(star_p.lines[4][1], "14");
BOOST_CHECK_EQUAL(star_p.lines[4][2], "15");
}
BOOST_AUTO_TEST_CASE(star_missing_data)
{
std::ifstream s("testfiles/missing_data.cif");
LoopTestParser star_p(s);
BOOST_CHECK_THROW(star_p.Parse(), IOException);
}
BOOST_AUTO_TEST_SUITE_END();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment