xref: /aosp_15_r20/external/pytorch/test/cpp/api/namespace.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <gtest/gtest.h>
2 
3 #include <torch/torch.h>
4 
5 struct Node {};
6 
7 // If `torch::autograd::Note` is leaked into the root namespace, the following
8 // compile error would throw:
9 // ```
10 // void NotLeakingSymbolsFromTorchAutogradNamespace_test_func(Node *node) {}
11 //                                                            ^
12 // error: reference to `Node` is ambiguous
13 // ```
NotLeakingSymbolsFromTorchAutogradNamespace_test_func(Node * node)14 void NotLeakingSymbolsFromTorchAutogradNamespace_test_func(Node* node) {}
15 
TEST(NamespaceTests,NotLeakingSymbolsFromTorchAutogradNamespace)16 TEST(NamespaceTests, NotLeakingSymbolsFromTorchAutogradNamespace) {
17   // Checks that we are not leaking symbols from the
18   // `torch::autograd` namespace to the root namespace
19   NotLeakingSymbolsFromTorchAutogradNamespace_test_func(nullptr);
20 }
21