* Fix many warnings & hints

git-svn-id: trunk@37356 -
This commit is contained in:
michael 2017-09-29 07:50:50 +00:00
parent 488e7af362
commit edca192fad
13 changed files with 140 additions and 55 deletions

View File

@ -47,12 +47,19 @@ type
TPersistentBufDataSet=class(TBufDataset)
private
TempFileName:string;
protected
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField); override;
public
destructor Destroy; override;
end;
{ TPersistentBufDataSet }
procedure TPersistentBufDataSet.LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField);
begin
Raise ENotImplemented.Create('LoadBlobIntoBuffer not implemented');
end;
destructor TPersistentBufDataSet.Destroy;
begin
Close; // no locks on TempFileName

View File

@ -17,8 +17,8 @@ uses
bufdatasettoolsunit,
memdstoolsunit,
SdfDSToolsUnit,
tcsdfdata,
// Units wich contain the tests
tcsdfdata,
TestBasics,
TestDBBasics,
TestFieldTypes,

View File

@ -11,7 +11,7 @@ object FormIniEditor: TFormIniEditor
OnDestroy = FormDestroy
OnDropFiles = FormDropFiles
OnShow = FormShow
LCLVersion = '1.1'
LCLVersion = '1.9.0.0'
inline SynMemo: TSynMemo
Cursor = crIBeam
Left = 8
@ -450,11 +450,12 @@ object FormIniEditor: TFormIniEditor
ShortCut = 57379
end>
MouseActions = <>
MouseTextActions = <>
MouseSelActions = <>
Lines.Strings = (
''
)
SelectedColor.FrameEdges = sfeAround
VisibleSpecialChars = [vscSpace, vscTabAtLast]
SelectedColor.BackPriority = 50
SelectedColor.ForePriority = 50
SelectedColor.FramePriority = 50
@ -473,7 +474,6 @@ object FormIniEditor: TFormIniEditor
MouseActions = <>
MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone
MarkupInfo.FrameEdges = sfeAround
DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False
@ -490,13 +490,11 @@ object FormIniEditor: TFormIniEditor
MouseActions = <>
MarkupInfo.Background = clWhite
MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
end
object SynGutterCodeFolding1: TSynGutterCodeFolding
MouseActions = <>
MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
MouseActionsExpanded = <>
MouseActionsCollapsed = <>
end
@ -504,7 +502,7 @@ object FormIniEditor: TFormIniEditor
end
object FileNameEdit: TFileNameEdit
Left = 56
Height = 21
Height = 27
Top = 24
Width = 368
OnAcceptFileName = FileNameEditAcceptFileName
@ -517,28 +515,28 @@ object FormIniEditor: TFormIniEditor
end
object INIFileLabel: TLabel
Left = 8
Height = 13
Height = 17
Top = 24
Width = 32
Width = 37
Caption = 'INI file'
ParentColor = False
end
object ProfileSelect: TComboBox
Left = 56
Height = 21
Height = 29
Hint = 'Choose the profile you want to enable'
Top = 61
Width = 164
ItemHeight = 13
ItemHeight = 0
OnSelect = ProfileSelectSelect
Sorted = True
TabOrder = 1
end
object ProfileLabel: TLabel
Left = 8
Height = 13
Height = 17
Top = 64
Width = 30
Width = 36
Caption = 'Profile'
ParentColor = False
end
@ -565,9 +563,9 @@ object FormIniEditor: TFormIniEditor
end
object Label1: TLabel
Left = 8
Height = 13
Height = 17
Top = 0
Width = 229
Width = 240
Caption = 'Changes need a program restart to load!'
Font.Color = clRed
Font.Style = [fsBold]
@ -577,14 +575,6 @@ object FormIniEditor: TFormIniEditor
object SynIniHighlighter: TSynIniSyn
DefaultFilter = 'INI Files (*.ini)|*.ini'
Enabled = False
CommentAttri.FrameEdges = sfeAround
TextAttri.FrameEdges = sfeAround
SectionAttri.FrameEdges = sfeAround
KeyAttri.FrameEdges = sfeAround
NumberAttri.FrameEdges = sfeAround
SpaceAttri.FrameEdges = sfeAround
StringAttri.FrameEdges = sfeAround
SymbolAttri.FrameEdges = sfeAround
left = 32
top = 456
end

View File

