forked from Research/WhisperCom
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
/*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
/** @file */
|
|
|
|
/**
|
|
* \defgroup test_message_class Tests for Whisper::Message
|
|
* Test include functional correctness.
|
|
*/
|
|
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
#include <catch2/catch.hpp>
|
|
#include <memory>
|
|
#include <Whisper/Message.hpp>
|
|
|
|
/**
|
|
* \brief Verify that data classification compile and can be used
|
|
* \ingroup compile_data_tests
|
|
*/
|
|
SCENARIO("instantiating a Whisper::Message","[message]")
|
|
{
|
|
GIVEN("nothing")
|
|
{
|
|
std::unique_ptr<Whisper::Message> msg;
|
|
|
|
|
|
WHEN("instantiating some classifications")
|
|
{
|
|
REQUIRE_NOTHROW([&]()
|
|
{
|
|
msg = std::make_unique<Whisper::Message>();
|
|
}());
|
|
|
|
|
|
THEN("default values are set")
|
|
{
|
|
REQUIRE(msg->type() == Whisper::MessageType::NONE);
|
|
REQUIRE(msg->hasEnconding() == false);
|
|
REQUIRE(msg->id() > 0);
|
|
REQUIRE(msg->replyId() == 0);
|
|
REQUIRE(msg->src() == 0);
|
|
REQUIRE(msg->dst() == 0);
|
|
|
|
REQUIRE_THROWS([&]()
|
|
{
|
|
msg->encode();
|
|
}());
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|