fix: inconsistency assert

This commit is contained in:
Alessandro Sidero 2025-04-15 17:48:00 +02:00
commit 4268ae661b
3 changed files with 6 additions and 8 deletions

View file

@ -48,7 +48,7 @@ public:
*/
eoRanking(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e)
{
assert(1 < pressure and exponent <= 2);
assert(1 < pressure and pressure <= 2);
}
/* helper function: finds index in _pop of _eo, an EOT * */

View file

@ -59,7 +59,7 @@ public:
*/
eoRankingCached(double _p = 2.0, double _e = 1.0) : pressure(_p), exponent(_e), cached_pSize(0)
{
assert(1 < pressure and exponent <= 2);
assert(1 < pressure and pressure <= 2);
}
/*

View file

@ -175,19 +175,17 @@ void test_Assertions(eoParser &parser)
{
// Test valid parameters (should succeed)
bool valid_ok = true;
valid_ok &= testRankingConstructor(1.1, 1.0); // Valid pressure and exponent
valid_ok &= testRankingConstructor(1.1, 2.0); // Edge case valid
valid_ok &= testRankingCachedConstructor(1.1, 1.0); // Valid pressure and exponent
valid_ok &= testRankingCachedConstructor(1.1, 2.0); // Edge case valid
valid_ok &= testRankingConstructor(1.1, 1.0); // Valid pressure
valid_ok &= testRankingCachedConstructor(1.1, 1.0); // Valid pressure
// Test invalid parameters (should fail)
bool invalid_ok = true;
invalid_ok &= !testRankingConstructor(1.0, 1.0); // pressure = 1 (invalid)
invalid_ok &= !testRankingConstructor(0.5, 1.0); // pressure < 1 (invalid)
invalid_ok &= !testRankingConstructor(2.0, 2.1); // exponent > 2 (invalid)
invalid_ok &= !testRankingConstructor(2.1, 1.0); // pressure > 2 (invalid)
invalid_ok &= !testRankingCachedConstructor(1.0, 1.0); // pressure = 1 (invalid)
invalid_ok &= !testRankingCachedConstructor(0.5, 1.0); // pressure < 1 (invalid)
invalid_ok &= !testRankingCachedConstructor(2.5, 2.1); // exponent > 2 (invalid)
invalid_ok &= !testRankingCachedConstructor(2.1, 1.0); // pressure > 2 (invalid)
if (!valid_ok)
{