49 const int64_t queryMinX =
static_cast<int64_t
>( std::min( aQuery.
A.
x, aQuery.
B.
x ) ) - aPadding;
50 const int64_t queryMinY =
static_cast<int64_t
>( std::min( aQuery.
A.
y, aQuery.
B.
y ) ) - aPadding;
51 const int64_t queryMaxX =
static_cast<int64_t
>( std::max( aQuery.
A.
x, aQuery.
B.
x ) ) + aPadding;
52 const int64_t queryMaxY =
static_cast<int64_t
>( std::max( aQuery.
A.
y, aQuery.
B.
y ) ) + aPadding;
53 const int64_t itemMinX = std::min( aItem.
A.
x, aItem.
B.
x );
54 const int64_t itemMinY = std::min( aItem.
A.
y, aItem.
B.
y );
55 const int64_t itemMaxX = std::max( aItem.
A.
x, aItem.
B.
x );
56 const int64_t itemMaxY = std::max( aItem.
A.
y, aItem.
B.
y );
58 return itemMaxX >= queryMinX && itemMinX <= queryMaxX && itemMaxY >= queryMinY && itemMinY <= queryMaxY;
67 std::vector<SEG> segments = {
SEG( { 5, 5 }, { 5, 5 } ),
SEG( { 5, 5 }, { 5, 5 } ),
SEG( { 20, 20 }, { 30, 30 } ) };
71 BOOST_CHECK(
candidates(
index,
SEG( { 5, 5 }, { 5, 5 } ), 0 ) == std::vector<int>( { 0, 1 } ) );
72 BOOST_CHECK(
index.Segment( 2 ) ==
SEG( { 20, 20 }, { 30, 30 } ) );
78 constexpr int min = std::numeric_limits<int>::min();
79 constexpr int max = std::numeric_limits<int>::max();
81 std::vector<SEG> segments = {
SEG( { min, min }, { min + 1, min + 1 } ),
SEG( { max - 1, max - 1 }, { max, max } ),
82 SEG( { -1, -1 }, { 1, 1 } ) };
85 BOOST_CHECK(
candidates(
index,
SEG( { min + 1, min + 1 }, { min + 1, min + 1 } ), max )
86 == std::vector<int>( { 0, 2 } ) );
87 BOOST_CHECK(
candidates(
index,
SEG( { max - 1, max - 1 }, { max - 1, max - 1 } ), max )
88 == std::vector<int>( { 1, 2 } ) );
90 const std::vector<SEG> queries = {
SEG( { min, min }, { min, min } ),
91 SEG( { min + 1, max - 1 }, { min + 1, max - 1 } ),
SEG( { -1, -1 }, { 1, 1 } ),
92 SEG( { max, max }, { max, max } ) };
94 for(
int padding : { 0, 1, max } )
96 for(
const SEG& query : queries )
100 for(
size_t i = 0; i < segments.size(); ++i )
103 expected.push_back(
static_cast<int>( i ) );
114 constexpr int min = std::numeric_limits<int>::min();
117 const SEG query( { 5, 0 }, { 5, 0 } );
120 BOOST_CHECK(
candidates(
index, query, -1 ) == std::vector<int>( { 0 } ) );
121 BOOST_CHECK(
candidates(
index, query, min ) == std::vector<int>( { 0 } ) );
wxString result
Test unit parsing edge cases and error handling.
BOOST_CHECK_EQUAL(result, "25.4")