From 5c4506a8c5ee1a82268146007619b09e980a7a57 Mon Sep 17 00:00:00 2001 From: manuel Date: Sat, 2 May 2009 17:28:21 +0200 Subject: add some assert() to make tutor happy --- ue2/imgsynth2/cpixmap.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ue2/imgsynth2/cpixmap.cpp') diff --git a/ue2/imgsynth2/cpixmap.cpp b/ue2/imgsynth2/cpixmap.cpp index 94f0310..52f9825 100644 --- a/ue2/imgsynth2/cpixmap.cpp +++ b/ue2/imgsynth2/cpixmap.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef DEBUG # include #endif @@ -123,6 +124,7 @@ void CPixmap::read(std::ifstream& in) throw FileError("Pixmap has no imagename."); /* additional: check "{" exists */ + assert(!line.empty()); if (line[line.length() - 1] != '{') throw FileError("Pixmap array has no opening bracket."); @@ -236,6 +238,7 @@ void CPixmap::read(std::ifstream& in) for(uint32_t x = 0; x < getWidth(); x++) { character = line.substr(x * m_fileheader.nChar, m_fileheader.nChar); + assert(!character.empty()); if (colornr.find(character) == colornr.end()) throw FileError("Pixel has no reference in colortable."); @@ -265,6 +268,7 @@ void CPixmap::read(std::ifstream& in) const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length) { static const char code[] = PIXMAP_COLORCHARS; + assert(strlen(code) > 0); string str(""); for(unsigned int i = length - 1; i > 0; i--) { @@ -272,6 +276,7 @@ const std::string CPixmap::getXPMColorID(unsigned int index, unsigned int length index /= strlen(code); } str += code[index]; + assert(!str.empty()); return str; } @@ -286,6 +291,7 @@ void CPixmap::write(std::ofstream& out) out << PIXMAP_IDENTIFIER << endl; /* variables*/ + assert(!m_imagename.empty()); out << "static char * " << m_imagename << "[] = {" << endl; out << "\"" << m_fileheader.width << " " << m_fileheader.height << " " << m_fileheader.nColor << " " << m_fileheader.nChar; -- cgit v1.2.3