stringize_macros_unittest.cc 1.0 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2010 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "butil/strings/stringize_macros.h"
  5. #include <gtest/gtest.h>
  6. // Macros as per documentation in header file.
  7. #define PREPROCESSOR_UTIL_UNITTEST_A FOO
  8. #define PREPROCESSOR_UTIL_UNITTEST_B(x) myobj->FunctionCall(x)
  9. #define PREPROCESSOR_UTIL_UNITTEST_C "foo"
  10. TEST(StringizeTest, Ansi) {
  11. EXPECT_STREQ(
  12. "PREPROCESSOR_UTIL_UNITTEST_A",
  13. STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A));
  14. EXPECT_STREQ(
  15. "PREPROCESSOR_UTIL_UNITTEST_B(y)",
  16. STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y)));
  17. EXPECT_STREQ(
  18. "PREPROCESSOR_UTIL_UNITTEST_C",
  19. STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C));
  20. EXPECT_STREQ("FOO", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_A));
  21. EXPECT_STREQ("myobj->FunctionCall(y)",
  22. STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_B(y)));
  23. EXPECT_STREQ("\"foo\"", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_C));
  24. }