File: testcastleparameters.pas

package info (click to toggle)
castle-game-engine 7.0~alpha.3%2Bdfsg2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 969,476 kB
  • sloc: pascal: 911,523; javascript: 28,186; cpp: 14,157; xml: 9,939; ansic: 9,229; java: 3,653; objc: 2,737; sh: 1,214; makefile: 657; php: 65; lisp: 21; ruby: 8
file content (504 lines) | stat: -rw-r--r-- 21,339 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
// -*- compile-command: "./test_single_testcase.sh TTestParsingParameters" -*-
{
  Copyright 2004-2023 Michalis Kamburelis.

  This file is part of "Castle Game Engine".

  "Castle Game Engine" is free software; see the file COPYING.txt,
  included in this distribution, for details about the copyright.

  "Castle Game Engine" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  ----------------------------------------------------------------------------
}

{ Test CastleParameters unit. }
unit TestCastleParameters;

interface

uses Classes, SysUtils,
  CastleTester, CastleParameters, CastleUtils;

type
  TParsedOption = record
    OptionNum: Integer;
    HasArgument: boolean;
    Argument: string;
    SeparateArgs: TSeparateArgs;
  end;
  PParsedOption = ^TParsedOption;
  TParsedOptionList = {$ifdef FPC}specialize{$endif} TStructList<TParsedOption>;

  TTestParsingParameters = class(TCastleTestCase)
  private
    procedure AssertParsEqual(const ParsValues: array of string; const ParsTestName: string);
    procedure AssertParsedParsEqual(const ParsedPars1: TParsedOptionList;
      const ParsedPars2: array of TParsedOption; const ParsTestName: string);
  published
    procedure TestParsingParameters;
    procedure TestOptionDescription;
  end;

implementation

uses CastleStringUtils, CastleLog;

procedure ParseNextParam(OptionNum: Integer; HasArgument: boolean;
  const Argument: string; const SeparateArgs: TSeparateArgs; Data: Pointer);
var
  ParsedArray: TParsedOptionList absolute Data;
  LastItem: PParsedOption;
begin
  LastItem := PParsedOption(ParsedArray.Add);
  LastItem^.OptionNum := OptionNum;
  LastItem^.HasArgument := HasArgument;
  LastItem^.Argument := Argument;
  LastItem^.SeparateArgs := SeparateArgs;
end;

{ Parse command-line parameters returning a list of parsed options.
  Works exactly like previous TParameters.Parse procedure,
  but instead of using a callback like OptionProc, this time
  it returns a list.
  @groupBegin }
function ParseParameters(
  Options: POption_Array; OptionsCount: Integer;
  ParseOnlyKnownOptions: boolean = false): TParsedOptionList; overload;
begin
  result := TParsedOptionList.Create;
  try
    Parameters.Parse(Options, OptionsCount,
      {$ifdef FPC}@{$endif}ParseNextParam, result,
      ParseOnlyKnownOptions);
  except result.Free; raise end;
end;

function ParseParameters(
  const Options: array of TOption; ParseOnlyKnownOptions: boolean = false): TParsedOptionList; overload;
begin
 result := ParseParameters(@Options, High(Options) + 1, ParseOnlyKnownOptions);
end;

procedure TTestParsingParameters.AssertParsEqual(const ParsValues: array of string;
  const ParsTestName: string);
var
  I: Integer;
begin
  AssertEquals('Parameters Count at ' + ParsTestName, High(ParsValues), Parameters.High);
  for I := 0 to Parameters.High do
    AssertEquals('Parameters Values at ' + ParsTestName, Parameters[I], ParsValues[I]);
end;

procedure TTestParsingParameters.AssertParsedParsEqual(const ParsedPars1: TParsedOptionList;
  const ParsedPars2: array of TParsedOption; const ParsTestName: string);
var
  I, J: Integer;
begin
  AssertEquals('Count at ' + ParsTestName, High(ParsedPars2), ParsedPars1.Count - 1);
  for I := 0 to ParsedPars1.Count - 1 do
  begin
    AssertEquals('OptionNum at '   + ParsTestName, ParsedPars1.L[I].OptionNum  , ParsedPars2[I].OptionNum  );
    AssertEquals('HasArgument at ' + ParsTestName, ParsedPars1.L[I].HasArgument, ParsedPars2[I].HasArgument);
    AssertEquals('Argument at '    + ParsTestName, ParsedPars1.L[I].Argument   , ParsedPars2[I].Argument   );
    for J := Low(TSeparateArgs) to High(TSeparateArgs) do
      AssertEquals('SeparateArgs at ' + ParsTestName, ParsedPars1.L[I].SeparateArgs[J], ParsedPars2[I].SeparateArgs[J]);
  end;
