Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expected values #5

Open
kallisti5 opened this issue Jul 26, 2015 · 2 comments
Open

expected values #5

kallisti5 opened this issue Jul 26, 2015 · 2 comments

Comments

@kallisti5
Copy link

It would be nice if the assertions showed expected values instead of just a failure:

#include <NetworkAddress.h>

#include "tpunit++.hpp"


struct BNetworkAddressFixture
    : public tpunit::TestFixture
{
    BNetworkAddressFixture() : tpunit::TestFixture(
        TEST(BNetworkAddressFixture::tSetToIPv4),
        TEST(BNetworkAddressFixture::tSetToIPv6)
    )
    {}

    void tSetToIPv4()
    {
        BNetworkAddress address;
        ASSERT_TRUE(address.IsEmpty());
        address.SetTo("127.0.0.1");
        ASSERT_FALSE(address.IsEmpty());
        ASSERT_TRUE(address.Family() == AF_INET);
    }

    void tSetToIPv6()
    {
        BNetworkAddress address;
        ASSERT_TRUE(address.IsEmpty());
        address.SetTo("::1");
        ASSERT_FALSE(address.IsEmpty());
        ASSERT_TRUE(address.Family() == AF_INET6);
    }
} __BNetworkAddressFixture;
/Builds/bunittest> ./kits/network/BNetworkAddress 
[--------------]
[ RUN          ] BNetworkAddressFixture::tSetToIPv4
[       PASSED ] BNetworkAddressFixture::tSetToIPv4
[ RUN          ] BNetworkAddressFixture::tSetToIPv6
[              ]    assertion #1 at kits/network/BNetworkAddress.cpp:29
[       FAILED ] BNetworkAddressFixture::tSetToIPv6
[--------------]

[==============]
[ TEST RESULTS ] Passed: 1, Failed: 1
[==============]
@tpounds
Copy link
Owner

tpounds commented Jul 26, 2015

Thanks for the feature request. I agree this would make the assertions much more useful. To make this work generically I will need to switch from using printf to std::ostream to make outputting arbitrary types possible.

@iwiznia
Copy link

iwiznia commented Aug 9, 2018

This would be just amazing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants