From: Tomek Mrugalski Date: Tue, 23 Oct 2018 18:23:57 +0000 (+0200) Subject: [#65,!30] Updated test utils (mostly comments) X-Git-Tag: 65-libyang-clean-keatext_base~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5b1b5f52f5ad353efd30f7bef68349f04a53aed;p=thirdparty%2Fkea.git [#65,!30] Updated test utils (mostly comments) --- diff --git a/src/lib/yang/testutils/translator_test.cc b/src/lib/yang/testutils/translator_test.cc index 304554a86e..0020e863a4 100644 --- a/src/lib/yang/testutils/translator_test.cc +++ b/src/lib/yang/testutils/translator_test.cc @@ -256,14 +256,20 @@ YangRepr::set(const Tree& tree, S_Session session) const { bool YangRepr::validate(S_Session session, std::ostream& errs) const { try { + // Try to validate. If it succeeds, then we're done here. session->validate(); return (true); } catch (const std::exception& ex) { errs << "validate fails with " << ex.what() << endl; } try { + // If we get here, it means the validate() threw exceptions. S_Errors s_errors = session->get_last_errors(); if (!s_errors) { + + // This is really weird. An exception was thrown, but + // get_last_errors() didn't return anything. Maybe we're out of + // memory or something? errs << "no errors" << endl; return (false); } diff --git a/src/lib/yang/testutils/translator_test.h b/src/lib/yang/testutils/translator_test.h index 1036021186..0cb5f8b1a9 100644 --- a/src/lib/yang/testutils/translator_test.h +++ b/src/lib/yang/testutils/translator_test.h @@ -16,6 +16,9 @@ namespace yang { namespace test { /// @brief Yang/sysrepo datastore textual representation class. +/// +/// This class allows to store a configuration tree in YANG format. +/// It is used in tests to conduct operations on whole configurations. class YangRepr { public: @@ -25,7 +28,7 @@ public: YangRepr(const std::string& model) : model_(model) { } - /// @brief The item class. + /// @brief A struct representing a single entry. struct YangReprItem { /// @brief Constructor with content. /// @@ -38,10 +41,11 @@ public: : xpath_(xpath), value_(value), type_(type), settable_(settable) { } - /// @brief Factory from session. + /// @brief Retrieves configuration parameter from sysrepo /// - /// @param xpath The xpath. + /// @param xpath The xpath of an element to be retrieved /// @param session Sysrepo session. + /// @return YangReprItem instance representing configuration parameter static YangReprItem get(const std::string& xpath, S_Session session); /// @brief The xpath. @@ -57,6 +61,9 @@ public: bool settable_; /// @brief The equal operator ignoring settable. + /// + /// @param other the other object to compare with + /// @return true if equal bool operator==(const YangReprItem& other) const { return ((xpath_ == other.xpath_) && (value_ == other.value_) && @@ -64,6 +71,9 @@ public: } /// @brief The unequal operator ignoring settable. + /// + /// @param other the other object to compare with + /// @return false if equal bool operator!=(const YangReprItem& other) const { return (!(*this == other)); } @@ -77,17 +87,19 @@ public: /// @param session Sysrepo session. Tree get(S_Session session) const; - /// @brief Verify tree. + /// @brief Verifies a tree. /// /// @param expected The expected value. /// @param session Sysrepo session. /// @param errs Error stream. - /// @return True if verification succeeds, false with errors displayed + /// @return true if verification succeeds, false with errors displayed /// on errs if it fails. bool verify(const Tree& expected, S_Session session, std::ostream& errs) const; - /// @brief Set tree to session. + /// @brief Sets specified tree in a sysrepo. + /// + /// The actual access parameters are specified within session. /// /// @param tree The tree to install. /// @param session Sysrepo session.