diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-17 19:05:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-17 19:05:06 +0200 |
| commit | 8e6f60fc8f442351bdc948d2142914d3946ce34d (patch) | |
| tree | 1f64298027479032d2f2f108d52fc26c3082944c | |
| parent | c521d9eb71c9ca96348598d20eecb5ffd746aabf (diff) | |
| download | conky-theme-udt-8e6f60fc8f442351bdc948d2142914d3946ce34d.tar.gz conky-theme-udt-8e6f60fc8f442351bdc948d2142914d3946ce34d.zip | |
test: cover the rate counter's explicit fallback interval
The widget passes conky's update_interval rather than letting it default, so
the argument path is the one that ships and nothing exercised it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
| -rw-r--r-- | test/test_data.lua | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_data.lua b/test/test_data.lua index 478bf78..1b6c580 100644 --- a/test/test_data.lua +++ b/test/test_data.lua @@ -209,4 +209,13 @@ assert(same_second ~= nil and same_second >= 0, local r4 = data.new_rate_counter() assert(r4:sample(nil, 100) == nil, 'a nil byte count gives nil') +-- The fallback interval is a constructor argument, and the widget passes +-- conky's real update_interval rather than letting it default. That is the +-- path that ships, so it is the path that gets a test: at a 5s interval the +-- same 2048 bytes must read as 409.6 B/s, not 1024. +local r5 = data.new_rate_counter(5) +r5:sample(1000, 100) +assert(r5:sample(3048, 100) == 2048 / 5, + 'an explicit fallback interval must be used, got ' .. tostring(r5:sample(3048, 100))) + print('test_data: all assertions passed') |
