Debian Codegraph @

tools/build-tool/tests/testtoolmanifest.pas

raw
1 {
2 Copyright 2024-2024 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Automatic tests of ToolManifest unit. }
17 unit TestToolManifest;
18
19 interface
20
21 uses
22 Classes, SysUtils, CastleTester,
23 ToolManifest;
24
25 type
26 TTestToolManifest = class(TCastleTestCase)
27 published
28 procedure TestStandaloneSourceToProgramName;
29 procedure TestCheckExecutableName;
30 end;
31
32 implementation
33
34 uses CastleLog;
35
36 procedure TTestToolManifest.TestStandaloneSourceToProgramName;
37 begin
38 AssertEquals('my_program', TCastleManifest.StandaloneSourceToProgramName('my_program.lpr'));
39 AssertEquals('my_program', TCastleManifest.StandaloneSourceToProgramName('code/my_program.lpr'));
40 end;
41
42 procedure TTestToolManifest.TestCheckExecutableName;
43 begin
44 TCastleManifest.CheckExecutableName('my_program');
45 TCastleManifest.CheckExecutableName('model-program');
46 TCastleManifest.CheckExecutableName('样例中文文本');
47 TCastleManifest.CheckExecutableName('my program');
48
49 try
50 TCastleManifest.CheckExecutableName('slash/not/allowed');
51 Fail('Should fail');
52 except
53 on E: Exception do
54 WritelnLog('Valid exception: ' + E.Message);
55 end;
56
57 try
58 TCastleManifest.CheckExecutableName('bashslash\not allowed');
59 Fail('Should fail');
60 except
61 on E: Exception do
62 WritelnLog('Valid exception: ' + E.Message);
63 end;
64
65 try
66 TCastleManifest.CheckExecutableName('as:,');
67 Fail('Should fail');
68 except
69 on E: Exception do
70 WritelnLog('Valid exception: ' + E.Message);
71 end;
72 end;
73
74 initialization
75 RegisterTest(TTestToolManifest);
76 end.