xref: /aosp_15_r20/external/emboss/compiler/back_end/cpp/testcode/namespace_test.cc (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1 // Copyright 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // Tests that generated code ends up in the correct C++ namespaces.
16 #include <stdint.h>
17 
18 #include <vector>
19 
20 #include "gtest/gtest.h"
21 #include "testdata/absolute_cpp_namespace.emb.h"
22 #include "testdata/cpp_namespace.emb.h"
23 #include "testdata/no_cpp_namespace.emb.h"
24 
25 namespace emboss {
26 namespace test {
27 namespace {
28 
TEST(Namespace,FooValueHasCorrectValueInDifferentNamespaces)29 TEST(Namespace, FooValueHasCorrectValueInDifferentNamespaces) {
30   EXPECT_EQ(static_cast</**/ ::emboss_generated_code::Foo>(10),
31             ::emboss_generated_code::Foo::VALUE);
32   EXPECT_EQ(static_cast</**/ ::emboss::test::no_leading_double_colon::Foo>(11),
33             ::emboss::test::no_leading_double_colon::Foo::VALUE);
34   EXPECT_EQ(static_cast</**/ ::emboss::test::leading_double_colon::Foo>(12),
35             ::emboss::test::leading_double_colon::Foo::VALUE);
36 }
37 
38 }  // namespace
39 }  // namespace test
40 }  // namespace emboss
41