Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8732101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:22:37+00:00 2026-06-13T09:22:37+00:00

I use CPPUNIT_ASSERT_EQUAL(a, b) to check the value a and b. The a and

  • 0

I use CPPUNIT_ASSERT_EQUAL(a, b) to check the value a and b. The a and b are unsigned char type. So, when this assertion failed it will display the expected and actual value. Because the type is unsigned char, the expected and actual value will be displayed as characters. For example, 35 will be displayed as #. But this is not what I want. Of course, CPPUNIT_ASSERT_EQUAL((int)a, (int)b) may be a solution but it looks like strange. In addition, it would be better if the values are displayed as hex format. But I don’t know how to reach this. It would be highly appreciated if somebody gives a answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:22:37+00:00Added an answer on June 13, 2026 at 9:22 am

    I’d think the only way to achieve this effect is to adapt a and/or b with a suitable type which does the required comparison but is formatted differently than unsigned char. This could look something like this:

    template <typename T>
    struct as_hex_t
    {
        as_hex_t(T const& value): d_value(value) {}
        T const& d_value;
    };
    bool operator== (as_hex_t<T> const& v0, as_hex_t<T> const& v1) {
        return v0.d_value == v1.d_value;
    }
    std::ostream& operator<< (std::ostream& out, as_hex_t const& value) {
        return out << std::hex << unsigned(value.d_value) << std::dec;
    }
    template <typenane T>
    as_hex_t<T> as_hex(T const& val) { return as_hex_t<T>(val); }
    
    CPPUNIT_ASSERT_EQUAL(as_hex(a), as_hex(b));
    

    Obviously, the type to adapt the values is just needed to be defined once in a suitable place and can go into a suitable macro. I don’t know CPPUNIT but I could image that something like this exists somewhere.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use default: <input type=radio name=restype value=resdef onfocus=document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true; checked=checked /><br
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
use this code, in the Preferences activity, to know when the reset preference has
Use trap to capture signals like this: i=-1;while((++i<33)); do trap echo $i >> log.txt
Use case is this: I want to unit test (in browser, QUnit or something
use a reapeter to display data, but sometimes the data is to big to
Use Case Show a photo uploaded by the user in a square box with
use C#,want to upload excel file on google doc. bellow syntax use to upload
use Text::Table; my $tb = Text::Table->new(Planet,Radius\nkm,Density\ng/cm^3); $tb->load( [ Mercury,2360,3.7], [ Mercury,2360,3.7], [ Mercury,2360,3.7], );
use strict; use warnings; use Time::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More no_plan; use Test::Exception;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.