[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Wed Dec 30 21:04:07 EST 2009
changeset b5a542b7f9fd in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=b5a542b7f9fd
summary: Updated FindSpatialIndex.cmake macro to determine version of the package and test against required version. Currently, SpatialIndex 1.4.0 or later version is required.
changeset 18b2578d36fd in /Volumes/Data/www/liblas.org/hg
details: http://hg.liblas.orghg?cmd=changeset;node=18b2578d36fd
summary: Updated FindSpatialIndex.cmake macro to determine version of the package and test against required version. Currently, SpatialIndex 1.4.0 or later version is required.
diffstat:
CMakeLists.txt | 2 +-
build/cmake/FindSpatialIndex.cmake | 50 ++++-
test/unit/lasheader_test.cpp | 41 ++-
test/unit/tut/tut_cppunit_reporter.hpp | 201 ++++++++++++++++++
test/unit/tut/tut_restartable.hpp | 28 +-
test/unit/tut/tut_xml_reporter.hpp | 361 +++++++++++++++++++++++++++++++++
6 files changed, 647 insertions(+), 36 deletions(-)
diffs (truncated from 837 to 300 lines):
diff -r f3b481d2694b -r 18b2578d36fd CMakeLists.txt
--- a/CMakeLists.txt Wed Dec 30 23:39:27 2009 +0000
+++ b/CMakeLists.txt Thu Dec 31 02:03:32 2009 +0000
@@ -179,7 +179,7 @@
ENDIF()
# Spatial Index support - optional, default=OFF
-SET(WITH_SPATIALINDEX FALSE CACHE BOOL "Choose if GeoTIFF support should be built")
+SET(WITH_SPATIALINDEX FALSE CACHE BOOL "Choose if SpatialIndex support should be built")
IF(WITH_SPATIALINDEX)
FIND_PACKAGE(SpatialIndex 1.4.0)
diff -r f3b481d2694b -r 18b2578d36fd build/cmake/FindSpatialIndex.cmake
--- a/build/cmake/FindSpatialIndex.cmake Wed Dec 30 23:39:27 2009 +0000
+++ b/build/cmake/FindSpatialIndex.cmake Thu Dec 31 02:03:32 2009 +0000
@@ -5,6 +5,7 @@
# SPATIALINDEX_FOUND = if the library found
# SPATIALINDEX_LIBRARY = full path to the library
# SPATIALINDEX_INCLUDE_DIR = where to find the library headers
+# SPATIALINDEX_VERSION = version of library which was found, e.g. "1.4.0"
#
# Copyright (c) 2009 Mateusz Loskot <mateusz at loskot.net>
#
@@ -13,7 +14,6 @@
#
###############################################################################
MESSAGE(STATUS "Searching for SpatialIndex ${SpatialIndex_FIND_VERSION}+ library")
-MESSAGE(STATUS " NOTE: Required version is not checked - to be implemented")
IF(SPATIALINDEX_INCLUDE_DIR)
# Already in cache, be silent
@@ -32,10 +32,13 @@
ENDIF()
FIND_PATH(SPATIALINDEX_INCLUDE_DIR
- NAMES RTree.h
- PATH_PREFIXES spatialindex
- PATHS
- ${OSGEO4W_ROOT_DIR}/include)
+ NAMES SpatialIndex.h RTree.h
+ HINTS
+ ${OSGEO4W_ROOT_DIR}/include
+ PATHS
+ ${OSGEO4W_ROOT_DIR}/include
+ PATH_SUFFIXES spatialindex
+ DOC "Path to include directory of SpatialIndex library")
SET(SPATIALINDEX_NAMES ${OSGEO4W_IMPORT_LIBRARY} spatialindex)
FIND_LIBRARY(SPATIALINDEX_LIBRARY
@@ -43,10 +46,45 @@
PATHS
${OSGEO4W_ROOT_DIR}/lib)
+IF (SPATIALINDEX_INCLUDE_DIR)
+ SET(SPATIALINDEX_VERSION 0)
+
+ SET(SPATIALINDEX_VERSION_H "${SPATIALINDEX_INCLUDE_DIR}/Version.h")
+ FILE(READ ${SPATIALINDEX_VERSION_H} SPATIALINDEX_VERSION_H_CONTENTS)
+
+ IF (DEFINED SPATIALINDEX_VERSION_H_CONTENTS)
+ STRING(REGEX REPLACE ".*#define[ \t]SIDX_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" SIDX_VERSION_MAJOR "${SPATIALINDEX_VERSION_H_CONTENTS}")
+ STRING(REGEX REPLACE ".*#define[ \t]SIDX_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" SIDX_VERSION_MINOR "${SPATIALINDEX_VERSION_H_CONTENTS}")
+ STRING(REGEX REPLACE ".*#define[ \t]SIDX_VERSION_REV[ \t]+([0-9]+).*" "\\1" SIDX_VERSION_REV "${SPATIALINDEX_VERSION_H_CONTENTS}")
+
+ IF(NOT ${SIDX_VERSION_MAJOR} MATCHES "[0-9]+")
+ MESSAGE(FATAL_ERROR "SpatialIndex version parsing failed for SIDX_VERSION_MAJOR!")
+ ENDIF()
+ IF(NOT ${SIDX_VERSION_MINOR} MATCHES "[0-9]+")
+ MESSAGE(FATAL_ERROR "SpatialIndex version parsing failed for SIDX_VERSION_MINOR!")
+ ENDIF()
+ IF(NOT ${SIDX_VERSION_REV} MATCHES "[0-9]+")
+ MESSAGE(FATAL_ERROR "SpatialIndex version parsing failed for SIDX_VERSION_REV!")
+ ENDIF()
+
+ SET(SPATIALINDEX_VERSION "${SIDX_VERSION_MAJOR}.${SIDX_VERSION_MINOR}.${SIDX_VERSION_REV}"
+ CACHE INTERNAL "The version string for SpatialIndex library")
+
+ IF (SPATIALINDEX_VERSION VERSION_EQUAL SpatialIndex_FIND_VERSION OR
+ SPATIALINDEX_VERSION VERSION_GREATER SpatialIndex_FIND_VERSION)
+ MESSAGE(STATUS "Found SpatialIndex version: ${SPATIALINDEX_VERSION}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "SpatialIndex version check failed. Version ${SPATIALINDEX_VERSION} was found, at least version ${SpatialIndex_FIND_VERSION} is required")
+ ENDIF()
+ ELSE()
+ MESSAGE(FATAL_ERROR "Failed to open ${SPATIALINDEX_VERSION_H} file")
+ ENDIF()
+ENDIF()
+
# Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE
# if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SPATIALINDEX DEFAULT_MSG SPATIALINDEX_LIBRARY SPATIALINDEX_INCLUDE_DIR)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SpatialIndex DEFAULT_MSG SPATIALINDEX_LIBRARY SPATIALINDEX_INCLUDE_DIR)
# TODO: Do we want to mark these as advanced? --mloskot
# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:mark_as_advanced
diff -r f3b481d2694b -r 18b2578d36fd test/unit/lasheader_test.cpp
--- a/test/unit/lasheader_test.cpp Wed Dec 30 23:39:27 2009 +0000
+++ b/test/unit/lasheader_test.cpp Thu Dec 31 02:03:32 2009 +0000
@@ -50,13 +50,13 @@
h1.SetFileSignature(sig);
ensure_not(h1.GetFileSignature() == sig);
- ensure_equals(h1.GetFileSignature().size(), 4);
+ ensure_equals(h1.GetFileSignature().size(), std::string::size_type(4));
ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
LASHeader h2(h1);
ensure_not(h2.GetFileSignature() == sig);
- ensure_equals(h2.GetFileSignature().size(), 4);
+ ensure_equals(h2.GetFileSignature().size(), std::string::size_type(4));
ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
}
@@ -87,14 +87,14 @@
h1.SetFileSignature(sig);
ensure_not(h1.GetFileSignature() == sig);
- ensure_equals(h1.GetFileSignature().size(), 4);
+ ensure_equals(h1.GetFileSignature().size(), std::string::size_type(4));
ensure_equals(h1.GetFileSignature(), LASHeader::FileSignature);
LASHeader h2;
h2 = h1;
ensure_not(h2.GetFileSignature() == sig);
- ensure_equals(h2.GetFileSignature().size(), 4);
+ ensure_equals(h2.GetFileSignature().size(), std::string::size_type(4));
ensure_equals(h2.GetFileSignature(), LASHeader::FileSignature);
}
@@ -210,12 +210,12 @@
h.SetSystemId(sysid1);
ensure_equals(h.GetSystemId(), sysid1);
ensure_equals(h.GetSystemId().size(), len1);
- ensure_equals(h.GetSystemId(true).size(), 32);
+ ensure_equals(h.GetSystemId(true).size(), std::string::size_type(32));
h.SetSystemId(sysid2);
ensure_equals(h.GetSystemId(), sysid2);
ensure_equals(h.GetSystemId().size(), len2);
- ensure_equals(h.GetSystemId(true).size(), 32);
+ ensure_equals(h.GetSystemId(true).size(), std::string::size_type(32));
}
// Test Get/SetSoftwareId
@@ -234,12 +234,12 @@
h.SetSoftwareId(softid1);
ensure_equals(h.GetSoftwareId(), softid1);
ensure_equals(h.GetSoftwareId().size(), len1);
- ensure_equals(h.GetSoftwareId(true).size(), 32);
+ ensure_equals(h.GetSoftwareId(true).size(), std::string::size_type(32));
h.SetSoftwareId(softid2);
ensure_equals(h.GetSoftwareId(), softid2);
ensure_equals(h.GetSoftwareId().size(), len2);
- ensure_equals(h.GetSoftwareId(true).size(), 32);
+ ensure_equals(h.GetSoftwareId(true).size(), std::string::size_type(32));
}
// Test GetPointRecordsByReturnCount
@@ -247,28 +247,31 @@
template<>
void to::test<11>()
{
+ typedef ::liblas::LASHeader::RecordsByReturnArray::size_type size_type;
+ typedef ::liblas::uint32_t count_type;
+
liblas::LASHeader h;
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
h.SetPointRecordsByReturnCount(0, 100);
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
- ensure_equals(h.GetPointRecordsByReturnCount().at(0), 100);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
+ ensure_equals(h.GetPointRecordsByReturnCount().at(0), count_type(100));
h.SetPointRecordsByReturnCount(1, 101);
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
- ensure_equals(h.GetPointRecordsByReturnCount().at(1), 101);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
+ ensure_equals(h.GetPointRecordsByReturnCount().at(1), count_type(101));
h.SetPointRecordsByReturnCount(2, 102);
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
- ensure_equals(h.GetPointRecordsByReturnCount().at(2), 102);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
+ ensure_equals(h.GetPointRecordsByReturnCount().at(2), count_type(102));
h.SetPointRecordsByReturnCount(3, 103);
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
- ensure_equals(h.GetPointRecordsByReturnCount().at(3), 103);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
+ ensure_equals(h.GetPointRecordsByReturnCount().at(3), count_type(103));
h.SetPointRecordsByReturnCount(4, 104);
- ensure_equals(h.GetPointRecordsByReturnCount().size(), 5);
- ensure_equals(h.GetPointRecordsByReturnCount().at(4), 104);
+ ensure_equals(h.GetPointRecordsByReturnCount().size(), size_type(5));
+ ensure_equals(h.GetPointRecordsByReturnCount().at(4), count_type(104));
try
{
diff -r f3b481d2694b -r 18b2578d36fd test/unit/tut/tut_cppunit_reporter.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/unit/tut/tut_cppunit_reporter.hpp Thu Dec 31 02:03:32 2009 +0000
@@ -0,0 +1,201 @@
+
+#ifndef TUT_CPPUNIT_REPORTER
+#define TUT_CPPUNIT_REPORTER
+
+#include <tut/tut.hpp>
+#include <string>
+#include <fstream>
+#include <vector>
+#include <stdexcept>
+
+namespace tut
+{
+
+/**
+ * CppUnit TUT reporter
+ */
+class cppunit_reporter : public tut::callback
+{
+ private:
+ std::vector<tut::test_result> failed_tests;
+ std::vector<tut::test_result> passed_tests;
+ std::string filename;
+
+ std::string encode(const std::string & text)
+ {
+ std::string out;
+
+ for (unsigned int i=0; i<text.length(); ++i) {
+ char c = text[i];
+ switch (c) {
+ case '<':
+ out += "<";
+ break;
+ case '>':
+ out += ">";
+ break;
+ case '&':
+ out += "&";
+ break;
+ case '\'':
+ out += "'";
+ break;
+ case '"':
+ out += """;
+ break;
+ default:
+ out += c;
+ }
+ }
+
+ return out;
+ }
+
+public:
+
+ cppunit_reporter(const std::string & _filename = "")
+ {
+ setFilename(_filename);
+ }
+
+ void setFilename(const std::string & _filename)
+ {
+ if (_filename == "")
+ {
+ filename = "testResult.xml";
+ }
+ else
+ {
+ filename = _filename;
+ }
+ }
+
+ void run_started()
+ {
+ failed_tests.clear();
+ passed_tests.clear();
+ }
+
+ void test_completed(const tut::test_result& tr)
+ {
+ if (tr.result == test_result::ok) {
+ passed_tests.push_back(tr);
+ } else {
+ failed_tests.push_back(tr);
+ }
+ }
+
+ void run_completed()
+ {
+ int errors = 0;
+ int failures = 0;
More information about the Liblas-commits
mailing list