end;

procedure TTestParsingParameters.TestParsingParameters;

  function DynParsedOptionArrayToStr(const Name: string;
    V: TParsedOptionList): string;
  var
    I: Integer;
  begin
    Result := Name + NL;
    for I := 0 to v.Count - 1 do
      Result := Result + Format('  [%d] OptionNum %d, HasArg %s, Argument "%s"',  [
        I,
        v.L[I].OptionNum,
        BoolToStr(v.L[I].HasArgument, true),
        v.L[I].Argument
      ]) + NL;
  end;

  function ParsToStr: String;
  var
    I: Integer;
  begin
    Result := 'Params now = ' + NL;
    for I := 0 to Parameters.High do
      Result := Result + Format('  ParStr(%d) = "%s"', [I, Parameters[I]]) + NL;
  end;

  procedure CheckPars(const TestName: string; const StartPars: array of string;
    const Options: array of TOption;
    const GoodAnswer: array of TParsedOption; const GoodRest: array of string;
    ParseOnlyKnownOptions: boolean);
  var
    Answer: TParsedOptionList;
  begin
    Parameters.AssignArray(StartPars);
    AssertParsEqual(StartPars, TestName);

    try
      Answer := ParseParameters(Options, ParseOnlyKnownOptions);
    except
      Fail('TestParsingParameters:' + TestName + ': Failed, unexpected exception');
      raise;
    end;

    try
      try
        AssertParsedParsEqual(Answer, GoodAnswer, TestName);
        AssertParsEqual(GoodRest, TestName);
      except
        Fail('TestParsingParameters:' + TestName + ': Failed on testcase:' + NL +
          DynParsedOptionArrayToStr('Answer', Answer) + NL +
          ParsToStr
        );
        raise;
      end;
    finally Answer.Free end;
  end;

  procedure CheckParsFail(TestName: string; const StartPars: array of string;
    const Options: array of TOption; EClass: ExceptClass; const EMessage: string);
  var
    Answer: TParsedOptionList;
  begin
    Parameters.AssignArray(StartPars);
    AssertParsEqual(StartPars, TestName);

    try
      Answer := ParseParameters(Options);
      try
        Fail('TestParsingParameters:' + TestName + ': Should have raised an exception, but succeeded: ' + NL +
          DynParsedOptionArrayToStr('Answer', Answer) + NL +
          ParsToStr
        );
      finally Answer.Free end;
    except
      on E: Exception do
      begin
        if not (E is EClass) then
          raise { exception classes other than EClass are left to crash the test. }
        else
        if EMessage = '' then
          WriteLnLog('TestParsingParameters:' + TestName + ': OK, exception as expected. Any message allowed. Current message: ' + E.Message)
        else
          AssertEquals(EMessage, E.Message);
          //AssertEquals(EMessage, E.Message, 'TestParsingParameters:' + TestName + ': Exception as expected, but invalid message');
      end;
    end;
  end;

