PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 0ms

/deps/glm-0.9.4.0/test/gtc/gtc_type_precision.cpp

https://bitbucket.org/sturmh/dirtygraphics
C++ | 169 lines | 150 code | 11 blank | 8 comment | 95 complexity | d61672bb833112b89bbedf461e23fd92 MD5 | raw file
  1///////////////////////////////////////////////////////////////////////////////////////////////////
  2// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
  3///////////////////////////////////////////////////////////////////////////////////////////////////
  4// Created : 2010-09-16
  5// Updated : 2011-05-08
  6// Licence : This source is under MIT licence
  7// File    : test/gtc/type_precision.cpp
  8///////////////////////////////////////////////////////////////////////////////////////////////////
  9
 10#include <glm/glm.hpp>
 11#include <glm/gtc/type_precision.hpp>
 12
 13static int test_scalar_size()
 14{
 15	int Error = 0;
 16    Error += sizeof(glm::int8) != 1;
 17    Error += sizeof(glm::int16) != 2;
 18    Error += sizeof(glm::int32) != 4;
 19    Error += sizeof(glm::int64) != 8;
 20    Error += sizeof(glm::uint8) != 1;
 21    Error += sizeof(glm::uint16) != 2;
 22    Error += sizeof(glm::uint32) != 4;
 23    Error += sizeof(glm::uint64) != 8;
 24    Error += sizeof(glm::float16) != 2;
 25    Error += sizeof(glm::float32) != 4;
 26    Error += sizeof(glm::float64) != 8;
 27	return Error;
 28}
 29
 30static int test_fvec_size()
 31{
 32    int Error = 0;
 33    Error += sizeof(glm::f16vec2) != 4;
 34    Error += sizeof(glm::f16vec3) != 6;
 35    Error += sizeof(glm::f16vec4) != 8;
 36    Error += sizeof(glm::f32vec2) != 8;
 37    Error += sizeof(glm::f32vec3) != 12;
 38    Error += sizeof(glm::f32vec4) != 16;
 39    Error += sizeof(glm::f64vec2) != 16;
 40    Error += sizeof(glm::f64vec3) != 24;
 41    Error += sizeof(glm::f64vec4) != 32;
 42	return Error;
 43}
 44
 45static int test_ivec_size()
 46{
 47    int Error = 0;
 48    Error += sizeof(glm::i8vec2) != 2;
 49    Error += sizeof(glm::i8vec3) != 3;
 50    Error += sizeof(glm::i8vec4) != 4;
 51    Error += sizeof(glm::i16vec2) != 4;
 52    Error += sizeof(glm::i16vec3) != 6;
 53    Error += sizeof(glm::i16vec4) != 8;
 54    Error += sizeof(glm::i32vec2) != 8;
 55    Error += sizeof(glm::i32vec3) != 12;
 56    Error += sizeof(glm::i32vec4) != 16;
 57    Error += sizeof(glm::i64vec2) != 16;
 58    Error += sizeof(glm::i64vec3) != 24;
 59    Error += sizeof(glm::i64vec4) != 32;
 60	return Error;
 61}
 62
 63static int test_uvec_size()
 64{
 65    int Error = 0;
 66    Error += sizeof(glm::u8vec2) != 2;
 67    Error += sizeof(glm::u8vec3) != 3;
 68    Error += sizeof(glm::u8vec4) != 4;
 69    Error += sizeof(glm::u16vec2) != 4;
 70    Error += sizeof(glm::u16vec3) != 6;
 71    Error += sizeof(glm::u16vec4) != 8;
 72    Error += sizeof(glm::u32vec2) != 8;
 73    Error += sizeof(glm::u32vec3) != 12;
 74    Error += sizeof(glm::u32vec4) != 16;
 75    Error += sizeof(glm::u64vec2) != 16;
 76    Error += sizeof(glm::u64vec3) != 24;
 77    Error += sizeof(glm::u64vec4) != 32;
 78	return Error;
 79}
 80
 81static int test_hmat_size()
 82{
 83    int Error = 0;
 84    Error += sizeof(glm::f16mat2) != 8;
 85    Error += sizeof(glm::f16mat3) != 18;
 86    Error += sizeof(glm::f16mat4) != 32;
 87    Error += sizeof(glm::f16mat2x2) != 8;
 88    Error += sizeof(glm::f16mat2x3) != 12;
 89    Error += sizeof(glm::f16mat2x4) != 16;
 90    Error += sizeof(glm::f16mat3x2) != 12;
 91    Error += sizeof(glm::f16mat3x3) != 18;
 92    Error += sizeof(glm::f16mat3x4) != 24;
 93    Error += sizeof(glm::f16mat4x2) != 16;
 94    Error += sizeof(glm::f16mat4x3) != 24;
 95    Error += sizeof(glm::f16mat4x4) != 32;
 96	return Error;
 97}
 98
 99static int test_fmat_size()
