[Liblas-commits] hg-main-tree: input tests passing
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Apr 26 13:57:26 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/2e79c922a0ce
changeset: 664:2e79c922a0ce
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Apr 26 10:57:16 2011 -0700
description:
input tests passing
diffstat:
src/Bounds.cpp | 16 +++++++++-------
src/Range.cpp | 2 ++
src/Utils.cpp | 20 +++++++++++++++-----
test/unit/BoundsTest.cpp | 8 +++-----
test/unit/RangeTest.cpp | 5 ++---
5 files changed, 31 insertions(+), 20 deletions(-)
diffs (140 lines):
diff -r b1a5d46b86a2 -r 2e79c922a0ce src/Bounds.cpp
--- a/src/Bounds.cpp Tue Apr 26 10:34:57 2011 -0700
+++ b/src/Bounds.cpp Tue Apr 26 10:57:16 2011 -0700
@@ -47,8 +47,6 @@
{
Bounds<double>::RangeVector v;
- char c;
-
Utils::eatwhitespace(istr);
if (!Utils::eatcharacter(istr,'('))
@@ -61,20 +59,24 @@
Range<double> r;
istr >> r;
+ v.push_back(r);
Utils::eatwhitespace(istr);
- if ((c = (char)istr.peek()) == ',')
+ if (Utils::eatcharacter(istr,','))
+ {
done = false;
- else if ((c = (char)istr.peek()) == ')')
+ }
+ else if (Utils::eatcharacter(istr,')'))
+ {
done = true;
+ }
else
+ {
throw libpc_error("Bounds parser failed");
+ }
}
- if (!Utils::eatcharacter(istr,')'))
- throw libpc_error("Bounds parser failed");
-
Bounds<double> xxx(v);
bounds = xxx;
diff -r b1a5d46b86a2 -r 2e79c922a0ce src/Range.cpp
--- a/src/Range.cpp Tue Apr 26 10:34:57 2011 -0700
+++ b/src/Range.cpp Tue Apr 26 10:57:16 2011 -0700
@@ -53,6 +53,8 @@
istr >> low;
+ Utils::eatwhitespace(istr);
+
if (!Utils::eatcharacter(istr,','))
throw libpc_error("Range parser failed");
diff -r b1a5d46b86a2 -r 2e79c922a0ce src/Utils.cpp
--- a/src/Utils.cpp Tue Apr 26 10:34:57 2011 -0700
+++ b/src/Utils.cpp Tue Apr 26 10:57:16 2011 -0700
@@ -50,6 +50,10 @@
#include <libpc/exceptions.hpp>
+#ifdef LIBPC_COMPILER_MSVC
+# pragma warning(disable: 4127) // conditional expression is constant
+#endif
+
namespace libpc
{
@@ -179,20 +183,26 @@
void Utils::eatwhitespace(std::istream& s)
{
- char c;
- while (isspace(c = (char)s.peek()))
+ while (true)
{
- s >> c;
+ const char c = (char)s.peek();
+ if (!isspace(c)) break;
+
+ // throw it away
+ s.get();
}
+ return;
}
bool Utils::eatcharacter(std::istream& s, char x)
{
- char c = (char)s.peek();
+ const char c = (char)s.peek();
if (c != x) return false;
- s >> c;
+ // throw it away
+ s.get();
+
return true;
}
diff -r b1a5d46b86a2 -r 2e79c922a0ce test/unit/BoundsTest.cpp
--- a/test/unit/BoundsTest.cpp Tue Apr 26 10:34:57 2011 -0700
+++ b/test/unit/BoundsTest.cpp Tue Apr 26 10:57:16 2011 -0700
@@ -258,14 +258,12 @@
BOOST_AUTO_TEST_CASE(test_input)
{
- Bounds<double> r(1,2,10,20);
-
- std::stringstream iss;
- iss << "[10 .. 20]";
+ std::stringstream ss("([1.1, 101.1], [2.2, 102.2], [3.3, 103.3])", std::stringstream::in | std::stringstream::out);
Bounds<double> rr;
- iss >> rr;
+ ss >> rr;
+ Bounds<double> r(1.1,2.2,3.3,101.1,102.2,103.3);
BOOST_CHECK(r == rr);
return;
diff -r b1a5d46b86a2 -r 2e79c922a0ce test/unit/RangeTest.cpp
--- a/test/unit/RangeTest.cpp Tue Apr 26 10:34:57 2011 -0700
+++ b/test/unit/RangeTest.cpp Tue Apr 26 10:57:16 2011 -0700
@@ -218,13 +218,12 @@
BOOST_AUTO_TEST_CASE(test_input)
{
- Range<double> r(10,20);
-
- std::stringstream ss("[10 , 20]", std::stringstream::in | std::stringstream::out);
+ std::stringstream ss("[1.1, 2.2]", std::stringstream::in | std::stringstream::out);
Range<double> rr;
ss >> rr;
+ const Range<double> r(1.1,2.2);
BOOST_CHECK(r == rr);
return;
More information about the Liblas-commits
mailing list