grantila / q

A platform-independent promise library for C++, implementing asynchronous continuations.
http://libq.io
Apache License 2.0
193 stars 24 forks source link

Use of q-test with gmock overrides EXPECT_CALL #23

Closed deblauwetom closed 6 years ago

deblauwetom commented 6 years ago

Hi!

First: libq is awesome, and the more I work with the better I find it :)

So now I am using gmock and gtest, and it seems the EXPECT_CALL, which is a standard gmock call is also defined in "spy.hpp". So I worked around it by defining this in my default unittesting header:

#pragma once

#define QTEST_ON_GTEST
#include <q-test/q-test.hpp>
#include <q-test/expect.hpp>
#define GMOCK_EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)

But by default, my non-libq code uses EXPECT_CALL of gmock a lot, and now I would have to use GMOCK_EXPECT_CALL wherever I use the libqtest header, which is unexpected for most people I think. So just letting you know that maybe the specific libqtest defines should better be using a prefix eg QTEST_EXPECT_CALL instead, or something similar.

grantila commented 6 years ago

You're right, this sloppy (but pretty) naming can conflict with other libraries. I added Q_ in front of all of them, and the old names (e.g. EXPECT_CALL) is now just an alias of e.g. Q_EXPECT_CALL. These aliases can be prevented by defining QTEST_NO_PRETTY_MACROS either globally in your project, or in the common include file you have, where you include the q-test headers.

Fixed in master (0117848bb3e6f0b130b546bc5851caf5f95f8b7e)