summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global/qcomparehelpers/tst_qcomparehelpers.cpp
blob: e3810f8605289092d5a85384827c0668153f3e44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include <QtCore/qcompare.h>
#include <QtTest/qtest.h>
#include <QtTest/private/qcomparisontesthelper_p.h>

class IntWrapper
{
public:
    // implicit constructor and operator int() to simulate the case that
    // triggers a bug on MSVC < 19.36.
    IntWrapper(int val) : m_val(val) {}
    operator int() const noexcept { return m_val; }

    int value() const { return m_val; }

private:
    friend bool comparesEqual(const IntWrapper &lhs, const IntWrapper &rhs) noexcept
    { return lhs.m_val == rhs.m_val; }
    friend Qt::strong_ordering
    compareThreeWay(const IntWrapper &lhs, const IntWrapper &rhs) noexcept
    {
        // ### Qt::compareThreeWay
        if (lhs.m_val < rhs.m_val)
            return Qt::strong_ordering::less;
        else if (lhs.m_val > rhs.m_val)
            return Qt::strong_ordering::greater;
        else
            return Qt::strong_ordering::equal;
    }
    friend bool comparesEqual(const IntWrapper &lhs, int rhs) noexcept
    { return lhs.m_val == rhs; }
    friend Qt::strong_ordering compareThreeWay(const IntWrapper &lhs, int rhs) noexcept
    { return compareThreeWay(lhs, IntWrapper(rhs)); }

    Q_DECLARE_STRONGLY_ORDERED(IntWrapper)
    Q_DECLARE_STRONGLY_ORDERED(IntWrapper, int)

    int m_val = 0;
};

class DoubleWrapper
{
public:
    explicit DoubleWrapper(double val) : m_val(val) {}
    double value() const { return m_val; }

private:
    friend bool comparesEqual(const DoubleWrapper &lhs, const DoubleWrapper &rhs) noexcept
    { return lhs.m_val == rhs.m_val; }
    friend Qt::partial_ordering
    compareThreeWay(const DoubleWrapper &lhs, const DoubleWrapper &rhs) noexcept
    {
        // ### Qt::compareThreeWay
        if (qIsNaN(lhs.m_val) || qIsNaN(rhs.m_val))
            return Qt::partial_ordering::unordered;

        if (lhs.m_val < rhs.m_val)
            return Qt::partial_ordering::less;
        else if (lhs.m_val > rhs.m_val)
            return Qt::partial_ordering::greater;
        else
            return Qt::partial_ordering::equivalent;
    }
    friend bool comparesEqual(const DoubleWrapper &lhs, const IntWrapper &rhs) noexcept
    { return comparesEqual(lhs, DoubleWrapper(rhs.value())); }
    friend Qt::partial_ordering
    compareThreeWay(const DoubleWrapper &lhs, const IntWrapper &rhs) noexcept
    { return compareThreeWay(lhs, DoubleWrapper(rhs.value())); }
    friend bool comparesEqual(const DoubleWrapper &lhs, double rhs) noexcept
    { return lhs.m_val == rhs; }
    friend Qt::partial_ordering compareThreeWay(const DoubleWrapper &lhs, double rhs) noexcept
    {
        // ### Qt::compareThreeWay
        if (qIsNaN(lhs.m_val) || qIsNaN(rhs))
            return Qt::partial_ordering::unordered;

        if (lhs.m_val < rhs)
            return Qt::partial_ordering::less;
        else if (lhs.m_val > rhs)
            return Qt::partial_ordering::greater;
        else
            return Qt::partial_ordering::equivalent;
    }

    Q_DECLARE_PARTIALLY_ORDERED(DoubleWrapper)
    Q_DECLARE_PARTIALLY_ORDERED(DoubleWrapper, IntWrapper)
    Q_DECLARE_PARTIALLY_ORDERED(DoubleWrapper, double)

    double m_val = 0.0;
};

template <typename String>
class StringWrapper
{
public:
    explicit StringWrapper(String val) : m_val(val) {}
    String value() const { return m_val; }

private:
    // Some of the helper functions are intentionally NOT marked as noexcept
    // to test the conditional noexcept in the macros.
    template <typename T>
    friend bool comparesEqual(const StringWrapper<T> &, const StringWrapper<T> &) noexcept;
    template <typename T>
    friend Qt::weak_ordering
    compareThreeWay(const StringWrapper<T> &, const StringWrapper<T> &) noexcept;
    template <typename T>
    friend bool comparesEqual(const StringWrapper<T> &, QAnyStringView);
    template <typename T>
    friend Qt::weak_ordering compareThreeWay(const StringWrapper<T> &, QAnyStringView);

