From 567ddba32454391619f26479e3a1ceffaac9c4e0 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 19 Jan 2016 20:42:11 +0100 Subject: [PATCH] Merge with develop --- code/nel/include/nel/misc/string_common.h | 34 ----- code/nel/src/3d/fxaa.cpp | 20 +-- code/nel/src/3d/geometry_program.cpp | 4 +- code/nel/src/3d/gpu_program_params.cpp | 11 +- code/nel/src/3d/pixel_program.cpp | 4 +- code/nel/src/3d/program.cpp | 10 +- code/nel/src/3d/render_target_manager.cpp | 18 +-- code/nel/src/3d/stereo_debugger.cpp | 18 +-- code/nel/src/3d/stereo_display.cpp | 10 +- code/nel/src/3d/stereo_hmd.cpp | 2 +- code/nel/src/3d/stereo_libvr.cpp | 18 +-- code/nel/src/3d/stereo_ovr.cpp | 16 +-- code/nel/src/3d/stereo_ovr_04.cpp | 16 +-- .../nel/tools/nel_unit_test/nel_unit_test.exp | Bin 624 -> 0 bytes .../nel_unit_test/ut_misc_string_common.h | 119 +++++++++--------- 15 files changed, 134 insertions(+), 166 deletions(-) delete mode 100644 code/nel/tools/nel_unit_test/nel_unit_test.exp diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index d0a667563..9ac55101f 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -280,40 +280,6 @@ inline bool fromString(const std::string &str, bool &val) return true; } -inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } } -inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } } -inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } } -inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } } -inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } } -inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } } -inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%" NL_I64 "u", &val) == 1; if (!ret) val = 0; return ret; } -inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%" NL_I64 "d", &val) == 1; if (!ret) val = 0; return ret; } -inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; } -inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; } - -inline bool fromString(const char *str, bool &val) -{ - switch (str[0]) - { - case '1': - case 't': - case 'y': - case 'T': - case 'Y': - val = true; - return true; - case '0': - case 'f': - case 'n': - case 'F': - case 'N': - val = false; - return true; - } - - return false; -} - inline bool fromString(const std::string &str, std::string &val) { val = str; return true; } // stl vectors of bool use bit reference and not real bools, so define the operator for bit reference diff --git a/code/nel/src/3d/fxaa.cpp b/code/nel/src/3d/fxaa.cpp index 8f074287c..1eff22501 100644 --- a/code/nel/src/3d/fxaa.cpp +++ b/code/nel/src/3d/fxaa.cpp @@ -25,8 +25,8 @@ * . */ -#include -#include +#include "std3d.h" +#include "nel/3d/fxaa.h" // STL includes @@ -34,14 +34,14 @@ // #include // Project includes -#include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" +#include "nel/3d/render_target_manager.h" using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/3d/geometry_program.cpp b/code/nel/src/3d/geometry_program.cpp index 26fb15ae9..8f785b6c6 100644 --- a/code/nel/src/3d/geometry_program.cpp +++ b/code/nel/src/3d/geometry_program.cpp @@ -23,9 +23,9 @@ #include "std3d.h" -#include +#include "nel/3d/geometry_program.h" -#include +#include "nel/3d/driver.h" namespace NL3D { diff --git a/code/nel/src/3d/gpu_program_params.cpp b/code/nel/src/3d/gpu_program_params.cpp index 144c9a22d..9e84865be 100644 --- a/code/nel/src/3d/gpu_program_params.cpp +++ b/code/nel/src/3d/gpu_program_params.cpp @@ -25,18 +25,19 @@ * . */ -#include -#include +#include "std3d.h" +#include "nel/misc/types_nl.h" +#include "nel/3d/gpu_program_params.h" // STL includes // NeL includes // #include -#include -#include +#include "nel/misc/vector.h" +#include "nel/misc/matrix.h" // Project includes -#include +#include "nel/3d/driver.h" using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/3d/pixel_program.cpp b/code/nel/src/3d/pixel_program.cpp index adb2163e5..120e7def6 100644 --- a/code/nel/src/3d/pixel_program.cpp +++ b/code/nel/src/3d/pixel_program.cpp @@ -23,9 +23,9 @@ #include "std3d.h" -#include +#include "nel/3d/pixel_program.h" -#include +#include "nel/3d/driver.h" namespace NL3D { diff --git a/code/nel/src/3d/program.cpp b/code/nel/src/3d/program.cpp index 390fdf314..738b57550 100644 --- a/code/nel/src/3d/program.cpp +++ b/code/nel/src/3d/program.cpp @@ -25,17 +25,19 @@ * . */ -#include -#include +#include "std3d.h" + +#include "nel/misc/types_nl.h" +#include "nel/3d/program.h" // STL includes // NeL includes // #include -#include +#include "nel/misc/string_mapper.h" // Project includes -#include +#include "nel/3d/driver.h" using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/3d/render_target_manager.cpp b/code/nel/src/3d/render_target_manager.cpp index 0c4daa507..4b552c62e 100644 --- a/code/nel/src/3d/render_target_manager.cpp +++ b/code/nel/src/3d/render_target_manager.cpp @@ -25,21 +25,21 @@ * . */ -#include -#include +#include "std3d.h" +#include "nel/3d/render_target_manager.h" // STL includes #include // NeL includes // #include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" // Project includes diff --git a/code/nel/src/3d/stereo_debugger.cpp b/code/nel/src/3d/stereo_debugger.cpp index 6650e1c2b..138f8e3ae 100644 --- a/code/nel/src/3d/stereo_debugger.cpp +++ b/code/nel/src/3d/stereo_debugger.cpp @@ -27,7 +27,7 @@ #if !FINAL_VERSION #include "std3d.h" -#include +#include "nel/3d/stereo_debugger.h" // STL includes @@ -35,14 +35,14 @@ // #include // Project includes -#include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" +#include "nel/3d/render_target_manager.h" using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/3d/stereo_display.cpp b/code/nel/src/3d/stereo_display.cpp index 2a79c1039..dede3fbf6 100644 --- a/code/nel/src/3d/stereo_display.cpp +++ b/code/nel/src/3d/stereo_display.cpp @@ -26,7 +26,7 @@ */ #include "std3d.h" -#include +#include "nel/3d/stereo_display.h" // STL includes @@ -34,10 +34,10 @@ // #include // Project includes -#include -#include -#include -#include +#include "nel/3d/stereo_ovr.h" +#include "nel/3d/stereo_ovr_04.h" +#include "nel/3d/stereo_libvr.h" +#include "nel/3d/stereo_debugger.h" using namespace std; // using namespace NLMISC; diff --git a/code/nel/src/3d/stereo_hmd.cpp b/code/nel/src/3d/stereo_hmd.cpp index 25249e2b4..207965636 100644 --- a/code/nel/src/3d/stereo_hmd.cpp +++ b/code/nel/src/3d/stereo_hmd.cpp @@ -26,7 +26,7 @@ */ #include "std3d.h" -#include +#include "nel/3d/stereo_hmd.h" // STL includes diff --git a/code/nel/src/3d/stereo_libvr.cpp b/code/nel/src/3d/stereo_libvr.cpp index c655f959c..2f31beac4 100644 --- a/code/nel/src/3d/stereo_libvr.cpp +++ b/code/nel/src/3d/stereo_libvr.cpp @@ -28,8 +28,8 @@ #ifdef HAVE_LIBVR #include "std3d.h" -#include -#include +#include "nel/misc/time_nl.h" +#include "nel/3d/stereo_libvr.h" // STL includes #include @@ -41,13 +41,13 @@ extern "C" { // NeL includes // #include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" // Project includes diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index f4b910bc6..103b44696 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -44,7 +44,7 @@ #ifdef HAVE_LIBOVR_02 #include "std3d.h" -#include +#include "nel/3d/stereo_ovr.h" // STL includes #include @@ -55,13 +55,13 @@ // NeL includes // #include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" // Project includes diff --git a/code/nel/src/3d/stereo_ovr_04.cpp b/code/nel/src/3d/stereo_ovr_04.cpp index 121855fb8..fcccc2f6b 100644 --- a/code/nel/src/3d/stereo_ovr_04.cpp +++ b/code/nel/src/3d/stereo_ovr_04.cpp @@ -44,7 +44,7 @@ #ifdef HAVE_LIBOVR #include "std3d.h" -#include +#include "nel/3d/stereo_ovr_04.h" // STL includes #include @@ -55,13 +55,13 @@ // NeL includes // #include -#include -#include -#include -#include -#include -#include -#include +#include "nel/3d/u_camera.h" +#include "nel/3d/u_driver.h" +#include "nel/3d/material.h" +#include "nel/3d/texture_bloom.h" +#include "nel/3d/texture_user.h" +#include "nel/3d/driver_user.h" +#include "nel/3d/u_texture.h" // Project includes diff --git a/code/nel/tools/nel_unit_test/nel_unit_test.exp b/code/nel/tools/nel_unit_test/nel_unit_test.exp deleted file mode 100644 index f3dcfd7a9e684ca6939310924328131125d77edf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmZWn!A`05j8~h0W zfe-LIG~PVm%r*tZN#C0{kL~Wxl%|z~@6Xr9!~$3a6PCjRPkU)We2)kaZ&YBcAZqwH z0q-Wga*I5Qcf^-bbE?7m8C7&f=HgM1A@ly`h=-jd61t;#tQ|h$;PS93y2?}Ii%6?6 ztldz);VT)-2W?mGcI;-uy#fKJCGdv_|7`u3#= zdCcY;wndzHq21C+Af$cdR9U;ux*}qsh#t)#U=t2Y7WUp*97)ZW{edHb;^+mYQ@Z%? z4@m>hL;UP|eGYJdRqCkT;ECF!L1j+5iUyWB!yASFfa=UCyH$*RIG;Hv%wQ=~ #include struct CUTMiscStringCommon : public Test::Suite @@ -63,11 +64,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("-128", val); - TEST_ASSERT(ret && val == -128); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("127", val); - TEST_ASSERT(ret && val == 127); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-129", val); @@ -123,11 +124,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("0", val); - TEST_ASSERT(ret && val == 0); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("255", val); - TEST_ASSERT(ret && val == 255); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-1", val); @@ -187,11 +188,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("-32768", val); - TEST_ASSERT(ret && val == -32768); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("32767", val); - TEST_ASSERT(ret && val == 32767); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-32769", val); @@ -247,11 +248,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("0", val); - TEST_ASSERT(ret && val == 0); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("65535", val); - TEST_ASSERT(ret && val == 65535); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-1", val); @@ -311,11 +312,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("-2147483648", val); - TEST_ASSERT(ret && val == INT_MIN); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("2147483647", val); - TEST_ASSERT(ret && val == INT_MAX); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-2147483649", val); @@ -371,11 +372,11 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("0", val); - TEST_ASSERT(ret && val == 0); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("4294967295", val); - TEST_ASSERT(ret && val == 4294967295); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("-1", val); @@ -435,21 +436,19 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("-9223372036854775808", val); - TEST_ASSERT(ret && val == LLONG_MIN); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("9223372036854775807", val); - TEST_ASSERT(ret && val == LLONG_MAX); + TEST_ASSERT(ret && val == std::numeric_limits::max()); - // min limit -1 + // min limit -1, unable to compare with minimum value because no lower type ret = NLMISC::fromString("-9223372036854775809", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(LLONG_MIN == val); + TEST_ASSERT(ret && val == std::numeric_limits::max()); - // max limit +1 + // max limit +1, unable to compare with maximum value because no higher type ret = NLMISC::fromString("9223372036854775808", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(LLONG_MAX == val); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // with period ret = NLMISC::fromString("1.2", val); @@ -497,22 +496,19 @@ struct CUTMiscStringCommon : public Test::Suite // min limit ret = NLMISC::fromString("0", val); - TEST_ASSERT(ret && val == 0); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("18446744073709551615", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(ULLONG_MAX == val); + TEST_ASSERT(ret && val == std::numeric_limits::max()); - // min limit -1 + // min limit -1, unable to compare with minimum value because no lower type ret = NLMISC::fromString("-1", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(ULLONG_MAX == val); + TEST_ASSERT(ret && val == std::numeric_limits::max()); - // max limit +1 + // max limit +1, unable to compare with maximum value because no higher type ret = NLMISC::fromString("18446744073709551616", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(ULLONG_MAX == val); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // with period ret = NLMISC::fromString("1.2", val); @@ -548,64 +544,67 @@ struct CUTMiscStringCommon : public Test::Suite // positive value ret = NLMISC::fromString("1", val); - TEST_ASSERT(ret && val == 1); + TEST_ASSERT(ret && val == 1.f); // negative value ret = NLMISC::fromString("-1", val); - TEST_ASSERT(ret && val == -1); + TEST_ASSERT(ret && val == -1.f); // bad character ret = NLMISC::fromString("a", val); - TEST_ASSERT(!ret && val == 0); + TEST_ASSERT(!ret && val == 0.f); // right character and bad character ret = NLMISC::fromString("1a", val); - TEST_ASSERT(ret && val == 1); + TEST_ASSERT(ret && val == 1.f); // min limit - ret = NLMISC::fromString("-2147483648", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(INT_MIN == val); + ret = NLMISC::fromString("-3.4028235e+038", val); + TEST_ASSERT(ret && val == -std::numeric_limits::max()); + + // min limit towards 0 + ret = NLMISC::fromString("1.1754944e-038", val); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit - ret = NLMISC::fromString("2147483647", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(INT_MAX == val); + ret = NLMISC::fromString("3.4028235e+038", val); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 - ret = NLMISC::fromString("-2147483649", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(INT_MIN == val); + ret = NLMISC::fromString("-3.4028235e+048", val); + TEST_ASSERT(ret && val == -std::numeric_limits::infinity()); + + // min limit towards 0 -1 + ret = NLMISC::fromString("1.1754944e-048", val); + TEST_ASSERT(ret && val == 0.f); // max limit +1 - ret = NLMISC::fromString("2147483648", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(INT_MAX == val); + ret = NLMISC::fromString("3.4028235e+048", val); + TEST_ASSERT(ret && val == std::numeric_limits::infinity()); // with period ret = NLMISC::fromString("1.2", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(1.2f == val); + TEST_ASSERT(ret && val == 1.2f); // with coma ret = NLMISC::fromString("1,2", val); - TEST_ASSERT(ret && val == 1); + TEST_ASSERT(ret && val == 1.f); // with spaces before ret = NLMISC::fromString(" 10", val); - TEST_ASSERT(ret && val == 10); + TEST_ASSERT(ret && val == 10.f); // with spaces after ret = NLMISC::fromString("10 ", val); - TEST_ASSERT(ret && val == 10); + TEST_ASSERT(ret && val == 10.f); // with 0s before ret = NLMISC::fromString("001", val); - TEST_ASSERT(ret && val == 1); + TEST_ASSERT(ret && val == 1.f); // with + before ret = NLMISC::fromString("+1", val); - TEST_ASSERT(ret && val == 1); + TEST_ASSERT(ret && val == 1.f); } void fromStringDouble() @@ -632,24 +631,24 @@ struct CUTMiscStringCommon : public Test::Suite TEST_ASSERT(ret && val == 1.0); // min limit + ret = NLMISC::fromString("-1.7976931348623158e+308", val); + TEST_ASSERT(ret && val == -std::numeric_limits::max()); + + // min limit towards 0 ret = NLMISC::fromString("2.2250738585072014e-308", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(DBL_MIN == val); + TEST_ASSERT(ret && val == std::numeric_limits::min()); // max limit ret = NLMISC::fromString("1.7976931348623158e+308", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(DBL_MAX == val); + TEST_ASSERT(ret && val == std::numeric_limits::max()); // min limit -1 ret = NLMISC::fromString("3e-408", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(0 == val); + TEST_ASSERT(ret && val == 0.0); // max limit +1 ret = NLMISC::fromString("2e+308", val); - TEST_ASSERT_MSG(ret, "should succeed"); - TEST_ASSERT(INFINITY == val); + TEST_ASSERT(ret && val == std::numeric_limits::infinity()); // with period ret = NLMISC::fromString("1.2", val);