// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov #include #include #include #include template void VerifyType(const T& DefaultNull, const T& AlternateNull) { // Create a sparse array ... vtkSmartPointer> array = vtkSmartPointer>::New(); array->Resize(2); // Verify that the default nullptr value is initialized correctly ... if (array->GetNullValue() != DefaultNull) { throw std::runtime_error( "Incorrect default nullptr value for " + std::string(array->GetClassName())); } // Verify that GetValue() returns the default nullptr value for nullptr elements ... if (array->GetValue(1) != DefaultNull) { throw std::runtime_error( "Empty value did not return default nullptr for " + std::string(array->GetClassName())); } // Verify that we can override the default nullptr value ... array->SetNullValue(AlternateNull); if (array->GetNullValue() != AlternateNull) { throw std::runtime_error( "Error overriding nullptr value for " + std::string(array->GetClassName())); } // Verify that GetValue() returns the alternate nullptr value for nullptr elements ... if (array->GetValue(1) != AlternateNull) { throw std::runtime_error( "Empty value did not overridden nullptr for " + std::string(array->GetClassName())); } } int TestArrayNullValues(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { try { VerifyType(0, 1); VerifyType(0, 1); VerifyType(0, 1); VerifyType(0, 1); VerifyType(0, 1); VerifyType(0, 1); VerifyType(0.0f, 1); VerifyType(0.0, 1); VerifyType(0, 1); VerifyType(vtkStdString(), "foo"); return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } }