Skip to content

Commit d254f72

Browse files
CopilotDefaultRyan
andauthored
fix: normalize CRLF to LF in test/test/box_string.cpp (#1557)
* Initial plan * fix: convert CRLF to LF in test/test/box_string.cpp Agent-Logs-Url: https://github.com/microsoft/cppwinrt/sessions/9b31d4ec-f1c5-4859-89a1-3249eb553c5c Co-authored-by: DefaultRyan <26174284+DefaultRyan@users.noreply.github.com> * Add workflow to check line endings in pull requests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: DefaultRyan <26174284+DefaultRyan@users.noreply.github.com> Co-authored-by: Ryan Shepherd <ryansh@microsoft.com>
1 parent 3893ce8 commit d254f72

File tree

2 files changed

+85
-53
lines changed

2 files changed

+85
-53
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Check Line Endings
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
check-line-endings:
11+
name: Enforce .gitattributes line endings
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
16+
- name: Check for line ending violations
17+
run: |
18+
# Re-normalize all files according to .gitattributes
19+
git add --renormalize .
20+
21+
# Check if renormalization changed anything
22+
if git diff --cached --name-only | grep -q .; then
23+
echo "::error::The following files have line endings that don't match .gitattributes settings:"
24+
git diff --cached --name-only
25+
echo ""
26+
echo "To fix, run:"
27+
echo " git add --renormalize ."
28+
echo " git commit -m 'Normalize line endings'"
29+
exit 1
30+
fi
31+
32+
echo "All files have correct line endings."

test/test/box_string.cpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
#include "pch.h"
2-
3-
TEST_CASE("box_string")
4-
{
5-
// hstring
6-
{
7-
winrt::hstring value = L"hstring";
8-
auto boxed = winrt::box_value(value);
9-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"hstring");
10-
}
11-
12-
// wchar_t const* (string literal)
13-
{
14-
auto boxed = winrt::box_value(L"literal");
15-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"literal");
16-
}
17-
18-
// std::wstring
19-
{
20-
std::wstring value = L"wstring";
21-
auto boxed = winrt::box_value(value);
22-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"wstring");
23-
}
24-
25-
// std::wstring_view (null-terminated)
26-
{
27-
std::wstring_view value = L"view";
28-
auto boxed = winrt::box_value(value);
29-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"view");
30-
}
31-
32-
// std::wstring_view (not null-terminated)
33-
// Regression test for https://github.com/microsoft/cppwinrt/issues/1527
34-
{
35-
std::wstring source = L"ABCDE";
36-
std::wstring_view value(source.data(), 3); // "ABC"
37-
auto boxed = winrt::box_value(value);
38-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"ABC");
39-
}
40-
41-
// Empty string
42-
{
43-
auto boxed = winrt::box_value(winrt::hstring{});
44-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"");
45-
}
46-
47-
// Empty wstring_view
48-
{
49-
std::wstring_view value;
50-
auto boxed = winrt::box_value(value);
51-
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"");
52-
}
53-
}
1+
#include "pch.h"
2+
3+
TEST_CASE("box_string")
4+
{
5+
// hstring
6+
{
7+
winrt::hstring value = L"hstring";
8+
auto boxed = winrt::box_value(value);
9+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"hstring");
10+
}
11+
12+
// wchar_t const* (string literal)
13+
{
14+
auto boxed = winrt::box_value(L"literal");
15+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"literal");
16+
}
17+
18+
// std::wstring
19+
{
20+
std::wstring value = L"wstring";
21+
auto boxed = winrt::box_value(value);
22+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"wstring");
23+
}
24+
25+
// std::wstring_view (null-terminated)
26+
{
27+
std::wstring_view value = L"view";
28+
auto boxed = winrt::box_value(value);
29+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"view");
30+
}
31+
32+
// std::wstring_view (not null-terminated)
33+
// Regression test for https://github.com/microsoft/cppwinrt/issues/1527
34+
{
35+
std::wstring source = L"ABCDE";
36+
std::wstring_view value(source.data(), 3); // "ABC"
37+
auto boxed = winrt::box_value(value);
38+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"ABC");
39+
}
40+
41+
// Empty string
42+
{
43+
auto boxed = winrt::box_value(winrt::hstring{});
44+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"");
45+
}
46+
47+
// Empty wstring_view
48+
{
49+
std::wstring_view value;
50+
auto boxed = winrt::box_value(value);
51+
REQUIRE(winrt::unbox_value<winrt::hstring>(boxed) == L"");
52+
}
53+
}

0 commit comments

Comments
 (0)