| trunk/Source/ShineOn.RTL/Classes.pas |
| 189 | 189 | //FStringsAdapter:IStringsAdapter; |
| 190 | 190 | FUpdateCount:Int32; |
| 191 | 191 | FDelimiter, FQuoteChar:Char; |
| 192 | FLineBreak: String; |
| 192 | 193 | function GetCommaText:String; |
| 193 | 194 | procedure SetCommaText(Value:String); |
| 194 | 195 | function GetName(Index:Integer):String; |
| ... | ... | |
| 242 | 243 | property Count: Integer read GetCount; |
| 243 | 244 | property Delimiter: Char read FDelimiter write FDelimiter; |
| 244 | 245 | property DelimitedText: String read GetDelimitedText write SetDelimitedText; |
| 246 | property LineBreak: String read FLineBreak write FLineBreak; |
| 245 | 247 | property Names[Index: Integer]: String read GetName; |
| 246 | 248 | property Objects[Index: Integer]: Object read GetObject write PutObject; |
| 247 | 249 | property QuoteChar: Char read FQuoteChar write FQuoteChar; |
| ... | ... | |
| 1196 | 1198 | for i:Int32 := 0 to Count - 1 do |
| 1197 | 1199 | begin |
| 1198 | 1200 | S.Append(Strings[i]); |
| 1199 | | if i <> Count -1 then |
| 1200 | | S.Append(System.Environment.NewLine); |
| 1201 | if (i <> Count -1) and not string.IsNullOrEmpty(FLineBreak) then |
| 1202 | S.Append(FLineBreak); |
| 1201 | 1203 | end; |
| 1202 | 1204 | Result := S.ToString; |
| 1203 | 1205 | end; |
| ... | ... | |
| 1209 | 1211 | end; |
| 1210 | 1212 | |
| 1211 | 1213 | procedure TStrings.SetTextStr(Value: String); |
| 1212 | | var S:String; |
| 1214 | var |
| 1215 | iPos: Integer; |
| 1216 | iStart: Integer; |
| 1217 | iLength: Integer; |
| 1213 | 1218 | begin |
| 1214 | | Clear; |
| 1215 | | if Value <> nil then |
| 1216 | | with T:System.IO.StringReader := new System.IO.StringReader(Value) do |
| 1219 | BeginUpdate; |
| 1220 | try |
| 1221 | Clear; |
| 1222 | if String.IsNullOrEmpty(Value) then |
| 1223 | Exit; |
| 1224 | if String.IsNullOrEmpty(FLineBreak) then |
| 1217 | 1225 | begin |
| 1218 | | while true do |
| 1219 | | begin |
| 1220 | | S := T.ReadLine; |
| 1221 | | if S = nil then |
| 1222 | | Exit; |
| 1223 | | Add(S); |
| 1224 | | end; |
| 1226 | Add(Value); |
| 1227 | Exit; |
| 1225 | 1228 | end; |
| 1229 | iStart := 0; |
| 1230 | iLength := FLineBreak.Length; |
| 1231 | iPos := Value.IndexOf(FLineBreak); |
| 1232 | while iPos > -1 do |
| 1233 | begin |
| 1234 | Add(Value.Substring(iStart, iPos - iStart)); |
| 1235 | iStart := iPos + iLength; |
| 1236 | iPos := Value.IndexOf(FLineBreak, iStart); |
| 1237 | end; |
| 1238 | if iStart <= Value.Length then |
| 1239 | Add(Value.Substring(iStart, Value.Length - iStart)); |
| 1240 | finally |
| 1241 | EndUpdate; |
| 1242 | end; |
| 1226 | 1243 | end; |
| 1227 | 1244 | |
| 1228 | 1245 | function TStrings.CompareStrings(S1, S2: String): Integer; |
| ... | ... | |
| 1248 | 1265 | inherited Create; |
| 1249 | 1266 | FQuoteChar := '"'; |
| 1250 | 1267 | FDelimiter := ','; |
| 1268 | FLineBreak := System.Environment.NewLine; |
| 1251 | 1269 | end; |
| 1252 | 1270 | |
| 1253 | 1271 | function TStrings.Add(S: String): Integer; |
| trunk/Source/NUnit/TestStrings.pas |
| 1 | // The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); |
| 2 | // you may not use this file except in compliance with the License. You may obtain a copy of the |
| 3 | // License at http://www.mozilla.org/MPL/ |
| 4 | // |
| 5 | // Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF |
| 6 | // ANY KIND, either express or implied. See the License for the specificlanguage governing rights and |
| 7 | // limitations under the License. |
| 8 | |
| 9 | namespace NUnit.ShineOn.RTL; |
| 10 | |
| 11 | interface |
| 12 | |
| 13 | uses |
| 14 | Nunit.Framework, |
| 15 | ShineOn.RTL; |
| 16 | |
| 17 | type |
| 18 | [TestFixture] |
| 19 | TestStrings = public class(Object) |
| 20 | public |
| 21 | [Test] |
| 22 | method SetTextStr; |
| 23 | end; |
| 24 | |
| 25 | implementation |
| 26 | |
| 27 | { TestStrings } |
| 28 | |
| 29 | method TestStrings.SetTextStr; |
| 30 | const |
| 31 | cLine1: String = 'A'; |
| 32 | cLine2: String = 'B'; |
| 33 | cLine3: String = cLine1 + #0 + cLine2; |
| 34 | var |
| 35 | pList: TStringList; |
| 36 | begin |
| 37 | //Nil Text |
| 38 | pList := new TStringList(); |
| 39 | pList.Text := nil; |
| 40 | Assert.AreEqual(pList.Count, 0); |
| 41 | |
| 42 | //EmptyText |
| 43 | pList := new TStringList(); |
| 44 | pList.Text := ''; |
| 45 | Assert.AreEqual(pList.Count, 0); |
| 46 | |
| 47 | //Normal Text |
| 48 | pList := new TStringList(); |
| 49 | pList.Text := cLine1 + System.Environment.NewLine + cLine2; |
| 50 | Assert.AreEqual(pList.Count, 2); |
| 51 | Assert.AreEqual(pList[0], cLine1); |
| 52 | Assert.AreEqual(pList[1], cLine2); |
| 53 | |
| 54 | //Special Text |
| 55 | pList := new TStringList(); |
| 56 | pList.Text := cLine3; |
| 57 | Assert.AreEqual(pList.Count, 1); |
| 58 | Assert.AreEqual(pList[0], cLine3); |
| 59 | |
| 60 | //No LineBreak |
| 61 | pList := new TStringList(); |
| 62 | pList.LineBreak := nil; |
| 63 | pList.Text := cLine1 + System.Environment.NewLine + cLine2; |
| 64 | Assert.AreEqual(pList.Count, 1); |
| 65 | Assert.AreEqual(pList[0], pList.Text); |
| 66 | end; |
| 67 | |
| 68 | end. |
| trunk/Source/NUnit/NUnit.ShineOn.RTL.oxygene |
| 29 | 29 | </Reference> |
| 30 | 30 | <ProjectReference Include="..\ShineOn.RTL\ShineOn.RTL.oxygene"> |
| 31 | 31 | <Project>{EADE7853-FDBE-4770-B0B2-5FF5FDD2DBF7}</Project> |
| 32 | | <HintPath>$(Project)\..\bin\ShineOn.Rtl.dll</HintPath> |
| 32 | <HintPath>..\bin\ShineOn.Rtl.dll</HintPath> |
| 33 | 33 | <Name>ShineOn.RTL</Name> |
| 34 | 34 | </ProjectReference> |
| 35 | 35 | <Reference Include="System"> |
| ... | ... | |
| 65 | 65 | <Compile Include="TestFileStream.pas" /> |
| 66 | 66 | <Compile Include="TestIniFiles.pas" /> |
| 67 | 67 | <Compile Include="TestStringRead.pas" /> |
| 68 | <Compile Include="TestStrings.pas" /> |
| 68 | 69 | <Compile Include="TestStringWrite.pas" /> |
| 69 | 70 | <Compile Include="TestStrUtils.pas" /> |
| 70 | 71 | <Compile Include="TestSystem.pas" /> |
| 71 | 72 | |