PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/packages/fcl-db/tests/tcsqlscanner.pas

https://github.com/slibre/freepascal
Pascal | 1626 lines | 1305 code | 290 blank | 31 comment | 0 complexity | af1666554f13cc7e2efc09060c99512f MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
   1{
   2    This file is part of the Free Component Library
   3    Copyright (c) 2010 by the Free Pascal development team
   4
   5    SQL source lexical scanner test suite
   6
   7    See the file COPYING.FPC, included in this distribution,
   8    for details about the copyright.
   9
  10    This program is distributed in the hope that it will be useful,
  11    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13
  14 **********************************************************************}
  15unit tcsqlscanner;
  16
  17{$mode objfpc}{$H+}
  18
  19interface
  20
  21uses
  22  Classes, SysUtils, fpcunit, testutils, testregistry, fpsqlscanner;
  23
  24type
  25
  26  { TTestSQLScanner }
  27
  28  TTestSQLScanner= class(TTestCase)
  29  Private
  30    FStream : TStream;
  31    FLineReader : TLineReader;
  32    FScanner : TSQLScanner;
  33    FErrorSource : String;
  34    FErrorOptions : TSQLScannerOptions;
  35    procedure AssertEquals(AMessage: String; AExpected, AActual : TSQLToken); overload;
  36    procedure CheckToken(AToken: TSQLToken; ASource: String);
  37    procedure CheckTokens(ASource: String; ATokens: array of TSQLToken);
  38    procedure DoTestFloat(F: Double);
  39    procedure DoTestFloat(F: Double; S: String);
  40    procedure DoTestString(S: String; DoubleDelim : Boolean = False);
  41    procedure TestErrorSource;
  42  protected
  43    Function CreateScanner(AInput : String; AOptions : TSQLScannerOptions = []) : TSQLScanner;
  44    procedure FreeScanner;
  45    procedure SetUp; override;
  46    procedure TearDown; override;
  47    Property Scanner : TSQLScanner Read FScanner;
  48  published
  49    procedure TestAction;
  50    procedure TestAdd;
  51    procedure TestAdmin;
  52    procedure TestAfter;
  53    procedure TestALTER;
  54    procedure TestAnd;
  55    procedure TestAny;
  56    procedure TestAs;
  57    procedure TestASC;
  58    procedure TestASCENDING;
  59    Procedure TestAt;
  60    procedure TestAuto;
  61    procedure TestAVG;
  62    procedure TestAssign;
  63    procedure TestBefore;
  64    Procedure TestBegin;
  65    procedure TestBetween;
  66    procedure TestBlob;
  67    procedure TestBraceClose;
  68    procedure TestBraceOpen;
  69    procedure TestBy;
  70    Procedure TestCache;
  71    procedure TestCascade;
  72    procedure TestChar;
  73    procedure TestCharacter;
  74    procedure TestCheck;
  75    procedure TestCollate;
  76    procedure TestColon;
  77    procedure TestColumn;
  78    procedure TestComma;
  79    procedure TestCommit;
  80    procedure TestComputed;
  81    procedure TestConcatenate;
  82    Procedure TestConditional;
  83    Procedure TestConnect;
  84    procedure TestConstraint;
  85    procedure TestContaining;
  86    procedure TestCount;
  87    procedure TestCreate;
  88    procedure TestCString;
  89    Procedure TestDatabase;
  90    Procedure TestDate;
  91    Procedure TestDecimal;
  92    procedure TestDeclare;
  93    procedure TestDefault;
  94    procedure TestDelete;
  95    procedure TestDesc;
  96    procedure TestDescending;
  97    procedure TestDistinct;
  98    procedure TestDiv;
  99    procedure TestDO;
 100    procedure TestDomain;
 101    procedure TestDot;
 102    procedure TestDrop;
 103    procedure TestElse;
 104    procedure TestEmpty;
 105    procedure TestEnd;
 106    Procedure TestEntryPoint;
 107    procedure TestEq;
 108    procedure TestEscape;
 109    procedure TestException;
 110    procedure TestExists;
 111    procedure TestExit;
 112    Procedure TestExternal;
 113    Procedure TestExtract;
 114    procedure TestFile;
 115    Procedure TestFloat;
 116    procedure TestFor;
 117    procedure TestForeign;
 118    procedure TestFreeIt;
 119    procedure TestFunction;
 120    Procedure TestGDSError;
 121    procedure TestGE;
 122    procedure TestGenerator;
 123    procedure TestGrant;
 124    procedure TestGreaterThan;
 125    procedure TestGroup;
 126    Procedure TestHaving;
 127    procedure TestIf;
 128    procedure TestIn;
 129    procedure TestIndex;
 130    procedure TestInner;
 131    procedure TestInsert;
 132    procedure TestInt;
 133    procedure TestInteger;
 134    procedure TestInto;
 135    procedure TestIs;
 136    procedure TestJoin;
 137    procedure TestKey;
 138    procedure TestLeft;
 139    Procedure TestLength;
 140    procedure TestLike;
 141    procedure TestLE;
 142    procedure TestLessThan;
 143    Procedure TestManual;
 144    Procedure TestModuleName;
 145    procedure TestMax;
 146    procedure TestMerge;
 147    procedure TestMin;
 148    procedure TestMinus;
 149    procedure TestMul;
 150    procedure TestNational;
 151    procedure TestNatural;
 152    procedure TestNE;
 153    procedure TestNo;
 154    procedure TestNot;
 155    procedure TestNull;
 156    procedure TestNumeric;
 157    Procedure TestOn;
 158    Procedure TestOption;
 159    Procedure TestOr;
 160    Procedure TestOrder;
 161    Procedure TestOuter;
 162    Procedure TestPage;
 163    Procedure TestPages;
 164    Procedure TestPageSize;
 165    Procedure TestPassword;
 166    procedure TestPlus;
 167    procedure TestPosition;
 168    Procedure TestPostEvent;
 169    procedure TestPrimary;
 170    procedure TestPrivileges;
 171    procedure TestProcedure;
 172    procedure TestPublic;
 173    Procedure TestReferences;
 174    Procedure TestRelease;
 175    Procedure TestReturningValues;
 176    Procedure TestReturns;
 177    Procedure TestRetain;
 178    Procedure TestRevoke;
 179    Procedure TestRight;
 180    Procedure TestRole;
 181    Procedure TestRollback;
 182    Procedure TestSegment;
 183    Procedure TestSelect;
 184    procedure TestSemicolon;
 185    Procedure TestSet;
 186    Procedure TestSchema;
 187    Procedure TestShadow;
 188    Procedure TestSingular;
 189    Procedure TestSize;
 190    Procedure TestSkip;
 191    Procedure TestSome;
 192    Procedure TestSort;
 193    Procedure TestSnapshot;
 194    Procedure TestSQLCode;
 195    procedure TestSquareBraceClose;
 196    procedure TestSquareBraceOpen;
 197    Procedure TestStarting;
 198    procedure TestString;
 199    procedure TestSubtype;
 200    Procedure TestSum;
 201    Procedure TestSuspend;
 202    Procedure TestTable;
 203    Procedure TestThen;
 204    Procedure TestTime;
 205    Procedure TestTimeStamp;
 206    Procedure TestTo;
 207    Procedure TestTransaction;
 208    Procedure TestTrigger;
 209    Procedure TestType;
 210    Procedure TestUnion;
 211    Procedure TestUnique;
 212    Procedure TestUpdate;
 213    Procedure TestUpper;
 214    Procedure TestUser;
 215    procedure TestValue;
 216    procedure TestValues;
 217    procedure TestVariable;
 218    procedure TestVarChar;
 219    Procedure TestVarying;
 220    Procedure TestView;
 221    Procedure TestWhen;
 222    Procedure TestWhere;
 223    procedure TestWhile;
 224    procedure TestWith;
 225    procedure TestWork;
 226    Procedure Test2Words;
 227    procedure Test3Words;
 228    procedure TestIdentifier;
 229    procedure TestIdentifier2;
 230    procedure TestIdentifier3;
 231    procedure TestIdentifier4;
 232    procedure TestIdentifier5;
 233    procedure TestIdentifierDotIdentifier;
 234    procedure TestEOLN;
 235    procedure TestEOLN2;
 236    procedure TestEOLN3;
 237    procedure TestEOLN4;
 238    procedure TestComment1;
 239    procedure TestComment2;
 240    procedure TestComment3;
 241    procedure TestComment4;
 242    procedure TestComment5;
 243    procedure TestComment6;
 244    procedure TestFloatLiteral;
 245    procedure TestStringLiteral1;
 246    procedure TestStringLiteral2;
 247    procedure TestStringError;
 248    procedure TestFloatError;
 249    Procedure TestOptionsoDoubleQuoteStringLiteral;
 250    Procedure TestOptionsoSingleQuoteIdentifier;
 251    procedure TestOptionsoBackQuoteIdentifier;
 252    procedure TestOptionNosoBackQuoteIdentifier;
 253    procedure TestOptionNosoBackslashEscapes;
 254    procedure TestOptionsoBackslashEscapesTab;
 255    procedure TestOptionsoBackslashEscapesNewLine;
 256    procedure TestOptionsoBackslashEscapesBackSlash;
 257    procedure TestOptionsoBackslashEscapesBackspace;
 258    procedure TestOptionsoBackslashEscapesLineFeed;
 259    procedure TestOptionsoBackslashEscapesNewPage;
 260    procedure TestOptionsoBackslashEscapesSlash;
 261    procedure TestOptionsoBackslashEscapesQuote;
 262    procedure TestOptionsoBackslashEscapesDoubleQuote;
 263  end;
 264
 265implementation
 266
 267uses typinfo;
 268
 269procedure TTestSQLScanner.AssertEquals(AMessage: String; AExpected,
 270  AActual: TSQLToken);
 271
 272Var
 273  S,EN1,EN2 : String;
 274
 275begin
 276  If (AActual<>AExpected) then
 277    begin
 278    EN1:=GetEnumName(TypeINfo(TSQLToken),Ord(AExpected));
 279    EN2:=GetEnumName(TypeINfo(TSQLToken),Ord(AActual));
 280    S:=Format('%s : %s <> %s',[AMessage,EN1,EN2]);
 281    Fail(S);
 282    end;
 283end;
 284
 285procedure TTestSQLScanner.CheckToken(AToken: TSQLToken; ASource: String);
 286
 287Var
 288  J : TSqlToken;
 289  EN2 : String;
 290
 291begin
 292  CreateScanner(ASource);
 293  J:=Scanner.FetchToken;
 294  EN2:=GetEnumName(TypeINfo(TSQLToken),Ord(AToken));
 295  AssertEquals(Format('Source %s should result in %s.',[ASource,EN2]),AToken,J);
 296end;
 297
 298
 299procedure TTestSQLScanner.DoTestFloat(F: Double);
 300Var
 301  S : String;
 302
 303begin
 304  Str(F,S);
 305  DoTestFloat(F,S);
 306end;
 307
 308procedure TTestSQLScanner.DoTestFloat(F: Double; S: String);
 309Var
 310  J : TSQLToken;
 311  C : Double;
 312  I : integer;
 313  V : String;
 314
 315begin
 316  CreateScanner(S);
 317  try
 318    J:=FScanner.FetchToken;
 319    AssertEquals(S+' is a number',tsqlFloatNumber,J);
 320    V:=FScanner.CurTokenString;
 321    Val(V,C,I);
 322    If (I<>0) then
 323      Fail(FScanner.CurTokenString+' does not contain a float value');
 324    AssertEquals('Parsed float equals original float',F,C);
 325  finally
 326    FreeScanner;
 327  end;
 328end;
 329
 330procedure TTestSQLScanner.DoTestString(S: String; DoubleDelim : Boolean = False);
 331Var
 332  J : TSQLToken;
 333  C : Char;
 334
 335begin
 336  CreateScanner(S);
 337  try
 338    J:=FScanner.FetchToken;
 339    AssertEquals(S+' is a string',tsqlString,J);
 340    If (Length(S)>0) and (S[1] in ['"','''']) then
 341      begin
 342      C:=S[1];
 343      S:=Copy(S,2,Length(S)-2);
 344      end;
 345    If DoubleDelim then
 346      S:=StringReplace(S,C+C,C,[rfReplaceAll]);
 347    AssertEquals('Correct string is returned',S,FScanner.CurTokenString);
 348  finally
 349    FreeScanner;
 350  end;
 351end;
 352
 353procedure TTestSQLScanner.TestErrorSource;
 354begin
 355  CreateScanner(FErrorSource,FErrorOptions);
 356  While (FScanner.FetchToken<>tsqlEOF) do ;
 357end;
 358
 359function TTestSQLScanner.CreateScanner(AInput: String; AOptions : TSQLScannerOptions = []): TSQLScanner;
 360begin
 361  FStream:=TStringStream.Create(AInput);
 362  FLineReader:=TStreamLineReader.Create(Fstream);
 363  FScanner:=TSQLScanner.Create(FLineReader);
 364  FScanner.Options:=AOptions;
 365  Result:=FSCanner;
 366end;
 367
 368procedure TTestSQLScanner.FreeScanner;
 369begin
 370  FreeAndNil(FScanner);
 371  FreeAndNil(FLineReader);
 372  FreeAndNil(FStream);
 373end;
 374
 375procedure TTestSQLScanner.SetUp;
 376begin
 377  inherited SetUp;
 378  FErrorSource:='';
 379  FErrorOptions:=[];
 380end;
 381
 382procedure TTestSQLScanner.TearDown;
 383begin
 384  FreeScanner;
 385  iNHERITED;
 386end;
 387
 388procedure TTestSQLScanner.TestAction;
 389begin
 390  CheckToken(tsqlAction,'ACTION');
 391end;
 392
 393procedure TTestSQLScanner.TestAdd;
 394begin
 395  CheckToken(tsqlAdd,'ADD');
 396end;
 397
 398procedure TTestSQLScanner.TestAdmin;
 399begin
 400  CheckToken(tsqlAdmin,'ADMIN');
 401end;
 402
 403procedure TTestSQLScanner.TestAfter;
 404begin
 405  CheckToken(tsqlAfter,'AFTER');
 406end;
 407
 408procedure TTestSQLScanner.TestEmpty;
 409
 410Var
 411  J : TSQLToken;
 412begin
 413  CreateScanner('');
 414  J:=Scanner.FetchToken;
 415  If (J<>tsqlEOF) then
 416    Fail('Empty returns EOF');
 417end;
 418
 419procedure TTestSQLScanner.TestEnd;
 420begin
 421  CheckToken(tsqlEnd,'END');
 422end;
 423
 424procedure TTestSQLScanner.TestEntryPoint;
 425begin
 426  CheckToken(tsqlEntryPoint,'ENTRY_POINT');
 427end;
 428
 429procedure TTestSQLScanner.TestEscape;
 430begin
 431  CheckToken(tsqlEscape,'ESCAPE');
 432end;
 433
 434procedure TTestSQLScanner.TestException;
 435begin
 436  CheckToken(tsqlException,'EXCEPTION');
 437end;
 438
 439procedure TTestSQLScanner.TestExists;
 440begin
 441  CheckToken(tsqlExists,'EXISTS');
 442end;
 443
 444procedure TTestSQLScanner.TestExit;
 445begin
 446  CheckToken(tsqlExit,'EXIT');
 447end;
 448
 449procedure TTestSQLScanner.TestExternal;
 450begin
 451  CheckToken(tsqlExternal,'external');
 452end;
 453
 454procedure TTestSQLScanner.TestExtract;
 455begin
 456  CheckToken(tsqlExtract,'EXTRACT');
 457end;
 458
 459procedure TTestSQLScanner.TestAnd;
 460
 461begin
 462  CheckToken(tsqlAnd,'and');
 463end;
 464
 465procedure TTestSQLScanner.TestAny;
 466begin
 467  CheckToken(tsqlAny,'any');
 468end;
 469
 470procedure TTestSQLScanner.TestAs;
 471begin
 472  CheckToken(tsqlAs,'as');
 473end;
 474
 475procedure TTestSQLScanner.TestAt;
 476begin
 477  CheckToken(tsqlAt,'at');
 478end;
 479
 480procedure TTestSQLScanner.TestAuto;
 481begin
 482  CheckToken(tsqlAUTO,'auto');
 483end;
 484
 485procedure TTestSQLScanner.TestASC;
 486begin
 487  CheckToken(tsqlASC,'asc');
 488end;
 489
 490procedure TTestSQLScanner.TestASCENDING;
 491begin
 492  CheckToken(tsqlASCENDING,'ascending');
 493end;
 494
 495procedure TTestSQLScanner.TestAVG;
 496begin
 497  CheckToken(tsqlAVG,'avg');
 498end;
 499
 500procedure TTestSQLScanner.TestALTER;
 501begin
 502  CheckToken(tsqlALTER,'alter');
 503end;
 504
 505procedure TTestSQLScanner.TestBraceOpen;
 506
 507begin
 508  CheckToken(tsqlBraceOpen,'(');
 509end;
 510
 511procedure TTestSQLScanner.TestBraceClose;
 512
 513begin
 514  CheckToken(tsqlBraceClose,')');
 515end;
 516
 517
 518procedure TTestSQLScanner.TestComma;
 519
 520begin
 521  CheckToken(tsqlComma,',');
 522end;
 523
 524procedure TTestSQLScanner.TestCommit;
 525begin
 526  CheckToken(tsqlCommit,'COMMIT');
 527end;
 528
 529procedure TTestSQLScanner.TestComputed;
 530begin
 531  CheckToken(tsqlComputed,'COMPUTED');
 532end;
 533
 534procedure TTestSQLScanner.TestConditional;
 535begin
 536  CheckToken(tsqlConditional,'CONDITIONAL');
 537end;
 538
 539procedure TTestSQLScanner.TestConnect;
 540begin
 541  CheckToken(tsqlConnect,'CONNECT');
 542end;
 543
 544procedure TTestSQLScanner.TestConstraint;
 545begin
 546  CheckToken(tsqlConstraint,'CONSTRAINT');
 547end;
 548
 549procedure TTestSQLScanner.TestColon;
 550
 551begin
 552  CheckToken(tsqlColon,':');
 553end;
 554
 555procedure TTestSQLScanner.TestColumn;
 556begin
 557  CheckToken(tsqlColumn,'COLUMN');
 558end;
 559
 560procedure TTestSQLScanner.TestDot;
 561
 562begin
 563  CheckToken(tsqlDot,'.');
 564end;
 565
 566procedure TTestSQLScanner.TestDrop;
 567begin
 568  CheckToken(tsqldrop,'DROP');
 569end;
 570
 571procedure TTestSQLScanner.TestSemicolon;
 572
 573begin
 574  CheckToken(tsqlSemicolon,';');
 575end;
 576
 577procedure TTestSQLScanner.TestSet;
 578begin
 579  CheckToken(tsqlSet,'SET');
 580end;
 581
 582procedure TTestSQLScanner.TestSchema;
 583begin
 584  CheckToken(tsqlSchema,'SCHEMA');
 585end;
 586
 587procedure TTestSQLScanner.TestShadow;
 588begin
 589  CheckToken(tsqlShadow,'SHADOW');
 590end;
 591
 592procedure TTestSQLScanner.TestSingular;
 593begin
 594  CheckToken(tsqlSINGULAR,'SINGULAR');
 595end;
 596
 597procedure TTestSQLScanner.TestSize;
 598begin
 599  CheckToken(tsqlSize,'size');
 600end;
 601
 602procedure TTestSQLScanner.TestSkip;
 603begin
 604  CheckToken(tsqlSkip,'skip');
 605end;
 606
 607procedure TTestSQLScanner.TestSome;
 608begin
 609  CheckToken(tsqlSome,'some');
 610end;
 611
 612procedure TTestSQLScanner.TestSort;
 613begin
 614  CheckToken(tsqlSort,'sort');
 615end;
 616
 617procedure TTestSQLScanner.TestSnapshot;
 618begin
 619  CheckToken(tsqlSnapshot,'snapshot');
 620end;
 621
 622procedure TTestSQLScanner.TestSQLCode;
 623begin
 624  CheckToken(tsqlSQLCOde,'SQLCODE');
 625end;
 626
 627procedure TTestSQLScanner.TestSquareBraceClose;
 628begin
 629  CheckToken(tsqlSquareBraceClose,']');
 630end;
 631
 632procedure TTestSQLScanner.TestSquareBraceOpen;
 633begin
 634  CheckToken(tsqlSquareBraceOpen,'[');
 635end;
 636
 637procedure TTestSQLScanner.TestSubtype;
 638begin
 639  CheckToken(tsqlSubtype,'sub_type');
 640end;
 641
 642procedure TTestSQLScanner.TestSuspend;
 643begin
 644  CheckToken(tsqlSuspend,'Suspend');
 645end;
 646
 647procedure TTestSQLScanner.TestStarting;
 648begin
 649  CheckToken(tsqlStarting,'starting');
 650end;
 651
 652procedure TTestSQLScanner.TestSum;
 653begin
 654  CheckToken(tsqlSum,'sum');
 655end;
 656
 657procedure TTestSQLScanner.TestString;
 658begin
 659  DoTestString('''A string''');
 660  DoTestString('''''');
 661  DoTestString(''' " ''');
 662  DoTestString('''A string''');
 663  DoTestString(''' '''' ''',True);
 664  DoTestString('''12345'#10'67890''');
 665  DoTestString('''12345'#13'67890''');
 666  DoTestString('''12345'#13#10'67890''');
 667end;
 668
 669procedure TTestSQLScanner.TestTable;
 670begin
 671  CheckToken(tsqltable,'TABLE');
 672end;
 673
 674procedure TTestSQLScanner.TestThen;
 675begin
 676  CheckToken(tsqlThen,'THEN');
 677end;
 678
 679procedure TTestSQLScanner.TestTime;
 680begin
 681  CheckToken(tsqlTime,'TIME');
 682end;
 683
 684procedure TTestSQLScanner.TestTimeStamp;
 685begin
 686  CheckToken(tsqlTimeStamp,'TIMESTAMP');
 687end;
 688
 689procedure TTestSQLScanner.TestTo;
 690begin
 691  CheckToken(tsqlTo,'TO');
 692end;
 693
 694procedure TTestSQLScanner.TestTransaction;
 695begin
 696  CheckToken(tsqlTransaction,'TRANSACTION');
 697end;
 698
 699procedure TTestSQLScanner.TestTrigger;
 700begin
 701  CheckToken(tsqlTrigger,'TRIGGER');
 702end;
 703
 704procedure TTestSQLScanner.TestType;
 705begin
 706  CheckToken(tsqltype,'TYPE');
 707end;
 708
 709procedure TTestSQLScanner.TestUnion;
 710begin
 711  CheckToken(tsqlUnion,'UNION');
 712end;
 713
 714procedure TTestSQLScanner.TestUnique;
 715begin
 716  CheckToken(tsqlUnique,'UNIQUE');
 717end;
 718
 719procedure TTestSQLScanner.TestUpdate;
 720begin
 721  CheckToken(tsqlUPDATE,'UPDATE');
 722end;
 723
 724procedure TTestSQLScanner.TestUpper;
 725begin
 726  CheckToken(tsqlUPPER,'UPPER');
 727end;
 728
 729procedure TTestSQLScanner.TestUser;
 730begin
 731  CheckToken(tsqlUSER,'USER');
 732end;
 733
 734procedure TTestSQLScanner.TestValues;
 735begin
 736  CheckToken(tsqlVALUES,'VALUES');
 737end;
 738
 739procedure TTestSQLScanner.TestValue;
 740begin
 741  CheckToken(tsqlVALUE,'VALUE');
 742end;
 743
 744procedure TTestSQLScanner.TestAssign;
 745
 746begin
 747  CheckToken(tsqlEq,'=');
 748end;
 749
 750procedure TTestSQLScanner.TestBefore;
 751begin
 752  CheckToken(tsqlbefore,'BEFORE');
 753end;
 754
 755procedure TTestSQLScanner.TestBegin;
 756begin
 757  CheckToken(tsqlbegin,'BEGIN');
 758end;
 759
 760procedure TTestSQLScanner.TestBetween;
 761begin
 762  CheckToken(tsqlBetween,'BETWEEN');
 763end;
 764
 765procedure TTestSQLScanner.TestGreaterThan;
 766
 767begin
 768  CheckToken(tsqlGT,'>');
 769end;
 770
 771procedure TTestSQLScanner.TestGroup;
 772begin
 773  CheckToken(tsqlGroup,'group');
 774end;
 775
 776procedure TTestSQLScanner.TestHaving;
 777begin
 778  CheckToken(tsqlHaving,'HAVING');
 779end;
 780
 781procedure TTestSQLScanner.TestLessThan;
 782
 783begin
 784  CheckToken(tsqlLT,'<');
 785end;
 786
 787procedure TTestSQLScanner.TestManual;
 788begin
 789  Checktoken(tsqlManual,'manual');
 790end;
 791
 792procedure TTestSQLScanner.TestModuleName;
 793begin
 794  Checktoken(tsqlModuleName,'module_name');
 795end;
 796
 797procedure TTestSQLScanner.TestMax;
 798begin
 799  Checktoken(tsqlMax,'max');
 800end;
 801
 802procedure TTestSQLScanner.TestMerge;
 803begin
 804  Checktoken(tsqlMerge,'merge');
 805end;
 806
 807procedure TTestSQLScanner.TestMin;
 808begin
 809  Checktoken(tsqlMin,'min');
 810end;
 811
 812procedure TTestSQLScanner.TestPlus;
 813
 814begin
 815  CheckToken(tsqlPlus,'+');
 816end;
 817
 818procedure TTestSQLScanner.TestPosition;
 819begin
 820  Checktoken(tsqlposition,'position');
 821end;
 822
 823procedure TTestSQLScanner.TestPostEvent;
 824begin
 825  Checktoken(tsqlpostevent,'post_event');
 826end;
 827
 828procedure TTestSQLScanner.TestPrimary;
 829begin
 830  Checktoken(tsqlprimary,'primary');
 831end;
 832
 833procedure TTestSQLScanner.TestPrivileges;
 834begin
 835  Checktoken(tsqlprivileges,'privileges');
 836end;
 837
 838procedure TTestSQLScanner.TestProcedure;
 839begin
 840  Checktoken(tsqlprocedure,'procedure');
 841end;
 842
 843procedure TTestSQLScanner.TestPublic;
 844begin
 845  CheckToken(tsqlPublic,'PUBLIC');
 846end;
 847
 848procedure TTestSQLScanner.TestReferences;
 849begin
 850  CheckToken(tsqlReferences,'REFERENCES');
 851end;
 852
 853procedure TTestSQLScanner.TestRelease;
 854begin
 855  CheckToken(tsqlrelease,'release');
 856end;
 857
 858procedure TTestSQLScanner.TestReturningValues;
 859begin
 860  CheckToken(tsqlreturningvalues,'returning_values');
 861end;
 862
 863procedure TTestSQLScanner.TestReturns;
 864begin
 865  CheckToken(tsqlreturns,'returns');
 866end;
 867
 868procedure TTestSQLScanner.TestRetain;
 869begin
 870  Checktoken(tsqlRetain,'retain');
 871end;
 872
 873procedure TTestSQLScanner.TestRevoke;
 874begin
 875  Checktoken(tsqlRevoke,'revoke');
 876end;
 877
 878procedure TTestSQLScanner.TestRight;
 879begin
 880  Checktoken(tsqlright,'right');
 881end;
 882
 883procedure TTestSQLScanner.TestRole;
 884begin
 885  Checktoken(tsqlrole,'role');
 886end;
 887
 888procedure TTestSQLScanner.TestRollback;
 889begin
 890  Checktoken(tsqlrollback,'rollback');
 891end;
 892
 893procedure TTestSQLScanner.TestSegment;
 894begin
 895  CheckToken(tsqlSegment,'SEGMENT');
 896end;
 897
 898procedure TTestSQLScanner.TestSelect;
 899begin
 900  CheckToken(tsqlSelect,'SELECT');
 901end;
 902
 903procedure TTestSQLScanner.TestMinus;
 904
 905begin
 906  CheckToken(tsqlMinus,'-');
 907end;
 908
 909procedure TTestSQLScanner.TestMul;
 910
 911begin
 912  CheckToken(tsqlMul,'*');
 913end;
 914
 915procedure TTestSQLScanner.TestNational;
 916begin
 917  CheckToken(tsqlNational,'NATIONAL');
 918end;
 919
 920procedure TTestSQLScanner.TestNatural;
 921begin
 922  CheckToken(tsqlNatural,'NATURAL');
 923end;
 924
 925procedure TTestSQLScanner.TestDiv;
 926
 927begin
 928  CheckToken(tsqlDiv,'/');
 929end;
 930
 931procedure TTestSQLScanner.TestEq;
 932
 933begin
 934  CheckToken(tsqlEq,'==');
 935end;
 936
 937procedure TTestSQLScanner.TestFloat;
 938begin
 939  CheckToken(tsqlFloat,'FLOAT');
 940end;
 941
 942procedure TTestSQLScanner.TestGE;
 943
 944begin
 945  CheckToken(tsqlGE,'>=');
 946end;
 947
 948procedure TTestSQLScanner.TestGenerator;
 949begin
 950  CheckToken(tsqlGenerator,'generator');
 951end;
 952
 953procedure TTestSQLScanner.TestGrant;
 954begin
 955  CheckToken(tsqlGrant,'grant');
 956end;
 957
 958procedure TTestSQLScanner.TestLE;
 959
 960begin
 961  CheckToken(tsqlLE,'<=');
 962end;
 963
 964
 965procedure TTestSQLScanner.TestNE;
 966
 967begin
 968  CheckToken(tsqlNE,'<>');
 969end;
 970
 971procedure TTestSQLScanner.TestNo;
 972begin
 973  CheckToken(tsqlNo,'no');
 974end;
 975
 976procedure TTestSQLScanner.TestNot;
 977
 978begin
 979  CheckToken(tsqlNot,'not');
 980end;
 981
 982procedure TTestSQLScanner.TestNull;
 983begin
 984  CheckToken(tsqlnull,'null');
 985end;
 986
 987procedure TTestSQLScanner.TestNumeric;
 988begin
 989  CheckToken(tsqlNumeric,'NUMERIC');
 990end;
 991
 992procedure TTestSQLScanner.TestOn;
 993begin
 994  CheckToken(tsqlON,'on');
 995end;
 996
 997procedure TTestSQLScanner.TestOption;
 998begin
 999  CheckToken(tsqlOption,'option');
1000end;
1001
1002procedure TTestSQLScanner.TestOr;
1003begin
1004  CheckToken(tsqlOR,'or');
1005end;
1006
1007procedure TTestSQLScanner.TestOrder;
1008begin
1009  CheckToken(tsqlORDER,'order');
1010end;
1011
1012procedure TTestSQLScanner.TestOuter;
1013begin
1014  CheckToken(tsqlOUTER,'outer');
1015end;
1016
1017procedure TTestSQLScanner.TestPage;
1018begin
1019  CheckToken(tsqlPage,'PAGE');
1020end;
1021
1022procedure TTestSQLScanner.TestPages;
1023begin
1024  CheckToken(tsqlPages,'PAGES');
1025end;
1026
1027procedure TTestSQLScanner.TestPageSize;
1028begin
1029  CheckToken(tsqlPageSize,'PAGE_SIZE');
1030end;
1031
1032procedure TTestSQLScanner.TestPassword;
1033begin
1034  CheckToken(tsqlPassword,'PASSWORD');
1035end;
1036
1037{
1038procedure TTestSQLScanner.TestTrue;
1039
1040begin
1041  CheckToken(tsqlTrue,'true');
1042end;
1043
1044procedure TTestSQLScanner.TestFalse;
1045
1046begin
1047  CheckToken(tsqlFalse,'false');
1048end;
1049}
1050
1051procedure TTestSQLScanner.TestBy;
1052
1053begin
1054  CheckToken(tsqlBy,'by');
1055end;
1056
1057procedure TTestSQLScanner.TestCache;
1058begin
1059  CheckToken(tsqlCache,'CACHE');
1060end;
1061
1062procedure TTestSQLScanner.TestCascade;
1063begin
1064  CheckToken(tsqlCascade,'cascade');
1065end;
1066
1067procedure TTestSQLScanner.TestBlob;
1068
1069begin
1070  CheckToken(tsqlBlob,'blob');
1071end;
1072
1073procedure TTestSQLScanner.TestChar;
1074begin
1075  CheckToken(tsqlChar,'char');
1076end;
1077
1078procedure TTestSQLScanner.TestCharacter;
1079begin
1080  CheckToken(tsqlCharacter,'character');
1081end;
1082
1083procedure TTestSQLScanner.TestCheck;
1084begin
1085  CheckToken(tsqlCHECK,'check');
1086end;
1087
1088procedure TTestSQLScanner.TestCollate;
1089
1090begin
1091  CheckToken(tsqlCollate,'collate');
1092end;
1093
1094procedure TTestSQLScanner.TestConcatenate;
1095begin
1096  CheckToken(tsqlConcatenate,'||');
1097end;
1098
1099procedure TTestSQLScanner.TestContaining;
1100
1101begin
1102  CheckToken(tsqlContaining,'containing');
1103end;
1104
1105procedure TTestSQLScanner.TestCount;
1106
1107begin
1108  CheckToken(tsqlCount,'count');
1109end;
1110
1111procedure TTestSQLScanner.TestCreate;
1112begin
1113  CheckToken(tsqlCreate,'create');
1114end;
1115
1116procedure TTestSQLScanner.TestCString;
1117begin
1118  CheckToken(tsqlCString,'CSTRING');
1119end;
1120
1121procedure TTestSQLScanner.TestDatabase;
1122begin
1123  CheckToken(tsqlDatabase,'database');
1124end;
1125
1126procedure TTestSQLScanner.TestDate;
1127begin
1128  CheckToken(tsqlDate,'date');
1129end;
1130
1131procedure TTestSQLScanner.TestDecimal;
1132begin
1133  CheckToken(tsqlDecimal,'decimal');
1134end;
1135
1136procedure TTestSQLScanner.TestDefault;
1137
1138begin
1139  CheckToken(tsqldefault,'default');
1140end;
1141
1142procedure TTestSQLScanner.TestDelete;
1143
1144begin
1145  CheckToken(tsqldelete,'delete');
1146end;
1147
1148procedure TTestSQLScanner.TestDeclare;
1149begin
1150  CheckToken(tsqlDeclare,'DECLARE');
1151end;
1152
1153procedure TTestSQLScanner.TestDesc;
1154begin
1155  CheckToken(tsqlDESC,'DESC');
1156end;
1157
1158procedure TTestSQLScanner.TestDescending;
1159begin
1160 CheckToken(tsqlDescending,'DESCENDING');
1161end;
1162
1163procedure TTestSQLScanner.TestDistinct;
1164begin
1165 CheckToken(tsqlDistinct,'DISTINCT');
1166end;
1167
1168procedure TTestSQLScanner.TestDO;
1169
1170begin
1171  CheckToken(tsqldo,'do');
1172end;
1173
1174procedure TTestSQLScanner.TestDomain;
1175begin
1176  CheckToken(tsqlDomain,'domain');
1177end;
1178
1179procedure TTestSQLScanner.TestElse;
1180
1181begin
1182  CheckToken(tsqlelse,'else');
1183end;
1184
1185procedure TTestSQLScanner.TestFor;
1186
1187begin
1188  CheckToken(tsqlfor,'for');
1189end;
1190
1191procedure TTestSQLScanner.TestForeign;
1192begin
1193  CheckToken(tsqlForeign,'foreign');
1194end;
1195
1196procedure TTestSQLScanner.TestFreeIt;
1197begin
1198  CheckToken(tsqlFreeIt,'FREE_IT');
1199end;
1200
1201procedure TTestSQLScanner.TestFile;
1202begin
1203  CheckToken(tsqlFile,'FILE');
1204end;
1205
1206procedure TTestSQLScanner.TestFunction;
1207
1208begin
1209  CheckToken(tsqlfunction,'function');
1210end;
1211
1212procedure TTestSQLScanner.TestGDSError;
1213begin
1214  CheckToken(tsqlGDSCODE,'GDSCODE');
1215end;
1216
1217procedure TTestSQLScanner.TestIf;
1218
1219begin
1220  CheckToken(tsqlif,'if');
1221end;
1222
1223procedure TTestSQLScanner.TestIn;
1224
1225begin
1226  CheckToken(tsqlin,'in');
1227end;
1228
1229procedure TTestSQLScanner.TestInner;
1230
1231begin
1232  CheckToken(tsqlInner,'inner');
1233end;
1234
1235procedure TTestSQLScanner.TestInsert;
1236
1237begin
1238  CheckToken(tsqlInsert,'insert');
1239end;
1240
1241procedure TTestSQLScanner.TestInt;
1242
1243begin
1244  CheckToken(tsqlInt,'int');
1245end;
1246
1247procedure TTestSQLScanner.TestInteger;
1248
1249begin
1250  CheckToken(tsqlInteger,'integer');
1251end;
1252
1253procedure TTestSQLScanner.TestInto;
1254begin
1255  CheckToken(tsqlInto,'into');
1256end;
1257
1258procedure TTestSQLScanner.TestIs;
1259begin
1260  CheckToken(tsqlis,'is');
1261end;
1262
1263procedure TTestSQLScanner.TestJoin;
1264begin
1265  CheckToken(tsqlJoin,'JOIN');
1266end;
1267
1268procedure TTestSQLScanner.TestKey;
1269begin
1270  CheckToken(tsqlKey,'KEY');
1271end;
1272
1273procedure TTestSQLScanner.TestLeft;
1274begin
1275  CheckToken(tsqlLEFT,'LEFT');
1276end;
1277
1278procedure TTestSQLScanner.TestLength;
1279begin
1280  CheckToken(tsqlLength,'LENGTH');
1281end;
1282
1283procedure TTestSQLScanner.TestLike;
1284begin
1285  CheckToken(tsqlLIKE,'LIKE');
1286end;
1287
1288procedure TTestSQLScanner.TestIndex;
1289begin
1290  CheckToken(tsqlindex,'index');
1291end;
1292
1293procedure TTestSQLScanner.TestVariable;
1294
1295begin
1296  CheckToken(tsqlvariable,'variable');
1297end;
1298
1299procedure TTestSQLScanner.TestVarChar;
1300begin
1301  CheckToken(tsqlvarchar,'varchar');
1302end;
1303
1304procedure TTestSQLScanner.TestVarying;
1305begin
1306  CheckToken(tsqlvarying,'varying');
1307end;
1308
1309procedure TTestSQLScanner.TestView;
1310begin
1311  CheckToken(tsqlview,'view');
1312end;
1313
1314procedure TTestSQLScanner.TestWhen;
1315begin
1316  CheckToken(tsqlWhen,'when');
1317end;
1318
1319procedure TTestSQLScanner.TestWhere;
1320begin
1321  CheckToken(tsqlwhere,'where');
1322end;
1323
1324procedure TTestSQLScanner.TestWhile;
1325
1326begin
1327  CheckToken(tsqlwhile,'while');
1328end;
1329
1330procedure TTestSQLScanner.TestWith;
1331
1332begin
1333  CheckToken(tsqlwith,'with');
1334end;
1335
1336procedure TTestSQLScanner.TestWork;
1337begin
1338  CheckToken(tsqlWork,'work');
1339end;
1340
1341procedure TTestSQLScanner.CheckTokens(ASource : String; ATokens : Array of TSQLToken);
1342
1343Var
1344  I : Integer;
1345  J : TSQLToken;
1346  S : String;
1347
1348begin
1349  CreateScanner(ASource);
1350  For I:=Low(ATokens) to High(ATokens) do
1351    begin
1352    J:=FScanner.FetchToken;
1353    S:=GetEnumName(TypeINfo(TSQLToken),Ord(ATokens[i]));
1354    S:=Format('Source "%s", token %d (%s): expected %s',[ASource,I,FScanner.CurTokenString,S]);
1355    AssertEquals(S,ATokens[i],J);
1356    end;
1357end;
1358
1359procedure TTestSQLScanner.Test2Words;
1360begin
1361  CheckTokens('with do',[tsqlWith,tsqlDo]);
1362end;
1363
1364procedure TTestSQLScanner.Test3Words;
1365begin
1366  CheckTokens('with do for',[tsqlWith,tsqlDo,tsqlFor]);
1367end;
1368
1369procedure TTestSQLScanner.TestIdentifier;
1370begin
1371  CheckToken(tsqlIdentifier,'something');
1372  AssertEquals('Correct identifier','something',FScanner.CurTokenString);
1373end;
1374
1375procedure TTestSQLScanner.TestIdentifier2;
1376begin
1377  CheckToken(tsqlIdentifier,'"_something"');
1378  AssertEquals('Correct identifier','_something',FScanner.CurTokenString);
1379end;
1380
1381procedure TTestSQLScanner.TestIdentifier3;
1382begin
1383  CheckToken(tsqlIdentifier,'RDB$');
1384  AssertEquals('Correct identifier','RDB$',FScanner.CurTokenString);
1385end;
1386
1387procedure TTestSQLScanner.TestIdentifier4;
1388begin
1389  CheckToken(tsqlIdentifier,'A_0');
1390  AssertEquals('Correct identifier','A_0',FScanner.CurTokenString);
1391end;
1392
1393procedure TTestSQLScanner.TestIdentifier5;
1394begin
1395  FErrorSource:='$0';
1396  AssertException('Identifier cannot start with _',ESQLScannerError,@TestErrorSource);
1397end;
1398
1399procedure TTestSQLScanner.TestIdentifierDotIdentifier;
1400begin
1401  CheckTokens('something.different',[tsqlIdentifier,tsqldot,tsqlIdentifier]);
1402//  AssertEquals('Correct identifier','something',FScanner.CurTokenString);
1403end;
1404
1405procedure TTestSQLScanner.TestEOLN;
1406begin
1407  CreateScanner('something');
1408  FScanner.FetchToken;
1409  AssertEquals('Got to end of line after reading single token at EOF',True,FScanner.IsEndOfLine);
1410//  AssertEquals('Correct identifier','something',FScanner.CurTokenString);
1411end;
1412
1413procedure TTestSQLScanner.TestEOLN2;
1414begin
1415  CreateScanner('something different');
1416  FScanner.FetchToken;
1417  AssertEquals('Not yet end of line after reading single token at EOF',False,FScanner.IsEndOfLine);
1418end;
1419
1420procedure TTestSQLScanner.TestEOLN3;
1421begin
1422  CreateScanner('something'#13#10'different');
1423  FScanner.FetchToken;
1424  AssertEquals('End of line after reading single token',True,FScanner.IsEndOfLine);
1425end;
1426
1427procedure TTestSQLScanner.TestEOLN4;
1428begin
1429  CreateScanner('something'#10'different');
1430  FScanner.FetchToken;
1431  AssertEquals('End of line after reading first token',True,FScanner.IsEndOfLine);
1432  FScanner.FetchToken;
1433  AssertEquals('End of line after reading second token',True,FScanner.IsEndOfLine);
1434end;
1435
1436procedure TTestSQLScanner.TestComment1;
1437begin
1438  CreateScanner('-- some comment string');
1439  AssertEquals('Comment line is skipped',tsqlEOF,FScanner.FetchToken);
1440end;
1441
1442procedure TTestSQLScanner.TestComment2;
1443begin
1444  CreateScanner('--  some comment string');
1445  FScanner.Options:=[soReturnComments];
1446  AssertEquals('Comment line is returned',tsqlComment,FScanner.FetchToken);
1447  AssertEquals('Comment contents is returned',' some comment string',FScanner.CurTokenString);
1448end;
1449
1450procedure TTestSQLScanner.TestComment3;
1451begin
1452  CreateScanner('/* some comment string */');
1453  AssertEquals('Comment line is skipped',tsqlEOF,FScanner.FetchToken);
1454end;
1455
1456procedure TTestSQLScanner.TestComment4;
1457begin
1458  CreateScanner('/* some comment string */');
1459  FScanner.Options:=[soReturnComments];
1460  AssertEquals('Comment line is returned',tsqlComment,FScanner.FetchToken);
1461  AssertEquals('Comment contents is returned',' some comment string ',FScanner.CurTokenString);
1462end;
1463
1464procedure TTestSQLScanner.TestComment5;
1465begin
1466  CreateScanner('/* some nested comment -- string */');
1467  FScanner.Options:=[soReturnComments];
1468  AssertEquals('Comment line is returned',tsqlComment,FScanner.FetchToken);
1469  AssertEquals('Comment contents is returned',' some nested comment -- string ',FScanner.CurTokenString);
1470end;
1471
1472procedure TTestSQLScanner.TestComment6;
1473begin
1474  CreateScanner('-- /* some nested comment string */');
1475  FScanner.Options:=[soReturnComments];
1476  AssertEquals('Comment line is returned',tsqlComment,FScanner.FetchToken);
1477  AssertEquals('Comment contents is returned','/* some nested comment string */',FScanner.CurTokenString);
1478end;
1479
1480procedure TTestSQLScanner.TestFloatLiteral;
1481begin
1482  DoTestFloat(1.2);
1483  DoTestFloat(-1.2);
1484  DoTestFloat(1.2e1);
1485  DoTestFloat(-1.2e1);
1486  DoTestFloat(1.2,'1.2');
1487  DoTestFloat(-1.2,'-1.2');
1488  DoTestFloat(0,'0.0');
1489end;
1490
1491procedure TTestSQLScanner.TestStringLiteral1;
1492begin
1493  CreateScanner('''A''');
1494  FScanner.Options:=[];
1495  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1496  AssertEquals('Correct string','A',FScanner.CurTokenString);
1497end;
1498
1499procedure TTestSQLScanner.TestStringLiteral2;
1500begin
1501  CreateScanner('"A"',[soDoubleQuoteStringLiteral]);
1502  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1503  AssertEquals('Correct string','A',FScanner.CurTokenString);
1504end;
1505
1506procedure TTestSQLScanner.TestStringError;
1507begin
1508
1509end;
1510
1511procedure TTestSQLScanner.TestFloatError;
1512begin
1513  FErrorSource:='1xz';
1514  AssertException('Wrong float',ESQLScannerError,@TestErrorSource);
1515end;
1516
1517procedure TTestSQLScanner.TestOptionsoDoubleQuoteStringLiteral;
1518begin
1519  CreateScanner('"A"',[soDoubleQuoteStringLiteral]);
1520  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1521  AssertEquals('Correct string','A',FScanner.CurTokenString);
1522end;
1523
1524procedure TTestSQLScanner.TestOptionsoSingleQuoteIdentifier;
1525begin
1526  CreateScanner('''A''',[soSingleQuoteIdentifier,soDoubleQuoteStringLiteral]);
1527  If (Scanner.Options<>[soSingleQuoteIdentifier,soDoubleQuoteStringLiteral]) then
1528    Fail('Options not correctly set');
1529  AssertEquals('Identifier is returned',tsqlIdentifier,FScanner.FetchToken);
1530  AssertEquals('Correct string','A',FScanner.CurTokenString);
1531end;
1532
1533procedure TTestSQLScanner.TestOptionsoBackQuoteIdentifier;
1534begin
1535  CreateScanner('`A`',[soBackQuoteIdentifier]);
1536  AssertEquals('String is returned',tsqlIdentifier,FScanner.FetchToken);
1537  AssertEquals('Correct string','A',FScanner.CurTokenString);
1538end;
1539
1540procedure TTestSQLScanner.TestOptionNosoBackQuoteIdentifier;
1541begin
1542  FErrorSource:='`A`';
1543  AssertException('Wrong token',ESQLScannerError,@TestErrorSource);
1544end;
1545
1546procedure TTestSQLScanner.TestOptionsoBackslashEscapesTab;
1547begin
1548  CreateScanner('''\t''',[soBackslashEscapes]);
1549  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1550  AssertEquals('Correct string',#9,FScanner.CurTokenString);
1551end;
1552
1553procedure TTestSQLScanner.TestOptionsoBackslashEscapesNewLine;
1554begin
1555  CreateScanner('''\n''',[soBackslashEscapes]);
1556  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1557  AssertEquals('Correct string',#10,FScanner.CurTokenString);
1558end;
1559
1560procedure TTestSQLScanner.TestOptionsoBackslashEscapesLineFeed;
1561
1562begin
1563  CreateScanner('''\r''',[soBackslashEscapes]);
1564  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1565  AssertEquals('Correct string',#13,FScanner.CurTokenString);
1566end;
1567
1568procedure TTestSQLScanner.TestOptionsoBackslashEscapesBackSlash;
1569
1570begin
1571  CreateScanner('''\\''',[soBackslashEscapes]);
1572  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1573  AssertEquals('Correct string','\',FScanner.CurTokenString);
1574end;
1575
1576procedure TTestSQLScanner.TestOptionsoBackslashEscapesNewPage;
1577
1578begin
1579  CreateScanner('''\f''',[soBackslashEscapes]);
1580  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1581  AssertEquals('Correct string',#12,FScanner.CurTokenString);
1582end;
1583
1584procedure TTestSQLScanner.TestOptionsoBackslashEscapesSlash;
1585begin
1586  CreateScanner('''\/''',[soBackslashEscapes]);
1587  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1588  AssertEquals('Correct string','/',FScanner.CurTokenString);
1589end;
1590
1591procedure TTestSQLScanner.TestOptionsoBackslashEscapesBackspace;
1592
1593begin
1594  CreateScanner('''\f''',[soBackslashEscapes]);
1595  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1596  AssertEquals('Correct string',#12,FScanner.CurTokenString);
1597end;
1598
1599procedure TTestSQLScanner.TestOptionsoBackslashEscapesQuote;
1600
1601begin
1602  CreateScanner('''\''''',[soBackslashEscapes]);
1603  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1604  AssertEquals('Correct string','''',FScanner.CurTokenString);
1605end;
1606
1607procedure TTestSQLScanner.TestOptionsoBackslashEscapesDoubleQuote;
1608begin
1609  CreateScanner('''\"''',[soBackslashEscapes]);
1610  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1611  AssertEquals('Correct string','"',FScanner.CurTokenString);
1612end;
1613
1614procedure TTestSQLScanner.TestOptionNosoBackslashEscapes;
1615begin
1616  CreateScanner('''\"''',[]);
1617  AssertEquals('String is returned',tsqlString,FScanner.FetchToken);
1618  AssertEquals('Correct string','\"',FScanner.CurTokenString);
1619end;
1620
1621
1622initialization
1623
1624  RegisterTest(TTestSQLScanner);
1625end.
1626