Debian Codegraph @

tests/code/testcases/testcastlecurves.pas

raw
1 // -*- compile-command: "./test_single_testcase.sh TTestCastleCurves" -*-
2 {
3 Copyright 2016-2021 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" 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 ----------------------------------------------------------------------------
15 }
16
17 { Test CastleCurves unit. }
18 unit TestCastleCurves;
19
20 interface
21
22 uses CastleTester;
23
24 type
25 TTestCastleCurves = class(TCastleTestCase)
26 published
27 procedure TestBoundingBox;
28 end;
29
30 implementation
31
32 uses SysUtils, Classes, Math,
33 CastleVectors, CastleUtils, CastleCurves, CastleBoxes;
34
35 procedure TTestCastleCurves.TestBoundingBox;
36 var
37 Curve: TPiecewiseCubicBezier;
38 begin
39 Curve := TPiecewiseCubicBezier.Create;
40 try
41 AssertBoxesEqual(TBox3D.Empty, Curve.BoundingBox);
42 Curve.UpdateControlPoints;
43 AssertBoxesEqual(TBox3D.Empty, Curve.BoundingBox); // still empty
44
45 Curve.ControlPoints.Add(Vector3(3, 4, 5));
46 Curve.ControlPoints.Add(Vector3(33, 44, 54));
47 Curve.UpdateControlPoints;
48 AssertBoxesEqual(Box3D(
49 Vector3(3, 4, 5),
50 Vector3(33, 44, 54)), Curve.BoundingBox);
51 finally FreeAndNil(Curve) end;
52 end;
53
54 initialization
55 RegisterTest(TTestCastleCurves);
56 end.