[PPL-devel] [GIT] ppl/ppl(master): Document and test exception thrown by PIP_Problem:: print_solution().
Enea Zaffanella
zaffanella at cs.unipr.it
Sat Feb 20 11:18:21 CET 2010
Module: ppl/ppl
Branch: master
Commit: e890db63f60fa120d9fc6ba046b5ffa24072ae67
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=e890db63f60fa120d9fc6ba046b5ffa24072ae67
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Sat Feb 20 10:05:36 2010 +0100
Document and test exception thrown by PIP_Problem::print_solution().
---
src/PIP_Problem.cc | 4 ++--
src/PIP_Problem.defs.hh | 11 +++++++++++
tests/PIP_Problem/exceptions1.cc | 17 +++++++++++++++++
3 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/PIP_Problem.cc b/src/PIP_Problem.cc
index aa34943..ad234eb 100644
--- a/src/PIP_Problem.cc
+++ b/src/PIP_Problem.cc
@@ -666,8 +666,8 @@ PPL::PIP_Problem::print_solution(std::ostream& s, unsigned indent) const {
break;
case PARTIALLY_SATISFIABLE:
- throw std::domain_error("PIP_Problem::print_solution():\n"
- "the PIP problem has not been solved.");
+ throw std::logic_error("PIP_Problem::print_solution():\n"
+ "the PIP problem has not been solved.");
}
}
diff --git a/src/PIP_Problem.defs.hh b/src/PIP_Problem.defs.hh
index b4c6081..0015aac 100644
--- a/src/PIP_Problem.defs.hh
+++ b/src/PIP_Problem.defs.hh
@@ -456,6 +456,17 @@ public:
bool OK() const;
//! Prints on \p s the solution computed for \p *this.
+ /*!
+ \param s
+ The output stream.
+
+ \param indent
+ An indentation parameter (default value 0).
+
+ \exception std::logic_error
+ Thrown if trying to print the solution when the PIP problem
+ still has to be solved.
+ */
void print_solution(std::ostream& s, unsigned indent = 0) const;
PPL_OUTPUT_DECLARATIONS
diff --git a/tests/PIP_Problem/exceptions1.cc b/tests/PIP_Problem/exceptions1.cc
index 3f01ab1..d9c5966 100644
--- a/tests/PIP_Problem/exceptions1.cc
+++ b/tests/PIP_Problem/exceptions1.cc
@@ -276,6 +276,22 @@ test12() {
return false;
}
+bool
+test13() {
+ PIP_Problem pip;
+ try {
+ // Printing the solution before trying to solve the problem.
+ pip.print_solution(nout);
+ }
+ catch (std::logic_error& e) {
+ nout << "logic_error: " << e.what() << endl << endl;
+ return true;
+ }
+ catch (...) {
+ }
+ return false;
+}
+
} // namespace
BEGIN_MAIN
@@ -291,4 +307,5 @@ BEGIN_MAIN
DO_TEST(test10);
DO_TEST(test11);
DO_TEST(test12);
+ DO_TEST(test13);
END_MAIN
More information about the PPL-devel
mailing list