diff --git a/lib/platform.h b/lib/platform.h index 6d9833240d2..d3da41cdaec 100644 --- a/lib/platform.h +++ b/lib/platform.h @@ -139,7 +139,11 @@ namespace cppcheck { bool isWindows() const { return type == Type::Win32A || type == Type::Win32W || - type == Type::Win64; + type == Type::Win64 +#ifdef _WIN32 + || type == Type::Native +#endif + ; } const char *toString() const { diff --git a/test/testplatform.cpp b/test/testplatform.cpp index 7dbb24789b6..3a37a32c09b 100644 --- a/test/testplatform.cpp +++ b/test/testplatform.cpp @@ -34,6 +34,7 @@ class TestPlatform : public TestFixture { TEST_CASE(valid_config_win32w); TEST_CASE(valid_config_unix32); TEST_CASE(valid_config_win64); + TEST_CASE(valid_config_native); TEST_CASE(valid_config_file_1); TEST_CASE(valid_config_file_2); TEST_CASE(valid_config_file_3); @@ -181,6 +182,16 @@ class TestPlatform : public TestFixture { ASSERT_EQUALS(64, platform.long_long_bit); } + void valid_config_native() const { + cppcheck::Platform platform; + PLATFORM(platform, cppcheck::Platform::Type::Native); +#ifdef _WIN32 + ASSERT(platform.isWindows()); +#else + ASSERT(!platform.isWindows()); +#endif + } + void valid_config_file_1() const { // Valid platform configuration with all possible values specified. // Similar to the avr8 platform file. diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 1e633a0f0b2..90a1bff8710 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -42,6 +42,7 @@ class TestSimplifyTokens : public TestFixture { void run() override { TEST_CASE(combine_strings); TEST_CASE(combine_wstrings); + TEST_CASE(combine_wstrings_Windows); TEST_CASE(combine_ustrings); TEST_CASE(combine_Ustrings); TEST_CASE(combine_u8strings); @@ -270,6 +271,16 @@ class TestSimplifyTokens : public TestFixture { ASSERT_EQUALS(expected, tokenizer.tokens()->stringifyList(nullptr, false)); } + void combine_wstrings_Windows() { +#if defined(_WIN32) && defined(UNICODE) + const char code[] = "const auto* f() {\n" + " return _T(\"abc\") _T(\"def\") _T(\"ghi\");\n" + "}"; + + ASSERT_EQUALS("const auto * f ( ) { return L\"abcdefghi\" ; }", tok(code, /*simplify*/ true, cppcheck::Platform::Type::Native)); +#endif + } + void combine_ustrings() { const char code[] = "abcd = u\"ab\" u\"cd\";";