Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include "core/common/status.h"
#include "gtest/gtest.h"
#include "gmock/gmock.h"
 
// helpers to run a function and check the status, outputting any error if it fails.
// note: wrapped in do{} while(false) so the _tmp_status variable has limited scope
#define ASSERT_STATUS_OK(function)                  \
  do {                                              \
    Status _tmp_status = (function);                \
    ASSERT_TRUE(_tmp_status.IsOK()) << _tmp_status; \
  } while (false)
 
#define EXPECT_STATUS_OK(function)                  \
  do {                                              \
    Status _tmp_status = (function);                \
    EXPECT_TRUE(_tmp_status.IsOK()) << _tmp_status; \
  } while (false)
 
#define ASSERT_STATUS_NOT_OK(function) \
  do {                                 \
    Status _tmp_status = (function);   \
    ASSERT_FALSE(_tmp_status.IsOK());  \
  } while (false)
 
#define EXPECT_STATUS_NOT_OK(function) \
  do {                                 \
    Status _tmp_status = (function);   \
    EXPECT_FALSE(_tmp_status.IsOK());  \
  } while (false)
 
#define ASSERT_STATUS_NOT_OK_AND_HAS_SUBSTR(function, msg)              \
  do {                                                                  \
    Status _tmp_status = (function);                                    \
    ASSERT_FALSE(_tmp_status.IsOK());                                   \
    ASSERT_THAT(_tmp_status.ErrorMessage(), ::testing::HasSubstr(msg)); \
  } while (false)
 
#define EXPECT_STATUS_NOT_OK_AND_HAS_SUBSTR(function, msg)              \
  do {                                                                  \
    Status _tmp_status = (function);                                    \
    EXPECT_FALSE(_tmp_status.IsOK());                                   \
    EXPECT_THAT(_tmp_status.ErrorMessage(), ::testing::HasSubstr(msg)); \
  } while (false)