100{
101    int Error = 0;
102    Error += sizeof(glm::fmat2) != 16;
103    Error += sizeof(glm::fmat3) != 36;
104    Error += sizeof(glm::fmat4) != 64;
105    Error += sizeof(glm::fmat2x2) != 16;
106    Error += sizeof(glm::fmat2x3) != 24;
107    Error += sizeof(glm::fmat2x4) != 32;
108    Error += sizeof(glm::fmat3x2) != 24;
109    Error += sizeof(glm::fmat3x3) != 36;
110    Error += sizeof(glm::fmat3x4) != 48;
111    Error += sizeof(glm::fmat4x2) != 32;
112    Error += sizeof(glm::fmat4x3) != 48;
113    Error += sizeof(glm::fmat4x4) != 64;
114
115    Error += sizeof(glm::f32mat2) != 16;
116    Error += sizeof(glm::f32mat3) != 36;
117    Error += sizeof(glm::f32mat4) != 64;
118    Error += sizeof(glm::f32mat2x2) != 16;
119    Error += sizeof(glm::f32mat2x3) != 24;
120    Error += sizeof(glm::f32mat2x4) != 32;
121    Error += sizeof(glm::f32mat3x2) != 24;
122    Error += sizeof(glm::f32mat3x3) != 36;
123    Error += sizeof(glm::f32mat3x4) != 48;
124    Error += sizeof(glm::f32mat4x2) != 32;
125    Error += sizeof(glm::f32mat4x3) != 48;
126    Error += sizeof(glm::f32mat4x4) != 64;
127	return Error;
128}
129
130static int test_dmat_size()
131{
132    int Error = 0;
133    Error += sizeof(glm::f64mat2) != 32;
134    Error += sizeof(glm::f64mat3) != 72;
135    Error += sizeof(glm::f64mat4) != 128;
136    Error += sizeof(glm::f64mat2x2) != 32;
137    Error += sizeof(glm::f64mat2x3) != 48;
138    Error += sizeof(glm::f64mat2x4) != 64;
139    Error += sizeof(glm::f64mat3x2) != 48;
140    Error += sizeof(glm::f64mat3x3) != 72;
141    Error += sizeof(glm::f64mat3x4) != 96;
142    Error += sizeof(glm::f64mat4x2) != 64;
143    Error += sizeof(glm::f64mat4x3) != 96;
144    Error += sizeof(glm::f64mat4x4) != 128;
145	return Error;
146}
147
148static int test_quat_size()
149{
150    int Error = 0;
151    Error += sizeof(glm::f16quat) != 8; 
152    Error += sizeof(glm::f32quat) != 16; 
153    Error += sizeof(glm::f64quat) != 32;
154	return Error;
155}
156
157int main()
158{
159	int Error = 0;
160    Error += test_scalar_size();
161	Error += test_fvec_size();
162    Error += test_ivec_size();
163	Error += test_uvec_size();
164	Error += test_hmat_size();
165	Error += test_fmat_size();
166	Error += test_dmat_size();
167	Error += test_quat_size();
168	return Error;
169}