[BUG] UnitTest::expectEquals on uint32_t

Hey,

I’m quit new to this forum and couldn’t find a better category and any Bug report related to the issue I’ve found.

Bug description:
On compiling a Unit Test class containing a test function with the form
expectEquals(uint32_t, uint32_t, juce::String)
generates the following compiler error:

..../JUCE/modules/juce_core/unit_tests/juce_UnitTest.h:295:55 Use of overloaded operator '<<' is ambiguous (with operand types 'juce::String' and 'unsigned int')

System Setup:
MacOS (MacBook Air with M2, Ventura 13.0)
Projucer / Juce version: 7.0.3
macOS Deployment Target configured: 10.15
xCode (Version 14.2) is used as generated by Projucer

Best regards,
EmbeddedMonkey

Maybe you could post the offending line of code??

The called function looks like this
expectEquals(handler->IndexA, (uint32_t)0xDE002200, "Assert: Handler Index A was updated");

where handler is a struct that contains IndexA as uint32_t variable. Adding casts at any position has no effect on the compiler error.

The compiler error message leads to the following code section:

juce_UnitTest.h line 285

    template <class ValueType>
    void expectResultAndPrint (ValueType value, ValueType valueToCompareTo, bool result,
                               String compDescription, String failureMessage)
    {
        if (! result)
        {
            if (failureMessage.isNotEmpty())
                failureMessage << " -- ";

            failureMessage << "Expected value" << (compDescription.isEmpty() ? "" : " ")
                           << compDescription << ": " << valueToCompareTo
                           << ", Actual value: " << value;
        }

        expect (result, failureMessage);
    }

More precise is the following << operator call mentioned in the compiler error message

": " << valueToCompareTo

there’s a bool parameter there that you’re passing a string into:

ValueType value, ValueType valueToCompareTo, bool result,

The function causing the error is NOT the function I am calling as you can see in the two code snippets I’ve posted. The function causing the error is called somewhere within JUCE during the processing of the function I’ve called within my test class

1 Like

yeah, sorry, was looking at wrong bit of code.