cyclonedds-cxx icon indicating copy to clipboard operation
cyclonedds-cxx copied to clipboard

No QOS operator<< / GMock no match for operator<<

Open NoeSechet opened this issue 2 years ago • 1 comments

Hi!

Were are trying to test our application with GTest and its mocking feature.

We would get the following error:

/home/n.sechet/{....}/include/gtest/gtest-printers.h:291:36: error: no matching function for call to ‘testing::internal::internal_stream_operator_without_lexical_name_lookup::StreamPrinter::PrintValue(const dds::core::TEntityQos<org::eclipse::cyclonedds::pub::qos::PublisherQosDelegate>&, std::nullptr_t)’
     T, decltype(Printer::PrintValue(std::declval<const T&>(), nullptr)),
                 ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/n.sechet/{....}/include/gtest/gtest-printers.h:212:15: note: candidate: template<class T, class, class> static void testing::internal::internal_stream_operator_without_lexical_name_lookup::StreamPrinter::PrintValue(const T&, std::ostream*)
   static void PrintValue(const T& value, ::std::ostream* os) {
               ^~~~~~~~~~
/home/n.sechet/{....}/include/gtest/gtest-printers.h:212:15: note:   template argument deduction/substitution failed:
/home/n.sechet/{....}/include/gtest/gtest-printers.h:211:33: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘const dds::core::TEntityQos<org::eclipse::cyclonedds::pub::qos::PublisherQosDelegate>’)
             typename = decltype(std::declval<std::ostream&>()
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                 << std::declval<const T&>())>
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~

We believe it's because in the current QOS classes do not overwrite the operator<<, which the GTest library uses in the background.

Is there any plan to overwrite more operators in the QOS classes?

Thank you for your work

NoeSechet avatar Mar 16 '22 14:03 NoeSechet

I am afraid I don't feel qualified to answer this question (too C++-y for me). @e-hndrks does this sounds like a feasible extension, would it run into other ways in which << is already used for QoS's, or is there some other reason to think we may come to regret it if we do this?

eboasson avatar Mar 16 '22 16:03 eboasson