summaryrefslogtreecommitdiffhomepage
path: root/FoundationEx/test/data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'FoundationEx/test/data.cpp')
-rw-r--r--FoundationEx/test/data.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/FoundationEx/test/data.cpp b/FoundationEx/test/data.cpp
new file mode 100644
index 0000000..09ab49b
--- /dev/null
+++ b/FoundationEx/test/data.cpp
@@ -0,0 +1,26 @@
+#include <filesystem>
+#include <fstream>
+
+#include <gtest/gtest.h>
+
+#include <starshatter/foundation/data.h>
+
+
+namespace data = starshatter::foundation::data;
+namespace fs = std::filesystem;
+
+
+TEST(FoundationEx, OpenRelativePathOnFilesystem)
+{
+ fs::current_path(fs::temp_directory_path());
+ {
+ std::fstream tmp("sample", tmp.out | tmp.binary);
+ tmp << "Hello, there!\n";
+ }
+ data::toggle_filesystem(true);
+ auto file = data::open("sample");
+ ASSERT_TRUE(file.valid());
+ ASSERT_LT(0, file.available());
+ const auto text = file.more();
+ ASSERT_STREQ("Hello, there!\n", text);
+}