Skip to content
Snippets Groups Projects
Commit 10373c01 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

SCHWED-2589: clean exception handling for MMCifInfoRevisions.

parent 64324e9a
No related branches found
No related tags found
No related merge requests found
......@@ -993,6 +993,7 @@ of the annotation available.
:type i: :class:`int`
:return: Date the PDB revision took place. Expected format 'yyyy-mm-dd'.
:rtype: :class:`str`
:raises: Exception if *i* out of bounds.
.. method:: GetNum(i)
......@@ -1000,6 +1001,7 @@ of the annotation available.
:type i: :class:`int`
:return: Unique identifier of revision (assigned in increasing order)
:rtype: :class:`int`
:raises: Exception if *i* out of bounds.
.. method:: GetStatus(i)
......@@ -1007,10 +1009,11 @@ of the annotation available.
:type i: :class:`int`
:return: The status of this revision.
:rtype: :class:`str`
:raises: Exception if *i* out of bounds.
.. method:: GetLastDate()
:return: Date of the latest revision.
:return: Date of the latest revision ('?' if no revision set).
:rtype: :class:`str`
.. method:: SetDateOriginal(date)
......
......@@ -728,24 +728,27 @@ public:
///
/// \param i position in list
/// \return date
String GetDate(size_t i) const { return date_[i]; }
String GetDate(size_t i) const { return date_.at(i); }
/// \brief Get revision num by index in list.
///
/// \param i position in list
/// \return num
int GetNum(size_t i) const { return num_[i]; }
int GetNum(size_t i) const { return num_.at(i); }
/// \brief Get revision status by index in list.
///
/// \param i position in list
/// \return status
String GetStatus(size_t i) const { return status_[i]; }
String GetStatus(size_t i) const { return status_.at(i); }
/// \brief Get date of last revision.
///
/// \return date
String GetLastDate() const { return date_.back(); }
String GetLastDate() const {
if (date_.empty()) return "?";
else return date_.back();
}
/// \brief Get the index of the full release revision.
///
......
......@@ -225,6 +225,12 @@ BOOST_AUTO_TEST_CASE(mmcif_info_revisions)
MMCifInfoRevisions rev = MMCifInfoRevisions();
BOOST_CHECK(rev.GetDateOriginal() == "?");
BOOST_CHECK(rev.GetFirstRelease() == 0);
BOOST_CHECK(rev.GetSize() == 0);
BOOST_CHECK(rev.GetLastDate() == "?");
BOOST_CHECK_THROW(rev.GetDate(0), std::out_of_range);
BOOST_CHECK_THROW(rev.GetNum(0), std::out_of_range);
BOOST_CHECK_THROW(rev.GetStatus(0), std::out_of_range);
rev.SetDateOriginal("2012-05-04");
rev.AddRevision(1, "2012-05-04", "in preparation");
......@@ -239,6 +245,9 @@ BOOST_AUTO_TEST_CASE(mmcif_info_revisions)
BOOST_CHECK(rev.GetFirstRelease() == 2);
BOOST_CHECK(rev.GetNum(1) == 2);
BOOST_CHECK(rev.GetStatus(1) == "full release");
BOOST_CHECK_THROW(rev.GetDate(2), std::out_of_range);
BOOST_CHECK_THROW(rev.GetNum(2), std::out_of_range);
BOOST_CHECK_THROW(rev.GetStatus(2), std::out_of_range);
BOOST_TEST_MESSAGE(" done.");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment