[ignition-math2] 08/08: Implement autotest

Jose Luis Rivero jrivero-guest at moszumanska.debian.org
Sat May 16 00:15:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

jrivero-guest pushed a commit to branch master
in repository ignition-math2.

commit f55bb6c1dfa63ea76f4d61aec6c6154b818d8b4e
Author: Jose Luis Rivero <jrivero at osrfoundation.org>
Date:   Sat May 16 00:14:23 2015 +0000

    Implement autotest
---
 debian/control       |  1 +
 debian/tests/build   | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 debian/tests/control |  2 ++
 3 files changed, 86 insertions(+)

diff --git a/debian/control b/debian/control
index 5d3144f..8da6afc 100644
--- a/debian/control
+++ b/debian/control
@@ -3,6 +3,7 @@ Standards-Version: 3.9.6
 Maintainer: Jose Luis Rivero <jrivero at osrfoundation.org>
 Section: science
 Priority: extra
+Testsuite: autopkgtest
 Build-Depends: cmake,
                debhelper (>= 9),
                python,
diff --git a/debian/tests/build b/debian/tests/build
new file mode 100755
index 0000000..76c652c
--- /dev/null
+++ b/debian/tests/build
@@ -0,0 +1,83 @@
+#!/bin/sh
+# autopkgtest check: Build and run a program against ign-math, to verify that the
+# headers and pkg-config file are installed correctly
+# (C) 2012 Jose Luis Rivero
+# Author: Jose Luis Rivero <jrivero at osrfoundation.org>
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+cat <<EOF > igntest.c
+
+#include <iostream>
+#include <ignition/math.hh>
+
+int main(int argc, char **argv)
+{
+  // Create a triangle with the following vertices:
+  // 1: x = -1, y = 0
+  // 2: x = 0, y = 1
+  // 3: x = 1, y = 0
+  ignition::math::Triangled tri(
+      ignition::math::Vector2d(-1, 0),
+      ignition::math::Vector2d(0, 1),
+      ignition::math::Vector2d(1, 0));
+
+  // The individual vertices are accessible through the [] operator
+  std::cout << "Vertex 1: " << tri[0] << "\n"
+            << "Vertex 2: " << tri[1] << "\n"
+            << "Vertex 3: " << tri[2] << "\n";
+
+  // Each side of the triangle is also accessible via the Side function
+  std::cout << "Side 1: " << tri.Side(0) << "\n"
+            << "Side 2: " << tri.Side(1) << "\n"
+            << "Side 3: " << tri.Side(2) << "\n";
+
+  // It's also possible to set each vertex individually.
+  tri.Set(0, ignition::math::Vector2d(-10, 0));
+  tri.Set(1, ignition::math::Vector2d(0, 20));
+  tri.Set(2, ignition::math::Vector2d(10, 2));
+
+  // Or set all the vertices at once.
+  tri.Set(ignition::math::Vector2d(-1, 0),
+          ignition::math::Vector2d(0, 1),
+          ignition::math::Vector2d(1, 0));
+
+  // You can get the perimeter length and area of the triangle
+  std::cout << "Perimeter=" << tri.Perimeter()
+            << " Area=" << tri.Area() << "\n";
+
+  // The Contains functions check if a line or point is inside the triangle
+  if (tri.Contains(ignition::math::Vector2d(0, 0.5)))
+    std::cout << "Triangle contains the point 0, 0.5\n";
+  else
+    std::cout << "Triangle does not contain the point 0, 0.5\n";
+
+  // The Intersect function check if a line segment intersects the triangle.
+  // It also returns the points of intersection
+  ignition::math::Vector2d pt1, pt2;
+  if (tri.Intersects(ignition::math::Line2d(-2, 0.5, 2, 0.5), pt1, pt2))
+  {
+    std::cout << "A line from (-2, 0.5) to (2, 0.5) intersects "
+              << "the triangle at the\nfollowing points:\n"
+              << "\t Pt1=" << pt1 << "\n"
+              << "\t Pt2=" << pt2 << "\n";
+  }
+  else
+  {
+    std::cout << "A line from (-2, 0.5) to (2, 0.5) does not intersect "
+              << "the triangle\n";
+  }
+
+  // There are more functions in Triangle. Take a look at the API;
+  // http://ignitionrobotics.org/libraries/ign_mat/api
+}
+EOF
+
+g++ -o igntest igntest.c `pkg-config --cflags --libs ignition-math2`
+echo "build: OK"
+[ -x igntest ]
+./igntest
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..4bdbefe
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: build
+Depends: libignition-math2-dev, build-essential

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ignition-math2.git



More information about the debian-science-commits mailing list