summaryrefslogtreecommitdiff
path: root/project2/ut/testPresenter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/ut/testPresenter.cpp')
-rw-r--r--project2/ut/testPresenter.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/project2/ut/testPresenter.cpp b/project2/ut/testPresenter.cpp
new file mode 100644
index 0000000..e93d7aa
--- /dev/null
+++ b/project2/ut/testPresenter.cpp
@@ -0,0 +1,109 @@
+#include "testPresenter.h"
+#include "misc.h"
+#include <boost/filesystem/operations.hpp>
+#include <boost/test/test_tools.hpp>
+#include <fstream>
+#include <boost/format.hpp>
+
+TestPresenter::TestPresenter() :
+ MultiRowSetPresenter(Default)
+{
+}
+
+void
+TestPresenter::addNamedValue(const Glib::ustring & name, const VariableType & value) const
+{
+ presenterData.push_back(stringbf("%s: %s=%s", __FUNCTION__, name, value));
+}
+
+void
+TestPresenter::addNewRow(const Glib::ustring & name) const
+{
+ presenterData.push_back(stringbf("%s: %s", __FUNCTION__, name));
+}
+
+void
+TestPresenter::finishRow() const
+{
+ presenterData.push_back(stringbf("%s", __FUNCTION__));
+}
+
+void
+TestPresenter::addNewRowSet(const Glib::ustring & name) const
+{
+ presenterData.push_back(stringbf("%s: %s", __FUNCTION__, name));
+}
+
+void
+TestPresenter::addNewRowSet(const Glib::ustring & name, const Glib::ustring & ns) const
+{
+ presenterData.push_back(stringbf("%s: %s:%s", __FUNCTION__, ns, name));
+}
+
+void
+TestPresenter::finishRowSet() const
+{
+ presenterData.push_back(stringbf("%s", __FUNCTION__));
+}
+
+void
+TestPresenter::addNewArray(const Glib::ustring & name, bool objects) const
+{
+ presenterData.push_back(stringbf("%s: %s(%s)", __FUNCTION__, name, objects));
+}
+
+void
+TestPresenter::finishArray(bool objects) const
+{
+ presenterData.push_back(stringbf("%s: (%s)", __FUNCTION__, objects));
+}
+
+void
+TestPresenter::init(ExecContext *)
+{
+ presenterData.push_back(stringbf("%s", __FUNCTION__));
+}
+
+const PresenterData &
+TestPresenter::GetPresenterData() const
+{
+ return presenterData;
+}
+
+namespace std {
+ std::istream &
+ operator>>(std::istream & s, PresenterData & v)
+ {
+ while (true) {
+ char buf[BUFSIZ];
+ s.getline(buf, sizeof(buf));
+ if (s.good()) {
+ v.push_back(buf);
+ }
+ else {
+ break;
+ }
+ }
+ return s;
+ }
+
+ std::ostream &
+ operator<<(std::ostream & s, const PresenterData & v)
+ {
+ for (const auto & e : v) {
+ s << "[" << e << "]" << std::endl;
+ }
+ return s;
+ }
+
+ bool
+ operator==(const PresenterData & left, const boost::filesystem::path & rightPath)
+ {
+ PresenterData right;
+ BOOST_REQUIRE(boost::filesystem::exists(rightPath));
+ fstream strm(rightPath.string());
+ strm >> right;
+ return (left == right);
+ }
+}
+