From d7b7b4b3391cf99ca63d8311eac3957df7a862ed Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 7 Jul 2009 04:22:49 +0000 Subject: New C++ dmnsn_display* wrapper for tests. --- tests/testsxx.cpp | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'tests/testsxx.cpp') diff --git a/tests/testsxx.cpp b/tests/testsxx.cpp index 1247eee..f3dcca5 100644 --- a/tests/testsxx.cpp +++ b/tests/testsxx.cpp @@ -19,16 +19,38 @@ #include "testsxx.hpp" -// Print a progress bar of the progress of `progress' -std::ostream& -operator<<(std::ostream& ostr, const Dimension::Progress& progress) +namespace Dimension { - const unsigned int increments = 32; + Display::Display(const Canvas& canvas) + : m_display(dmnsn_new_display(canvas.dmnsn())) + { + if (!m_display) { + throw Dimension_Error("Couldn't create display."); + } + } + + Display::~Display() + { + dmnsn_delete_display(m_display); + } + + void + Display::flush() + { + dmnsn_display_frame(m_display); + } + + // Print a progress bar of the progress of `progress' + std::ostream& + operator<<(std::ostream& ostr, const Dimension::Progress& progress) + { + const unsigned int increments = 32; - ostr << "|" << std::flush; - for (unsigned int i = 0; i < increments; ++i) { - progress.wait(static_cast(i + 1)/increments); - ostr << "=" << std::flush; + ostr << "|" << std::flush; + for (unsigned int i = 0; i < increments; ++i) { + progress.wait(static_cast(i + 1)/increments); + ostr << "=" << std::flush; + } + return ostr << "|" << std::flush; } - return ostr << "|" << std::flush; -} +} \ No newline at end of file -- cgit v1.2.3