const
  { Pars1_2 ------------------------------------------------------------ }

  Pars1_2Question: array[0..4]of string =
  ('--zero-niewazne', 'ala', '--mama', 'teresa', '--kot-kocur=cygan');

  Pars1: array[0..3]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:#0; Long:'kot'; Argument: oaOptional),
    (Short:#0; Long:'kot-kocur'; Argument: oaOptional),
    (Short:'a'; Long:'ala'; Argument: oaNone)
  );
  Pars1Answer: array[0..1]of TParsedOption = (
    (OptionNum:0; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:2; HasArgument: true; Argument:'cygan'; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars1Rest: array[0..2]of string = ('--zero-niewazne', 'ala', 'teresa');

  Pars2: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaRequired),
    (Short:#0; Long:'kot-kocur'; Argument: oaOptional),
    (Short:'a'; Long:'ala'; Argument: oaNone)
  );
  Pars2Answer: array[0..1]of TParsedOption = (
    (OptionNum:0; HasArgument: true; Argument:'teresa'; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:1; HasArgument: true; Argument:'cygan'; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars2Rest: array[0..1]of string = ('--zero-niewazne', 'ala');

  { Pars3 ------------------------------------------------------------ }

  Pars3Question: array[0..8]of string =
  ('-l=no', 'ala', '-l', '-l=foo nie=l', '--mama', '--', 'teresa', '--kot=cygan', '--');

  Pars3: array[0..3]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:#0; Long:'kot'; Argument: oaOptional),
    (Short:'a'; Long:'ala'; Argument: oaNone),
    (Short:'l'; Long:'lollobrygida'; Argument: oaOptional)
  );
  Pars3Answer: array[0..2]of TParsedOption = (
    (OptionNum:3; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:3; HasArgument: true; Argument:'foo nie=l'; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:0; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars3Rest: array[0..4]of string = ('-l=no', 'ala', 'teresa', '--kot=cygan', '--');

  { Pars4_5 ------------------------------------------------------------ }

  Pars4_5Question: array[0..2]of string = ('-nic', '--ala spacja', '--kot');
  Pars45Rest: array[0..0]of string = ('-nic');

  Pars4: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:#0; Long:'kot'; Argument: oaOptional),
    (Short:'a'; Long:'ala spacja'; Argument: oaNone)
  );
  Pars4Answer: array[0..1]of TParsedOption = (
    (OptionNum:2; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:1; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','',''))
  );

  Pars5: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:#0; Long:'kot'; Argument: oaOptional),
    (Short:'a'; Long:'ala spacja'; Argument: oaRequired)
  );
  Pars5Answer: array[0..0]of TParsedOption = (
    (OptionNum:2; HasArgument: true; Argument:'--kot'; SeparateArgs: ('','','', '','','', '','',''))
  );

  { Pars6 ------------------------------------------------------------ }

  Pars6Question: array[0..4]of string = ('--zero-niewazne', '--ala spacja', '-ma', '--kot', '-m');
  Pars6: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'a'; Long:'ala spacja'; Argument: oaNone)
  );

  { '--kot' powinien zostac zignorowany jesli uruchomimy z ParseOnlyKnownOptions.
    Podobnie '-ma' (mimo ze -m i -a są znane to są combined short option,
    not supported when ParseOnlyKnownOptions).
    Jednak '--ala spacja' powinno zostac sparsowane i usuniete, oraz '-m'. }
  Pars6_OnlyKnown_Answer: array[0..1]of TParsedOption = (
    (OptionNum:1; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:0; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars6_OnlyKnown_Rest: array[0..2]of string =
  ('--zero-niewazne', '-ma', '--kot');

  { Pars7 ------------------------------------------------------------ }

  Pars7Question: array[0..2]of string = ('zero', '-a', '-k');
  Pars7: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'a'; Long:'ala spacja'; Argument: oaNone)
  );

  { Pars8 ------------------------------------------------------------ }

  Pars8Question: array[0..2]of string = ('hehe', '--=ala spacja', '--kot');
  Pars8: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'a'; Long:'ala spacja'; Argument: oaRequired)
  );

  { Pars9 ------------------------------------------------------------ }

  Pars9Question: array[0..2]of string = ('foo', 'blah', '--kot');
  Pars9: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaRequired)
  );

  { Pars10 ------------------------------------------------------------ }

  Pars10Question: array[0..0]of string = ('--kot=blah');
  Pars10: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone)
  );
  Pars10Rest: array[0..0]of string = ('--kot=blah');

  { Pars11 ------------------------------------------------------------ }

  Pars11Question: array[0..1]of string = ('ble', '--kot=blah');
  Pars11: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone)
  );

  { Pars12 ------------------------------------------------------------ }

  Pars12Question: array[0..1]of string = ('ble', '-=blah');
  Pars12: array[0..1]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone)
  );

  { Pars13 ------------------------------------------------------------ }

  Pars13Question: array[0..4]of string = ('--ble', '--ble', '1 ', '2', '3');
  Pars13: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone),
    (Short:'b'; Long:'ble'; Argument: oaRequired2Separate)
  );
  Pars13Answer: array[0..0]of TParsedOption = (
    (OptionNum:2; HasArgument: false; Argument:''; SeparateArgs:('1 ','2','', '','','', '','',''))
  );
  Pars13Rest: array[0..1]of string = ('--ble', '3');

  { Pars14 ------------------------------------------------------------ }

  Pars14Question: array[0..4]of string = ('--ble', '--ble', '1 ', '2', '3');
  Pars14: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone),
    (Short:'b'; Long:'ble'; Argument: oaRequired3Separate)
  );
  Pars14Answer: array[0..0]of TParsedOption = (
    (OptionNum:2; HasArgument: false; Argument:''; SeparateArgs:('1 ', '2', '3', '','','', '','',''))
  );
  Pars14Rest: array[0..0]of string = ('--ble');

  { Pars15 ------------------------------------------------------------ }

  Pars15Question: array[0..4]of string = ('--ble', '--ble', '1 ', '2', '3');
  Pars15: array[0..2]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'kot'; Argument: oaNone),
    (Short:'b'; Long:'ble'; Argument: oaRequired4Separate)
  );

  { Pars16 ------------------------------------------------------------ }

  { '-' is not errorneous "empty short option", it is treated as usual
    non-option parameter. '' is harmless too. }
  Pars16Question: array[0..2]of string = ('ble', '-', '');
  Pars16: array[0..0]of TOption = (
    (Short:'b'; Long:'ble'; Argument: oaRequired3Separate)
  );
  Pars16Rest: array[0..2]of string = ('ble', '-', '');

  { Pars17 ------------------------------------------------------------ }

  { #0 is not allowed as short option (Short = #0 means "no short form for this
    option exists") }
  Pars17Question: array[0..1]of string = ('--ble', '-'#0);
  Pars17: array[0..0]of TOption = (
    (Short:#0; Long:'mama'; Argument: oaOptional)
  );

  { Pars18 ------------------------------------------------------------- }

  { combining short options works. Arguments for last option are allowed. }
  Pars18Question: array[0..4]of string = ('-zero', '-abc', '--rere', 'blabla', '-abc=foo');
  Pars18: array[0..2]of TOption = (
    (Short:'a'; Long:'ania'; Argument: oaOptional),
    (Short:'b'; Long:'basia'; Argument: oaOptional),
    (Short:'c'; Long:'cycek'; Argument: oaRequired)
  );
  Pars18Answer: array[0..5]of TParsedOption = (
    (OptionNum:0; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:1; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:2; HasArgument: true; Argument:'--rere'; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:0; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:1; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:2; HasArgument: true; Argument:'foo'; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars18Rest: array[0..1]of string = ('-zero', 'blabla');

  { Pars19 -------------------------------------------------------------- }

  { specyfying argument for paReuired?Separate is not allowed }
  Pars19Question: array[0..3]of string = ('', '--baba=kobita', '1', '2');
  Pars19: array[0..0]of TOption = (
    (Short:'a'; Long:'baba'; Argument: oaRequired2Separate)
  );

  { Pars20 ----------------------------------------------------------------- }

  { ParseOnlyKnownOptions parses short options, although not combined ones.
    Leaves the rest (unknown options (long and short), and combined short options
    (regardless if known or not)).
    Honors also -- and doesn't interpret things afterwards, although doesn't remove --. }
  Pars20Question: array[0..8]of string = ('--bar', '-sb=xyz', '--ble=xyz', '-s', '--1', '2', '--foo', '--', '--1');
  Pars20: array[0..3]of TOption = (
    (Short:'m'; Long:'mama'; Argument: oaOptional),
    (Short:'k'; Long:'1'; Argument: oaRequired),
    (Short:'b'; Long:'ble'; Argument: oaRequired),
    (Short:'s'; Long:'something'; Argument: oaNone)
  );
  Pars20_OnlyKnown_Answer: array[0..2]of TParsedOption = (
    (OptionNum:2; HasArgument: true; Argument:'xyz'; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:3; HasArgument: false; Argument:''; SeparateArgs: ('','','', '','','', '','','')),
    (OptionNum:1; HasArgument: true; Argument:'2'; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars20_OnlyKnown_Rest: array[0..4]of string = ('--bar', '-sb=xyz', '--foo', '--', '--1');

  { Pars21 ----------------------------------------------------------------- }

  Pars21Question: array[0..2]of string =
  ('glplotter.exe', '--grid-custom', '12');
  Pars21: array[0..3] of TOption = (
    (Short:'h'; Long:'help'; Argument: oaNone),
    (Short:#0; Long:'grid-custom'; Argument: oaRequired),
    (Short:#0; Long:'light'; Argument: oaNone),
    (Short:#0; Long:'dark'; Argument: oaNone)
  );
  Pars21Answer: array[0..0]of TParsedOption = (
    (OptionNum:1; HasArgument: true; Argument:'12'; SeparateArgs: ('','','', '','','', '','',''))
  );
  Pars21Rest: array[0..0]of string = ('glplotter.exe');

begin
  CheckPars('1', Pars1_2Question, Pars1, Pars1Answer, Pars1Rest, false);
  CheckPars('2', Pars1_2Question, Pars2, Pars2Answer, Pars2Rest, false);
  CheckPars('3', Pars3Question, Pars3, Pars3Answer, Pars3Rest, false);
  CheckPars('4', Pars4_5Question, Pars4, Pars4Answer, Pars45Rest, false);
  CheckPars('5', Pars4_5Question, Pars5, Pars5Answer, Pars45Rest, false);

  CheckParsFail('6', Pars6Question, Pars6, EInvalidLongOption, 'Invalid long option "--kot"');
  CheckPars('6_OnlyKnown', Pars6Question, Pars6, Pars6_OnlyKnown_Answer, Pars6_OnlyKnown_Rest, true);
  CheckParsFail('7', Pars7Question, Pars7, EInvalidShortOption, 'Invalid short option character "k" in parameter "-k"');
  CheckParsFail('8', Pars8Question, Pars8, EInvalidParams, 'Invalid empty parameter "--=ala spacja"');
  CheckParsFail('9', Pars9Question, Pars9, EMissingOptionArgument, 'Missing argument for option --kot');
  CheckPars('10', Pars10Question, Pars10, [], Pars10Rest, false);
  CheckParsFail('11', Pars11Question, Pars11, EExcessiveOptionArgument, 'Excessive argument for option --kot');
  CheckParsFail('12', Pars12Question, Pars12, EInvalidParams, 'Invalid empty parameter "-=blah"');

  CheckPars('13', Pars13Question, Pars13, Pars13Answer, Pars13Rest, false);
  CheckPars('14', Pars14Question, Pars14, Pars14Answer, Pars14Rest, false);
  CheckParsFail('15', Pars15Question, Pars15, EMissingOptionArgument, 'Not enough arguments for option --ble, this option needs 4 arguments but we have only 3');
  CheckPars('16', Pars16Question, Pars16, [], Pars16Rest, false);
  CheckParsFail('17', Pars17Question, Pars17, EInvalidShortOption, 'Invalid short option character "#0 (null char)" in parameter "-'#0'"');
  CheckPars('18', Pars18Question, Pars18, Pars18Answer, Pars18Rest, false);
  CheckParsFail('19', Pars19Question, Pars19, EExcessiveOptionArgument, 'Option --baba requires 2 arguments, you cannot give them using the form --option=argument, you must give all the arguments as separate parameters');
  CheckPars('20_OnlyKnown', Pars20Question, Pars20, Pars20_OnlyKnown_Answer, Pars20_OnlyKnown_Rest, true);
  CheckPars('21', Pars21Question, Pars21, Pars21Answer, Pars21Rest, false);
end;

procedure TTestParsingParameters.TestOptionDescription;
begin
  AssertEquals(
    '  --fast                Do not "clean"' + NL +
    '                        before "package". Recompile only what changed. This' + NL +
    '                        is faster for development, but cannot guarantee' + NL +
    '                        that everything is recompiled in a release mode.',
    OptionDescription('--fast',
      'Do not "clean"' + NL + 'before "package". Recompile only what changed. This is faster for development, but cannot guarantee that everything is recompiled in a release mode.')
  );

  AssertEquals(
    '  --fast                Do not "clean" before "package". Recompile only' + NL +
    '                        what changed. This is faster for development, but' + NL +
    '                        cannot guarantee that everything is recompiled in a' + NL +
    '                        release mode.',
    OptionDescription('--fast',
      'Do not "clean" before "package". Recompile only what changed. This is faster for development, but cannot guarantee that everything is recompiled in a release mode.')
  );
end;

initialization
  RegisterTest(TTestParsingParameters);
end.