Skip to content

[Documentation]: Clarify which string comparison macros support wide strings #4843

@mondious

Description

@mondious

Describe the issue

Summary

There seems to be an inconsistency in the documentation regarding wide string (wchar_t*) support in string comparison assertions.

Details

In older versions of the documentation (e.g. v1.10.x), the primer.md stated:

*STREQ* and *STRNE* also accept wide C strings (wchar_t*).

In newer versions (e.g. v1.12.x and later), this wording in reference/assertions.md changed to:

These assertions also accept wide C strings (wchar_t*).

This phrasing makes it look like all string-related assertions (including EXPECT_STRCASEEQ / EXPECT_STRCASENE) support wide C strings.
However, based on the implementation and testing, only EXPECT_STREQ and EXPECT_STRNE actually support wchar_t*. The case-insensitive variants (EXPECT_STRCASEEQ / EXPECT_STRCASENE) do not support wide strings.

Expected

The documentation should clearly state that only EXPECT_STREQ and EXPECT_STRNE support wchar_t*, and that the case-insensitive variants do not.

Suggested fix

Reword the documentation to explicitly mention which macros support wide C strings, to avoid confusion for users.

Example:

"EXPECT_STREQ and EXPECT_STRNE also accept wide C strings (wchar_t*).
Case-insensitive variants (EXPECT_STRCASEEQ and EXPECT_STRCASENE) currently do not support wide C strings."


This should help clarify the intended behavior and avoid misleading readers.

Steps to reproduce the problem

#include <gtest/gtest.h>

#include <cwchar>

TEST(Tests, Test) {
    EXPECT_STRCASEEQ(L"HELLO", L"hello"); // cannot compile
    EXPECT_STRCASENE(L"HELLO", L"hello"); // cannot compile
}

int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

What version of GoogleTest are you using?

1.17.0

What operating system and version are you using?

Windows 11 24H2

What compiler and version are you using?

cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35213 for x64

What build system are you using?

cmake --version
cmake version 4.0.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions