1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "testing/rust_gtest_interop/rust_gtest_interop.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace rust_gtest_interop {
10
rust_gtest_default_factory(void (* body)(testing::Test *))11 testing::Test* rust_gtest_default_factory(void (*body)(testing::Test*)) {
12 return rust_gtest_factory_for_subclass<testing::Test>(body);
13 }
14
rust_gtest_add_test(GtestFactoryFunction gtest_factory,void (* test_function)(testing::Test *),const char * test_suite_name,const char * test_name,const char * file,int32_t line)15 void rust_gtest_add_test(GtestFactoryFunction gtest_factory,
16 void (*test_function)(testing::Test*),
17 const char* test_suite_name,
18 const char* test_name,
19 const char* file,
20 int32_t line) {
21 auto factory = [=]() { return gtest_factory(test_function); };
22 testing::RegisterTest(test_suite_name, test_name, nullptr, nullptr, file,
23 line, factory);
24 }
25
rust_gtest_add_failure_at(const char * file,int32_t line,const char * message)26 void rust_gtest_add_failure_at(const char* file,
27 int32_t line,
28 const char* message) {
29 ADD_FAILURE_AT(reinterpret_cast<const char*>(file), line) << message;
30 }
31
32 } // namespace rust_gtest_interop
33