1
// TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016, 2018, 2023 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "SerialPatch.h"
22 #include "StringUtils.h"
25 TEST(CSerialPatch
, Parse
)
27 CStringA patch1header
= "From 3a3d3d4a31f093ff351dd7de53e6904d618a82d5 Mon Sep 17 00:00:00 2001\nFrom: Sven Strickroth <email@cs-ware.de>\nDate: Wed, 24 Feb 2016 22:22:49 +0100\nSubject: [PATCH] RefBrowse: Start new process for showing log\n\n";
28 CStringA patch1body
= "(fixes issue #2709)\n\nSigned-off-by: Sven Strickroth <email@cs-ware.de>\n---\n src/TortoiseProc/BrowseRefsDlg.cpp | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/src/TortoiseProc/BrowseRefsDlg.cpp b/src/TortoiseProc/BrowseRefsDlg.cpp\nindex 1c9f1a7..e8159bc 100644\n--- a/src/TortoiseProc/BrowseRefsDlg.cpp\n+++ b/src/TortoiseProc/BrowseRefsDlg.cpp\n@@ -1098,23 +1098,23 @@ void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPSh\n {\r\n case eCmd_ViewLog:\r\n {\r\n- CLogDlg dlg;\r\n- dlg.SetRange(g_Git.FixBranchName(selectedLeafs[0]->GetRefName()));\r\n- dlg.DoModal();\r\n-- \n2.7.0.windows.1\n\n";
29 CStringA patch1
= patch1header
+ patch1body
;
31 CString tmpfile
= GetTempFile();
32 ASSERT_STRNE(L
"", tmpfile
);
33 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch1
)));
36 ASSERT_EQ(0, parser
.Parse(tmpfile
, false));
37 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser
.m_Author
);
38 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser
.m_Date
);
39 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser
.m_Subject
);
40 ASSERT_STREQ(patch1
, parser
.m_Body
);
41 ASSERT_TRUE(parser
.m_strBody
.IsEmpty());
43 ASSERT_EQ(0, parser2
.Parse(tmpfile
, true));
44 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser2
.m_Author
);
45 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser2
.m_Date
);
46 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser2
.m_Subject
);
47 ASSERT_STREQ(patch1
, parser2
.m_Body
);
48 ASSERT_STREQ(CString(patch1body
), parser2
.m_strBody
);
51 CStringA patch2longheader
= "From c445609da424a6e6229c469e01ce3df5ef099ddd Mon Sep 17 00:00:00 2001\nFrom: Sven Strickroth <email@cs-ware.de>\nDate: Sun, 27 Dec 2015 15:49:34 +0100\nSubject: [PATCH 2/3] Remove dynamic linking using GetProcAddress() for APIs\n that are available on Vista now that XP support is no longer needed\n\n";
52 CStringA patch2body
= patch1body
;
53 CStringA patch2
= patch2longheader
+ patch2body
;
54 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch2
)));
56 ASSERT_EQ(0, parser3
.Parse(tmpfile
, false));
57 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser3
.m_Author
);
58 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser3
.m_Date
);
59 ASSERT_STREQ(L
"[PATCH 2/3] Remove dynamic linking using GetProcAddress() for APIs that are available on Vista now that XP support is no longer needed", parser3
.m_Subject
);
60 ASSERT_STREQ(patch2
, parser3
.m_Body
);
61 ASSERT_TRUE(parser3
.m_strBody
.IsEmpty());
63 ASSERT_EQ(0, parser4
.Parse(tmpfile
, true));
64 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser4
.m_Author
);
65 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser4
.m_Date
);
66 ASSERT_STREQ(L
"[PATCH 2/3] Remove dynamic linking using GetProcAddress() for APIs that are available on Vista now that XP support is no longer needed", parser4
.m_Subject
);
67 ASSERT_STREQ(patch2
, parser4
.m_Body
);
68 ASSERT_STREQ(CString(patch2body
), parser4
.m_strBody
);
71 CStringA patch3header
= "From 8bf757a62dab483e738fb0ea20d2240c6d554462 Mon Sep 17 00:00:00 2001\nFrom: Sven Strickroth <email@cs-ware.de>\nDate: Thu, 25 Feb 2016 04:07:55 +0100\nSubject: [PATCH] =?UTF-8?q?=C3=B6d=C3=B6=C3=A4=C3=BC?=\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\n";
72 CStringA patch3body
= patch1body
;
73 CStringA patch3
= patch3header
+ patch3body
;
74 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch3
)));
76 ASSERT_EQ(0, parser5
.Parse(tmpfile
, false));
77 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser5
.m_Author
);
78 ASSERT_STREQ(L
"Thu, 25 Feb 2016 04:07:55 +0100", parser5
.m_Date
);
79 ASSERT_STREQ(L
"[PATCH] =?UTF-8?q?=C3=B6d=C3=B6=C3=A4=C3=BC?=", parser5
.m_Subject
);
80 ASSERT_STREQ(patch3
, parser5
.m_Body
);
81 ASSERT_TRUE(parser5
.m_strBody
.IsEmpty());
83 ASSERT_EQ(0, parser6
.Parse(tmpfile
, true));
84 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser6
.m_Author
);
85 ASSERT_STREQ(L
"Thu, 25 Feb 2016 04:07:55 +0100", parser6
.m_Date
);
86 ASSERT_STREQ(L
"[PATCH] =?UTF-8?q?=C3=B6d=C3=B6=C3=A4=C3=BC?=", parser6
.m_Subject
);
87 ASSERT_STREQ(patch3
, parser6
.m_Body
);
88 ASSERT_STREQ(CString(patch3body
), parser6
.m_strBody
);
91 patch1header
.Replace("\n", "\r\n");
92 patch1
= patch1header
+ patch1body
;
93 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch1
)));
95 ASSERT_EQ(0, parser7
.Parse(tmpfile
, true));
96 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser7
.m_Author
);
97 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser7
.m_Date
);
98 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser7
.m_Subject
);
99 ASSERT_STREQ(patch1
, parser7
.m_Body
);
100 ASSERT_STREQ(CString(patch1body
), parser7
.m_strBody
);
102 // different order and additional headers
103 CStringA patch4header
= "From c445609da424a6e6229c469e01ce3df5ef099ddd Mon Sep 17 00:00:00 2001\nContent-Type: text/plain\nSubject: [PATCH 2/3] Remove dynamic linking using GetProcAddress()\n\tfor APIs\nSomething: else\nDate: Sun, 27 Dec 2015 15:49:34 +0100\nFrom: Sven Strickroth <email@cs-ware.de>\n\n";
104 CStringA patch4body
= patch1body
;
105 CStringA patch4
= patch4header
+ patch4body
;
106 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch4
)));
107 CSerialPatch parser8
;
108 ASSERT_EQ(0, parser8
.Parse(tmpfile
, false));
109 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser8
.m_Author
);
110 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser8
.m_Date
);
111 ASSERT_STREQ(L
"[PATCH 2/3] Remove dynamic linking using GetProcAddress()\tfor APIs", parser8
.m_Subject
);
112 ASSERT_STREQ(patch4
, parser8
.m_Body
);
113 ASSERT_TRUE(parser8
.m_strBody
.IsEmpty());
114 CSerialPatch parser9
;
115 ASSERT_EQ(0, parser9
.Parse(tmpfile
, true));
116 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser9
.m_Author
);
117 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser9
.m_Date
);
118 ASSERT_STREQ(L
"[PATCH 2/3] Remove dynamic linking using GetProcAddress()\tfor APIs", parser9
.m_Subject
);
119 ASSERT_STREQ(patch4
, parser9
.m_Body
);
120 ASSERT_STREQ(CString(patch4body
), parser9
.m_strBody
);