Library: fix failed tests(1) -- Rational_test
Problems in `Rational_test` were caused by `#include' reorderings regarding ''rational'' and ''intgral'' numbers. The actual root cause is the fact that `FSecs` is only a typedef, which prevents us from providing a string conversion for rational numbers without ambiguity
This commit is contained in:
parent
0b9e184fa3
commit
766da84a62
4 changed files with 60 additions and 34 deletions
|
|
@ -65,7 +65,7 @@ namespace lumiera {
|
||||||
|
|
||||||
namespace { // implementation details
|
namespace { // implementation details
|
||||||
|
|
||||||
void
|
inline void
|
||||||
throwIfError()
|
throwIfError()
|
||||||
{
|
{
|
||||||
if (lumiera_error_peek())
|
if (lumiera_error_peek())
|
||||||
|
|
@ -78,7 +78,7 @@ namespace lumiera {
|
||||||
* \em given instance descriptor to open an instance handle.
|
* \em given instance descriptor to open an instance handle.
|
||||||
* @throws error::Config when the registration process fails
|
* @throws error::Config when the registration process fails
|
||||||
*/
|
*/
|
||||||
LumieraInterface
|
inline LumieraInterface
|
||||||
register_and_open (LumieraInterface descriptor)
|
register_and_open (LumieraInterface descriptor)
|
||||||
{
|
{
|
||||||
if (!descriptor) return NULL;
|
if (!descriptor) return NULL;
|
||||||
|
|
@ -93,7 +93,7 @@ namespace lumiera {
|
||||||
/** do a lookup within the interfaceregistry
|
/** do a lookup within the interfaceregistry
|
||||||
* using the name/version found within the interface
|
* using the name/version found within the interface
|
||||||
* handle, to ensure it is still valid and registered */
|
* handle, to ensure it is still valid and registered */
|
||||||
bool
|
inline bool
|
||||||
verify_validity (LumieraInterface ifa)
|
verify_validity (LumieraInterface ifa)
|
||||||
{
|
{
|
||||||
REQUIRE (ifa);
|
REQUIRE (ifa);
|
||||||
|
|
@ -156,9 +156,10 @@ namespace lumiera {
|
||||||
: util::NonCopyable
|
: util::NonCopyable
|
||||||
{
|
{
|
||||||
using IH = InstanceHandle<I,I>;
|
using IH = InstanceHandle<I,I>;
|
||||||
|
|
||||||
IH& ih_;
|
IH& ih_;
|
||||||
|
|
||||||
Link (IH& ih)
|
Link(IH& ih)
|
||||||
: ih_{ih}
|
: ih_{ih}
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
@ -226,7 +227,7 @@ namespace lumiera {
|
||||||
throwIfError();
|
throwIfError();
|
||||||
}
|
}
|
||||||
|
|
||||||
~InstanceHandle ()
|
~InstanceHandle()
|
||||||
{
|
{
|
||||||
lumiera_interface_close (&instance_->interface_header_);
|
lumiera_interface_close (&instance_->interface_header_);
|
||||||
if (desc_)
|
if (desc_)
|
||||||
|
|
@ -239,14 +240,14 @@ namespace lumiera {
|
||||||
* @note we don't provide `operator*`
|
* @note we don't provide `operator*`
|
||||||
*/
|
*/
|
||||||
FA*
|
FA*
|
||||||
operator-> () const
|
operator->() const
|
||||||
{
|
{
|
||||||
return facadeLink_.operator ->();
|
return facadeLink_.operator ->();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** directly access the instance via the CL interface */
|
/** directly access the instance via the CL interface */
|
||||||
I&
|
I&
|
||||||
get () const
|
get() const
|
||||||
{
|
{
|
||||||
ENSURE(instance_);
|
ENSURE(instance_);
|
||||||
return *instance_;
|
return *instance_;
|
||||||
|
|
@ -270,11 +271,10 @@ namespace lumiera {
|
||||||
isValid() const
|
isValid() const
|
||||||
{
|
{
|
||||||
return instance_
|
return instance_
|
||||||
&& verify_validity (&instance_->interface_header_);
|
and verify_validity (&instance_->interface_header_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace lumiera
|
} // namespace lumiera
|
||||||
|
#endif /*LUMIERA_INSTANCEHANDLE_H*/
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "lib/test/run.hpp"
|
#include "lib/test/run.hpp"
|
||||||
#include "lib/integral.hpp"
|
#include "lib/integral.hpp"
|
||||||
#include "lib/format-cout.hpp"
|
#include "lib/format-cout.hpp"
|
||||||
|
#include "lib/test/test-helper.hpp"
|
||||||
|
|
||||||
#include "lib/rational.hpp"
|
#include "lib/rational.hpp"
|
||||||
|
|
||||||
|
|
@ -87,9 +88,9 @@ namespace test {
|
||||||
CHECK (2_r/3 /(3_r/4)== 8_r/9);
|
CHECK (2_r/3 /(3_r/4)== 8_r/9);
|
||||||
CHECK (2_r/3 / 3 /4 == 1_r/18); // usual precedence and brace rules apply, yielding 2/36 here
|
CHECK (2_r/3 / 3 /4 == 1_r/18); // usual precedence and brace rules apply, yielding 2/36 here
|
||||||
|
|
||||||
CHECK (util::toString(23_r/55) == "23/55sec"); //////////////////////////TICKET #1259 and #1261 : FSecs should really be a distinct (wrapper) type,
|
CHECK (util::toString(23_r/55) == "23/55sec"_expect); ///////////////////TICKET #1259 and #1261 : FSecs should really be a distinct (wrapper) type,
|
||||||
//////////////////////////TICKET #1259 and #1261 : ...then this custom conversion with the suffix "sec" would not kick in here
|
///////////////////TICKET #1259 and #1261 : ...then this custom conversion with the suffix "sec" would not kick in here
|
||||||
CHECK (util::toString(24_r/56) == "3/7sec" ); // rational numbers are normalised and reduced immediately
|
CHECK (util::toString(24_r/56) == "3/7sec"_expect ); // rational numbers are normalised and reduced immediately
|
||||||
|
|
||||||
CHECK (Rat(10,3).numerator() == int64_t(10));
|
CHECK (Rat(10,3).numerator() == int64_t(10));
|
||||||
CHECK (Rat(10,3).denominator() == int64_t(3));
|
CHECK (Rat(10,3).denominator() == int64_t(3));
|
||||||
|
|
@ -118,32 +119,32 @@ namespace test {
|
||||||
CHECK (MAXI > 0); // so this one still works
|
CHECK (MAXI > 0); // so this one still works
|
||||||
CHECK (MAXI+1 < 0); // but one more and we get a wrap-around
|
CHECK (MAXI+1 < 0); // but one more and we get a wrap-around
|
||||||
CHECK (MAXI+1 < -MAXI);
|
CHECK (MAXI+1 < -MAXI);
|
||||||
CHECK (util::toString(MAXI) == "9223372036854775807sec"); /////////TICKET #1259 should be "9223372036854775807/1 -- get rid of the "sec" suffix
|
CHECK (util::toString(MAXI) == "9223372036854775807sec"_expect); /////////TICKET #1259 should be "9223372036854775807/1 -- get rid of the "sec" suffix
|
||||||
CHECK (util::toString(MAXI+1) == "-9223372036854775808sec"); /////////TICKET #1259 should be "-9223372036854775808/1"
|
CHECK (util::toString(MAXI+1) == "-9223372036854775808sec"_expect); /////////TICKET #1259 should be "-9223372036854775808/1"
|
||||||
CHECK (util::toString(-MAXI) == "-9223372036854775807sec"); /////////TICKET #1259 should be "-9223372036854775807/1"
|
CHECK (util::toString(-MAXI) == "-9223372036854775807sec"_expect); /////////TICKET #1259 should be "-9223372036854775807/1"
|
||||||
|
|
||||||
CHECK (MINI > 0); // smallest representable number above zero
|
CHECK (MINI > 0); // smallest representable number above zero
|
||||||
CHECK (1-MINI < 1);
|
CHECK (1-MINI < 1);
|
||||||
CHECK (0 < 1-MINI); // can be used below 1 just fine
|
CHECK (0 < 1-MINI); // can be used below 1 just fine
|
||||||
CHECK (0 > 1+MINI); // but above we get a wrap-around in normalised numerator
|
CHECK (0 > 1+MINI); // but above we get a wrap-around in normalised numerator
|
||||||
CHECK (util::toString(MINI) == "1/9223372036854775807sec");
|
CHECK (util::toString(MINI) == "1/9223372036854775807sec"_expect);
|
||||||
CHECK (util::toString(-MINI) == "-1/9223372036854775807sec");
|
CHECK (util::toString(-MINI) == "-1/9223372036854775807sec"_expect);
|
||||||
CHECK (util::toString(1-MINI) == "9223372036854775806/9223372036854775807sec");
|
CHECK (util::toString(1-MINI) == "9223372036854775806/9223372036854775807sec"_expect);
|
||||||
CHECK (util::toString(1+MINI) == "-9223372036854775808/9223372036854775807sec");
|
CHECK (util::toString(1+MINI) == "-9223372036854775808/9223372036854775807sec"_expect);
|
||||||
|
|
||||||
CHECK ((MAXI-1)/MAXI == 1-MINI);
|
CHECK ((MAXI-1)/MAXI == 1-MINI);
|
||||||
CHECK (MAXI/(MAXI-1) > 1); // as workaround we have to use a slightly larger ULP
|
CHECK (MAXI/(MAXI-1) > 1); // as workaround we have to use a slightly larger ULP
|
||||||
CHECK (MAXI/(MAXI-1) - 1 > MINI); // ...this slightly larger one works without wrap-around
|
CHECK (MAXI/(MAXI-1) - 1 > MINI); // ...this slightly larger one works without wrap-around
|
||||||
CHECK (1 - MAXI/(MAXI-1) < -MINI);
|
CHECK (1 - MAXI/(MAXI-1) < -MINI);
|
||||||
CHECK (util::toString(MAXI/(MAXI-1)) == "9223372036854775807/9223372036854775806sec");
|
CHECK (util::toString(MAXI/(MAXI-1)) == "9223372036854775807/9223372036854775806sec"_expect);
|
||||||
CHECK (util::toString(MAXI/(MAXI-1) - 1) == "1/9223372036854775806sec");
|
CHECK (util::toString(MAXI/(MAXI-1) - 1) == "1/9223372036854775806sec"_expect);
|
||||||
CHECK (util::toString(1 - MAXI/(MAXI-1)) == "-1/9223372036854775806sec");
|
CHECK (util::toString(1 - MAXI/(MAXI-1)) == "-1/9223372036854775806sec"_expect);
|
||||||
|
|
||||||
// Now entering absolute danger territory....
|
// Now entering absolute danger territory....
|
||||||
const Rat MIMI = -MAXI-1; // this is the most extreme negative representable value
|
const Rat MIMI = -MAXI-1; // this is the most extreme negative representable value
|
||||||
CHECK (MIMI < 0);
|
CHECK (MIMI < 0);
|
||||||
CHECK (util::toString(MIMI) == "-9223372036854775808sec"); /////////TICKET #1259 should be "-9223372036854775808/1"
|
CHECK (util::toString(MIMI) == "-9223372036854775808sec"_expect); /////////TICKET #1259 should be "-9223372036854775808/1"
|
||||||
CHECK (util::toString(1/MIMI) == "-1/-9223372036854775808sec");
|
CHECK (util::toString(1/MIMI) == "-1/-9223372036854775808sec"_expect);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
-1-1/MIMI; // ...but it can't be used for any calculation without blowing up
|
-1-1/MIMI; // ...but it can't be used for any calculation without blowing up
|
||||||
|
|
@ -354,10 +355,10 @@ namespace test {
|
||||||
CHECK (approx (sleazy+7) == 14);
|
CHECK (approx (sleazy+7) == 14);
|
||||||
CHECK (approx (sleazy+9_r/5) == 8.80000019f);
|
CHECK (approx (sleazy+9_r/5) == 8.80000019f);
|
||||||
|
|
||||||
CHECK (util::toString (poison) == "9223372036854775719/1317624576693539401sec");
|
CHECK (util::toString (poison) == "9223372036854775719/1317624576693539401sec"_expect);
|
||||||
CHECK (util::toString (poison+1) =="-7905747460161236496/1317624576693539401sec");
|
CHECK (util::toString (poison+1) =="-7905747460161236496/1317624576693539401sec"_expect);
|
||||||
CHECK (util::toString (sleazy) == "117440511/16777216sec");
|
CHECK (util::toString (sleazy) == "117440511/16777216sec"_expect);
|
||||||
CHECK (util::toString (sleazy+1) == "134217727/16777216sec");
|
CHECK (util::toString (sleazy+1) == "134217727/16777216sec"_expect);
|
||||||
|
|
||||||
// also works towards larger denominator, or with negative numbers...
|
// also works towards larger denominator, or with negative numbers...
|
||||||
CHECK (reQuant (1/poison, MAX) == 1317624576693539413_r/9223372036854775807);
|
CHECK (reQuant (1/poison, MAX) == 1317624576693539413_r/9223372036854775807);
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ namespace test {
|
||||||
VecI data;
|
VecI data;
|
||||||
for (uint i=0; i<cnt; ++i)
|
for (uint i=0; i<cnt; ++i)
|
||||||
{
|
{
|
||||||
int someNumber { rani (2*NUMBER_LIMIT) - NUMBER_LIMIT};
|
int someNumber = -int(NUMBER_LIMIT)+rani(2*NUMBER_LIMIT);
|
||||||
if (!someNumber) someNumber -= 1 + rani (NUMBER_LIMIT);
|
if (!someNumber) someNumber -= 1 + rani(NUMBER_LIMIT);
|
||||||
|
|
||||||
data.push_back (someNumber);
|
data.push_back (someNumber);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57513,7 +57513,7 @@
|
||||||
</node>
|
</node>
|
||||||
<node BACKGROUND_COLOR="#fafe99" COLOR="#fa002a" CREATED="1731466845496" ID="ID_108595980" MODIFIED="1731466860399" TEXT="Tests scheitern nach Umstellung">
|
<node BACKGROUND_COLOR="#fafe99" COLOR="#fa002a" CREATED="1731466845496" ID="ID_108595980" MODIFIED="1731466860399" TEXT="Tests scheitern nach Umstellung">
|
||||||
<icon BUILTIN="broken-line"/>
|
<icon BUILTIN="broken-line"/>
|
||||||
<node CREATED="1731466868785" ID="ID_1204988400" MODIFIED="1731466887399" TEXT="Rational_test">
|
<node COLOR="#435e98" CREATED="1731466868785" ID="ID_1204988400" MODIFIED="1731516821863" TEXT="Rational_test">
|
||||||
<richcontent TYPE="NOTE"><html>
|
<richcontent TYPE="NOTE"><html>
|
||||||
<head/>
|
<head/>
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -57521,9 +57521,35 @@
|
||||||
0000000515: CHECK: rational-test.cpp:90: thread_1: demonstrate_basics: (util::toString(23_r/55) == "23/55sec")
|
0000000515: CHECK: rational-test.cpp:90: thread_1: demonstrate_basics: (util::toString(23_r/55) == "23/55sec")
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
|
</html></richcontent>
|
||||||
|
<node CREATED="1731516823812" ID="ID_1419872560" MODIFIED="1731516925668" TEXT="bedingt durch Reorganisation #includes">
|
||||||
|
<richcontent TYPE="NOTE"><html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
...hatte vor einiger Zeit aufgeräumt und einen eigenen #include "lib/integral.hpp" geschaffen. Dadurch ist downstream der #include für time-value.hpp rausgefallen, und damit fehlte die String-conversion für Rationals
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
</richcontent>
|
</richcontent>
|
||||||
</node>
|
</node>
|
||||||
|
<node CREATED="1731516926921" ID="ID_1885341686" MODIFIED="1731516970756" TEXT="die eigentliche Ursache ist das ungelöste Problem mit FSecs">
|
||||||
|
<richcontent TYPE="NOTE"><html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
...dazu nochmal über die ganze Problematik nachgedacht und entsprechende Kommentare in #1258 und #1261 hinterlassen
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</richcontent>
|
||||||
|
<font ITALIC="true" NAME="SansSerif" SIZE="12"/>
|
||||||
|
</node>
|
||||||
|
</node>
|
||||||
<node CREATED="1731466941465" ID="ID_1180140959" MODIFIED="1731467103523" TEXT="SchedulerCommutator_test">
|
<node CREATED="1731466941465" ID="ID_1180140959" MODIFIED="1731467103523" TEXT="SchedulerCommutator_test">
|
||||||
<richcontent TYPE="NOTE"><html>
|
<richcontent TYPE="NOTE"><html>
|
||||||
<head/>
|
<head/>
|
||||||
|
|
@ -57538,8 +57564,7 @@
|
||||||
<font size="1">0000000598: UNIMPLEMENTED: scheduler-commutator.hpp:204: thread_1: findWork: how to trigger a Scheduler-Emergency from here </font>
|
<font size="1">0000000598: UNIMPLEMENTED: scheduler-commutator.hpp:204: thread_1: findWork: how to trigger a Scheduler-Emergency from here </font>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html></richcontent>
|
||||||
</richcontent>
|
|
||||||
</node>
|
</node>
|
||||||
<node CREATED="1731466991636" ID="ID_1891507132" MODIFIED="1731467127501" TEXT="SchedulerStress_test">
|
<node CREATED="1731466991636" ID="ID_1891507132" MODIFIED="1731467127501" TEXT="SchedulerStress_test">
|
||||||
<richcontent TYPE="NOTE"><html>
|
<richcontent TYPE="NOTE"><html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue