Skip to content
New issue

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

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

Already on GitHub? # to your account

Nullptr issue. #110

Closed
iSLC opened this issue Dec 10, 2017 · 3 comments
Closed

Nullptr issue. #110

iSLC opened this issue Dec 10, 2017 · 3 comments

Comments

@iSLC
Copy link

iSLC commented Dec 10, 2017

Description

I was trying to test a string view default constructor and to see if the pointer was indeed null. Since I've assigned nullptr to it.

Steps to reproduce

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"

struct test
{
	const char * ptr;

	test() : ptr(nullptr) { }

	const char * get() const { return ptr; }
};

TEST_CASE("dummy")
{
    test o;
    FAST_REQUIRE_NE(o.get(), nullptr);
}

Output:

src\main.cpp(15)
TEST CASE:  dummy

src\main.cpp(19) FATAL ERROR!
  FAST_REQUIRE_NE( o.get(), nullptr )
with expansion:
  FAST_REQUIRE_NE( NULL, nullptr )

Am I required to use NULL instead of nullptr ? Because I would prefer the later.

Extra information

  • doctest version: v1.2.6
  • Operating System: Windows
  • Compiler+version: gcc version 7.2.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
@iSLC
Copy link
Author

iSLC commented Dec 10, 2017

Seems to work if i use CHECK(o.get() == nullptr); I guess I should use that instead. But still bothers me why the first approach failed.

@iSLC
Copy link
Author

iSLC commented Dec 10, 2017

Never mind. I was too focused on the error to notice my copy/paste mistake. As I was testing NE instead of EQ. My apologies.

@iSLC iSLC closed this as completed Dec 10, 2017
@onqtam
Copy link
Member

onqtam commented Dec 11, 2017

Glad you solved the issue :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants