Use assertions where appropriate

This commit is contained in:
Olivier Teulière 2012-01-17 00:31:26 +01:00
parent 482b5d674f
commit d32f3fdf81

View file

@ -27,6 +27,7 @@
#include "move.h" #include "move.h"
#include "rack.h" #include "rack.h"
#include "pldrack.h" #include "pldrack.h"
#include "debug.h"
Move::Move(const Round &iRound) Move::Move(const Round &iRound)
@ -61,45 +62,29 @@ Move::Move(const wstring &iLetters)
const Round & Move::getRound() const const Round & Move::getRound() const
{ {
if (m_type != VALID_ROUND) ASSERT(m_type == VALID_ROUND, "Incorrect move type");
{
// FIXME: throw an exception object instead
throw 1;
}
return m_round; return m_round;
} }
const wstring & Move::getBadWord() const const wstring & Move::getBadWord() const
{ {
if (m_type != INVALID_WORD) ASSERT(m_type == INVALID_WORD, "Incorrect move type");
{
// FIXME: throw an exception object instead
throw 1;
}
return m_word; return m_word;
} }
const wstring & Move::getBadCoord() const const wstring & Move::getBadCoord() const
{ {
if (m_type != INVALID_WORD) ASSERT(m_type == INVALID_WORD, "Incorrect move type");
{
// FIXME: throw an exception object instead
throw 1;
}
return m_coord; return m_coord;
} }
const wstring & Move::getChangedLetters() const const wstring & Move::getChangedLetters() const
{ {
if (m_type != CHANGE_LETTERS && ASSERT(m_type == CHANGE_LETTERS && m_type != PASS,
m_type != PASS) "Incorrect move type");
{
// FIXME: throw an exception object instead
throw 1;
}
return m_letters; return m_letters;
} }