1111
1212#include < cstdio>
1313#include " Framework/ASoA.h"
14+ #include " Framework/ExpressionHelpers.h"
1415#include " Framework/Expressions.h"
1516#include " Framework/AnalysisHelpers.h"
1617#include " CommonConstants/MathConstants.h"
@@ -625,11 +626,7 @@ TEST_CASE("TestFilteredOperators")
625626 FilteredTest filteredIntersection = filtered1 * filtered2;
626627 REQUIRE (0 == filteredIntersection.size ());
627628
628- i = 0 ;
629- for (auto const & _ : filteredIntersection) {
630- i++;
631- }
632- REQUIRE (i == 0 );
629+ REQUIRE (filteredIntersection.size () == 0 );
633630
634631 expressions::Filter f3 = o2::aod::test::x < 3 ;
635632 auto s3 = expressions::createSelection (testA.asArrowTable (), f3);
@@ -890,7 +887,7 @@ TEST_CASE("TestAdvancedIndices")
890887 std::array<int , 4 > withSlices = {3 , 6 , 13 , 19 };
891888 std::array<std::pair<int , int >, 4 > bounds = {std::pair{1 , 5 }, std::pair{3 , 3 }, std::pair{11 , 11 }, std::pair{10 , 18 }};
892889 std::array<int , 4 > withSets = {0 , 1 , 13 , 14 };
893- unsigned int sizes[] = {3 , 1 , 5 , 4 };
890+ unsigned const int sizes[] = {3 , 1 , 5 , 4 };
894891 unsigned int c1 = 0 ;
895892 unsigned int c2 = 0 ;
896893 for (auto i = 0 ; i < 20 ; ++i) {
@@ -927,13 +924,11 @@ TEST_CASE("TestAdvancedIndices")
927924 REQUIRE (bbbs);
928925
929926 if (i == withSlices[c1]) {
930- auto it = ops.begin ();
927+ auto lit = ops.begin ();
931928 REQUIRE (ops.size () == bounds[c1].second - bounds[c1].first + 1 );
932- REQUIRE (it.globalIndex () == bounds[c1].first );
933- for (auto j = 1 ; j < ops.size (); ++j) {
934- ++it;
935- }
936- REQUIRE (it.globalIndex () == bounds[c1].second );
929+ REQUIRE (lit.globalIndex () == bounds[c1].first );
930+ lit.moveByIndex (ops.size () - 1 );
931+ REQUIRE (lit.globalIndex () == bounds[c1].second );
937932 ++c1;
938933 } else {
939934 REQUIRE (ops.size () == 0 );
@@ -949,7 +944,7 @@ TEST_CASE("TestAdvancedIndices")
949944 REQUIRE (opss.begin ()->globalIndex () == i + 1 );
950945 REQUIRE (opss.back ().globalIndex () == i + sizes[c2]);
951946 int c3 = 0 ;
952- for (auto & id : opss_ids) {
947+ for (auto const & id : opss_ids) {
953948 REQUIRE (id == i + 1 + c3);
954949 ++c3;
955950 }
@@ -976,7 +971,7 @@ TEST_CASE("TestSelfIndexRecursion")
976971 std::array<int , 4 > withSlices = {3 , 6 , 13 , 19 };
977972 std::array<std::pair<int , int >, 4 > bounds = {std::pair{1 , 5 }, std::pair{3 , 3 }, std::pair{11 , 11 }, std::pair{10 , 18 }};
978973 std::array<int , 4 > withSets = {0 , 1 , 13 , 14 };
979- unsigned int sizes[] = {3 , 1 , 5 , 4 };
974+ unsigned const int sizes[] = {3 , 1 , 5 , 4 };
980975 unsigned int c1 = 0 ;
981976 unsigned int c2 = 0 ;
982977 for (auto i = 0 ; i < 20 ; ++i) {
@@ -1076,7 +1071,7 @@ TEST_CASE("TestSelfIndexRecursion")
10761071 auto const & fpa = fp;
10771072
10781073 // iterators acquired through different means should have consistent types
1079- for (auto & it1 : fpa) {
1074+ for (auto const & it1 : fpa) {
10801075 [[maybe_unused]] auto it2 = fpa.rawIteratorAt (0 );
10811076 [[maybe_unused]] auto it3 = fpa.iteratorAt (0 );
10821077 auto bit1 = std::same_as<std::decay_t <decltype (it1)>, std::decay_t <decltype (it2)>>;
@@ -1111,7 +1106,7 @@ TEST_CASE("TestSelfIndexRecursion")
11111106 auto const & ffpa = ffp;
11121107
11131108 // rawIteratorAt() should create an unfiltered iterator, unlike begin() and iteratorAt()
1114- for (auto & it1 : ffpa) {
1109+ for (auto const & it1 : ffpa) {
11151110 [[maybe_unused]] auto it2 = ffpa.rawIteratorAt (0 );
11161111 [[maybe_unused]] auto it3 = ffpa.iteratorAt (0 );
11171112 using T1 = std::decay_t <decltype (it1)>;
@@ -1359,9 +1354,8 @@ TEST_CASE("TestArrayColumns")
13591354 TableBuilder b;
13601355 auto writer = b.cursor <o2::aod::BILists>();
13611356 int8_t ii[32 ];
1362- uint32_t bb;
13631357 for (auto i = 0 ; i < 20 ; ++i) {
1364- bb = 0 ;
1358+ uint32_t bb = 0 ;
13651359 for (auto j = 0 ; j < 32 ; ++j) {
13661360 ii[j] = j;
13671361 if (j % 2 == 0 ) {
@@ -1481,3 +1475,95 @@ TEST_CASE("TestWritingCursorLastIndexAndReserve")
14811475 REQUIRE (table->num_columns () == 2 );
14821476 cursor.release ();
14831477}
1478+
1479+ namespace o2 ::aod
1480+ {
1481+ namespace test
1482+ {
1483+ DECLARE_SOA_COLUMN (UInt8, guint8, uint8_t );
1484+ DECLARE_SOA_COLUMN (UInt16, guint16, uint16_t );
1485+ DECLARE_SOA_COLUMN (UInt32, guint32, uint32_t );
1486+ DECLARE_SOA_COLUMN (UInt64, guint64, uint64_t );
1487+ } // namespace test
1488+
1489+ DECLARE_SOA_TABLE (UnsignedIntTest8, " TEST" , " TSHI8" , test::UInt8);
1490+ DECLARE_SOA_TABLE (UnsignedIntTest16, " TEST" , " TSHI16" , test::UInt16);
1491+ DECLARE_SOA_TABLE (UnsignedIntTest32, " TEST" , " TSHI32" , test::UInt32);
1492+ DECLARE_SOA_TABLE (UnsignedIntTest64, " TEST" , " TSHI64" , test::UInt64);
1493+ } // namespace o2::aod
1494+
1495+ TEST_CASE (" TestUnsignedIntExpressions" )
1496+ {
1497+ auto max8 = std::numeric_limits<uint8_t >::max ();
1498+ auto max16 = std::numeric_limits<uint8_t >::max ();
1499+ auto max32 = std::numeric_limits<uint8_t >::max ();
1500+ auto max64 = std::numeric_limits<uint8_t >::max ();
1501+
1502+ TableBuilder b8;
1503+ auto writer8 = b8.cursor <o2::aod::UnsignedIntTest8>();
1504+ for (uint64_t i = 0 ; i < max8; i += (max8 / 100 )) {
1505+ writer8 (0 , i);
1506+ }
1507+ auto t8 = b8.finalize ();
1508+ o2::aod::UnsignedIntTest8 at8{{t8}};
1509+
1510+ uint8_t limit8 = max8 / 2 + 1 ;
1511+ o2::framework::expressions::Filter test8 = o2::aod::test::guint8 < limit8;
1512+ auto s8 = o2::framework::expressions::createSelection (t8, test8);
1513+
1514+ o2::soa::Filtered<o2::aod::UnsignedIntTest8> fat8{{t8}, s8};
1515+
1516+ REQUIRE (at8.size () == 128 );
1517+ REQUIRE (fat8.size () == 64 );
1518+
1519+ TableBuilder b16;
1520+ auto writer16 = b16.cursor <o2::aod::UnsignedIntTest16>();
1521+ for (uint64_t i = 0 ; i < max16; i += (max16 / 100 )) {
1522+ writer16 (0 , i);
1523+ }
1524+ auto t16 = b16.finalize ();
1525+ o2::aod::UnsignedIntTest16 at16{{t16}};
1526+
1527+ uint16_t limit16 = max16 / 2 + 1 ;
1528+ o2::framework::expressions::Filter test16 = o2::aod::test::guint16 < limit16;
1529+ auto s16 = o2::framework::expressions::createSelection (t16, test16);
1530+
1531+ o2::soa::Filtered<o2::aod::UnsignedIntTest16> fat16{{t16}, s16};
1532+
1533+ REQUIRE (at16.size () == 128 );
1534+ REQUIRE (fat16.size () == 64 );
1535+
1536+ TableBuilder b32;
1537+ auto writer32 = b32.cursor <o2::aod::UnsignedIntTest32>();
1538+ for (uint64_t i = 0 ; i < max32; i += (max32 / 100 )) {
1539+ writer32 (0 , i);
1540+ }
1541+ auto t32 = b32.finalize ();
1542+ o2::aod::UnsignedIntTest32 at32{{t32}};
1543+
1544+ uint32_t limit32 = max32 / 2 + 1 ;
1545+ o2::framework::expressions::Filter test32 = o2::aod::test::guint32 < limit32;
1546+ auto s32 = o2::framework::expressions::createSelection (t32, test32);
1547+
1548+ o2::soa::Filtered<o2::aod::UnsignedIntTest32> fat32{{t32}, s32};
1549+
1550+ REQUIRE (at32.size () == 128 );
1551+ REQUIRE (fat32.size () == 64 );
1552+
1553+ TableBuilder b64;
1554+ auto writer64 = b64.cursor <o2::aod::UnsignedIntTest64>();
1555+ for (uint64_t i = 0 ; i < max64; i += (max64 / 100 )) {
1556+ writer64 (0 , i);
1557+ }
1558+ auto t64 = b64.finalize ();
1559+ o2::aod::UnsignedIntTest64 at64{{t64}};
1560+
1561+ uint64_t limit64 = max64 / 2 + 1 ;
1562+ o2::framework::expressions::Filter test64 = o2::aod::test::guint64 < limit64;
1563+ auto s64 = o2::framework::expressions::createSelection (t64, test64);
1564+
1565+ o2::soa::Filtered<o2::aod::UnsignedIntTest64> fat64{{t64}, s64};
1566+
1567+ REQUIRE (at64.size () == 128 );
1568+ REQUIRE (fat64.size () == 64 );
1569+ }
0 commit comments