You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.4 KiB
C++
98 lines
3.4 KiB
C++
/***************************************************************************
|
|
* 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()
|