• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2024 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 an emb compiled with enable_enum_traits = False actually compiles.
16 
17 #include <stdint.h>
18 
19 #include <vector>
20 
21 #include "gmock/gmock.h"
22 #include "gtest/gtest.h"
23 #include "testdata/no_enum_traits.emb.h"
24 
25 namespace emboss {
26 namespace test {
27 namespace {
28 
TEST(NoEnumTraits,Compiles)29 TEST(NoEnumTraits, Compiles) {
30   ::std::vector<uint8_t> backing_store(1);
31   auto view = MakeBarView(&backing_store);
32   view.foo().Write(Foo::VALUE);
33   EXPECT_TRUE(view.Ok());
34 
35   // Check that we don't accidentally include `emboss_text_util.h` via our
36   // generated header.
37 #ifdef EMBOSS_RUNTIME_CPP_EMBOSS_TEXT_UTIL_H_
38   const bool emboss_text_util_is_present = true;
39 #else
40   const bool emboss_text_util_is_present = false;
41 #endif
42 
43   EXPECT_FALSE(emboss_text_util_is_present);
44 }
45 
46 }  // namespace
47 }  // namespace test
48 }  // namespace emboss
49