config_test.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2019 The Abseil Authors.
  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. #include "absl/flags/config.h"
  15. #ifdef __APPLE__
  16. #include <TargetConditionals.h>
  17. #endif
  18. #include "gtest/gtest.h"
  19. #ifndef ABSL_FLAGS_STRIP_NAMES
  20. #error ABSL_FLAGS_STRIP_NAMES is not defined
  21. #endif
  22. #ifndef ABSL_FLAGS_STRIP_HELP
  23. #error ABSL_FLAGS_STRIP_HELP is not defined
  24. #endif
  25. namespace {
  26. // Test that ABSL_FLAGS_STRIP_NAMES and ABSL_FLAGS_STRIP_HELP are configured how
  27. // we expect them to be configured by default. If you override this
  28. // configuration, this test will fail, but the code should still be safe to use.
  29. TEST(FlagsConfigTest, Test) {
  30. #if defined(__ANDROID__)
  31. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 1);
  32. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 1);
  33. #elif defined(__myriad2__)
  34. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 0);
  35. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 0);
  36. #elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
  37. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 1);
  38. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 1);
  39. #elif defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED
  40. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 1);
  41. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 1);
  42. #elif defined(__APPLE__)
  43. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 0);
  44. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 0);
  45. #elif defined(_WIN32)
  46. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 0);
  47. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 0);
  48. #elif defined(__linux__)
  49. EXPECT_EQ(ABSL_FLAGS_STRIP_NAMES, 0);
  50. EXPECT_EQ(ABSL_FLAGS_STRIP_HELP, 0);
  51. #endif
  52. }
  53. } // namespace