Lines Matching refs:result

31 TEST(result, result_accessors) {  in TEST()  argument
32 Result<std::string> result = "success"; in TEST() local
33 ASSERT_RESULT_OK(result); in TEST()
34 ASSERT_TRUE(result.has_value()); in TEST()
36 EXPECT_EQ("success", *result); in TEST()
37 EXPECT_EQ("success", result.value()); in TEST()
39 EXPECT_EQ('s', result->data()[0]); in TEST()
42 TEST(result, result_accessors_rvalue) { in TEST() argument
52 TEST(result, result_void) { in TEST() argument
77 TEST(result, result_error) { in TEST() argument
78 Result<void> result = Error() << "failure" << 1; in TEST() local
79 ASSERT_FALSE(result.ok()); in TEST()
80 ASSERT_FALSE(result.has_value()); in TEST()
82 EXPECT_EQ(0, result.error().code()); in TEST()
83 EXPECT_EQ("failure1", result.error().message()); in TEST()
86 TEST(result, result_error_empty) { in TEST() argument
87 Result<void> result = Error(); in TEST() local
88 ASSERT_FALSE(result.ok()); in TEST()
89 ASSERT_FALSE(result.has_value()); in TEST()
91 EXPECT_EQ(0, result.error().code()); in TEST()
92 EXPECT_EQ("", result.error().message()); in TEST()
95 TEST(result, result_error_rvalue) { in TEST() argument
110 TEST(result, result_errno_error) { in TEST() argument
113 Result<void> result = ErrnoError() << "failure" << 1; in TEST() local
115 ASSERT_FALSE(result.ok()); in TEST()
116 ASSERT_FALSE(result.has_value()); in TEST()
118 EXPECT_EQ(test_errno, result.error().code()); in TEST()
119 EXPECT_EQ("failure1: "s + strerror(test_errno), result.error().message()); in TEST()
122 TEST(result, result_errno_error_no_text) { in TEST() argument
125 Result<void> result = ErrnoError(); in TEST() local
127 ASSERT_FALSE(result.ok()); in TEST()
128 ASSERT_FALSE(result.has_value()); in TEST()
130 EXPECT_EQ(test_errno, result.error().code()); in TEST()
131 EXPECT_EQ(strerror(test_errno), result.error().message()); in TEST()
134 TEST(result, result_error_from_other_result) { in TEST() argument
136 Result<void> result = Error() << error_text; in TEST() local
138 ASSERT_FALSE(result.ok()); in TEST()
139 ASSERT_FALSE(result.has_value()); in TEST()
141 Result<std::string> result2 = result.error(); in TEST()
150 TEST(result, result_error_through_ostream) { in TEST() argument
152 Result<void> result = Error() << error_text; in TEST() local
154 ASSERT_FALSE(result.ok()); in TEST()
155 ASSERT_FALSE(result.has_value()); in TEST()
157 Result<std::string> result2 = Error() << result.error(); in TEST()
166 TEST(result, result_errno_error_through_ostream) { in TEST() argument
170 Result<void> result = ErrnoError() << error_text; in TEST() local
174 ASSERT_FALSE(result.ok()); in TEST()
175 ASSERT_FALSE(result.has_value()); in TEST()
177 Result<std::string> result2 = Error() << result.error(); in TEST()
186 TEST(result, constructor_forwarding) { in TEST() argument
187 auto result = Result<std::string>(std::in_place, 5, 'a'); in TEST() local
189 ASSERT_RESULT_OK(result); in TEST()
190 ASSERT_TRUE(result.has_value()); in TEST()
192 EXPECT_EQ("aaaaa", *result); in TEST()
242 ConstructorTracker result(in + " " + in); in ReturnConstructorTracker() local
243 return result; in ReturnConstructorTracker()
246 TEST(result, no_copy_on_return) { in TEST() argument
287 TEST(result, result_result_with_success) { in TEST() argument
289 auto result = return_result_result_with_success(); in TEST() local
290 ASSERT_RESULT_OK(result); in TEST()
291 ASSERT_RESULT_OK(*result); in TEST()
293 auto inner_result = result.value(); in TEST()
297 TEST(result, result_result_with_failure) { in TEST() argument
301 auto result = return_result_result_with_error(); in TEST() local
302 ASSERT_RESULT_OK(result); in TEST()
303 ASSERT_FALSE(result->ok()); in TEST()
304 EXPECT_EQ("failure string", (*result).error().message()); in TEST()
305 EXPECT_EQ(6, (*result).error().code()); in TEST()
311 TEST(result, result_two_parameter_constructor_same_type) { in TEST() argument
314 TestStruct(Result<TestStruct> result, int value) : value_(result->value_ * value) {} in TEST()
322 auto result = return_test_struct(); in TEST() local
323 ASSERT_RESULT_OK(result); in TEST()
324 EXPECT_EQ(36, result->value_); in TEST()
327 TEST(result, die_on_access_failed_result) { in TEST() argument
328 Result<std::string> result = Error(); in TEST() local
329 ASSERT_DEATH(*result, ""); in TEST()
332 TEST(result, die_on_get_error_succesful_result) { in TEST() argument
333 Result<std::string> result = "success"; in TEST() local
334 ASSERT_DEATH(result.error(), ""); in TEST()
343 TEST(result, preserve_errno) { in TEST() argument
346 Result<int> result = Error() << "Failed" << SetErrnoToTwo<char>; in TEST() local
347 ASSERT_FALSE(result.ok()); in TEST()
358 TEST(result, error_with_fmt) { in TEST() argument
359 Result<int> result = Errorf("{} {}!", "hello", "world"); in TEST() local
360 EXPECT_EQ("hello world!", result.error().message()); in TEST()
362 result = Errorf("{} {}!", std::string("hello"), std::string("world")); in TEST()
363 EXPECT_EQ("hello world!", result.error().message()); in TEST()
365 result = Errorf("{1} {0}!", "world", "hello"); in TEST()
366 EXPECT_EQ("hello world!", result.error().message()); in TEST()
368 result = Errorf("hello world!"); in TEST()
369 EXPECT_EQ("hello world!", result.error().message()); in TEST()
371 Result<int> result2 = Errorf("error occurred with {}", result.error()); in TEST()
376 result = ErrnoErrorf("{} {}!", "hello", "world"); in TEST()
377 EXPECT_EQ(test_errno, result.error().code()); in TEST()
378 EXPECT_EQ("hello world!: "s + strerror(test_errno), result.error().message()); in TEST()
381 TEST(result, error_with_fmt_carries_errno) { in TEST() argument
405 TEST(result, errno_chaining_multiple) { in TEST() argument