1 #include <glm/glm.hpp>
2 
3 #if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
4 
5 #include <glm/gtc/constants.hpp>
6 #include <glm/gtc/quaternion.hpp>
7 #include <glm/gtc/vec1.hpp>
8 #include <glm/ext/matrix_relational.hpp>
9 #include <glm/ext/vector_relational.hpp>
10 #include <cstring>
11 
test_vec_memcpy()12 static int test_vec_memcpy()
13 {
14 	int Error = 0;
15 
16 	{
17 		glm::ivec1 const A = glm::ivec1(76);
18 		glm::ivec1 B;
19 		std::memcpy(&B, &A, sizeof(glm::ivec1));
20 		Error += B == A ? 0 : 1;
21 	}
22 
23 	{
24 		glm::ivec2 const A = glm::ivec2(76);
25 		glm::ivec2 B;
26 		std::memcpy(&B, &A, sizeof(glm::ivec2));
27 		Error += B == A ? 0 : 1;
28 	}
29 
30 	{
31 		glm::ivec3 const A = glm::ivec3(76);
32 		glm::ivec3 B;
33 		std::memcpy(&B, &A, sizeof(glm::ivec3));
34 		Error += B == A ? 0 : 1;
35 	}
36 
37 	{
38 		glm::ivec4 const A = glm::ivec4(76);
39 		glm::ivec4 B;
40 		std::memcpy(&B, &A, sizeof(glm::ivec4));
41 		Error += B == A ? 0 : 1;
42 	}
43 
44 	return Error;
45 }
46 
test_mat_memcpy()47 static int test_mat_memcpy()
48 {
49 	int Error = 0;
50 
51 	{
52 		glm::mat2x2 const A = glm::mat2x2(76);
53 		glm::mat2x2 B;
54 		std::memcpy(&B, &A, sizeof(glm::mat2x2));
55 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
56 	}
57 
58 	{
59 		glm::mat2x3 const A = glm::mat2x3(76);
60 		glm::mat2x3 B;
61 		std::memcpy(&B, &A, sizeof(glm::mat2x3));
62 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
63 	}
64 
65 	{
66 		glm::mat2x4 const A = glm::mat2x4(76);
67 		glm::mat2x4 B;
68 		std::memcpy(&B, &A, sizeof(glm::mat2x4));
69 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
70 	}
71 
72 	{
73 		glm::mat3x2 const A = glm::mat3x2(76);
74 		glm::mat3x2 B;
75 		std::memcpy(&B, &A, sizeof(glm::mat3x2));
76 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
77 	}
78 
79 	{
80 		glm::mat3x3 const A = glm::mat3x3(76);
81 		glm::mat3x3 B;
82 		std::memcpy(&B, &A, sizeof(glm::mat3x3));
83 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
84 	}
85 
86 	{
87 		glm::mat3x4 const A = glm::mat3x4(76);
88 		glm::mat3x4 B;
89 		std::memcpy(&B, &A, sizeof(glm::mat3x4));
90 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
91 	}
92 
93 	{
94 		glm::mat4x2 const A = glm::mat4x2(76);
95 		glm::mat4x2 B;
96 		std::memcpy(&B, &A, sizeof(glm::mat4x2));
97 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
98 	}
99 
100 	{
101 		glm::mat4x3 const A = glm::mat4x3(76);
102 		glm::mat4x3 B;
103 		std::memcpy(&B, &A, sizeof(glm::mat4x3));
104 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
105 	}
106 
107 	{
108 		glm::mat4x4 const A = glm::mat4x4(76);
109 		glm::mat4x4 B;
110 		std::memcpy(&B, &A, sizeof(glm::mat4x4));
111 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
112 	}
113 
114 	return Error;
115 }
116 
test_quat_memcpy()117 static int test_quat_memcpy()
118 {
119 	int Error = 0;
120 
121 	{
122 		glm::quat const A = glm::quat(1, 0, 0, 0);
123 		glm::quat B;
124 		std::memcpy(&B, &A, sizeof(glm::quat));
125 		Error += glm::all(glm::equal(B, A, glm::epsilon<float>())) ? 0 : 1;
126 	}
127 
128 	return Error;
129 }
130 
131 #endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
132 
main()133 int main()
134 {
135 	int Error = 0;
136 
137 #	if GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
138 		Error += test_vec_memcpy();
139 		Error += test_mat_memcpy();
140 		Error += test_quat_memcpy();
141 #	endif//GLM_CONFIG_DEFAULTED_FUNCTIONS == GLM_ENABLE
142 
143 	return Error;
144 }
145 
146