aboutsummaryrefslogtreecommitdiff
path: root/sensor/test/SoilMoistureIoTest.cpp
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-03-23 00:14:56 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-03-23 00:14:56 +0100
commitf110a0912efb7245d6d548aa8a5ac0c89bcd9dc0 (patch)
tree5e9be9b2b2eda5082089a42570c5b88b65647f8b /sensor/test/SoilMoistureIoTest.cpp
parent52d0fe67f8998b215a47ebc697600cae49a7b17a (diff)
downloadble-toys-f110a0912efb7245d6d548aa8a5ac0c89bcd9dc0.tar.gz
ble-toys-f110a0912efb7245d6d548aa8a5ac0c89bcd9dc0.tar.bz2
ble-toys-f110a0912efb7245d6d548aa8a5ac0c89bcd9dc0.tar.xz
ble-toys-f110a0912efb7245d6d548aa8a5ac0c89bcd9dc0.zip
o Replacing regex based parsing with simpler and more correct tokenizing.
o Flushing output after each sample. o Adding back tests.
Diffstat (limited to 'sensor/test/SoilMoistureIoTest.cpp')
-rw-r--r--sensor/test/SoilMoistureIoTest.cpp48
1 files changed, 0 insertions, 48 deletions
diff --git a/sensor/test/SoilMoistureIoTest.cpp b/sensor/test/SoilMoistureIoTest.cpp
deleted file mode 100644
index 574885c..0000000
--- a/sensor/test/SoilMoistureIoTest.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-#include "SensorSample.h"
-
-#define BOOST_TEST_MODULE "SoilMoistureIoTest"
-
-#include <boost/test/unit_test.hpp>
-
-using namespace trygvis::soil_moisture;
-
-BOOST_AUTO_TEST_CASE(key_value_parser) {
- KeyDictionary dict;
-
- auto buffer = make_shared<VectorSampleOutputStream>();
-
- auto parser = new KeyValueSampleStreamParser(buffer, dict);
-
- char data[] = "a=1, b=2, c=3\n";
- parser->process(boost::asio::buffer(data, sizeof(data)));
- BOOST_CHECK_EQUAL(buffer->samples.size(), 1);
- BOOST_CHECK_EQUAL(dict.size(), 3);
- auto it = dict.begin();
- BOOST_CHECK_EQUAL((*it)->name, "a");
- BOOST_CHECK_EQUAL((*it++)->index, 0);
- BOOST_CHECK_EQUAL((*it)->name, "b");
- BOOST_CHECK_EQUAL((*it++)->index, 1);
- BOOST_CHECK_EQUAL((*it)->name, "c");
- BOOST_CHECK_EQUAL((*it++)->index, 2);
-}
-
-BOOST_AUTO_TEST_CASE(key_value_parser_with_custom_dict) {
- KeyDictionary dict;
-
- dict.indexOf("c");
- dict.indexOf("b");
-
- auto buffer = make_shared<VectorSampleOutputStream>();
-
- auto parser = new KeyValueSampleStreamParser(buffer, dict);
-
- char data[] = "a=1, b=2, c=3\n";
- parser->process(boost::asio::buffer(data, sizeof(data)));
- BOOST_CHECK_EQUAL(buffer->samples.size(), 1);
- BOOST_CHECK_EQUAL(dict.size(), 3);
- auto it = dict.begin();
- BOOST_CHECK_EQUAL((*it)->name, "c");
- BOOST_CHECK_EQUAL((*it++)->index, 0);
- BOOST_CHECK_EQUAL((*it)->name, "b");
- BOOST_CHECK_EQUAL((*it++)->index, 1);
-}