Skip to content

Commit

Permalink
add a test for the recent glew accessor functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Feb 20, 2017
1 parent 907ae2c commit 5c0b679
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions t/02_glew_version_accessors.t
@@ -0,0 +1,42 @@
#! /usr/bin/perl

use strict;
use warnings;
use Test::More;
use OpenGL::Modern ':all';
use OpenGL::Modern::Helpers 'glGetVersion_p';

SKIP: {
skip "glewContext did not succeed, skipping live tests", 1
unless glewCreateContext() == GLEW_OK; # returns GL_TRUE or GL_FALSE

my $gI_status = ( done_glewInit() ) ? GLEW_OK() : glewInit(); # returns GLEW_OK or ???
skip "glewInit did not succeed, skipping live tests", 1 unless $gI_status == GLEW_OK;

my @version_pairs = (
[ GLEW_VERSION_1_1, 1.1 ],
[ GLEW_VERSION_1_2, 1.2 ],
[ GLEW_VERSION_1_3, 1.3 ],
[ GLEW_VERSION_1_4, 1.4 ],
[ GLEW_VERSION_1_5, 1.5 ],
[ GLEW_VERSION_2_0, 2.0 ],
[ GLEW_VERSION_2_1, 2.1 ],
[ GLEW_VERSION_3_0, 3.0 ],
[ GLEW_VERSION_3_1, 3.1 ],
[ GLEW_VERSION_3_2, 3.2 ],
[ GLEW_VERSION_3_3, 3.3 ],
[ GLEW_VERSION_4_0, 4.0 ],
[ GLEW_VERSION_4_1, 4.1 ],
[ GLEW_VERSION_4_2, 4.2 ],
[ GLEW_VERSION_4_3, 4.3 ],
[ GLEW_VERSION_4_4, 4.4 ],
[ GLEW_VERSION_4_5, 4.5 ],
);
my $version = glGetVersion_p;
$_->[2] = $version >= $_->[1] ? 1 : 0 for @version_pairs;

is $_->[0], $_->[2], sprintf "glew version %.1f reported correctly as $_->[2] for $version", $_->[1] #
for @version_pairs;

done_testing;
}

0 comments on commit 5c0b679

Please sign in to comment.