test Picture: Change file open of ifstream to binary(and readonly) type
authorJunsuChoi <jsuya.choi@samsung.com>
Thu, 28 Oct 2021 03:07:49 +0000 (12:07 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Thu, 28 Oct 2021 06:19:31 +0000 (15:19 +0900)
When opening a file using ifstream, a different problem occurs for each platform.
To fix this, change to binary, readonly type.

refer to:
https://stackoverflow.com/questions/9817806/why-does-my-program-produce-different-results-on-windows-and-linux-about-file-r

test/testPicture.cpp

index 358d63d..677489a 100644 (file)
@@ -129,7 +129,7 @@ TEST_CASE("Load PNG file from data", "[tvgPicture]")
     REQUIRE(picture);
 
     //Open file
-    ifstream file(TEST_DIR"/test.png");
+    ifstream file(TEST_DIR"/test.png", std::ios::in | std::ios::binary);
     REQUIRE(file.is_open());
     auto size = sizeof(uint32_t) * (1000*1000);
     auto data = (char*)malloc(size);
@@ -170,7 +170,7 @@ TEST_CASE("Load JPG file from data", "[tvgPicture]")
     REQUIRE(picture);
 
     //Open file
-    ifstream file(TEST_DIR"/test.jpg");
+    ifstream file(TEST_DIR"/test.jpg", std::ios::in | std::ios::binary);
     REQUIRE(file.is_open());
     auto begin = file.tellg();
     file.seekg(0, std::ios::end);
@@ -214,7 +214,7 @@ TEST_CASE("Load TVG file from data", "[tvgPicture]")
     REQUIRE(picture);
 
     //Open file
-    ifstream file(TEST_DIR"/tag.tvg");
+    ifstream file(TEST_DIR"/tag.tvg", std::ios::in | std::ios::binary);
     REQUIRE(file.is_open());
     auto begin = file.tellg();
     file.seekg(0, std::ios::end);