[cluttermm] Point class test file added.



commit 76690d3e69234e539ef1128556f5d41ab3026252
Author: Ian Martin <martin_id vodafone co nz>
Date:   Tue Mar 11 23:16:50 2014 +1300

    Point class test file added.

 tests/Makefile.am         |    4 ++-
 tests/test-point-class.cc |   59 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fa14182..504bdfd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,7 +15,8 @@
 ## You should have received a copy of the GNU Lesser General Public License
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-check_PROGRAMS = test-alpha-creation test-alpha-func test-interval-creation
+check_PROGRAMS = test-alpha-creation test-alpha-func test-interval-creation \
+test-point-creation
 
 local_includes = -I$(top_builddir)/clutter $(if $(srcdir:.=),-I$(top_srcdir)/clutter)
 local_libs = $(top_builddir)/clutter/cluttermm/libcluttermm-$(CLUTTERMM_API_VERSION).la
@@ -27,3 +28,4 @@ LDADD = $(CLUTTERMM_LIBS) $(local_libs)
 test_alpha_creation_SOURCES    = test-alpha-creation.cc
 test_alpha_func_SOURCES        = test-alpha-func.cc
 test_interval_creation_SOURCES = test-interval-creation.cc
+test_point_creation_SOURCES    = test-point-class.cc
diff --git a/tests/test-point-class.cc b/tests/test-point-class.cc
new file mode 100644
index 0000000..8a0d1e3
--- /dev/null
+++ b/tests/test-point-class.cc
@@ -0,0 +1,59 @@
+#include <cluttermm.h>
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+  // initialize the C++ wrapper types
+  Clutter::init(&argc, &argv);
+
+  std::cout << "Creating Clutter::Point with (int) values: 8, 15" << std::endl;
+
+  Clutter::Point point0(0, 0);
+  Clutter::Point point1(8, 15);
+
+  std::cout<<"Initialisation: point0 = "<<point0.get_x()<<
+    "/ "<<point0.get_y()<<std::endl;
+  std::cout<<"and point1 = "<<point1.get_x()<<"/ "<<point1.get_y()<<std::endl;
+
+  float x_dist(0);
+  float y_dist(0);
+  float dist = point0.distance(point1, x_dist, y_dist);
+  std::cout << "Distance between the two is "<< dist <<
+    " with x and y distances " << x_dist << "/ " << y_dist << std::endl;
+
+  //make life easy and use the 3/4/5 triangle now:
+  point0.set_x(7);
+  point0.set_y(6);
+
+  point1.set_x(10);
+  point1.set_y(10);
+
+  dist = point0.distance(point1, x_dist, y_dist);
+  std::cout << "Reset values; now distance is "<< dist <<
+    " with x and y distances " << x_dist << "/ " << y_dist << std::endl;
+
+  //reversing to check negative values:
+
+  point0.set_x(10);
+  point0.set_y(10);
+
+  point1.set_x(7);
+  point1.set_y(6);
+
+  dist = point0.distance(point1, x_dist, y_dist);
+  std::cout << "Reversed values; now distance is "<< dist <<
+    " with x and y distances " << x_dist << "/ " << y_dist << std::endl;
+
+  //point equality function check:
+  Clutter::Point comp_point(7.0 ,6.0);
+  if(comp_point == point1){
+    std::cout << "Points equal." << std::endl;
+  }
+  else{
+    std::cout<< "Points not equal: comp = " << comp_point.get_x() <<
+    "/" << comp_point.get_y() << " vs " <<
+    point1.get_x() << "/" << point1.get_y() << std::endl;
+  }
+
+  return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]