~pete-woods/ubuntu-app-launch/port-some-c-to-cpp

« back to all changes in this revision

Viewing changes to tests/eventually-fixture.h

  • Committer: Bileto Bot
  • Author(s): Ted Gould
  • Date: 2017-04-04 21:47:13 UTC
  • mfrom: (307.2.33 system-app-watch)
  • Revision ID: ci-train-bot@canonical.com-20170404214713-eyjiw88wlq49ueoe
Watch system folders for apps added and removed (LP: #1630997, #1672392)

Approved by: Marcus Tomlinson, Pete Woods

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        return eventuallyLoop(func);                                                                             \
119
119
    }
120
120
 
 
121
#define _EVENTUALLY_FUTURE_HELPER(oper)                                                                            \
 
122
    template <typename comptype>                                                                                   \
 
123
    testing::AssertionResult eventuallyFutureHelper##oper(const char *desca, const char *descb, comptype expected, \
 
124
                                                          std::future<comptype> future)                            \
 
125
    {                                                                                                              \
 
126
        std::function<testing::AssertionResult(void)> func = [&]() {                                               \
 
127
            auto status = future.wait_for(std::chrono::seconds{0});                                                \
 
128
            if (status != std::future_status::ready)                                                               \
 
129
            {                                                                                                      \
 
130
                return testing::AssertionFailure();                                                                \
 
131
            }                                                                                                      \
 
132
            return testing::internal::CmpHelper##oper(desca, descb, expected, future.get());                       \
 
133
        };                                                                                                         \
 
134
        return eventuallyLoop(func);                                                                               \
 
135
    }                                                                                                              \
 
136
                                                                                                                   \
 
137
    template <typename comptype>                                                                                   \
 
138
    testing::AssertionResult eventuallyFutureHelper##oper(const char *desca, const char *descb, comptype expected, \
 
139
                                                          std::shared_future<comptype> future)                     \
 
140
    {                                                                                                              \
 
141
        std::function<testing::AssertionResult(void)> func = [&]() {                                               \
 
142
            auto status = future.wait_for(std::chrono::seconds{0});                                                \
 
143
            if (status != std::future_status::ready)                                                               \
 
144
            {                                                                                                      \
 
145
                return testing::AssertionFailure();                                                                \
 
146
            }                                                                                                      \
 
147
            return testing::internal::CmpHelper##oper(desca, descb, expected, future.get());                       \
 
148
        };                                                                                                         \
 
149
        return eventuallyLoop(func);                                                                               \
 
150
    }
 
151
 
121
152
    _EVENTUALLY_HELPER(EQ);
122
153
    _EVENTUALLY_HELPER(NE);
123
154
    _EVENTUALLY_HELPER(LT);
132
163
    _EVENTUALLY_FUNC_HELPER(STREQ);
133
164
    _EVENTUALLY_FUNC_HELPER(STRNE);
134
165
 
 
166
    _EVENTUALLY_FUTURE_HELPER(EQ);
 
167
    _EVENTUALLY_FUTURE_HELPER(NE);
 
168
    _EVENTUALLY_FUTURE_HELPER(LT);
 
169
    _EVENTUALLY_FUTURE_HELPER(GT);
 
170
    _EVENTUALLY_FUTURE_HELPER(STREQ);
 
171
    _EVENTUALLY_FUTURE_HELPER(STRNE);
 
172
 
135
173
#undef _EVENTUALLY_HELPER
136
174
#undef _EVENTUALLY_FUNC_HELPER
 
175
#undef _EVENTUALLY_FUTURE_HELPER
137
176
};
138
177
 
139
178
/* Helpers */
209
248
 
210
249
#define ASSERT_EVENTUALLY_FUNC_STRNE(expected, actual) \
211
250
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFuncHelperSTRNE, expected, actual)
 
251
 
 
252
/* Future Helpers */
 
253
#define EXPECT_EVENTUALLY_FUTURE_EQ(expected, actual) \
 
254
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperEQ, expected, actual)
 
255
 
 
256
#define EXPECT_EVENTUALLY_FUTURE_NE(expected, actual) \
 
257
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperNE, expected, actual)
 
258
 
 
259
#define EXPECT_EVENTUALLY_FUTURE_LT(expected, actual) \
 
260
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperLT, expected, actual)
 
261
 
 
262
#define EXPECT_EVENTUALLY_FUTURE_GT(expected, actual) \
 
263
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperGT, expected, actual)
 
264
 
 
265
#define EXPECT_EVENTUALLY_FUTURE_STREQ(expected, actual) \
 
266
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperSTREQ, expected, actual)
 
267
 
 
268
#define EXPECT_EVENTUALLY_FUTURE_STRNE(expected, actual) \
 
269
    EXPECT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperSTRNE, expected, actual)
 
270
 
 
271
#define ASSERT_EVENTUALLY_FUTURE_EQ(expected, actual) \
 
272
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperEQ, expected, actual)
 
273
 
 
274
#define ASSERT_EVENTUALLY_FUTURE_NE(expected, actual) \
 
275
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperNE, expected, actual)
 
276
 
 
277
#define ASSERT_EVENTUALLY_FUTURE_LT(expected, actual) \
 
278
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperLT, expected, actual)
 
279
 
 
280
#define ASSERT_EVENTUALLY_FUTURE_GT(expected, actual) \
 
281
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperGT, expected, actual)
 
282
 
 
283
#define ASSERT_EVENTUALLY_FUTURE_STREQ(expected, actual) \
 
284
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperSTREQ, expected, actual)
 
285
 
 
286
#define ASSERT_EVENTUALLY_FUTURE_STRNE(expected, actual) \
 
287
    ASSERT_PRED_FORMAT2(EventuallyFixture::eventuallyFutureHelperSTRNE, expected, actual)