/*******************************************************************************
***  This file is part of Dux Rei Nummariae.                                 ***
***                                                                          ***
***  Copyright (C) 2017, 2018, 2019, 2020, 2021                              ***
***  John Schneiderman <Licensing _AT_ Schneiderman _DOT_ me>                ***
***                                                                          ***
***  This program is free software: you can redistribute it and/or modify it ***
***  under the terms of the GNU Affero General Public License as published   ***
***  by the Free Software Foundation, either version 3 of the License, or    ***
***  (at your option) any later version.                                     ***
***                                                                          ***
***  This program is distributed in the hope that it will be useful, but     ***
***  WITHOUT ANY WARRANTY; without even the implied warranty of              ***
***  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    ***
***  See the GNU Affero General Public License for more details.             ***
***                                                                          ***
***  You should have received a copy of the GNU Affero General Public License***
***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
*******************************************************************************/
#include <QTest>
// using QTEST_MAIN

#include <foundation/Switch.h>
using drn::foundation::Switch;
using drn::foundation::SwitchStates;


namespace drn
{
namespace foundation
{
namespace tests
{

struct SwitchUT : QObject
{
	Q_OBJECT

private slots:
	//{ constructor Tests

	void constructor_Default_ShouldBeExpected()
	{
		Switch f{};
		QVERIFY2( ! f.isOn(), "The default flag should be off.");
	}
	void constructor_ValidParam_ShouldBeOnValue()
	{
		Switch f{SwitchStates::On};
		QVERIFY2(f.isOn(), "The default flag should be off.");
	}

	//}

	//{ toggle Tests

	void toggle_FromOff_ShouldBeOn()
	{
		Switch f{};
		f.toggle();
		QVERIFY2(f, "The flag should be on now.");
	}
	void toggle_FromOn_ShouldBeOff()
	{
		Switch f{SwitchStates::On};
		f.toggle();
		QVERIFY2( ! f, "The flag should be off now.");
	}

	//}

	//{ flipOff Tests

	void flipOff_FromOff_ShouldBeOff()
	{
		Switch f{};
		f.flipOff();
		QVERIFY2( ! f, "The flag should be off now.");
	}
	void flipOff_FromOn_ShouldBeOff()
	{
		Switch f{SwitchStates::On};
		f.flipOff();
		QVERIFY2( ! f, "The flag should be off now.");
	}

	//}

	//{ flipOn Tests

	void flipOn_FromOff_ShouldBeOn()
	{
		Switch f{};
		f.flipOn();
		QVERIFY2(f, "The flag should be on now.");
	}
	void flipOn_FromOn_ShouldBeOn()
	{
		Switch f{SwitchStates::On};
		f.flipOn();
		QVERIFY2(f, "The flag should be on now.");
	}

	//}
};

}}}

QTEST_MAIN(drn::foundation::tests::SwitchUT)
#include "Switch-unit-tests.moc"