    Q_DECLARE_WEAKLY_ORDERED(StringWrapper)
    Q_DECLARE_WEAKLY_ORDERED(StringWrapper, QAnyStringView)

    String m_val;
};

// StringWrapper comparison helper functions

bool equalsHelper(QAnyStringView lhs, QAnyStringView rhs) noexcept
{
    return QAnyStringView::compare(lhs, rhs, Qt::CaseInsensitive) == 0;
}

template <typename T>
bool comparesEqual(const StringWrapper<T> &lhs, const StringWrapper<T> &rhs) noexcept
{
    return equalsHelper(lhs.m_val, rhs.m_val);
}

Qt::weak_ordering compareHelper(QAnyStringView lhs, QAnyStringView rhs) noexcept
{
    const int res = QAnyStringView::compare(lhs, rhs, Qt::CaseInsensitive);
    if (res < 0)
        return Qt::weak_ordering::less;
    else if (res > 0)
        return Qt::weak_ordering::greater;
    else
        return Qt::weak_ordering::equivalent;
}

template <typename T>
Qt::weak_ordering compareThreeWay(const StringWrapper<T> &lhs, const StringWrapper<T> &rhs) noexcept
{
    return compareHelper(lhs.m_val, rhs.m_val);
}

template <typename T>
bool comparesEqual(const StringWrapper<T> &lhs, QAnyStringView rhs)
{
    return equalsHelper(lhs.m_val, rhs);
}

template <typename T>
Qt::weak_ordering compareThreeWay(const StringWrapper<T> &lhs, QAnyStringView rhs)
{
    return compareHelper(lhs.m_val, rhs);
}

// Test class

class tst_QCompareHelpers : public QObject
{
    Q_OBJECT

private:
    template <typename LeftType, typename RightType, typename OrderingType>
    void compareImpl();

    template <typename LeftType, typename RightType>
    void compareIntData();

    template <typename LeftType, typename RightType>
    void compareFloatData();

    template <typename LeftType, typename RightType>
    void compareStringData();

private slots:
    void comparisonCompiles();

    void compare_IntWrapper_data() { compareIntData<IntWrapper, IntWrapper>(); }
    void compare_IntWrapper() { compareImpl<IntWrapper, IntWrapper, Qt::strong_ordering>(); }

    void compare_IntWrapper_int_data() { compareIntData<IntWrapper, int>(); }
    void compare_IntWrapper_int() { compareImpl<IntWrapper, int, Qt::strong_ordering>(); }

    void compare_DoubleWrapper_data() { compareFloatData<DoubleWrapper, DoubleWrapper>(); }
    void compare_DoubleWrapper()
    { compareImpl<DoubleWrapper, DoubleWrapper, Qt::partial_ordering>(); }

    void compare_DoubleWrapper_double_data() { compareFloatData<DoubleWrapper, double>(); }
    void compare_DoubleWrapper_double()
    { compareImpl<DoubleWrapper, double, Qt::partial_ordering>(); }

    void compare_IntWrapper_DoubleWrapper_data();
    void compare_IntWrapper_DoubleWrapper()
    { compareImpl<IntWrapper, DoubleWrapper, Qt::partial_ordering>(); }

    void compare_StringWrapper_data()
    { compareStringData<StringWrapper<QString>, StringWrapper<QString>>(); }
    void compare_StringWrapper()
    { compareImpl<StringWrapper<QString>, StringWrapper<QString>, Qt::weak_ordering>(); }

    void compare_StringWrapper_AnyStringView_data()
    { compareStringData<StringWrapper<QString>, QAnyStringView>(); }
    void compare_StringWrapper_AnyStringView()
    { compareImpl<StringWrapper<QString>, QAnyStringView, Qt::weak_ordering>(); }

    void generatedClasses();
};

