File: testglversion.pas

package info (click to toggle)
castle-game-engine 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 164,776 kB
  • ctags: 30,841
  • sloc: pascal: 168,882; cpp: 1,340; objc: 730; makefile: 492; sh: 477; xml: 434; php: 1
file content (118 lines) | stat: -rw-r--r-- 3,024 bytes parent folder | download
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
{ -*- compile-command: "./compile_console.sh" -*- }
{
  Copyright 2008-2014 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.

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

unit TestGLVersion;

interface

uses fpcunit, testutils, testregistry;

type
  TTestGLVersion = class(TTestCase)
  published
    procedure Test1;
  end;

implementation

uses SysUtils, CastleGLVersion;

procedure TTestGLVersion.Test1;
var
  G: TGLVersion;
begin
  G := TGLVersion.Create('1.4 (2.1 Mesa 7.0.4)',
    'Mesa project: www.mesa3d.org', 'Mesa GLX Indirect');
  try
    Assert(G.VendorInfo = '(2.1 Mesa 7.0.4)');
    Assert(G.Vendor = 'Mesa project: www.mesa3d.org');
    Assert(G.Renderer = 'Mesa GLX Indirect');

    Assert(G.Major = 1);
    Assert(G.Minor = 4);

    { Test AtLeast method }
    Assert(G.AtLeast(0, 9));
    Assert(G.AtLeast(1, 0));
    Assert(G.AtLeast(1, 3));
    Assert(G.AtLeast(1, 4));
    Assert(not G.AtLeast(1, 5));
    Assert(not G.AtLeast(2, 0));

    Assert(not G.ReleaseExists);

    Assert(G.Mesa);
    Assert(G.VendorMajor = 7);
    Assert(G.VendorMinor = 0);
    Assert(G.VendorRelease = 4);
  finally FreeAndNil(G) end;

  G := TGLVersion.Create('2.1 Mesa 7.1', 'Brian Paul',
    'Mesa DRI Intel(blah blah blah)');
  try
    Assert(G.VendorInfo = 'Mesa 7.1');
    Assert(G.Vendor = 'Brian Paul');
    Assert(G.Renderer = 'Mesa DRI Intel(blah blah blah)');

    Assert(G.Major = 2);
    Assert(G.Minor = 1);

    Assert(not G.ReleaseExists);

    Assert(G.Mesa);
    Assert(G.VendorMajor = 7);
    Assert(G.VendorMinor = 1);
    Assert(G.VendorRelease = 0);
  finally FreeAndNil(G) end;

  G := TGLVersion.Create('1.2.3', 'foobar', '');
  try
    Assert(G.VendorInfo = '');
    Assert(G.Vendor = 'foobar');
    Assert(G.Renderer = '');

    Assert(G.Major = 1);
    Assert(G.Minor = 2);
    Assert(G.ReleaseExists);
    Assert(G.Release = 3);
    Assert(not G.Mesa);
  finally FreeAndNil(G) end;

  G := TGLVersion.Create('4.2.0 NVIDIA 304.108', 'NVIDIA Corporation', 'GeForce GTS 450/PCIe/SSE2/3DNOW!');
  try
    AssertEquals('NVIDIA 304.108', G.VendorInfo);
    AssertEquals('NVIDIA Corporation', G.Vendor);
    AssertEquals('GeForce GTS 450/PCIe/SSE2/3DNOW!', G.Renderer);

    AssertEquals(4, G.Major);
    AssertEquals(2, G.Minor);
    AssertEquals(true, G.ReleaseExists);
    AssertEquals(0, G.Release);

    AssertEquals(304, G.VendorMajor);
    AssertEquals(108, G.VendorMinor);
    AssertEquals(0, G.VendorRelease);

    Assert(not G.Mesa);
    Assert(not G.VendorATI);
    Assert(not G.VendorIntel);
    Assert(G.VendorNVidia);
  finally FreeAndNil(G) end;
end;

initialization
  RegisterTest(TTestGLVersion);
end.