summaryrefslogtreecommitdiff
path: root/libs/tdlib/td/tdutils/test/filesystem.cpp
diff options
context:
space:
mode:
authorMataes <mataes2007@gmail.com>2018-04-27 20:39:22 +0300
committerMataes <mataes2007@gmail.com>2018-04-27 20:39:22 +0300
commitb9ce1d4d98525490ca1a38e2d9fd4f3369adb3e0 (patch)
tree787c80a909776c1c4d099b638c83c7977bb070e2 /libs/tdlib/td/tdutils/test/filesystem.cpp
parent5ed0126c16d061d6e87aa20c718e14608c66feec (diff)
added tdlib library
Diffstat (limited to 'libs/tdlib/td/tdutils/test/filesystem.cpp')
-rw-r--r--libs/tdlib/td/tdutils/test/filesystem.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/libs/tdlib/td/tdutils/test/filesystem.cpp b/libs/tdlib/td/tdutils/test/filesystem.cpp
new file mode 100644
index 0000000000..a0a92c14eb
--- /dev/null
+++ b/libs/tdlib/td/tdutils/test/filesystem.cpp
@@ -0,0 +1,41 @@
+//
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+#include "td/utils/filesystem.h"
+#include "td/utils/tests.h"
+
+TEST(Misc, clean_filename) {
+ using td::clean_filename;
+ ASSERT_STREQ(clean_filename("-1234567"), "-1234567");
+ ASSERT_STREQ(clean_filename(".git"), "git");
+ ASSERT_STREQ(clean_filename("../../.git"), "git");
+ ASSERT_STREQ(clean_filename(".././.."), "");
+ ASSERT_STREQ(clean_filename("../"), "");
+ ASSERT_STREQ(clean_filename(".."), "");
+ ASSERT_STREQ(clean_filename("test/git/ as dsa . a"), "as dsa.a");
+ ASSERT_STREQ(clean_filename(" . "), "");
+ ASSERT_STREQ(clean_filename("!@#$%^&*()_+-=[]{;|:\"}'<>?,.`~"), "!@#$%^ ()_+-=[]{; } ,.~");
+ ASSERT_STREQ(clean_filename("!@#$%^&*()_+-=[]{}\\|:\";'<>?,.`~"), "; ,.~");
+ ASSERT_STREQ(clean_filename("عرفها بعد قد. هذا مع تاريخ اليميني واندونيسيا،, لعدم تاريخ لهيمنة الى"),
+ "عرفها بعد قد.هذا مع تاريخ اليميني");
+ ASSERT_STREQ(
+ clean_filename(
+ "012345678901234567890123456789012345678901234567890123456789adsasdasdsaa.01234567890123456789asdasdasdasd"),
+ "012345678901234567890123456789012345678901234567890123456789.01234567890123456789");
+ ASSERT_STREQ(clean_filename("01234567890123456789012345678901234567890123456789<>*?: <>*?:0123456789adsasdasdsaa. "
+ "0123456789`<><<>><><>0123456789asdasdasdasd"),
+ "01234567890123456789012345678901234567890123456789.0123456789");
+ ASSERT_STREQ(clean_filename("01234567890123456789012345678901234567890123456789<>*?: <>*?:0123456789adsasdasdsaa. "
+ "0123456789`<><><>0123456789asdasdasdasd"),
+ "01234567890123456789012345678901234567890123456789.0123456789 012");
+ ASSERT_STREQ(clean_filename("C:/document.tar.gz"), "document.tar.gz");
+ ASSERT_STREQ(clean_filename("test...."), "test");
+ ASSERT_STREQ(clean_filename("....test"), "test");
+ ASSERT_STREQ(clean_filename("test.exe...."), "test.exe"); // extension has changed
+ ASSERT_STREQ(clean_filename("test.exe01234567890123456789...."),
+ "test.exe01234567890123456789"); // extension may be more then 20 characters
+ ASSERT_STREQ(clean_filename("....test....asdf"), "test.asdf");
+}