neslib / Neslib.Yaml

A YAML library for Delphi
Other
85 stars 18 forks source link

AddOrSetValue Bug #7

Open gorepj opened 3 weeks ago

gorepj commented 3 weeks ago

Good morning I have come across a bug in my use of Neslib.Yaml When a node contains more than 10 child nodes The AddOrSetValue function incorrectly Updates value in the Document

Test Case procedure MyProc var Doc: IYamlDocument; begin Doc := TYamlDocument.CreateMapping; for var i := 0 to 16 do begin outputdebugstring(PChar(doc.Root.Values['ATestNode'].ToString('Empty'))); //Note this value after 10 or so updates Doc.Root.AddOrSetValue('Name'+i.tostring, i); Doc.Root.AddOrSetValue('ATestNode', 'TestValue'); end; mmoYAML.Lines.Text := doc.ToYaml; end;

resultant YAML

There are several lines referring to ATestNode

Name0: 0 ATestNode: TestValue Name1: 1 Name2: 2 Name3: 3 Name4: 4 Name5: 5 Name6: 6 Name7: 7 Name8: 8 Name9: 9 Name10: 10 Name11: 11 ATestNode: TestValue Name12: 12 Name13: 13 ATestNode: TestValue Name14: 14 Name15: 15 ATestNode: TestValue Name16: 16 ...