mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 10:09:19 +02:00
* fcl-db: additional stringfilter tests
git-svn-id: trunk@26252 -
This commit is contained in:
parent
f2096de53a
commit
4229c6b40f
@ -1320,7 +1320,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TTestCursorDBBasics.TestStringFilter;
|
procedure TTestCursorDBBasics.TestStringFilter;
|
||||||
// Tests a string expression filter
|
// Tests string expression filters
|
||||||
var
|
var
|
||||||
Counter : byte;
|
Counter : byte;
|
||||||
begin
|
begin
|
||||||
@ -1331,58 +1331,69 @@ begin
|
|||||||
// Check equality
|
// Check equality
|
||||||
Filter := '(name=''TestName3'')';
|
Filter := '(name=''TestName3'')';
|
||||||
Filtered := True;
|
Filtered := True;
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF, 'Simple equality');
|
||||||
CheckEquals(3,FieldByName('ID').asinteger);
|
CheckEquals(3,FieldByName('ID').asinteger,'Simple equality');
|
||||||
CheckEquals('TestName3',FieldByName('NAME').asstring);
|
CheckEquals('TestName3',FieldByName('NAME').asstring,'Simple equality');
|
||||||
next;
|
next;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF,'Simple equality');
|
||||||
|
|
||||||
// Check partial compare
|
// Check partial compare
|
||||||
Filter := '(name=''*Name5'')';
|
Filter := '(name=''*Name5'')';
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF, 'Partial compare');
|
||||||
CheckEquals(5,FieldByName('ID').asinteger);
|
CheckEquals(5,FieldByName('ID').asinteger,'Partial compare');
|
||||||
CheckEquals('TestName5',FieldByName('NAME').asstring);
|
CheckEquals('TestName5',FieldByName('NAME').asstring,'Partial compare');
|
||||||
next;
|
next;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF,'Partial compare');
|
||||||
|
|
||||||
// Check case-sensitivity
|
// Check case-sensitivity
|
||||||
Filter := '(name=''*name3'')';
|
Filter := '(name=''*name3'')';
|
||||||
first;
|
first;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF,'Case-sensitive search');
|
||||||
|
|
||||||
FilterOptions:=[foCaseInsensitive];
|
FilterOptions:=[foCaseInsensitive];
|
||||||
Filter := '(name=''testname3'')';
|
Filter := '(name=''testname3'')';
|
||||||
first;
|
first;
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF,'Case-insensitive search');
|
||||||
CheckEquals(3,FieldByName('ID').asinteger);
|
CheckEquals(3,FieldByName('ID').asinteger,'Case-insensitive search');
|
||||||
CheckEquals('TestName3',FieldByName('NAME').asstring);
|
CheckEquals('TestName3',FieldByName('NAME').asstring,'Case-insensitive search');
|
||||||
next;
|
next;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF);
|
||||||
|
|
||||||
// Check case-insensitive partial compare
|
// Check case-insensitive partial compare
|
||||||
Filter := '(name=''*name3'')';
|
Filter := '(name=''*name3'')';
|
||||||
first;
|
first;
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF, 'Case-insensitive partial compare');
|
||||||
CheckEquals(3,FieldByName('ID').asinteger);
|
CheckEquals(3,FieldByName('ID').asinteger, 'Case-insensitive partial compare');
|
||||||
CheckEquals('TestName3',FieldByName('NAME').asstring);
|
CheckEquals('TestName3',FieldByName('NAME').asstring, 'Case-insensitive partial compare');
|
||||||
next;
|
next;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF);
|
||||||
|
|
||||||
// Valid data with partial compare
|
// Multiple records with partial compare
|
||||||
Filter := '(name=''*name*'')';
|
Filter := '(name=''*name*'')';
|
||||||
first;
|
first;
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF,'Partial compare multiple records');
|
||||||
CheckEquals(1,FieldByName('ID').asinteger);
|
CheckEquals(1,FieldByName('ID').asinteger,'Partial compare multiple records');
|
||||||
CheckEquals('TestName1',FieldByName('NAME').asstring);
|
CheckEquals('TestName1',FieldByName('NAME').asstring,'Partial compare multiple records');
|
||||||
next;
|
next;
|
||||||
CheckFalse(EOF);
|
CheckFalse(EOF,'Partial compare multiple records');
|
||||||
CheckEquals(2,FieldByName('ID').asinteger);
|
CheckEquals(2,FieldByName('ID').asinteger,'Partial compare multiple records');
|
||||||
CheckEquals('TestName2',FieldByName('NAME').asstring);
|
CheckEquals('TestName2',FieldByName('NAME').asstring,'Partial compare multiple records');
|
||||||
|
|
||||||
// Invalid data with partial compare
|
// Invalid data with partial compare
|
||||||
Filter := '(name=''*neme*'')';
|
Filter := '(name=''*neme*'')';
|
||||||
first;
|
first;
|
||||||
CheckTrue(EOF);
|
CheckTrue(EOF,'Invalid data, partial compare');
|
||||||
|
|
||||||
|
// Multiple string filters
|
||||||
|
Filter := '(name=''*a*'') and (name=''*m*'')';
|
||||||
|
first;
|
||||||
|
CheckFalse(EOF,'Multiple string filters');
|
||||||
|
CheckEquals(1,FieldByName('ID').asinteger,'Multiple string filters');
|
||||||
|
CheckEquals('TestName1',FieldByName('NAME').asstring,'Multiple string filters');
|
||||||
|
next;
|
||||||
|
CheckFalse(EOF,'Multiple string filters');
|
||||||
|
CheckEquals(2,FieldByName('ID').asinteger,'Multiple string filters');
|
||||||
|
CheckEquals('TestName2',FieldByName('NAME').asstring,'Multiple string filters');
|
||||||
|
|
||||||
// Modify so we can use some tricky data
|
// Modify so we can use some tricky data
|
||||||
Filter := ''; //show all records again and allow edits
|
Filter := ''; //show all records again and allow edits
|
||||||
|
Loading…
Reference in New Issue
Block a user