-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gtest validating
mz_os_get_file_date
works on ADS
- Loading branch information
1 parent
4a1d10f
commit 888d471
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* test_file.cc - Test file functionality | ||
part of the minizip-ng project | ||
Copyright (C) Nathan Moinvaziri | ||
https://github.com/zlib-ng/minizip-ng | ||
This program is distributed under the terms of the same license as zlib. | ||
See the accompanying LICENSE file for the full text of the license. | ||
*/ | ||
|
||
#include "mz.h" | ||
#include "mz_os.h" | ||
|
||
#include <gtest/gtest.h> | ||
#include <fstream> | ||
#include <cstdio> | ||
|
||
TEST(os, get_file_date_ads) { | ||
const std::string main_stream_name = "minizip_ads_test"; | ||
const std::string ads_name = main_stream_name + ":ads"; | ||
const std::string ads_contents = "Alternate Data Stream"; | ||
|
||
// Create main stream | ||
std::ofstream main_stream(main_stream_name); | ||
main_stream.close(); | ||
|
||
// Attach ADS | ||
std::ofstream ads(ads_name); | ||
ads << ads_contents; | ||
ads.close(); | ||
|
||
// Get file date | ||
time_t modified_date = 0; | ||
time_t accessed_date = 0; | ||
time_t creation_date = 0; | ||
|
||
EXPECT_EQ(MZ_OK, mz_os_get_file_date(ads_name.c_str(), &modified_date, &accessed_date, &creation_date)); | ||
|
||
std::remove(main_stream_name.c_str()); | ||
|
||
ASSERT_GT(modified_date, 0); | ||
ASSERT_GT(accessed_date, 0); | ||
ASSERT_GT(creation_date, 0); | ||
} |