From b11f0cd3cc1342bc105573b12749c6759e714c94 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 1 Sep 2011 00:24:18 +0100 Subject: [PATCH 1/4] Added string cast test --- test/gtx/CMakeLists.txt | 1 + test/gtx/gtx_string_cast.cpp | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/gtx/gtx_string_cast.cpp diff --git a/test/gtx/CMakeLists.txt b/test/gtx/CMakeLists.txt index 38387f78..b7a44b8d 100644 --- a/test/gtx/CMakeLists.txt +++ b/test/gtx/CMakeLists.txt @@ -5,5 +5,6 @@ glmCreateTestGTC(gtx_random) glmCreateTestGTC(gtx_rotate_vector) glmCreateTestGTC(gtx_simd_vec4) glmCreateTestGTC(gtx_simd_mat4) +glmCreateTestGTC(gtx_string_cast) glmCreateTestGTC(gtx_ulp) glmCreateTestGTC(gtx_vector_angle) diff --git a/test/gtx/gtx_string_cast.cpp b/test/gtx/gtx_string_cast.cpp new file mode 100644 index 00000000..fedb43cc --- /dev/null +++ b/test/gtx/gtx_string_cast.cpp @@ -0,0 +1,43 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Created : 2011-09-01 +// Updated : 2011-09-01 +// Licence : This source is under MIT licence +// File : test/gtx/string_cast.cpp +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include + +int test_string_cast_vec() +{ + int Error = 0; + + glm::vec2 A1(1, 2); + + std::string A2 = glm::to_string(A1); + + Error += A2 != std::string("fvec2(1.000000, 2.000000)") ? 1 : 0; + + return Error; +} + +int test_string_cast_mat() +{ + int Error = 0; + + return Error; +} + +int main() +{ + int Error = 0; + Error += test_string_cast_vec(); + Error += test_string_cast_mat(); + return Error; +} + + From cec6cefa1b06a223ea4133b43662a736abff96db Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 1 Sep 2011 09:57:10 +0100 Subject: [PATCH 2/4] Added to_string scalars and vectors tests --- glm/gtx/string_cast.inl | 8 ++-- test/gtx/gtx_string_cast.cpp | 74 +++++++++++++++++++++++++++++++++--- 2 files changed, 72 insertions(+), 10 deletions(-) diff --git a/glm/gtx/string_cast.inl b/glm/gtx/string_cast.inl index 031ea55e..4014affc 100644 --- a/glm/gtx/string_cast.inl +++ b/glm/gtx/string_cast.inl @@ -41,7 +41,7 @@ namespace string_cast GLM_FUNC_QUALIFIER std::string to_string(detail::thalf const & x) { - return detail::format("half(%f)", float(x)); + return detail::format("half(%2.4f)", float(x)); } GLM_FUNC_QUALIFIER std::string to_string(float x) @@ -109,7 +109,7 @@ namespace string_cast detail::tvec2 const & v ) { - return detail::format("hvec2(%f, %f)", float(v.x), float(v.y)); + return detail::format("hvec2(%2.4f, %2.4f)", float(v.x), float(v.y)); } template <> @@ -118,7 +118,7 @@ namespace string_cast detail::tvec3 const & v ) { - return detail::format("hvec3(%f, %f, %f)", float(v.x), float(v.y), float(v.z)); + return detail::format("hvec3(%2.4f, %2.4f, %2.4f)", float(v.x), float(v.y), float(v.z)); } template <> @@ -127,7 +127,7 @@ namespace string_cast detail::tvec4 const & v ) { - return detail::format("hvec4(%f, %f, %f, %f)", float(v.x), float(v.y), float(v.z), float(v.w)); + return detail::format("hvec4(%2.4f, %2.4f, %2.4f, %2.4f)", float(v.x), float(v.y), float(v.z), float(v.w)); } //////////////////////////////// diff --git a/test/gtx/gtx_string_cast.cpp b/test/gtx/gtx_string_cast.cpp index fedb43cc..5ebedf69 100644 --- a/test/gtx/gtx_string_cast.cpp +++ b/test/gtx/gtx_string_cast.cpp @@ -12,20 +12,81 @@ #include #include -int test_string_cast_vec() +int test_string_cast_scalar() +{ + int Error = 0; + + glm::half A1(1.0); + std::string A2 = glm::to_string(A1); + Error += A2 != std::string("half(1.0000)") ? 1 : 0; + + float B1(1.0); + std::string B2 = glm::to_string(B1); + Error += B2 != std::string("float(1.000000)") ? 1 : 0; + + double C1(1.0); + std::string C2 = glm::to_string(C1); + Error += C2 != std::string("double(1.000000)") ? 1 : 0; + + return Error; +} + +int test_string_cast_vector() { int Error = 0; glm::vec2 A1(1, 2); - std::string A2 = glm::to_string(A1); - Error += A2 != std::string("fvec2(1.000000, 2.000000)") ? 1 : 0; + glm::vec3 B1(1, 2, 3); + std::string B2 = glm::to_string(B1); + Error += B2 != std::string("fvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; + + glm::vec4 C1(1, 2, 3, 4); + std::string C2 = glm::to_string(C1); + Error += C2 != std::string("fvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; + + glm::ivec2 D1(1, 2); + std::string D2 = glm::to_string(D1); + Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0; + + glm::ivec3 E1(1, 2, 3); + std::string E2 = glm::to_string(E1); + Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0; + + glm::ivec4 F1(1, 2, 3, 4); + std::string F2 = glm::to_string(F1); + Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0; + + glm::hvec2 G1(1, 2); + std::string G2 = glm::to_string(G1); + Error += G2 != std::string("hvec2(1.0000, 2.0000)") ? 1 : 0; + + glm::hvec3 H1(1, 2, 3); + std::string H2 = glm::to_string(H1); + Error += H2 != std::string("hvec3(1.0000, 2.0000, 3.0000)") ? 1 : 0; + + glm::hvec4 I1(1, 2, 3, 4); + std::string I2 = glm::to_string(I1); + Error += I2 != std::string("hvec4(1.0000, 2.0000, 3.0000, 4.0000)") ? 1 : 0; + + glm::dvec2 J1(1, 2); + std::string J2 = glm::to_string(J1); + Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0; + + glm::dvec3 K1(1, 2, 3); + std::string K2 = glm::to_string(K1); + Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0; + + glm::dvec4 L1(1, 2, 3, 4); + std::string L2 = glm::to_string(L1); + Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0; + return Error; } -int test_string_cast_mat() +int test_string_cast_matrix() { int Error = 0; @@ -35,8 +96,9 @@ int test_string_cast_mat() int main() { int Error = 0; - Error += test_string_cast_vec(); - Error += test_string_cast_mat(); + Error += test_string_cast_scalar(); + Error += test_string_cast_vector(); + Error += test_string_cast_matrix(); return Error; } From 22756dcc12798c1160649baa240da12156cc6af7 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 3 Sep 2011 10:54:38 +0100 Subject: [PATCH 3/4] Updated 0.9.2.4 --- doc/src/data.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/data.xml b/doc/src/data.xml index 3bb0402e..e928d45a 100644 --- a/doc/src/data.xml +++ b/doc/src/data.xml @@ -158,9 +158,10 @@ - + + - Fixed few bugs reported by GLM users. Thanks! + Fixed bugs and warnings reported by GLM users. Thanks! GLM 0.9.2.4 (zip) From fb2d15b5df9f3d95bc43980887a0304426f1757e Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 3 Sep 2011 21:53:18 +0100 Subject: [PATCH 4/4] updated readme --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 0e7560a4..3ae241ed 100644 --- a/readme.txt +++ b/readme.txt @@ -37,7 +37,7 @@ More informations in GLM manual: http://glm.g-truc.net/glm-0.9.2.pdf ================================================================================ -GLM 0.9.2.4: 2011-08-04 +GLM 0.9.2.4: 2011-09-03 -------------------------------------------------------------------------------- - Fixed extensions bugs