/***************************************************************************
 * exceptiontest.cpp
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2004-2007 the KTabEdit development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#include "exceptiontest.h"

#include "util/assert.h"
#include <iostream>

void ExceptionTest::testAssert()
{
	int i, j;
	
	i = j = 0;
	try {
		ASSERT(i == j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
	
	try {
		ASSERT( i != j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
}

void ExceptionTest::testPreCondition()
{
	int i, j;
	
	i = j = 0;
	try {
		PRECONDITION(i == j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
	
	try {
		PRECONDITION( i != j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
}

void ExceptionTest::testPostCondition()
{
	int i, j;
	
	i = j = 0;
	try {
		POSTCONDITION(i == j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
	
	try {
		POSTCONDITION( i != j);
	} catch(const ktabedit::ContractException& e) {
		std::cerr << e.what();
	}
}

QTEST_MAIN(ExceptionTest)
#include "exceptiontest.moc"
