3
# Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Lesser General Public
7
# License as published by the Free Software Foundation; either
8
# version 2.1 of the License, or (at your option) any later version.
10
# This library 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 GNU
13
# Lesser General Public License for more details.
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
# Unit tests of VCSUtils::parseFirstEOL().
24
use Test::Simple tests => 7;
30
$title = "parseFirstEOL: Empty string.";
31
ok(!defined(firstEOLInString("")), $title);
34
$title = "parseFirstEOL: Line without a line ending character";
35
ok(!defined(firstEOLInString("This line doesn't have a line ending character.")), $title);
38
$title = "parseFirstEOL: Line with Windows line ending.";
39
ok(firstEOLInString("This line ends with a Windows line ending.\r\n") eq "\r\n", $title);
42
$title = "parseFirstEOL: Line with Unix line ending.";
43
ok(firstEOLInString("This line ends with a Unix line ending.\n") eq "\n", $title);
46
$title = "parseFirstEOL: Line with Mac line ending.";
47
ok(firstEOLInString("This line ends with a Mac line ending.\r") eq "\r", $title);
50
$title = "parseFirstEOL: Line with Mac line ending followed by line without a line ending.";
51
ok(firstEOLInString("This line ends with a Mac line ending.\rThis line doesn't have a line ending.") eq "\r", $title);
54
$title = "parseFirstEOL: Line with a mix of line endings.";
55
ok(firstEOLInString("This line contains a mix of line endings.\r\n\r\n\r\r\n\n\n\n") eq "\r\n", $title);
61
open($fileHandle, "<", \$string);
62
return parseFirstEOL($fileHandle);