diff options
author | Syoyo Fujita <syoyo@lighttransport.com> | 2016-04-19 13:11:55 +0900 |
---|---|---|
committer | Syoyo Fujita <syoyo@lighttransport.com> | 2016-04-19 13:11:55 +0900 |
commit | a55247574c2c2436989a9a0654c51a62cc7193ba (patch) | |
tree | af70de47ba36ec6c9e67b938de7e331e1db864f4 | |
parent | f4695de408516f45652b161a34bb62fbe6edec07 (diff) | |
download | tinyobjloader-a55247574c2c2436989a9a0654c51a62cc7193ba.tar.gz |
Suppress VC2013 warnings.
Update AppVeyor script.
-rw-r--r-- | appveyor.yml | 11 | ||||
-rw-r--r-- | build.ninja | 18 | ||||
-rw-r--r-- | tests/config-msvc.py | 2 | ||||
-rw-r--r-- | tests/tester.cc | 23 | ||||
-rw-r--r-- | tests/vcbuild.bat | 1 | ||||
-rw-r--r-- | tiny_obj_loader.h | 26 |
6 files changed, 40 insertions, 41 deletions
diff --git a/appveyor.yml b/appveyor.yml index 38eaf15..b52a666 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,7 @@ version: 0.9.{build} -# scripts that runs after repo cloning. -install: - - vcsetup.bat - platform: x64 -configuration: Release -build: - parallel: true - project: TinyObjLoaderSolution.sln +build_script: + - cd tests + - vcbuild.bat diff --git a/build.ninja b/build.ninja deleted file mode 100644 index 5048ff1..0000000 --- a/build.ninja +++ /dev/null @@ -1,18 +0,0 @@ -# build.ninja -cc = clang -cxx = clang++ -cflags = -Werror -Weverything -cxxflags = -Werror -Weverything -#cflags = -O2 -#cxxflags = -O2 - -rule compile - command = $cxx $cxxflags -c $in -o $out - -rule link - command = $cxx $in -o $out - -build loader_example.o: compile loader_example.cc -build loader_example: link loader_example.o - -default loader_example diff --git a/tests/config-msvc.py b/tests/config-msvc.py index 06fae62..a7771de 100644 --- a/tests/config-msvc.py +++ b/tests/config-msvc.py @@ -32,7 +32,7 @@ cflags = { cxxflags = { "gnu" : [ "-O2", "-g" ] - , "msvc" : [ "/O2" ] + , "msvc" : [ "/O2", "/W4", "/EHsc"] , "clang" : [ "-O2", "-g", "-fsanitize=address" ] } diff --git a/tests/tester.cc b/tests/tester.cc index edb92ba..f16eeb0 100644 --- a/tests/tester.cc +++ b/tests/tester.cc @@ -300,6 +300,29 @@ TEST_CASE("cornell_box", "[Loader]") { REQUIRE(true == TestLoadObj("../models/cornell_box.obj", gMtlBasePath)); } +TEST_CASE("catmark_torus_creases0", "[Loader]") { + + tinyobj::attrib_t attrib; + std::vector<tinyobj::shape_t> shapes; + std::vector<tinyobj::material_t> materials; + + std::string err; + bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/catmark_torus_creases0.obj", gMtlBasePath, /*triangulate*/false); + + if (!err.empty()) { + std::cerr << err << std::endl; + } + + REQUIRE(true == ret); + + REQUIRE(1 == shapes.size()); + REQUIRE(8 == shapes[0].mesh.tags.size()); +} + +TEST_CASE("stream_load", "[Stream]") { + REQUIRE(true == TestStreamLoadObj()); +} + #if 0 int main( diff --git a/tests/vcbuild.bat b/tests/vcbuild.bat index 3dbc6c1..e864673 100644 --- a/tests/vcbuild.bat +++ b/tests/vcbuild.bat @@ -1,3 +1,4 @@ chcp 437 +python kuroga.py config-msvc.py call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86_amd64 ninja diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h index af395ff..5db2bb8 100644 --- a/tiny_obj_loader.h +++ b/tiny_obj_loader.h @@ -236,15 +236,6 @@ struct tag_sizes { int num_strings; }; -// for std::map -static inline bool operator<(const vertex_index &a, const vertex_index &b) { - if (a.v_idx != b.v_idx) return (a.v_idx < b.v_idx); - if (a.vn_idx != b.vn_idx) return (a.vn_idx < b.vn_idx); - if (a.vt_idx != b.vt_idx) return (a.vt_idx < b.vt_idx); - - return false; -} - struct obj_shape { std::vector<float> v; std::vector<float> vn; @@ -346,11 +337,13 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) { } // Read the integer part. - while ((end_not_reached = (curr != s_end)) && IS_DIGIT(*curr)) { + end_not_reached = (curr != s_end); + while (end_not_reached && IS_DIGIT(*curr)) { mantissa *= 10; mantissa += static_cast<int>(*curr - 0x30); curr++; read++; + end_not_reached = (curr != s_end); } // We must make sure we actually got something. @@ -362,11 +355,13 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) { if (*curr == '.') { curr++; read = 1; - while ((end_not_reached = (curr != s_end)) && IS_DIGIT(*curr)) { + end_not_reached = (curr != s_end); + while (end_not_reached && IS_DIGIT(*curr)) { // NOTE: Don't use powf here, it will absolutely murder precision. mantissa += static_cast<int>(*curr - 0x30) * pow(10.0, -read); read++; curr++; + end_not_reached = (curr != s_end); } } else if (*curr == 'e' || *curr == 'E') { } else { @@ -379,7 +374,8 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) { if (*curr == 'e' || *curr == 'E') { curr++; // Figure out if a sign is present and if it is. - if ((end_not_reached = (curr != s_end)) && (*curr == '+' || *curr == '-')) { + end_not_reached = (curr != s_end); + if (end_not_reached && (*curr == '+' || *curr == '-')) { exp_sign = *curr; curr++; } else if (IS_DIGIT(*curr)) { /* Pass through. */ @@ -389,11 +385,13 @@ static bool tryParseDouble(const char *s, const char *s_end, double *result) { } read = 0; - while ((end_not_reached = (curr != s_end)) && IS_DIGIT(*curr)) { + end_not_reached = (curr != s_end); + while (end_not_reached && IS_DIGIT(*curr)) { exponent *= 10; exponent += static_cast<int>(*curr - 0x30); curr++; read++; + end_not_reached = (curr != s_end); } exponent *= (exp_sign == '+' ? 1 : -1); if (read == 0) goto fail; @@ -493,7 +491,7 @@ static vertex_index parseTriple(const char **token, int vsize, int vnsize, // Parse raw triples: i, i/j/k, i//k, i/j static vertex_index parseRawTriple(const char **token) { - vertex_index vi(-2147483648); // 0x80000000 = -2147483648 = invalid + vertex_index vi(static_cast<int>(0x80000000)); // 0x80000000 = -2147483648 = invalid vi.v_idx = atoi((*token)); (*token) += strcspn((*token), "/ \t\r"); |