summaryrefslogtreecommitdiffstats
path: root/sigcore
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-12-23 16:07:04 -0500
committerBen Boeckel <MathStuf@gmail.com>2008-12-23 16:07:04 -0500
commitb8d7cbcdd25c43657e4097f42af20b8bf3725b4b (patch)
tree9be315f32cabd63202f189baa89eb9f4160bfe75 /sigcore
parenteb2308b8035302b76f794e83b9cf5c5f4cff7a4c (diff)
downloadsigen-b8d7cbcdd25c43657e4097f42af20b8bf3725b4b.tar.gz
sigen-b8d7cbcdd25c43657e4097f42af20b8bf3725b4b.tar.xz
sigen-b8d7cbcdd25c43657e4097f42af20b8bf3725b4b.zip
Fixed the Range test
Diffstat (limited to 'sigcore')
-rw-r--r--sigcore/Range.cpp2
-rw-r--r--sigcore/test/TestRange.cpp28
-rw-r--r--sigcore/test/TestRange.h45
3 files changed, 50 insertions, 25 deletions
diff --git a/sigcore/Range.cpp b/sigcore/Range.cpp
index 90d0bc53..323a0780 100644
--- a/sigcore/Range.cpp
+++ b/sigcore/Range.cpp
@@ -77,7 +77,7 @@ bool Sigcore::Range::in(const double value) const
bool Sigcore::Range::in(const Range& range) const
{
- return (range.valid() || ((m_minimum <= range.m_minimum) && (range.m_maximum <= m_maximum)));
+ return (range.valid() && (m_minimum <= range.m_minimum) && (range.m_maximum <= m_maximum));
}
Sigcore::Range Sigcore::Range::operator&(const Range& rhs) const
diff --git a/sigcore/test/TestRange.cpp b/sigcore/test/TestRange.cpp
index 88e76c7a..1fc7a79c 100644
--- a/sigcore/test/TestRange.cpp
+++ b/sigcore/test/TestRange.cpp
@@ -15,32 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Sicvore includes
-#include "../Range.h"
+// Header include
+#include "TestRange.h"
// QtTest includes
#include <QtTest/QTest>
-class TestRange : public QObject
-{
- Q_OBJECT
-
- private slots:
- void set();
- void setMinimum();
- void setMaximum();
- void valid();
- void in();
- void intersection();
- void setUnion();
- void negation();
- void addition();
- void subtraction();
- void multiplication();
- void division();
- void equality();
-};
-
void TestRange::set()
{
Sigcore::Range range(4., 5.);
@@ -99,7 +79,7 @@ void TestRange::in()
QCOMPARE(range.in(3.), true);
QCOMPARE(range.in(6.), false);
- QCOMPARE(range.in(Sigcore::Range(4., 6.)), true);
+ QCOMPARE(range.in(Sigcore::Range(1., 2.)), true);
QCOMPARE(range.in(Sigcore::Range(4., 6.)), false);
}
@@ -156,7 +136,7 @@ void TestRange::division()
{
Sigcore::Range range(1., 3.);
- QCOMPARE(range / Sigcore::Range(2., 4.), Sigcore::Range(2., 12.));
+ QCOMPARE(range / Sigcore::Range(2., 4.), Sigcore::Range(1./4., 3./2.));
QCOMPARE((range / Sigcore::Range(-2., 4.)).valid(), false);
QCOMPARE(range / 2., Sigcore::Range(.5, 1.5));
QCOMPARE(range / -2., Sigcore::Range(-1.5, -.5));
diff --git a/sigcore/test/TestRange.h b/sigcore/test/TestRange.h
new file mode 100644
index 00000000..301711a5
--- /dev/null
+++ b/sigcore/test/TestRange.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008 Ben Boeckel <MathStuf@gmail.com>
+ *
+ * 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/>.
+ */
+
+#ifndef TESTRANGE
+#define TESTRANGE
+
+// Sigcore includes
+#include "../Range.h"
+
+class TestRange : public QObject
+{
+ Q_OBJECT
+
+ private slots:
+ void set();
+ void setMinimum();
+ void setMaximum();
+ void valid();
+ void in();
+ void intersection();
+ void setUnion();
+ void negation();
+ void addition();
+ void subtraction();
+ void multiplication();
+ void division();
+ void equality();
+};
+
+#endif
+