Add tests against GitRev and GitRevLoglist
[TortoiseGit.git] / test / UnitTests / StringUtilsTest.cpp
blob702cf479b3bb6703865b3aa5e087311ba47b2ebc
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2015 - TortoiseGit
4 // Copyright (C) 2003-2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "stdafx.h"
22 #include "StringUtils.h"
24 TEST(CStringUtils, WordWrap)
26 CString longline = _T("this is a test of how a string can be splitted into several lines");
27 CString splittedline = CStringUtils::WordWrap(longline, 10, true, false, 4);
28 EXPECT_STREQ(_T("this is a\n test of\n how a\n string\n can be\n splitted\n into\n several\n lines"), splittedline);
29 longline = _T("c:\\this_is_a_very_long\\path_on_windows and of course some other words added to make the line longer");
30 splittedline = CStringUtils::WordWrap(longline, 10, true, false, 4);
31 EXPECT_STREQ(_T("...\\pat...\n and of\n course\n some\n other\n words\n added to\n make the\n line\n longer"), splittedline);
32 longline = _T("Forced failure in https://myserver.com/a_long_url_to_split PROPFIND error");
33 splittedline = CStringUtils::WordWrap(longline, 20, true, false, 4);
34 EXPECT_STREQ(_T("Forced failure in\n https://myserver.com/a_long_url_to_split\n PROPFIND error"), splittedline);
35 longline = _T("Forced\nfailure in https://myserver.com/a_long_url_to_split PROPFIND\nerror");
36 splittedline = CStringUtils::WordWrap(longline, 40, true, false, 4);
37 EXPECT_STREQ(_T("Forced\nfailure in\n https://myserver.com/a_long_url_to_split\n PROPFIND\nerror"), splittedline);
38 longline = _T("Failed to add file\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO1.java\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO2.java");
39 splittedline = CStringUtils::WordWrap(longline, 80, true, false, 4);
40 EXPECT_STREQ(_T("Failed to add\n file\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO1.java\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthing\n"), splittedline);
43 TEST(CStringUtils, LinesWrap)
45 CString longline = _T("this is a test of how a string can be splitted into several lines");
46 CString splittedline = CStringUtils::LinesWrap(longline, 10, true);
47 EXPECT_STREQ(_T("this is a\n test of\n how a\n string\n can be\n splitted\n into\n several\n lines"), splittedline);
48 longline = _T("c:\\this_is_a_very_long\\path_on_windows and of course some other words added to make the line longer");
49 splittedline = CStringUtils::LinesWrap(longline, 10);
50 EXPECT_STREQ(_T("c:\\this_is_a_very_long\\path_on_windows\n and of\n course\n some\n other\n words\n added to\n make the\n line\n longer"), splittedline);
51 longline = _T("Forced failure in https://myserver.com/a_long_url_to_split PROPFIND error");
52 splittedline = CStringUtils::LinesWrap(longline, 20, true);
53 EXPECT_STREQ(_T("Forced failure in\n https://myserver.com/a_long_url_to_split\n PROPFIND error"), splittedline);
54 longline = _T("Forced\nfailure in https://myserver.com/a_long_url_to_split PROPFIND\nerror");
55 splittedline = CStringUtils::LinesWrap(longline, 40);
56 EXPECT_STREQ(_T("Forced\nfailure in\n https://myserver.com/a_long_url_to_split\n PROPFIND\nerror"), splittedline);
57 longline = _T("Failed to add file\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO1.java\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO2.java");
58 splittedline = CStringUtils::LinesWrap(longline);
59 EXPECT_STREQ(_T("Failed to add file\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO1.java\n\nc:\\export\\spare\\Devl-JBoss\\development\\head\\src\\something\\CoreApplication\\somethingelse\\src\\com\\yetsomthingelse\\shipper\\DAO\\ShipmentInfoDAO2.java"), splittedline);
60 longline = _T("The commit comment is not properly formatted.\nFormat:\n Field 1 : Field 2 : Field 3\nWhere:\nField 1 - Team Name|Triage|Merge|Goal\nField 2 - V1 Backlog Item ID|Triage Number|SVNBranch|Goal Name\nField 3 - Description of change\nExamples:\n\nTeam Gamma : B-12345 : Changed some code\n Triage : 123 : Fixed production release bug\n Merge : sprint0812 : Merged sprint0812 into prod\n Goal : Implement Pre-Commit Hook : Commit message hook impl");
61 splittedline = CStringUtils::LinesWrap(longline, 80);
62 EXPECT_STREQ(_T("The commit comment is not properly formatted.\nFormat:\n Field 1 : Field 2 : Field 3\nWhere:\nField 1 - Team Name|Triage|Merge|Goal\nField 2 - V1 Backlog Item ID|Triage Number|SVNBranch|Goal Name\nField 3 - Description of change\nExamples:\n\nTeam Gamma : B-12345 : Changed some code\n Triage : 123 : Fixed production release bug\n Merge : sprint0812 : Merged sprint0812 into prod\n Goal : Implement Pre-Commit Hook : Commit message hook impl"), splittedline);