[v2,2/5] test: ipa: libipa: histogram: Add tests for quantile() returning a fraction
diff mbox series

Message ID 20250401123633.58887-3-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • Fix histogram for some (corner) cases
Related show

Commit Message

Stefan Klug April 1, 2025, 12:36 p.m. UTC
Add tests for quantile() returning a fractional value. These cases will
get fixed in the next commit. Therefore mark the test as should_fail.

Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

---

Changes in v2:
- Move test patch before fix and add should_fail.
- Fixed comment
- Collected tags
---
 test/ipa/libipa/histogram.cpp | 9 +++++++++
 test/ipa/libipa/meson.build   | 5 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/test/ipa/libipa/histogram.cpp b/test/ipa/libipa/histogram.cpp
index 312b88b0786b..5ce84a61b7da 100644
--- a/test/ipa/libipa/histogram.cpp
+++ b/test/ipa/libipa/histogram.cpp
@@ -42,10 +42,19 @@  protected:
 		ASSERT_EQ(hist.quantile(1.0), 2.0);
 		ASSERT_EQ(hist.quantile(0.5), 1.0);
 
+		/* Test quantile in the middle of a bin. */
+		ASSERT_EQ(hist.quantile(0.75), 1.5);
+
+		/* Test quantile smaller than the smallest histogram step. */
+		ASSERT_EQ(hist.quantile(0.001), 0.002);
+
 		ASSERT_EQ(hist.interQuantileMean(0.0, 1.0), 1.0);
 		ASSERT_EQ(hist.interQuantileMean(0.0, 0.5), 0.5);
 		ASSERT_EQ(hist.interQuantileMean(0.5, 1.0), 1.5);
 
+		/* Test interquantile mean that starts and ends in the middle of a bin. */
+		ASSERT_EQ(hist.interQuantileMean(0.25, 0.75), 1.0);
+
 		return TestPass;
 	}
 };
diff --git a/test/ipa/libipa/meson.build b/test/ipa/libipa/meson.build
index f094c1593f1b..83c84bd8c227 100644
--- a/test/ipa/libipa/meson.build
+++ b/test/ipa/libipa/meson.build
@@ -2,7 +2,7 @@ 
 
 libipa_test = [
     {'name': 'fixedpoint', 'sources': ['fixedpoint.cpp']},
-    {'name': 'histogram', 'sources': ['histogram.cpp']},
+    {'name': 'histogram', 'sources': ['histogram.cpp'], 'should_fail': true},
     {'name': 'interpolator', 'sources': ['interpolator.cpp']},
 ]
 
@@ -14,5 +14,6 @@  foreach test : libipa_test
                      include_directories : [test_includes_internal,
                                             '../../../src/ipa/libipa/'])
 
-    test(test['name'], exe, suite : 'ipa')
+    test(test['name'], exe, suite : 'ipa',
+         should_fail : test.get('should_fail', false))
 endforeach