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 8579413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:36:14+00:00 2026-06-11T20:36:14+00:00

I want to test if my application returns a nullptr unique ptr. I have

  • 0

I want to test if my application returns a nullptr unique ptr. I have tried a few things but nothing get through the compiler. I hope someone has already tried and found a way to make this work. Some things i have tried:

std::unique_ptr<SomeClass> some_class_ptr;

CPPUNIT_ASSERT_EQUAL(std::unique_ptr<SomeClass>(), some_class_ptr);

gives: libcppunit/include/cppunit/TestAssert.h|49|error: no match for ‘operator<<’ in ‘ost << x’|

Inside TestAssert.h:

template <class T>
void assertEquals( const T& expected,
                   const T& actual,
                   SourceLine sourceLine,
                   const std::string &message )
{
  if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion...
  {
    Asserter::failNotEqual( assertion_traits<T>::toString(expected),
                            assertion_traits<T>::toString(actual),
                            sourceLine,
                            message );
  }
}

CPPUNIT_ASSERT_EQUAL(nullptr, some_class_ptr);

gives: /tests/SomeTestClass.cpp|432|error: no matching function for call to ‘assertEquals(std::nullptr_t, std::unique_ptr&, CppUnit::SourceLine, const char [1])’|


CPPUNIT_ASSERT_EQUAL(nullptr, some_class_ptr.get());

gives: /tests/SomeTestClass.cpp|432|error: no matching function for call to ‘assertEquals(std::nullptr_t, std::unique_ptr::pointer, CppUnit::SourceLine, const char [1])’|


I think the first one should be the correct one but it is not compiling. Can anyone give me a correct construction for this ?

  • 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-11T20:36:14+00:00Added an answer on June 11, 2026 at 8:36 pm

    CPPUNIT_ASSERT_EQUAL requires its arguments to be of exactly the same type. Since you don’t need to be able to output a representation of the nullptr argument, you can just use CPPUNIT_ASSERT:

    CPPUNIT_ASSERT(nullptr == some_class_ptr);
    

    or

    CPPUNIT_ASSERT(!some_class_ptr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to Unit Test my application which use MSMQ but i found no
I have a very simple application test in which I want to drag and
I have a file upload application. I want to test my Upload controller. For
I am using GWT-CKEditor for my application. And I want to test it through
I have a Windows console application that returns some text. I want to read
I want to test my application (especially SQL statements) against different databases. Actually I'm
i just join phonegap, i want a built test application. i write some code
I want to test a Ajax based web application. I want to write the
I want to test Add new item activity in my application. When user fills
I develop the application on tablet and want to test it on smaller size

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.