1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016 - 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_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch1
)));
35 ASSERT_EQ(0, parser
.Parse(tmpfile
, false));
36 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser
.m_Author
);
37 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser
.m_Date
);
38 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser
.m_Subject
);
39 ASSERT_STREQ(patch1
, parser
.m_Body
);
40 ASSERT_TRUE(parser
.m_strBody
.IsEmpty());
42 ASSERT_EQ(0, parser2
.Parse(tmpfile
, true));
43 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser2
.m_Author
);
44 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser2
.m_Date
);
45 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser2
.m_Subject
);
46 ASSERT_STREQ(patch1
, parser2
.m_Body
);
47 ASSERT_STREQ(CString(patch1body
), parser2
.m_strBody
);
50 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";
51 CStringA patch2body
= patch1body
;
52 CStringA patch2
= patch2longheader
+ patch2body
;
53 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch2
)));
55 ASSERT_EQ(0, parser3
.Parse(tmpfile
, false));
56 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser3
.m_Author
);
57 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser3
.m_Date
);
58 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
);
59 ASSERT_STREQ(patch2
, parser3
.m_Body
);
60 ASSERT_TRUE(parser3
.m_strBody
.IsEmpty());
62 ASSERT_EQ(0, parser4
.Parse(tmpfile
, true));
63 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser4
.m_Author
);
64 ASSERT_STREQ(L
"Sun, 27 Dec 2015 15:49:34 +0100", parser4
.m_Date
);
65 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
);
66 ASSERT_STREQ(patch2
, parser4
.m_Body
);
67 ASSERT_STREQ(CString(patch2body
), parser4
.m_strBody
);
70 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";
71 CStringA patch3body
= patch1body
;
72 CStringA patch3
= patch3header
+ patch3body
;
73 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch3
)));
75 ASSERT_EQ(0, parser5
.Parse(tmpfile
, false));
76 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser5
.m_Author
);
77 ASSERT_STREQ(L
"Thu, 25 Feb 2016 04:07:55 +0100", parser5
.m_Date
);
78 ASSERT_STREQ(L
"[PATCH] =?UTF-8?q?=C3=B6d=C3=B6=C3=A4=C3=BC?=", parser5
.m_Subject
);
79 ASSERT_STREQ(patch3
, parser5
.m_Body
);
80 ASSERT_TRUE(parser5
.m_strBody
.IsEmpty());
82 ASSERT_EQ(0, parser6
.Parse(tmpfile
, true));
83 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser6
.m_Author
);
84 ASSERT_STREQ(L
"Thu, 25 Feb 2016 04:07:55 +0100", parser6
.m_Date
);
85 ASSERT_STREQ(L
"[PATCH] =?UTF-8?q?=C3=B6d=C3=B6=C3=A4=C3=BC?=", parser6
.m_Subject
);
86 ASSERT_STREQ(patch3
, parser6
.m_Body
);
87 ASSERT_STREQ(CString(patch3body
), parser6
.m_strBody
);
90 patch1header
.Replace("\n", "\r\n");
91 patch1
= patch1header
+ patch1body
;
92 ASSERT_TRUE(CStringUtils::WriteStringToTextFile(tmpfile
, CString(patch1
)));
94 ASSERT_EQ(0, parser7
.Parse(tmpfile
, true));
95 ASSERT_STREQ(L
"Sven Strickroth <email@cs-ware.de>", parser7
.m_Author
);
96 ASSERT_STREQ(L
"Wed, 24 Feb 2016 22:22:49 +0100", parser7
.m_Date
);
97 ASSERT_STREQ(L
"[PATCH] RefBrowse: Start new process for showing log", parser7
.m_Subject
);
98 ASSERT_STREQ(patch1
, parser7
.m_Body
);
99 ASSERT_STREQ(CString(patch1body
), parser7
.m_strBody
);