Initial commit based on common repo commit ffeb9c9b
This commit is contained in:
97
libs/gempa/caps/test/packet.cpp
Normal file
97
libs/gempa/caps/test/packet.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2018 by gempa GmbH *
|
||||
* *
|
||||
* All Rights Reserved. *
|
||||
* *
|
||||
* NOTICE: All information contained herein is, and remains *
|
||||
* the property of gempa GmbH and its suppliers, if any. The intellectual *
|
||||
* and technical concepts contained herein are proprietary to gempa GmbH *
|
||||
* and its suppliers. *
|
||||
* Dissemination of this information or reproduction of this material *
|
||||
* is strictly forbidden unless prior written permission is obtained *
|
||||
* from gempa GmbH. *
|
||||
* *
|
||||
* Author: Tracey Werner, Enrico Ellguth *
|
||||
* Email: tracey.werner@gempa.de, enrico.ellguth@gempa.de *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#define SEISCOMP_TEST_MODULE gempa
|
||||
#include <seiscomp3/unittest/unittests.h>
|
||||
|
||||
#include <gempa/caps/packet.h>
|
||||
#include <gempa/caps/rawpacket.cpp>
|
||||
#include <gempa/caps/utils.h>
|
||||
|
||||
|
||||
namespace gc = Gempa::CAPS;
|
||||
namespace bu = boost::unit_test;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(gempa_common_caps_packet)
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
||||
|
||||
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
BOOST_AUTO_TEST_CASE(equal_function) {
|
||||
|
||||
bu::unit_test_log.set_threshold_level(bu::log_warnings);
|
||||
bu::unit_test_log.set_threshold_level(bu::log_messages);
|
||||
|
||||
gc::DataRecord::Header header;
|
||||
gc::DataRecord::Header other;
|
||||
gc::Time t(1004791084,45368);
|
||||
|
||||
BOOST_CHECK_NO_THROW(header.setSamplingTime(t));
|
||||
header.samplingFrequencyNumerator = 3;
|
||||
header.samplingFrequencyDenominator = 7;
|
||||
BOOST_CHECK_EQUAL(header != other, true);
|
||||
|
||||
bool valid = header.compatible(other);
|
||||
BOOST_CHECK_EQUAL(valid, false);
|
||||
|
||||
other = header;
|
||||
valid = header.compatible(other);
|
||||
BOOST_CHECK_EQUAL(valid, true);
|
||||
BOOST_CHECK_EQUAL(header != other, false);
|
||||
}
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
||||
|
||||
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
BOOST_AUTO_TEST_CASE(getAndPut) {
|
||||
|
||||
gc::DataRecord::Header header;
|
||||
header.dataType = gc::DT_INT64;
|
||||
header.samplingFrequencyNumerator = 1;
|
||||
header.samplingFrequencyDenominator = 1;
|
||||
char buf[1024];
|
||||
gc::arraybuf abuf(buf, 1024);
|
||||
|
||||
BOOST_CHECK_EQUAL(header.samplingFrequencyNumerator, 1);
|
||||
BOOST_CHECK_EQUAL(header.samplingFrequencyDenominator, 1);
|
||||
BOOST_CHECK_EQUAL(header.dataType, gc::DT_INT64);
|
||||
bool valid = header.put(abuf);
|
||||
BOOST_CHECK_EQUAL(valid, true);
|
||||
|
||||
gc::DataRecord::Header otherHeader;
|
||||
valid = otherHeader.get(abuf);
|
||||
BOOST_CHECK_EQUAL(valid,true);
|
||||
BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyNumerator, 1);
|
||||
BOOST_CHECK_EQUAL(otherHeader.samplingFrequencyDenominator, 1);
|
||||
BOOST_CHECK_EQUAL(otherHeader.dataType, gc::DT_INT64);
|
||||
}
|
||||
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
||||
|
||||
|
||||
|
||||
|
||||
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
Reference in New Issue
Block a user