[Groonga-commit] groonga/grnxx at 89f0587 [master] Add tests for grnxx::GeoPoint.

Back to archive index

susumu.yata null+****@clear*****
Fri May 24 17:21:34 JST 2013


susumu.yata	2013-05-24 17:21:34 +0900 (Fri, 24 May 2013)

  New Revision: 89f0587045c9e48ad28eea50f1bf1cbe2abf3916
  https://github.com/groonga/grnxx/commit/89f0587045c9e48ad28eea50f1bf1cbe2abf3916

  Message:
    Add tests for grnxx::GeoPoint.

  Added files:
    test/test_geo_point.cpp
  Modified files:
    .gitignore
    test/Makefile.am

  Modified: .gitignore (+1 -0)
===================================================================
--- .gitignore    2013-05-24 17:20:32 +0900 (a6fca83)
+++ .gitignore    2013-05-24 17:21:34 +0900 (2b0f2f4)
@@ -39,6 +39,7 @@ test/test_duration
 test/test_error
 test/test_exception
 test/test_features
+test/test_geo_point
 test/test_grnxx
 test/test_intrinsic
 test/test_io

  Modified: test/Makefile.am (+4 -0)
===================================================================
--- test/Makefile.am    2013-05-24 17:20:32 +0900 (45beb00)
+++ test/Makefile.am    2013-05-24 17:21:34 +0900 (85ac15a)
@@ -13,6 +13,7 @@ TESTS =					\
 	test_error			\
 	test_exception			\
 	test_features			\
+	test_geo_point			\
 	test_grnxx			\
 	test_intrinsic			\
 	test_io				\
@@ -69,6 +70,9 @@ test_exception_LDADD = ../lib/grnxx/libgrnxx.la
 test_features_SOURCES = test_features.cpp
 test_features_LDADD = ../lib/grnxx/libgrnxx.la
 
+test_geo_point_SOURCES = test_geo_point.cpp
+test_geo_point_LDADD = ../lib/grnxx/libgrnxx.la
+
 test_grnxx_SOURCES = test_grnxx.cpp
 test_grnxx_LDADD = ../lib/grnxx/libgrnxx.la
 

  Added: test/test_geo_point.cpp (+85 -0) 100644
===================================================================
--- /dev/null
+++ test/test_geo_point.cpp    2013-05-24 17:21:34 +0900 (e263b93)
@@ -0,0 +1,85 @@
+/*
+  Copyright (C) 2012-2013  Brazil, Inc.
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public
+  License as published by the Free Software Foundation; either
+  version 2.1 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with this library; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+#include <cassert>
+
+#include "grnxx/geo_point.hpp"
+#include "grnxx/logger.hpp"
+
+namespace {
+
+void test_latitude() {
+  grnxx::GeoPoint point(123, 456);
+  assert(point.latitude() == 123);
+}
+
+void test_longitude() {
+  grnxx::GeoPoint point(123, 456);
+  assert(point.longitude() == 456);
+}
+
+void test_value() {
+  grnxx::GeoPoint point(123, 456);
+  const std::int32_t x[2] = { 123, 456 };
+  assert(point.value() == *reinterpret_cast<const std::uint64_t *>(x));
+}
+
+void test_set_latitude() {
+  grnxx::GeoPoint point(123, 456);
+  point.set_latitude(789);
+  assert(point.latitude() == 789);
+  assert(point.longitude() == 456);
+}
+
+void test_set_longitude() {
+  grnxx::GeoPoint point(123, 456);
+  point.set_longitude(789);
+  assert(point.latitude() == 123);
+  assert(point.longitude() == 789);
+}
+
+void test_set_value() {
+  grnxx::GeoPoint point(123, 456);
+  const std::int32_t x[2] = { 987, 654 };
+  point.set_value(*reinterpret_cast<const std::uint64_t *>(x));
+  assert(point.latitude() == 987);
+  assert(point.longitude() == 654);
+}
+
+void test_interleave() {
+  grnxx::GeoPoint point_1(123, 456);
+  grnxx::GeoPoint point_2(456, 789);
+  assert(point_1.interleave() < point_2.interleave());
+}
+
+}  // namespace
+
+int main() {
+  grnxx::Logger::set_flags(grnxx::LOGGER_WITH_ALL |
+                           grnxx::LOGGER_ENABLE_COUT);
+  grnxx::Logger::set_max_level(grnxx::NOTICE_LOGGER);
+
+  test_latitude();
+  test_longitude();
+  test_value();
+  test_set_latitude();
+  test_set_longitude();
+  test_set_value();
+  test_interleave();
+
+  return 0;
+}
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index