I know that dispatch_queue_t
is a c struct, and not an NSObject. So should we use XCTAssertEqual
or XCTAssertEqualObject
? Will it be possible when we have 2 different pointers to the same queue?
A dispatch_queue_t
is not a struct. It is a NSObject<OS_dispatch_queue>
. (There is an environment variable which can be used to control whether it is an object or not, but nowadays it almost always is an object.)
One should be wary of using any form of equality to determine if you are on the right queue because, if nothing else, one queue can target another. In our code, we don’t test the value of the queue, but rather tend to use dispatch_assert_queue
(or dispatchPrecondition(.onQueue())
in Swift).
The other alternative, if this is your own custom queue, is to dispatch_queue_set_specific
and then dispatch_queue_get_specific
.