mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 11:55:51 +00:00
Compare commits
1 Commits
2.2.0-rc3
...
release/2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b18e28c47 |
@@ -94,7 +94,7 @@ struct ReturnType {
|
||||
* @param warnings The warnings generated by the RPC call
|
||||
*/
|
||||
ReturnType(std::expected<boost::json::value, Status> result, boost::json::array warnings = {})
|
||||
: result{std::move(result)}, warnings{std::move(warnings)}
|
||||
: result{std::move(result)}, warnings(std::move(warnings))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "rpc/Errors.hpp"
|
||||
#include "rpc/common/Types.hpp"
|
||||
|
||||
#include <boost/json/array.hpp>
|
||||
#include <boost/json/value.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <expected>
|
||||
@@ -34,3 +36,46 @@ TEST(MaybeErrorTest, OperatorEquals)
|
||||
EXPECT_EQ(MaybeError{std::unexpected{Status{"Error"}}}, MaybeError{std::unexpected{Status{"Error"}}});
|
||||
EXPECT_NE(MaybeError{std::unexpected{Status{"Error"}}}, MaybeError{std::unexpected{Status{"Another_error"}}});
|
||||
}
|
||||
|
||||
TEST(ReturnTypeTests, Constructor)
|
||||
{
|
||||
boost::json::value const value{42};
|
||||
|
||||
{
|
||||
ReturnType const r{value};
|
||||
ASSERT_TRUE(r.result);
|
||||
EXPECT_EQ(r.result.value(), value);
|
||||
EXPECT_EQ(r.warnings, boost::json::array{});
|
||||
}
|
||||
|
||||
{
|
||||
boost::json::array const warnings{1, 2, 3};
|
||||
ReturnType const r{value, warnings};
|
||||
ASSERT_TRUE(r.result);
|
||||
EXPECT_EQ(r.result.value(), value);
|
||||
EXPECT_EQ(r.warnings, warnings);
|
||||
}
|
||||
|
||||
{
|
||||
Status const status{"Error"};
|
||||
|
||||
ReturnType const r{std::unexpected{status}};
|
||||
ASSERT_FALSE(r.result);
|
||||
EXPECT_EQ(r.result.error(), status);
|
||||
EXPECT_EQ(r.warnings, boost::json::array{});
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ReturnTypeTests, operatorBool)
|
||||
{
|
||||
{
|
||||
boost::json::value const value{42};
|
||||
ReturnType const r{value};
|
||||
EXPECT_TRUE(r);
|
||||
}
|
||||
{
|
||||
Status const status{"Error"};
|
||||
ReturnType const r{std::unexpected{status}};
|
||||
EXPECT_FALSE(r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user