@ -82,7 +82,7 @@ end;
procedure TFormIniEditor.FormShow(Sender: TObject);
begin
if FileNameEdit.FileName='' then
FileNameEdit.FileName:=ExpandFileNameUTF8(FIniFilename);
FileNameEdit.FileName:=FIniFilename;
end;
procedure TFormIniEditor.GUITimerTimer(Sender: TObject);

View File

@ -5,7 +5,7 @@ unit tccsvdataset;
interface
uses
Classes, db, SysUtils, fpcunit, testutils, testregistry, csvdataset;
Classes, db, SysUtils, fpcunit, testregistry, csvdataset;
type

View File

@ -7,7 +7,7 @@ unit TestBasics;
interface
uses
fpcunit, testutils, testregistry, testdecorator,
fpcunit, testregistry,
Classes, SysUtils, db;
type
@ -34,7 +34,49 @@ implementation
uses toolsunit;
Type HackedDataset = class(TDataset);
Type
HackedDataset = class(TDataset);
{ TMyDataset }
TMyDataset = Class(TDataset)
protected
function GetRecord(Buffer: TRecordBuffer; GetMode: TGetMode; DoCheck: Boolean): TGetResult; override;
procedure InternalClose; override;
procedure InternalInitFieldDefs; override;
procedure InternalOpen; override;
function IsCursorOpen: Boolean; override;
end;
{ TMyDataset }
function TMyDataset.GetRecord(Buffer: TRecordBuffer; GetMode: TGetMode; DoCheck: Boolean): TGetResult;
begin
Result:=grOK;
Raise ENotImplemented.Create('GetRecord not implemented');
end;
procedure TMyDataset.InternalClose;
begin
Raise ENotImplemented.Create('Internalclose not implemented');
end;
procedure TMyDataset.InternalInitFieldDefs;
begin
Raise ENotImplemented.Create('InternalInitFieldDefs not implemented');
end;
procedure TMyDataset.InternalOpen;
begin
Raise ENotImplemented.Create('InternalOpen not implemented');
end;
function TMyDataset.IsCursorOpen: Boolean;
begin
Result:=False;
Raise ENotImplemented.Create('IsCursorOpen not implemented');
end;
{ TTestBasics }
@ -42,7 +84,7 @@ function TTestBasics.CreateDatasetWith3Fields: TDataset;
var
F: TField;
begin
Result := TDataSet.Create(nil);
Result := TMyDataset.Create(nil);
F := TIntegerField.Create(Result);
F.FieldName := 'Field1';
F.DataSet := Result;
@ -169,7 +211,7 @@ var ds : TDataset;
end;
begin
ds := TDataset.Create(nil);
ds := TMyDataset.Create(nil);
try
F1:=TStringField.Create(ds);
@ -211,7 +253,7 @@ var ds : TDataset;
begin
// If a second field with the same name is added to a TFieldDefs, an exception
// should occur
ds := TDataset.create(nil);
ds := TMyDataset.Create(nil);
try
ds.FieldDefs.Add('Field1',ftInteger);
PassException:=False;

View File

@ -7,8 +7,7 @@ unit TestBufDatasetStreams;
interface
uses
fpcunit, testregistry,
Classes, SysUtils, db, BufDataset;
fpcunit, testregistry, Classes, SysUtils, db, BufDataset;
type
@ -16,6 +15,15 @@ type
TUpdDatasetProc = procedure(ADataset : TCustomBufDataset) of object;
// Use this class, it implements some abstract methods
{ TMyCustomBufDataset }
TMyCustomBufDataset = Class(TCustomBufDataset)
protected
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField); override;
end;
TTestBufDatasetStreams = class(TTestCase)
private
procedure CompareDatasets(ADataset1, ADataset2 : TDataset);
@ -94,6 +102,13 @@ const TestXMLFileName = 'test.xml';
TestBINFileName = 'test.dat';
TestFileNames: array[TDataPacketFormat] of string = (TestBINFileName, TestXMLFileName, TestXMLFileName, '');
{ TMyCustomBufDataset }
procedure TMyCustomBufDataset.LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField);
begin
Raise ENotImplemented.Create('LoadBlobIntoBuffer not implemented');
end;
procedure TTestBufDatasetStreams.CompareDatasets(ADataset1,
ADataset2: TDataset);
begin
@ -161,7 +176,7 @@ begin
AUpdDatasetProc(SaveDs);
SaveDs.SaveToFile(FileName, AFormat);
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
LoadDs.LoadFromFile(FileName);
CompareDatasets(SaveDs,LoadDs);
SaveDs.Close;
@ -416,7 +431,7 @@ begin
SaveDs.Open;
SaveDs.SaveToFile(TestXMLFileName, dfXML);
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
LoadDs.LoadFromFile(TestXMLFileName);
CompareDatasets(SaveDs,LoadDs);
LoadDs.Free;
@ -471,7 +486,7 @@ begin
SaveDs.Open;
SaveDs.SaveToFile(TestFileNames[AFormat], AFormat);
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
LoadDs.LoadFromFile(TestFileNames[AFormat]);
AssertEquals(SaveDs.FieldCount, LoadDs.FieldCount);
@ -536,7 +551,7 @@ begin
SaveDs.SaveToFile(TestXMLFileName,dfXML);
// Load this file in another dataset
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
try
LoadDs.LoadFromFile(TestXMLFileName);
LoadDS.First;
@ -588,7 +603,7 @@ begin
SaveToFile(TestFileNames[AFormat], AFormat);
end;
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
try
LoadDs.LoadFromFile(TestFileNames[AFormat]);
AssertEquals(SaveDs.FieldCount, LoadDs.FieldCount);

