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.
srsRAN_4G/lib/test/adt/optional_test.cc

35 lines
729 B
C++

/**
*
* \section COPYRIGHT
*
* Copyright 2013-2021 Software Radio Systems Limited
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the distribution.
*
*/
#include "srsran/adt/optional.h"
#include "srsran/common/test_common.h"
using namespace srsran;
void test_optional_int()
{
optional<int> opt, opt2(5);
TESTASSERT(not opt.has_value() and opt2.has_value());
TESTASSERT(not static_cast<bool>(opt) and static_cast<bool>(opt2));
TESTASSERT(opt2.value() == 5 and *opt2 == 5);
opt = 4;
TESTASSERT(opt.has_value());
TESTASSERT(opt != opt2);
opt2 = 4;
TESTASSERT(opt == opt2);
}
int main()
{
test_optional_int();
}