Lines Matching full:status
15 #include "pw_status/status.h"
22 constexpr Status::Code kInvalidCode = static_cast<Status::Code>(30);
24 TEST(Status, Default) { in TEST() argument
25 constexpr Status status; in TEST() local
26 static_assert(status.ok()); in TEST()
27 static_assert(Status() == status); in TEST()
30 TEST(Status, ConstructWithStatusCode) { in TEST() argument
31 constexpr Status status(PW_STATUS_ABORTED); in TEST() local
32 static_assert(status.IsAborted()); in TEST()
35 TEST(Status, AssignFromStatusCode) { in TEST() argument
36 Status status; in TEST() local
37 status = PW_STATUS_INTERNAL; in TEST()
38 EXPECT_EQ(Status::Internal(), status); in TEST()
41 TEST(Status, Ok_OkIsTrue) { in TEST() argument
42 static_assert(Status().ok()); in TEST()
43 static_assert(Status(PW_STATUS_OK).ok()); in TEST()
47 TEST(Status, NotOk_OkIsFalse) { in TEST() argument
48 static_assert(!Status::DataLoss().ok()); in TEST()
49 static_assert(!Status(kInvalidCode).ok()); in TEST()
52 TEST(Status, Code) { in TEST() argument
54 static_assert(PW_STATUS_OK == Status().code()); in TEST()
56 static_assert(PW_STATUS_CANCELLED == Status::Cancelled().code()); in TEST()
57 static_assert(PW_STATUS_UNKNOWN == Status::Unknown().code()); in TEST()
58 static_assert(PW_STATUS_INVALID_ARGUMENT == Status::InvalidArgument().code()); in TEST()
59 static_assert(PW_STATUS_DEADLINE_EXCEEDED == Status::DeadlineExceeded().code()); in TEST()
60 static_assert(PW_STATUS_NOT_FOUND == Status::NotFound().code()); in TEST()
61 static_assert(PW_STATUS_ALREADY_EXISTS == Status::AlreadyExists().code()); in TEST()
62 static_assert(PW_STATUS_PERMISSION_DENIED == Status::PermissionDenied().code()); in TEST()
63 static_assert(PW_STATUS_RESOURCE_EXHAUSTED == Status::ResourceExhausted().code()); in TEST()
64 static_assert(PW_STATUS_FAILED_PRECONDITION == Status::FailedPrecondition().code()); in TEST()
65 static_assert(PW_STATUS_ABORTED == Status::Aborted().code()); in TEST()
66 static_assert(PW_STATUS_OUT_OF_RANGE == Status::OutOfRange().code()); in TEST()
67 static_assert(PW_STATUS_UNIMPLEMENTED == Status::Unimplemented().code()); in TEST()
68 static_assert(PW_STATUS_INTERNAL == Status::Internal().code()); in TEST()
69 static_assert(PW_STATUS_UNAVAILABLE == Status::Unavailable().code()); in TEST()
70 static_assert(PW_STATUS_DATA_LOSS == Status::DataLoss().code()); in TEST()
71 static_assert(PW_STATUS_UNAUTHENTICATED == Status::Unauthenticated().code()); in TEST()
75 TEST(Status, EqualCodes) { in TEST() argument
76 static_assert(PW_STATUS_OK == Status()); in TEST()
78 static_assert(PW_STATUS_CANCELLED == Status::Cancelled()); in TEST()
79 static_assert(PW_STATUS_UNKNOWN == Status::Unknown()); in TEST()
80 static_assert(PW_STATUS_INVALID_ARGUMENT == Status::InvalidArgument()); in TEST()
81 static_assert(PW_STATUS_DEADLINE_EXCEEDED == Status::DeadlineExceeded()); in TEST()
82 static_assert(PW_STATUS_NOT_FOUND == Status::NotFound()); in TEST()
83 static_assert(PW_STATUS_ALREADY_EXISTS == Status::AlreadyExists()); in TEST()
84 static_assert(PW_STATUS_PERMISSION_DENIED == Status::PermissionDenied()); in TEST()
85 static_assert(PW_STATUS_RESOURCE_EXHAUSTED == Status::ResourceExhausted()); in TEST()
86 static_assert(PW_STATUS_FAILED_PRECONDITION == Status::FailedPrecondition()); in TEST()
87 static_assert(PW_STATUS_ABORTED == Status::Aborted()); in TEST()
88 static_assert(PW_STATUS_OUT_OF_RANGE == Status::OutOfRange()); in TEST()
89 static_assert(PW_STATUS_UNIMPLEMENTED == Status::Unimplemented()); in TEST()
90 static_assert(PW_STATUS_INTERNAL == Status::Internal()); in TEST()
91 static_assert(PW_STATUS_UNAVAILABLE == Status::Unavailable()); in TEST()
92 static_assert(PW_STATUS_DATA_LOSS == Status::DataLoss()); in TEST()
93 static_assert(PW_STATUS_UNAUTHENTICATED == Status::Unauthenticated()); in TEST()
96 TEST(Status, IsError) { in TEST() argument
97 static_assert(Status::Cancelled().IsCancelled()); in TEST()
98 static_assert(Status::Unknown().IsUnknown()); in TEST()
99 static_assert(Status::InvalidArgument().IsInvalidArgument()); in TEST()
100 static_assert(Status::DeadlineExceeded().IsDeadlineExceeded()); in TEST()
101 static_assert(Status::NotFound().IsNotFound()); in TEST()
102 static_assert(Status::AlreadyExists().IsAlreadyExists()); in TEST()
103 static_assert(Status::PermissionDenied().IsPermissionDenied()); in TEST()
104 static_assert(Status::ResourceExhausted().IsResourceExhausted()); in TEST()
105 static_assert(Status::FailedPrecondition().IsFailedPrecondition()); in TEST()
106 static_assert(Status::Aborted().IsAborted()); in TEST()
107 static_assert(Status::OutOfRange().IsOutOfRange()); in TEST()
108 static_assert(Status::Unimplemented().IsUnimplemented()); in TEST()
109 static_assert(Status::Internal().IsInternal()); in TEST()
110 static_assert(Status::Unavailable().IsUnavailable()); in TEST()
111 static_assert(Status::DataLoss().IsDataLoss()); in TEST()
112 static_assert(Status::Unauthenticated().IsUnauthenticated()); in TEST()
115 TEST(Status, IsNotError) { in TEST() argument
134 TEST(Status, Strings) { in TEST() argument
135 EXPECT_STREQ("OK", Status().str()); in TEST()
137 EXPECT_STREQ("CANCELLED", Status::Cancelled().str()); in TEST()
138 EXPECT_STREQ("UNKNOWN", Status::Unknown().str()); in TEST()
139 EXPECT_STREQ("INVALID_ARGUMENT", Status::InvalidArgument().str()); in TEST()
140 EXPECT_STREQ("DEADLINE_EXCEEDED", Status::DeadlineExceeded().str()); in TEST()
141 EXPECT_STREQ("NOT_FOUND", Status::NotFound().str()); in TEST()
142 EXPECT_STREQ("ALREADY_EXISTS", Status::AlreadyExists().str()); in TEST()
143 EXPECT_STREQ("PERMISSION_DENIED", Status::PermissionDenied().str()); in TEST()
144 EXPECT_STREQ("RESOURCE_EXHAUSTED", Status::ResourceExhausted().str()); in TEST()
145 EXPECT_STREQ("FAILED_PRECONDITION", Status::FailedPrecondition().str()); in TEST()
146 EXPECT_STREQ("ABORTED", Status::Aborted().str()); in TEST()
147 EXPECT_STREQ("OUT_OF_RANGE", Status::OutOfRange().str()); in TEST()
148 EXPECT_STREQ("UNIMPLEMENTED", Status::Unimplemented().str()); in TEST()
149 EXPECT_STREQ("INTERNAL", Status::Internal().str()); in TEST()
150 EXPECT_STREQ("UNAVAILABLE", Status::Unavailable().str()); in TEST()
151 EXPECT_STREQ("DATA_LOSS", Status::DataLoss().str()); in TEST()
152 EXPECT_STREQ("UNAUTHENTICATED", Status::Unauthenticated().str()); in TEST()
155 TEST(Status, UnknownString) { in TEST() argument
156 EXPECT_STREQ("INVALID STATUS", Status(kInvalidCode).str()); in TEST()
162 Status::Code PassStatusFromC(Status status);
164 Status::Code PassStatusFromCpp(Status status) { return status.code(); } in PassStatusFromCpp() argument
173 EXPECT_EQ(Status::Aborted(), PassStatusFromC(PW_STATUS_ABORTED)); in TEST()
174 EXPECT_EQ(Status::Unknown(), PassStatusFromC(Status::Unknown())); in TEST()
176 EXPECT_EQ(Status::NotFound(), PassStatusFromC(PW_STATUS_NOT_FOUND)); in TEST()