diff --git a/include/gsl/pointers b/include/gsl/pointers index 83ac9ea..cff2513 100644 --- a/include/gsl/pointers +++ b/include/gsl/pointers @@ -21,7 +21,7 @@ #include -#include +#include #include #include diff --git a/tests/notnull_tests.cpp b/tests/notnull_tests.cpp index 6111553..6c841f0 100644 --- a/tests/notnull_tests.cpp +++ b/tests/notnull_tests.cpp @@ -129,6 +129,38 @@ TEST_CASE("TestNotNullConstructors") std::make_shared(10)); // shared_ptr is nullptr assignable } +template +void ostream_helper(T v) +{ + not_null p(&v); + { + std::ostringstream os; + std::ostringstream ref; + os << p; + ref << &v; + CHECK(os.str() == ref.str()); + } + { + std::ostringstream os; + std::ostringstream ref; + os << *p; + ref << v; + CHECK(os.str() == ref.str()); + } +} + +TEST_CASE("TestNotNullostream") +{ + ostream_helper(17); + ostream_helper(21.5f); + ostream_helper(3.4566e-7f); + ostream_helper('c'); + ostream_helper(0x0123u); + ostream_helper("cstring"); + ostream_helper("string"); +} + + TEST_CASE("TestNotNullCasting") { MyBase base;