template<typename LeftType, typename RightType, typename OrderingType>
void tst_QCompareHelpers::compareImpl()
{
    QFETCH(LeftType, lhs);
    QFETCH(RightType, rhs);
    QFETCH(OrderingType, expectedOrdering);

    QTestPrivate::testAllComparisonOperators(lhs, rhs, expectedOrdering);
    if (QTest::currentTestFailed())
        return;
#ifdef __cpp_lib_three_way_comparison
    // Also check std types.

    // if Ordering == Qt::strong_ordering -> std::strong_ordering
    // else if Ordering == Qt::weak_ordering -> std::weak_ordering
    // else std::partial_ordering
    using StdType = std::conditional_t<
                        std::is_same_v<OrderingType, Qt::strong_ordering>,
                            std::strong_ordering,
                            std::conditional_t<std::is_same_v<OrderingType, Qt::weak_ordering>,
                                std::weak_ordering,
                                std::partial_ordering>>;

    QTestPrivate::testAllComparisonOperators(lhs, rhs, static_cast<StdType>(expectedOrdering));
    if (QTest::currentTestFailed())
        return;
#endif // __cpp_lib_three_way_comparison
}

template<typename LeftType, typename RightType>
void tst_QCompareHelpers::compareIntData()
{
    QTest::addColumn<LeftType>("lhs");
    QTest::addColumn<RightType>("rhs");
    QTest::addColumn<Qt::strong_ordering>("expectedOrdering");

    auto createRow = [](auto lhs, auto rhs, Qt::strong_ordering ordering) {
        QTest::addRow("%d vs %d", lhs, rhs) << LeftType(lhs) << RightType(rhs) << ordering;
    };

    createRow(0, 0, Qt::strong_ordering::equivalent);
    createRow(-1, 0, Qt::strong_ordering::less);
    createRow(1, 0, Qt::strong_ordering::greater);
    constexpr int max = std::numeric_limits<int>::max();
    constexpr int min = std::numeric_limits<int>::min();
    createRow(max, max, Qt::strong_ordering::equivalent);
    createRow(min, min, Qt::strong_ordering::equivalent);
    createRow(max, min, Qt::strong_ordering::greater);
    createRow(min, max, Qt::strong_ordering::less);
}

template<typename LeftType, typename RightType>
void tst_QCompareHelpers::compareFloatData()
{
    QTest::addColumn<LeftType>("lhs");
    QTest::addColumn<RightType>("rhs");
    QTest::addColumn<Qt::partial_ordering>("expectedOrdering");

    auto createRow = [](auto lhs, auto rhs, Qt::partial_ordering ordering) {
        QTest::addRow("%f vs %f", lhs, rhs) << LeftType(lhs) << RightType(rhs) << ordering;
    };

    createRow(0.0, 0.0, Qt::partial_ordering::equivalent);
    createRow(-0.000001, 0.0, Qt::partial_ordering::less);
    createRow(0.000001, 0.0, Qt::partial_ordering::greater);

    const double nan = qQNaN();
    createRow(nan, 0.0, Qt::partial_ordering::unordered);
    createRow(0.0, nan, Qt::partial_ordering::unordered);
    createRow(nan, nan, Qt::partial_ordering::unordered);

    const double inf = qInf();
    createRow(inf, 0.0, Qt::partial_ordering::greater);
    createRow(0.0, inf, Qt::partial_ordering::less);
    createRow(-inf, 0.0, Qt::partial_ordering::less);
    createRow(0.0, -inf, Qt::partial_ordering::greater);
    createRow(inf, inf, Qt::partial_ordering::equivalent);
    createRow(-inf, -inf, Qt::partial_ordering::equivalent);
    createRow(-inf, inf, Qt::partial_ordering::less);
    createRow(inf, -inf, Qt::partial_ordering::greater);

    createRow(nan, inf, Qt::partial_ordering::unordered);
    createRow(inf, nan, Qt::partial_ordering::unordered);
    createRow(nan, -inf, Qt::partial_ordering::unordered);
    createRow(-inf, nan, Qt::partial_ordering::unordered);
}

template<typename LeftType, typename RightType>
void tst_QCompareHelpers::compareStringData()
{
    QTest::addColumn<LeftType>("lhs");
    QTest::addColumn<RightType>("rhs");
    QTest::addColumn<Qt::weak_ordering>("expectedOrdering");

    auto createRow = [](auto lhs, auto rhs, Qt::weak_ordering ordering) {
        QTest::addRow("'%s' vs '%s'", lhs, rhs) << LeftType(lhs) << RightType(rhs) << ordering;
    };

    createRow("", "", Qt::weak_ordering::equivalent);
    createRow("Ab", "abc", Qt::weak_ordering::less);
    createRow("aBc", "AB", Qt::weak_ordering::greater);
    createRow("ab", "AB", Qt::weak_ordering::equivalent);
    createRow("ABC", "abc", Qt::weak_ordering::equivalent);
}

void tst_QCompareHelpers::comparisonCompiles()
{
    QTestPrivate::testAllComparisonOperatorsCompile<IntWrapper>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<IntWrapper, int>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper, double>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<DoubleWrapper, IntWrapper>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<StringWrapper<QString>>();
    if (QTest::currentTestFailed())
        return;

    QTestPrivate::testAllComparisonOperatorsCompile<StringWrapper<QString>, QAnyStringView>();
    if (QTest::currentTestFailed())
        return;
}

void tst_QCompareHelpers::compare_IntWrapper_DoubleWrapper_data()
{
    QTest::addColumn<IntWrapper>("lhs");
    QTest::addColumn<DoubleWrapper>("rhs");
    QTest::addColumn<Qt::partial_ordering>("expectedOrdering");

    auto createRow = [](auto lhs, auto rhs, Qt::partial_ordering ordering) {
        QTest::addRow("%d vs %f", lhs, rhs) << IntWrapper(lhs) << DoubleWrapper(rhs) << ordering;
    };

    createRow(0, 0.0, Qt::partial_ordering::equivalent);
    createRow(-1, 0.0, Qt::partial_ordering::less);
    createRow(1, 0.0, Qt::partial_ordering::greater);
    createRow(0, -0.000001, Qt::partial_ordering::greater);
    createRow(0, 0.000001, Qt::partial_ordering::less);

    constexpr int max = std::numeric_limits<int>::max();
    constexpr int min = std::numeric_limits<int>::min();
    const double nan = qQNaN();
    createRow(0, nan, Qt::partial_ordering::unordered);
    createRow(max, nan, Qt::partial_ordering::unordered);
    createRow(min, nan, Qt::partial_ordering::unordered);

    const double inf = qInf();
    createRow(0, inf, Qt::partial_ordering::less);
    createRow(0, -inf, Qt::partial_ordering::greater);
    createRow(max, inf, Qt::partial_ordering::less);
    createRow(max, -inf, Qt::partial_ordering::greater);
    createRow(min, inf, Qt::partial_ordering::less);
    createRow(min, -inf, Qt::partial_ordering::greater);
}

