* Lumiera source code always was copyrighted by individual contributors * there is no entity "Lumiera.org" which holds any copyrights * Lumiera source code is provided under the GPL Version 2+ == Explanations == Lumiera as a whole is distributed under Copyleft, GNU General Public License Version 2 or above. For this to become legally effective, the ''File COPYING in the root directory is sufficient.'' The licensing header in each file is not strictly necessary, yet considered good practice; attaching a licence notice increases the likeliness that this information is retained in case someone extracts individual code files. However, it is not by the presence of some text, that legally binding licensing terms become effective; rather the fact matters that a given piece of code was provably copyrighted and published under a license. Even reformatting the code, renaming some variables or deleting parts of the code will not alter this legal situation, but rather creates a derivative work, which is likewise covered by the GPL! The most relevant information in the file header is the notice regarding the time of the first individual copyright claim. By virtue of this initial copyright, the first author is entitled to choose the terms of licensing. All further modifications are permitted and covered by the License. The specific wording or format of the copyright header is not legally relevant, as long as the intention to publish under the GPL remains clear. The extended wording was based on a recommendation by the FSF. It can be shortened, because the full terms of the license are provided alongside the distribution, in the file COPYING.
115 lines
3.4 KiB
C++
115 lines
3.4 KiB
C++
/*
|
||
DigxelConfigurations(Test) - verify predefined standard Digxel configurations
|
||
|
||
Copyright (C)
|
||
2011, Hermann Vosseler <Ichthyostega@web.de>
|
||
|
||
**Lumiera** 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 further details.
|
||
|
||
* *****************************************************************/
|
||
|
||
/** @file digxel-configurations-test.cpp
|
||
** unit test \ref DigxelConfigurations_test
|
||
*/
|
||
|
||
|
||
#include "lib/test/run.hpp"
|
||
#include "lib/test/test-helper.hpp"
|
||
#include "lib/time/digxel.hpp"
|
||
#include "lib/format-cout.hpp"
|
||
#include "lib/error.hpp"
|
||
#include "lib/util.hpp"
|
||
|
||
using LERR_(ASSERTION);
|
||
using util::typeStr;
|
||
|
||
|
||
namespace lib {
|
||
namespace time{
|
||
namespace test{
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*******************************************************************//**
|
||
* @test verify correctness of the predefined standard Digxels.
|
||
* Some widely used standard configurations, including
|
||
* - default Digxel for int and double values
|
||
* - sexagesimal Digxel
|
||
* - hex byte Digxel
|
||
* - ...more to come
|
||
* @todo cover any newly added Digxel configurations.
|
||
* @see Digxel_test
|
||
*/
|
||
class DigxelConfigurations_test : public Test
|
||
{
|
||
virtual void
|
||
run (Arg)
|
||
{
|
||
verifyConfiguration<Digxel<int> > (123);
|
||
verifyConfiguration<Digxel<double>> (123.4567);
|
||
verifyConfiguration<SexaDigit > (42);
|
||
verifyConfiguration<SexaDigit > (-5);
|
||
verifyConfiguration<HexaDigit > (0xc);
|
||
verifyConfiguration<HexaDigit > (0x6f);
|
||
verifyConfiguration<CountVal > (-1234567890);
|
||
|
||
verifySignum();
|
||
}
|
||
|
||
|
||
void
|
||
verifySignum()
|
||
{
|
||
Signum sig;
|
||
CHECK (1 == sig);
|
||
|
||
sig = 123;
|
||
CHECK (1 == sig);
|
||
sig = -sig;
|
||
CHECK (-1 == sig);
|
||
sig += 98;
|
||
CHECK (+1 == sig);
|
||
CHECK (sig.show() == string(" "));
|
||
sig *= -1;
|
||
CHECK (sig.show() == string("-"));
|
||
}
|
||
|
||
|
||
template<class DIX, typename VAL>
|
||
void
|
||
verifyConfiguration (VAL testval)
|
||
{
|
||
DIX digxel;
|
||
CHECK (0 == digxel);
|
||
cout << typeStr(digxel) << "--empty--"<<digxel;
|
||
|
||
digxel = testval;
|
||
cout << "--(val="<<testval<<")--"<<digxel;
|
||
|
||
// verify buffer overrun protection
|
||
digxel = 123456789.12345;
|
||
string formatted;
|
||
#if false ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT
|
||
VERIFY_ERROR (ASSERTION, formatted = digxel.show() ); // should trigger assertion
|
||
formatted = digxel.show(); // second time doesn't reformat
|
||
CHECK (formatted.length() == digxel.maxlen());
|
||
cout << "--(clipped)--"<< digxel;
|
||
#endif ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT
|
||
|
||
cout <<"|"<< endl;
|
||
}
|
||
};
|
||
|
||
|
||
/** Register this test class... */
|
||
LAUNCHER (DigxelConfigurations_test, "unit common");
|
||
|
||
|
||
|
||
}}} // namespace lib::time::test
|