From 8e6f60fc8f442351bdc948d2142914d3946ce34d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 17 Sep 2026 19:05:06 +0200 Subject: 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 --- test/test_data.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') 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') -- cgit v1.2.3