View File

@ -94,7 +94,7 @@ begin
end;}
procedure TTestDatasources.TestDataEvent1;
var i,count : integer;
var
aDatasource : TDataSource;
aDatalink1,
aDatalink2 : TDataLink;

View File

@ -196,7 +196,22 @@ uses
strutils,
FmtBCD;
type THackDataLink=class(TDataLink);
type
THackDataLink=class(TDataLink);
{ TMyCustomBufDataset }
TMyCustomBufDataset = Class(TCustomBufDataset)
protected
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField); override;
end;
{ TMyCustomBufDataset }
procedure TMyCustomBufDataset.LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField);
begin
Raise ENotImplemented.Create('LoadBlobIntoBuffer not implemented');
end;
{ TTestCursorDBBasics }
@ -709,6 +724,7 @@ begin
for i:=13 to 15 do begin
datalink1.BufferCount := datalink1.BufferCount+1;
r := dataset1.RecNo; // syncronizes source dataset to ActiveRecord
AssertTrue(r>=0);
datalink1.ActiveRecord := datalink1.BufferCount-1;
CheckEquals(i, dataset1.FieldByName('ID').AsInteger);
end;
@ -1020,6 +1036,7 @@ begin
ds.Open;
ds.InsertRecord([0,'name']);
v := VarToStr(ds.Fields[1].OldValue);
AssertTrue(v<>null);
end;
procedure TTestCursorDBBasics.TestFieldOldValue;
@ -1577,7 +1594,7 @@ begin
TCustomBufDataset(ds).SaveToFile('test.xml');
ds.close;
LoadDs := TCustomBufDataset.Create(nil);
LoadDs := TMyCustomBufDataset.Create(nil);
try
LoadDs.LoadFromFile('test.xml');
FTestXMLDatasetDefinition(LoadDS);
@ -1611,7 +1628,7 @@ procedure TTestBufDatasetDBBasics.TestClientDatasetAsMemDataset;
var ds : TCustomBufDataset;
i : integer;
begin
ds := TCustomBufDataset.Create(nil);
ds := TMyCustomBufDataset.Create(nil);
try
DS.FieldDefs.Add('ID',ftInteger);
DS.FieldDefs.Add('NAME',ftString,50);
@ -2395,7 +2412,6 @@ procedure TTestBufDatasetDBBasics.TestIndexEditRecord;
// with a value at the end of the alphabet
var ds : TCustomBufDataset;
AFieldType : TFieldType;
OldID : Integer;
OldStringValue : string;
begin
ds := DBConnector.GetFieldDataset as TCustomBufDataset;
@ -2526,6 +2542,7 @@ begin
bufds := DBConnector.GetNDataset(5) as TCustomBufDataset;
s := bufds.IndexFieldNames;
s := bufds.IndexName;
AssertTrue(S<>'');
bufds.CompareBookmarks(nil,nil);
end;
{$endif fpc}
@ -2915,7 +2932,7 @@ begin
if Fields[i].DataType in ftBlobTypes then
begin
// Type should certainly fall into wider old style, imprecise TBlobType
if not(TBlobField(Fields[i]).BlobType in [Low(TBlobType)..High(TBlobType)]) then
if not(TBlobField(Fields[i]).BlobType in ftBlobTypes) then
fail('BlobType for field '+
Fields[i].FieldName+' is not in old wide incorrect TBlobType range. Actual value: '+
inttostr(word(TBlobField(Fields[i]).BlobType)));

View File

