| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/perl -w | |
| 2 # | |
| 3 # Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com) | |
| 4 # | |
| 5 # Redistribution and use in source and binary forms, with or without | |
| 6 # modification, are permitted provided that the following conditions | |
| 7 # are met: | |
| 8 # 1. Redistributions of source code must retain the above copyright | |
| 9 # notice, this list of conditions and the following disclaimer. | |
| 10 # 2. Redistributions in binary form must reproduce the above copyright | |
| 11 # notice, this list of conditions and the following disclaimer in the | |
| 12 # documentation and/or other materials provided with the distribution. | |
| 13 # | |
| 14 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY | |
| 15 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 16 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 17 # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 18 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 20 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
| 21 # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
| 23 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 | |
| 25 # Unit tests of parseDiffHeader(). | |
| 26 | |
| 27 use strict; | |
| 28 use warnings; | |
| 29 | |
| 30 use Test::More; | |
| 31 use VCSUtils; | |
| 32 | |
| 33 my @diffHashRefKeys = ( # The hash reference keys to check per diff. | |
| 34 "copiedFromPath", | |
| 35 "indexPath", | |
| 36 "sourceRevision", | |
| 37 "svnConvertedText", | |
| 38 ); | |
| 39 | |
| 40 # New test | |
| 41 my $testNameStart = "parsePatch(): [SVN: Rename] "; | |
| 42 my $patch = <<'END', | |
| 43 Index: Makefile | |
| 44 =================================================================== | |
| 45 --- Makefile (revision 53131) | |
| 46 +++ Makefile (working copy) | |
| 47 @@ -1,1 +0,0 @@ | |
| 48 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools | |
| 49 Index: Makefile_new | |
| 50 =================================================================== | |
| 51 --- Makefile_new (revision 53131) (from Makefile:53131) | |
| 52 +++ Makefile_new (working copy) | |
| 53 @@ -0,0 +1,1 @@ | |
| 54 +MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools | |
| 55 END | |
| 56 | |
| 57 my @expectedDiffHashRefs = ( | |
| 58 { | |
| 59 svnConvertedText => <<'END', | |
| 60 Index: Makefile | |
| 61 =================================================================== | |
| 62 --- Makefile (revision 53131) | |
| 63 +++ Makefile (working copy) | |
| 64 @@ -1,1 +0,0 @@ | |
| 65 -MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKitTools | |
| 66 END | |
| 67 copiedFromPath => undef, | |
| 68 indexPath => "Makefile", | |
| 69 sourceRevision => "53131", | |
| 70 }, | |
| 71 { | |
| 72 copiedFromPath => "Makefile", | |
| 73 indexPath => "Makefile_new", | |
| 74 sourceRevision => "53131", | |
| 75 }, | |
| 76 ); | |
| 77 | |
| 78 plan(tests => @expectedDiffHashRefs * @diffHashRefKeys); | |
| 79 | |
| 80 my $fileHandle; | |
| 81 open($fileHandle, "<", \$patch); | |
| 82 | |
| 83 my @gotDiffHashRefs = parsePatch($fileHandle); | |
| 84 | |
| 85 my $i = 0; | |
| 86 foreach my $expectedDiffHashRef (@expectedDiffHashRefs) { | |
| 87 | |
| 88 my $gotDiffHashRef = $gotDiffHashRefs[$i++]; | |
| 89 | |
| 90 foreach my $diffHashRefKey (@diffHashRefKeys) { | |
| 91 my $testName = "${testNameStart}[diff $i] key=\"$diffHashRefKey\""; | |
| 92 is($gotDiffHashRef->{$diffHashRefKey}, $expectedDiffHashRef->{$diffHashR
efKey}, $testName); | |
| 93 } | |
| 94 } | |
| OLD | NEW |