sled/src/status_or_test.cc
tqcq 74b59961ed
All checks were successful
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m23s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 1m25s
feat update
2024-03-23 15:40:27 +08:00

24 lines
635 B
C++

#include <gtest/gtest.h>
#include <sled/log/log.h>
#include <sled/status_or.h>
TEST(StatusOr, TestStatusOr)
{
sled::StatusOr<int> so;
EXPECT_FALSE(so.ok());
so = sled::StatusOr<int>(1);
EXPECT_TRUE(so.ok());
EXPECT_EQ(so.value(), 1);
EXPECT_EQ(so.status().code(), sled::StatusCode::kOk);
}
TEST(StatusOr, make_status_or)
{
auto from_raw_str = sled::make_status_or("hello");
auto from_string = sled::make_status_or(std::string("world"));
EXPECT_TRUE(from_raw_str.ok());
EXPECT_TRUE(from_string.ok());
EXPECT_EQ(from_raw_str.value(), "hello");
EXPECT_EQ(from_string.value(), "world");
}