From 84d96173750a8bce42d37e8bd3f409f519187f57 Mon Sep 17 00:00:00 2001 From: Simon Rose Date: Thu, 12 May 2022 10:57:37 +0200 Subject: [PATCH] Added one more put/process to go over the buffer length Note that it is not really a circular buffer in this case, but a full reset of the buffer to the beginning. This matches the documentation, but it seems valuable to add an explicit test for this case. --- modules/database/test/std/rec/compressTest.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/database/test/std/rec/compressTest.c b/modules/database/test/std/rec/compressTest.c index 98eb1bab7..ed5f31e63 100644 --- a/modules/database/test/std/rec/compressTest.c +++ b/modules/database/test/std/rec/compressTest.c @@ -590,8 +590,12 @@ testNto1LowValue(void) { void testAIAveragePartial(void) { double buf = 0.; - double data[4] = {1., 2., 3., 4.}; - double expected[4] = {1., 1.5, 2., 2.5}; + double data[5] = {1., 2., 3., 4., 5.}; + /* + * Note that the fifth dbPut essentially resets the circular buffer, so the + * average is once again the average of the _first_ entry alone. + */ + double expected[5] = {1., 1.5, 2., 2.5, 5.}; long nReq = 1; int i; DBADDR aiaddr, caddr; @@ -610,7 +614,7 @@ testAIAveragePartial(void) { fetchRecordOrDie("ai", aiaddr); fetchRecordOrDie("comp", caddr); - for (i = 0; i < 4; i++) { + for (i = 0; i < 5; i++) { dbScanLock(aiaddr.precord); dbPut(&aiaddr, DBR_DOUBLE, &data[i], 1); dbScanUnlock(aiaddr.precord); @@ -630,7 +634,7 @@ testAIAveragePartial(void) { MAIN(compressTest) { - testPlan(131); + testPlan(132); testFIFOCirc(); testLIFOCirc(); testArrayAverage();