]> granicus.if.org Git - taglib/commitdiff
Silence some MSVC specific warnings in tests.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 31 Jul 2015 11:55:23 +0000 (20:55 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Fri, 31 Jul 2015 11:55:23 +0000 (20:55 +0900)
tests/main.cpp
tests/utils.h

index ab89dc3e701e32496b4631ae18adf568f992a7a7..c83c9d132da85a815d78799d14e728622e46b51d 100644 (file)
@@ -17,7 +17,7 @@ int main(int argc, char* argv[])
   // Create the event manager and test controller
   CppUnit::TestResult controller;
 
-  // Add a listener that colllects test result
+  // Add a listener that collects test result
   CppUnit::TestResultCollector result;
   controller.addListener(&result);
 
@@ -39,12 +39,20 @@ int main(int argc, char* argv[])
     CppUnit::CompilerOutputter outputter(&result, std::cerr);
     outputter.write();
 
+#if defined(_MSC_VER) && _MSC_VER > 1500
+    char *xml = NULL;
+    ::_dupenv_s(&xml, NULL, "CPPUNIT_XML");
+#else
     char *xml = ::getenv("CPPUNIT_XML");
+#endif
     if(xml && !::strcmp(xml, "1")) {
       std::ofstream xmlfileout("cpptestresults.xml");
       CppUnit::XmlOutputter xmlout(&result, xmlfileout);
       xmlout.write();
     }
+#if defined(_MSC_VER) && _MSC_VER > 1500
+    ::free(xml);
+#endif
   }
   catch(std::invalid_argument &e){
     std::cerr << std::endl
index 1dfbec379add9e7f1155601e687f812b97095226..de51c04c1205b517ad3ad60aef652e235f381d9b 100644 (file)
@@ -33,7 +33,11 @@ inline string copyFile(const string &filename, const string &ext)
   GetTempPathA(sizeof(testFileName), testFileName);
   GetTempFileNameA(testFileName, "tag", 0, testFileName);
   DeleteFileA(testFileName);
+# if defined(_MSC_VER) && _MSC_VER > 1500
+  strcat_s(testFileName, ext.c_str());
+# else
   strcat(testFileName, ext.c_str());
+# endif
 #else
   snprintf(testFileName, sizeof(testFileName), "/%s/taglib-test-XXXXXX%s", P_tmpdir, ext.c_str());
   static_cast<void>(mkstemps(testFileName, 6));
@@ -74,7 +78,7 @@ inline bool fileEqual(const string &filename1, const string &filename2)
 
     if(n1 == 0) break;
 
-    if(memcmp(buf1, buf2, n1) != 0) return false;
+    if(memcmp(buf1, buf2, static_cast<size_t>(n1)) != 0) return false;
   }
 
   return stream1.good() == stream2.good();