aboutsummaryrefslogtreecommitdiff
path: root/sensor/test
diff options
context:
space:
mode:
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);
+
+}