test_featureutils.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /***************************************************************************
  2. test_featureutils.h
  3. --------------------
  4. begin : Jun 2020
  5. copyright : (C) 2020 by Ivan Ivanov
  6. email : ivan@opengis.ch
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #define CATCH_CONFIG_MAIN
  17. #include "qgsvectorlayer.h"
  18. #include "utils/featureutils.h"
  19. #include "catch2.h"
  20. TEST_CASE( "FeatureUtils" )
  21. {
  22. std::unique_ptr<QgsVectorLayer> vl = std::make_unique<QgsVectorLayer>( QStringLiteral( "Polygon?crs=epsg:3946" ), QStringLiteral( "vl" ), QStringLiteral( "memory" ) );
  23. QgsGeometry geometry = QgsGeometry::fromWkt( QStringLiteral( "Polygon (((8 8, 9 8, 8 9, 8 8)))" ) );
  24. QgsFeature f = FeatureUtils::initFeature( vl.get(), geometry );
  25. REQUIRE( f.fields() == vl->fields() );
  26. REQUIRE( f.geometry().equals( geometry ) );
  27. }