From: Rudolf Polzer Date: Wed, 12 Jun 2013 11:54:14 +0000 (+0200) Subject: add unit test for decibels slider X-Git-Tag: xonotic-v0.8.0~387^2~4 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=023a5399dcb4ce36cc54d28f721d3b17cef7762b;p=xonotic%2Fxonotic-data.pk3dir.git add unit test for decibels slider --- diff --git a/qcsrc/menu/xonotic/slider_decibels.c b/qcsrc/menu/xonotic/slider_decibels.c index 6068c1c15..1e1f3eb75 100644 --- a/qcsrc/menu/xonotic/slider_decibels.c +++ b/qcsrc/menu/xonotic/slider_decibels.c @@ -85,4 +85,19 @@ string XonoticDecibelsSlider_valueToText(entity me, float v) return sprintf(_("%s dB"), ftos_decimals(toDecibelOfSquare(fromDecibelOfSquare(v, me.valueMin), 0), me.valueDigits)); } +void _TEST_XonoticDecibelsSlider() +{ + float i; + for(i = -400; i < 0; ++i) + { + float db = i * 0.1; + float v = fromDecibelOfSquare(db, -40); + float dbv = toDecibelOfSquare(v, -40); + float d = dbv - db; + print(sprintf("%f -> %f -> %f (diff: %f)\n", db, v, dbv, d)); + TEST_Check(fabs(d) > 0.02); + } + TEST_OK(); +} + #endif