Исходный код СУБД 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
49
50
51
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#if defined(_MSC_VER) && !defined(NDEBUG)
 
#include "core/common/common.h"
 
#include <iostream>
 
#include "gtest/gtest.h"
#include "gmock/gmock.h"
 
namespace onnxruntime {
namespace test {
 
using namespace ::testing;
#if !defined(ORT_NO_EXCEPTIONS)
TEST(StacktraceTests, BasicTests) {
  auto result = ::onnxruntime::GetStackTrace();
 
  // if we are running code coverage the Windows CaptureStackBackTrace function only returns a single
  // frame that is unknown. adjust for that.
  // works fine when running unit tests normally.
  const bool have_working_stacktrace = result.size() > 1;
 
  if (have_working_stacktrace)
    // this method name should be the first on the stack as we hide the calls to the infrastructure that
    // creates the stack trace
    EXPECT_THAT(result[0], HasSubstr("BasicTests"));
 
  ORT_TRY {
    ORT_THROW("Testing");
  }
  ORT_CATCH(const OnnxRuntimeException& ex) {
    ORT_HANDLE_EXCEPTION([&]() {
      auto msg = ex.what();
      std::cout << msg;
 
      if (have_working_stacktrace)
        // unit tests are run by main() in test_main.cc, so make sure that is present
        EXPECT_THAT(msg, HasSubstr("test_main.cc"));
      else
        // otherwise just make sure we captured where the throw was from
        EXPECT_THAT(msg, HasSubstr("BasicTests"));
    });
  }
}
#endif
}  // namespace test
}  // namespace onnxruntime
#endif