From d405d1fd5e791b3ebc45dc980be2fce9ac0f3529 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Mon, 13 Jul 2020 15:05:23 +0200 Subject: libcamera: utils: Add alignUp and alignDown functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add to libcamera utils library two functions to round up or down a value to an alignment and add a test in test/utils.cpp for the two new functions. Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- test/utils.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/utils.cpp b/test/utils.cpp index f482e6a1..08f29389 100644 --- a/test/utils.cpp +++ b/test/utils.cpp @@ -166,6 +166,17 @@ protected: return TestFail; } + /* utils::alignUp() and utils::alignDown() tests. */ + if (utils::alignDown(6, 3) != 6 || utils::alignDown(7, 3) != 6) { + cerr << "utils::alignDown test failed" << endl; + return TestFail; + } + + if (utils::alignUp(6, 3) != 6 || utils::alignUp(7, 3) != 9) { + cerr << "utils::alignUp test failed" << endl; + return TestFail; + } + return TestPass; } }; -- cgit v1.2.1