[JEDI.NET-commits] nunit/source Jedi.IO.NUnit.pas,1.1,1.2
Status: Pre-Alpha
Brought to you by:
jedi_mbe
From: Marcel B. <jed...@us...> - 2005-03-28 18:14:04
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13643/nunit/source Modified Files: Jedi.IO.NUnit.pas Log Message: * Generalized calculation of system dependant result strings. * Added test cases for Jedi.IO.Path.CommonBase and Jedi.IO.Path.MakeRelativeFrom Index: Jedi.IO.NUnit.pas =================================================================== RCS file: /cvsroot/jedidotnet/nunit/source/Jedi.IO.NUnit.pas,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Jedi.IO.NUnit.pas 6 Dec 2004 11:44:09 -0000 1.1 --- Jedi.IO.NUnit.pas 28 Mar 2005 18:13:44 -0000 1.2 *************** *** 3,6 **** --- 3,10 ---- interface + uses + System.IO, + System.Reflection; + type PathTestCases = class *************** *** 8,26 **** class constructor Create; strict protected ! const sNormVolumeRoot = 'volume{0}{1}'; ! const sNormVolumeRoot2 = 'secondvolume{0}'; ! const sNormVolumeRootNoSlash = 'volume{0}'; ! const sNormInvalidVolumeRoot = '{1}path{1}volume{0}{1}'; ! const sNormInvalidRelativePathUpLevel = '..SubFolder2.2'; ! const sNormDeepVolumeRootedPath = 'volume{0}{1}MyRootFolder{1}SubFolder1{1}SubFolder1.1{1}SubFolder1.1.1'; ! const sNormVolumePath = 'primary{0}{1}PrimaryRoot{1}My Folder'; ! const sNormDeepRootedPath = '{1}MyRootFolder{1}SubFolder1{1}SubFolder1.1{1}SubFolder1.1.1'; ! const sNormRelativePath = 'SubFolder2{1}SubFolder2.1'; ! const sNormRelativePathUpLevel = '..{1}SubFolder2.2'; ! const sNormRelativePathUpTwoLevels = '..{1}..{1}SubFolder3{1}SubFolder3.1{1}SubFolder3.1.1{1}SubFolder3.1.4'; ! const sNormRelativePathUpTwoLevelsSep = '..{1}..{1}SubFolder4{1}SubFolder4.1{1}SubFolder4.1.1{1}SubFolder4.1.4'; ! const sNormStartWithThisPath = 'My Folder'; ! const sNormHasDottedFolderName = 'SubFolder5{1}.HiddenStuff'; ! const sNormWildcardedFile = '*.txt'; const sNormCombinedVolRootAndRelativePath = 'volume{0}{1}SubFolder2{1}SubFolder2.1'; --- 12,30 ---- class constructor Create; strict protected ! const sNormVolumeRootNormalized = 'volume{0}{1}'; ! const sNormVolumeRoot2Normalized = 'secondvolume{0}'; ! const sNormVolumeRootNoSlashNormalized = 'volume{0}'; ! const sNormInvalidVolumeRootNormalized = '{1}path{1}volume{0}{1}'; ! const sNormInvalidRelativePathUpLevelNormalized = '..SubFolder2.2'; ! const sNormDeepVolumeRootedPathNormalized = 'volume{0}{1}MyRootFolder{1}SubFolder1{1}SubFolder1.1{1}SubFolder1.1.1'; ! const sNormVolumePathNormalized = 'primary{0}{1}PrimaryRoot{1}My Folder'; ! const sNormDeepRootedPathNormalized = '{1}MyRootFolder{1}SubFolder1{1}SubFolder1.1{1}SubFolder1.1.1'; ! const sNormRelativePathNormalized = 'SubFolder2{1}SubFolder2.1'; ! const sNormRelativePathUpLevelNormalized = '..{1}SubFolder2.2'; ! const sNormRelativePathUpTwoLevelsNormalized = '..{1}..{1}SubFolder3{1}SubFolder3.1{1}SubFolder3.1.1{1}SubFolder3.1.4'; ! const sNormRelativePathUpTwoLevelsSepNormalized = '..{1}..{1}SubFolder4{1}SubFolder4.1{1}SubFolder4.1.1{1}SubFolder4.1.4'; ! const sNormStartWithThisPathNormalized = 'My Folder'; ! const sNormHasDottedFolderNameNormalized = 'SubFolder5{1}.HiddenStuff'; ! const sNormWildcardedFileNormalized = '*.txt'; const sNormCombinedVolRootAndRelativePath = 'volume{0}{1}SubFolder2{1}SubFolder2.1'; *************** *** 29,32 **** --- 33,46 ---- const sNormCombinedVolPathAndDeepRooted = 'primary{0}{1}MyRootFolder{1}SubFolder1{1}SubFolder1.1{1}SubFolder1.1.1'; const sNormCombinedRelAndRelPathUp = 'SubFolder2{1}SubFolder2.2'; + strict protected + const sNormCommonPathOf1And2 = 'c{0}{1}My Documents{1}Testing'; + const sNormCommonPathOf1And3 = 'c{0}{1}My Documents'; + const sNormCommonPathOf1And4 = 'c{0}'; + const sNormCommonPathOfAll4 = 'c{0}'; + strict protected + const sNormRelativePath1 = 'First folder{1}test1.txt'; + const sNormRelativePath2 = 'Second folder{1}test1.txt'; + const sNormRelativePath3 = '..{1}Secondary group{1}First folder{1}test 2.txt'; + const sNormRelativePath4 = '..{1}..{1}My Music{1}test1.mp3'; public const sVolumeRoot = 'volume:\'; *************** *** 45,49 **** const sHasDottedFolderName = 'SubFolder5\.HiddenStuff'; const sWildcardedFile = '*.txt'; ! class var sVolumeRootNormalized: string; --- 59,70 ---- const sHasDottedFolderName = 'SubFolder5\.HiddenStuff'; const sWildcardedFile = '*.txt'; ! public ! const sCommonPath1 = 'c:/My Documents\Testing\First folder/test1.txt'; ! const sCommonPath2 = 'c:\My Documents/Testing\Second folder/test1.txt'; ! const sCommonPath3 = 'c:\My Documents\Secondary group\First folder\test 2.txt'; ! const sCommonPath4 = 'c:\My Music\test1.mp3'; ! public ! const sRelativeBasePath = 'c:\My Documents\Testing'; ! public class var sVolumeRootNormalized: string; *************** *** 68,101 **** sCombinedVolPathAndDeepRooted: string; sCombinedRelAndRelPathUp: string; end; implementation - uses - System.IO; - class constructor PathTestCases.Create; begin ! sVolumeRootNormalized := System.String.Format(sNormVolumeRoot, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sVolumeRoot2Normalized := System.String.Format(sNormVolumeRoot2, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sVolumeRootNoSlashNormalized := System.String.Format(sNormVolumeRootNoSlash, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sInvalidVolumeRootNormalized := System.String.Format(sNormInvalidVolumeRoot, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sInvalidRelativePathUpLevelNormalized := System.String.Format(sNormInvalidRelativePathUpLevel, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sDeepVolumeRootedPathNormalized := System.String.Format(sNormDeepVolumeRootedPath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sDeepRootedPathNormalized := System.String.Format(sNormDeepRootedPath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sVolumePathNormalized := System.String.Format(sNormVolumePath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sRelativePathNormalized := System.String.Format(sNormRelativePath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sRelativePathUpLevelNormalized := System.String.Format(sNormRelativePathUpLevel, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sRelativePathUpTwoLevelsNormalized := System.String.Format(sNormRelativePathUpTwoLevels, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sRelativePathUpTwoLevelsSepNormalized := System.String.Format(sNormRelativePathUpTwoLevelsSep, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sStartWithThisPathNormalized := System.String.Format(sNormStartWithThisPath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sHasDottedFolderNameNormalized := System.String.Format(sNormHasDottedFolderName, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sWildcardedFileNormalized := System.String.Format(sNormWildcardedFile, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! ! sCombinedVolRootAndRelativePath := System.String.Format(sNormCombinedVolRootAndRelativePath, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sCombinedDeepVolRootAndRelPathUpTwo := System.String.Format(sNormCombinedDeepVolRootAndRelPathUpTwo, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sCombinedVolRoot2AndDeepRooted := System.String.Format(sNormCombinedVolRoot2AndDeepRooted, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sCombinedVolPathAndDeepRooted := System.String.Format(sNormCombinedVolPathAndDeepRooted, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); ! sCombinedRelAndRelPathUp := System.String.Format(sNormCombinedRelAndRelPathUp, Path.VolumeSeparatorChar, Path.DirectorySeparatorChar); end; --- 89,124 ---- sCombinedVolPathAndDeepRooted: string; sCombinedRelAndRelPathUp: string; + public + class var + sCommonPathOf1And2: string; + sCommonPathOf1And3: string; + sCommonPathOf1And4: string; + sCommonPathOfAll4: string; + public + class var + sRelativePath1: string; + sRelativePath2: string; + sRelativePath3: string; + sRelativePath4: string; end; implementation class constructor PathTestCases.Create; + var + field: FieldInfo; + secondField: FieldInfo; begin ! for field in TypeOf(PathTestCases).GetFields(BindingFlags.Static or BindingFlags.NonPublic) do ! begin ! if field.IsLiteral and field.Name.StartsWith('sNorm') then ! begin ! secondField := TypeOf(PathTestCases).GetField('s' + field.Name.Substring(5), ! BindingFlags.Static or BindingFlags.Public); ! if (secondField <> nil) then ! secondField.SetValue(nil, System.String.Format(string(field.GetValue(nil)), Path.VolumeSeparatorChar, ! Path.DirectorySeparatorChar)); ! end; ! end; end; |