// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause #define VTK_STREAMS_FWD_ONLY // like wrapper-generated sources #include "vtkObject.h" #include "vtkSmartPointer.h" #include "vtkStringFormatter.h" #include "vtkSystemIncludes.h" #include // test covers NOT including #include #include int TestOStreamWrapper(int, char*[]) { std::string const expect = "hello, world: 1"; std::string actual; std::string s = "hello, world"; vtkOStrStreamWrapper vtkmsg; vtkmsg << s << ": " << 1; actual = vtkmsg.str(); vtkmsg.rdbuf()->freeze(0); if (actual != expect) { vtk::println(stderr, "Expected '{:s}' but got '{:s}'", expect, actual); return 1; } // Verify that vtkSmartPointer can be printed as address. vtkSmartPointer smartPointedObject = vtkSmartPointer::New(); vtkOStrStreamWrapper oStrStreamWrapper; oStrStreamWrapper << smartPointedObject; std::string smartPointerStr = oStrStreamWrapper.str(); // Verify that the address retrieved by oStrStreamWrapper is the same as the real address std::stringstream strStream; strStream << smartPointedObject; if (smartPointerStr != strStream.str()) { vtk::println(stderr, "Output of oStrStreamWrapper for vtkSmartPointer ({:s}) differs from its address ({:s})", smartPointerStr, strStream.str()); return 1; } return 0; }