#define DECLARE_TYPE(Name, Type, Attrs, RetType, Constexpr, Suffix) \
class Dummy ## Name \
{ \
public: \
    Constexpr Dummy ## Name () {} \
\
private: \
    friend Attrs Constexpr bool \
    comparesEqual(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept; \
    friend Attrs Constexpr RetType \
    compareThreeWay(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept; \
    friend Attrs Constexpr bool \
    comparesEqual(const Dummy ## Name &lhs, int rhs) noexcept; \
    friend Attrs Constexpr RetType \
    compareThreeWay(const Dummy ## Name &lhs, int rhs) noexcept; \
    Q_DECLARE_ ## Type ##_ORDERED ## Suffix (Dummy ## Name) \
    Q_DECLARE_ ## Type ##_ORDERED ## Suffix (Dummy ## Name, int) \
}; \
\
Attrs Constexpr bool comparesEqual(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
Attrs Constexpr RetType \
compareThreeWay(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; } \
Attrs Constexpr bool comparesEqual(const Dummy ## Name &lhs, int rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
Attrs Constexpr RetType compareThreeWay(const Dummy ## Name &lhs, int rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return RetType::equivalent; }

DECLARE_TYPE(PartialConstAttr, PARTIALLY, Q_DECL_PURE_FUNCTION, Qt::partial_ordering, constexpr,
             _LITERAL_TYPE)
DECLARE_TYPE(PartialConst, PARTIALLY, /* no attrs */, Qt::partial_ordering, constexpr, _LITERAL_TYPE)
DECLARE_TYPE(PartialAttr, PARTIALLY, Q_DECL_CONST_FUNCTION, Qt::partial_ordering, , )
DECLARE_TYPE(Partial, PARTIALLY, /* no attrs */, Qt::partial_ordering, , )

DECLARE_TYPE(WeakConstAttr, WEAKLY, Q_DECL_PURE_FUNCTION, Qt::weak_ordering, constexpr, _LITERAL_TYPE)
DECLARE_TYPE(WeakConst, WEAKLY, /* no attrs */, Qt::weak_ordering, constexpr, _LITERAL_TYPE)
DECLARE_TYPE(WeakAttr, WEAKLY, Q_DECL_CONST_FUNCTION, Qt::weak_ordering, , )
DECLARE_TYPE(Weak, WEAKLY, /* no attrs */, Qt::weak_ordering, , )

DECLARE_TYPE(StrongConstAttr, STRONGLY, Q_DECL_PURE_FUNCTION, Qt::strong_ordering, constexpr,
             _LITERAL_TYPE)
DECLARE_TYPE(StrongConst, STRONGLY, /* no attrs */, Qt::strong_ordering, constexpr, _LITERAL_TYPE)
DECLARE_TYPE(StrongAttr, STRONGLY, Q_DECL_CONST_FUNCTION, Qt::strong_ordering, , )
DECLARE_TYPE(Strong, STRONGLY, /* no attrs */, Qt::strong_ordering, , )

#define DECLARE_EQUALITY_COMPARABLE(Name, Attrs, Constexpr, Suffix) \
class Dummy ## Name \
{ \
public: \
    Constexpr Dummy ## Name (int) {} \
\
private: \
    friend Attrs Constexpr bool \
    comparesEqual(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept; \
    friend Attrs Constexpr bool comparesEqual(const Dummy ## Name &lhs, int rhs) noexcept; \
    Q_DECLARE_EQUALITY_COMPARABLE ## Suffix (Dummy ## Name) \
    Q_DECLARE_EQUALITY_COMPARABLE ## Suffix (Dummy ## Name, int) \
}; \
\
Attrs Constexpr bool comparesEqual(const Dummy ## Name &lhs, const Dummy ## Name &rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \
Attrs Constexpr bool comparesEqual(const Dummy ## Name &lhs, int rhs) noexcept \
{ Q_UNUSED(lhs); Q_UNUSED(rhs); return true; } \

DECLARE_EQUALITY_COMPARABLE(ConstAttr, Q_DECL_PURE_FUNCTION, constexpr, _LITERAL_TYPE)
DECLARE_EQUALITY_COMPARABLE(Const, /* no attrs */, constexpr, _LITERAL_TYPE)
DECLARE_EQUALITY_COMPARABLE(Attr, Q_DECL_CONST_FUNCTION, , )
DECLARE_EQUALITY_COMPARABLE(None, /* no attrs */, , )

void tst_QCompareHelpers::generatedClasses()
{
#define COMPARE(ClassName) \
    do { \
        QTestPrivate::testAllComparisonOperatorsCompile<ClassName>(); \
        QTestPrivate::testAllComparisonOperatorsCompile<ClassName, int>(); \
    } while (0)

    COMPARE(DummyPartialConstAttr);
    COMPARE(DummyPartialConst);
    COMPARE(DummyPartialAttr);
    COMPARE(DummyPartial);

    COMPARE(DummyWeakConstAttr);
    COMPARE(DummyWeakConst);
    COMPARE(DummyWeakAttr);
    COMPARE(DummyWeak);

    COMPARE(DummyStrongConstAttr);
    COMPARE(DummyStrongConst);
    COMPARE(DummyStrongAttr);
    COMPARE(DummyStrong);
#undef COMPARE

    QTestPrivate::testEqualityOperatorsCompile<DummyConstAttr>();
    QTestPrivate::testEqualityOperatorsCompile<DummyConstAttr, int>();

    QTestPrivate::testEqualityOperatorsCompile<DummyConst>();
    QTestPrivate::testEqualityOperatorsCompile<DummyConst, int>();

    QTestPrivate::testEqualityOperatorsCompile<DummyAttr>();
    QTestPrivate::testEqualityOperatorsCompile<DummyAttr, int>();

    QTestPrivate::testEqualityOperatorsCompile<DummyNone>();
    QTestPrivate::testEqualityOperatorsCompile<DummyNone, int>();
}

QTEST_MAIN(tst_QCompareHelpers)
#include "tst_qcomparehelpers.moc"