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.
5 // Unit tests for stringize_macros.h
7 #include "base/stringize_macros.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 // Macros as per documentation in header file.
12 #define PREPROCESSOR_UTIL_UNITTEST_A FOO
13 #define PREPROCESSOR_UTIL_UNITTEST_B(x) myobj->FunctionCall(x)
14 #define PREPROCESSOR_UTIL_UNITTEST_C "foo"
16 TEST(StringizeTest
, Ansi
) {
18 "PREPROCESSOR_UTIL_UNITTEST_A",
19 STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A
));
21 "PREPROCESSOR_UTIL_UNITTEST_B(y)",
22 STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y
)));
24 "PREPROCESSOR_UTIL_UNITTEST_C",
25 STRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C
));
27 EXPECT_STREQ("FOO", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_A
));
28 EXPECT_STREQ("myobj->FunctionCall(y)",
29 STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_B(y
)));
30 EXPECT_STREQ("\"foo\"", STRINGIZE(PREPROCESSOR_UTIL_UNITTEST_C
));
35 TEST(StringizeTest
, Wide
) {
37 L
"PREPROCESSOR_UTIL_UNITTEST_A",
38 LSTRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_A
));
40 L
"PREPROCESSOR_UTIL_UNITTEST_B(y)",
41 LSTRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_B(y
)));
43 L
"PREPROCESSOR_UTIL_UNITTEST_C",
44 LSTRINGIZE_NO_EXPANSION(PREPROCESSOR_UTIL_UNITTEST_C
));
46 EXPECT_STREQ(L
"FOO", LSTRINGIZE(PREPROCESSOR_UTIL_UNITTEST_A
));
47 EXPECT_STREQ(L
"myobj->FunctionCall(y)",
48 LSTRINGIZE(PREPROCESSOR_UTIL_UNITTEST_B(y
)));
49 EXPECT_STREQ(L
"\"foo\"", LSTRINGIZE(PREPROCESSOR_UTIL_UNITTEST_C
));
52 TEST(ToLStringTest
, Main
) {
53 EXPECT_STREQ(L
"blat", TO_L_STRING_NO_EXPANSION("blat"));
55 EXPECT_STREQ(L
"foo", TO_L_STRING(PREPROCESSOR_UTIL_UNITTEST_C
));
56 EXPECT_STREQ(L
"blat", TO_L_STRING("blat"));
59 #endif // defined(OS_WIN)