@ -487,7 +487,7 @@ begin
try
ExportSettings.FieldDelimiter:=','; //RFC 4180 specified commas as delimiter
ExportSettings.HeaderRow:=true; //...allows an optional header line
ExportSettings.StringQuoteChar:='"'; //...requires quoting with " (if quoting)
ExportSettings.QuoteChar:='"'; //...requires quoting with " (if quoting)
// Fields containing line breaks (CRLF), double quotes,
// and commas should be enclosed in double-quotes.
// => this probably won't get tested with this test set.
@ -517,7 +517,7 @@ begin
ExportSettings:=TCSVFormatSettings.Create(true);
try
ExportSettings.FieldDelimiter:=';';
ExportSettings.StringQuoteChar:='"'; //try explicit assignment
ExportSettings.QuoteChar:='"'; //try explicit assignment
ExportSettings.RowDelimiter:=#10; //Unix/Linux format
ExportSettings.BooleanFalse:='onwaar'; //why not a Dutch output format?
ExportSettings.BooleanTrue:='waar'; //why not a Dutch output format?

View File

@ -2211,7 +2211,6 @@ end;
procedure TTestFieldTypes.TestFieldNames;
var FieldList : TStringList;
i : integer;
begin
FieldList := TStringList.Create;
try

View File

@ -23,6 +23,14 @@ type
{ TTestSpecificTBufDataset }
{ TMyBufDataset }
TMyBufDataset = Class(TBufDataset)
protected
procedure LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField); override;
end;
TTestSpecificTBufDataset = class(TDBBasicsTestCase)
private
procedure TestDataset(ABufDataset: TBufDataset; AutoInc: boolean = false);
@ -54,6 +62,13 @@ uses
variants,
FmtBCD;
{ TMyBufDataset }
procedure TMyBufDataset.LoadBlobIntoBuffer(FieldDef: TFieldDef; ABlobBuf: PBufBlobField);
begin
Raise ENotImplemented.Create('LoadBlobIntoBuffer not implemented');
end;
{ TTestSpecificTBufDataset }
procedure TTestSpecificTBufDataset.TestDataset(ABufDataset: TBufDataset;
@ -84,7 +99,7 @@ var
ds : TBufDataset;
f: TField;
begin
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
F := TAutoIncField.Create(ds);
F.FieldName:='ID';
F.DataSet:=ds;
@ -112,7 +127,7 @@ begin
DS.Close;
ds.Free;
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
ds.LoadFromFile(fn);
ds.Last;
CheckEquals(10,ds.FieldByName('Id').AsInteger);
@ -138,7 +153,7 @@ end;
procedure TTestSpecificTBufDataset.CreateDatasetFromFielddefs;
var ds : TBufDataset;
begin
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
DS.FieldDefs.Add('ID',ftInteger);
DS.FieldDefs.Add('NAME',ftString,50);
DS.CreateDataset;
@ -152,7 +167,7 @@ procedure TTestSpecificTBufDataset.CreateDatasetFromFields;
var ds : TBufDataset;
f: TField;
begin
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
F := TIntegerField.Create(ds);
F.FieldName:='ID';
F.DataSet:=ds;
@ -171,7 +186,7 @@ procedure TTestSpecificTBufDataset.TestOpeningNonExistingDataset;
var ds : TBufDataset;
f: TField;
begin
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
F := TIntegerField.Create(ds);
F.FieldName:='ID';
F.DataSet:=ds;
@ -179,7 +194,7 @@ begin
CheckException(ds.Open,EDatabaseError);
ds.Free;
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
DS.FieldDefs.Add('ID',ftInteger);
CheckException(ds.Open,EDatabaseError);
@ -191,7 +206,7 @@ var ds : TBufDataset;
f: TField;
i: integer;
begin
ds := TBufDataset.Create(nil);
ds := TMyBufDataset.Create(nil);
try
F := TIntegerField.Create(ds);
F.FieldName:='ID';
@ -260,7 +275,7 @@ var
BDS:TBufDataSet;
begin
BDS:=TBufDataSet.Create(nil);
BDS:=TMyBufDataset.Create(nil);
BDS.FieldDefs.Add('ID',ftLargeint);
BDS.CreateDataSet;
BDS.AppendRecord([1]);

View File

@ -12,7 +12,7 @@ interface
uses
{$IFDEF FPC}
fpcunit, testutils, testregistry, testdecorator,
fpcunit, testregistry,
{$ELSE FPC}
TestFramework,
{$ENDIF FPC}