aboutsummaryrefslogtreecommitdiff
path: root/sensor/test
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-03-28 21:52:46 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-03-28 21:52:46 +0100
commit8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7 (patch)
treed38b8762e08ecb33a4a94ad89b0d058e54a542b8 /sensor/test
parentf110a0912efb7245d6d548aa8a5ac0c89bcd9dc0 (diff)
downloadble-toys-8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7.tar.gz
ble-toys-8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7.tar.bz2
ble-toys-8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7.tar.xz
ble-toys-8d9760f9bfc8be9b1abad9a8212b14ffd4552fd7.zip
o Adding timestamp by default when converting samples.
Diffstat (limited to 'sensor/test')
-rw-r--r--sensor/test/SampleTest.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/sensor/test/SampleTest.cpp b/sensor/test/SampleTest.cpp
index 2404500..9737d02 100644
--- a/sensor/test/SampleTest.cpp
+++ b/sensor/test/SampleTest.cpp
@@ -18,7 +18,8 @@ BOOST_AUTO_TEST_CASE(key_value_parser) {
auto parser = make_shared<KeyValueSampleStreamParser>(buffer, dict);
char data[] = "a=1, b=2, c=3\n";
- parser->process(boost::asio::buffer(data, sizeof(data)));
+ auto buf = boost::asio::buffer(data, sizeof(data));
+ parser->process(buf);
BOOST_CHECK_EQUAL(buffer->samples.size(), 1);
BOOST_CHECK_EQUAL(dict.size(), 3);
auto it = dict.begin();
@@ -38,7 +39,8 @@ BOOST_AUTO_TEST_CASE(key_value_parser2) {
auto parser = make_shared<KeyValueSampleStreamParser>(buffer, dict);
char data[] = "now=1,sensor 1=0.000999999833333\n";
- parser->process(boost::asio::buffer(data, sizeof(data)));
+ auto buf = boost::asio::buffer(data, sizeof(data));
+ parser->process(buf);
BOOST_CHECK_EQUAL(buffer->samples.size(), 1);
SampleRecord& sample = buffer->samples[0];
BOOST_CHECK_EQUAL(dict.size(), 2);
@@ -65,7 +67,8 @@ BOOST_AUTO_TEST_CASE(key_value_parser_with_custom_dict) {
auto parser = make_shared<KeyValueSampleStreamParser>(buffer, dict);
char data[] = "a=1, b=2, c=3\n";
- parser->process(boost::asio::buffer(data, sizeof(data)));
+ auto buf = boost::asio::buffer(data, sizeof(data));
+ parser->process(buf);
BOOST_CHECK_EQUAL(buffer->samples.size(), 1);
BOOST_CHECK_EQUAL(dict.size(), 3);
auto it = dict.begin();
@@ -74,3 +77,16 @@ BOOST_AUTO_TEST_CASE(key_value_parser_with_custom_dict) {
BOOST_CHECK_EQUAL((*it)->name, "b");
BOOST_CHECK_EQUAL((*it++)->index, 1);
}
+
+BOOST_AUTO_TEST_CASE(type_detection_key_value) {
+ KeyDictionary dict;
+
+ auto output = make_shared<VectorSampleOutputStream>();
+
+ auto parser = open_sample_stream_parser(output, dict);
+
+ char data[] = "a=1, b=2, c=3\n";
+ auto buf = boost::asio::buffer(data, sizeof(data));
+ parser->process(buf);
+
+}