[niepce: 15/17] Add test for fraction



commit ff3b9548a1f3619deadf80e6c3b7eec17e82b47f
Author: Hub Figuiere <hub figuiere net>
Date:   Sun Jan 22 23:19:21 2012 -0800

    Add test for fraction

 .gitignore                       |    1 +
 src/fwk/base/t/testfractions.cpp |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6e158e8..47f495a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,6 +35,7 @@ m4/lt~obsolete.m4
 po/Makefile.in.in
 src/fwk/base/testmoniker
 src/fwk/base/testgeometry
+src/fwk/base/testfractions
 src/fwk/utils/test_db
 src/fwk/utils/test_db2
 src/fwk/utils/test_db3
diff --git a/src/fwk/base/t/testfractions.cpp b/src/fwk/base/t/testfractions.cpp
new file mode 100644
index 0000000..caee8c2
--- /dev/null
+++ b/src/fwk/base/t/testfractions.cpp
@@ -0,0 +1,35 @@
+/*
+ * niepce - base/t/testfractions.cpp
+ *
+ * Copyright (C) 2012 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+/** @brief unit test for files */
+
+#include <boost/test/minimal.hpp>
+
+#include <stdlib.h>
+#include <vector>
+#include <boost/rational.hpp>
+#include "fwk/base/fractions.hpp"
+
+int test_main( int, char *[] )             // note the name!
+{
+	double f = fwk::fraction_to_decimal("1/4");
+	boost::rational<int> r(1,4);
+	BOOST_CHECK(f == boost::rational_cast<double>(r));
+	return 0;
+}
+



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