mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
pow-testgiver support
This commit is contained in:
parent
dbde9c1c40
commit
f064b1047a
257 changed files with 6665 additions and 2608 deletions
|
@ -17,38 +17,43 @@
|
|||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "td/utils/Slice.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");
|
||||
ASSERT_STREQ(clean_filename("കറുപ്പ്.txt"), "കറപപ.txt");
|
||||
static void test_clean_filename(td::CSlice name, td::Slice result) {
|
||||
ASSERT_STREQ(td::clean_filename(name), result);
|
||||
}
|
||||
|
||||
TEST(Misc, clean_filename) {
|
||||
test_clean_filename("-1234567", "-1234567");
|
||||
test_clean_filename(".git", "git");
|
||||
test_clean_filename("../../.git", "git");
|
||||
test_clean_filename(".././..", "");
|
||||
test_clean_filename("../", "");
|
||||
test_clean_filename("..", "");
|
||||
test_clean_filename("test/git/ as dsa . a", "as dsa.a");
|
||||
test_clean_filename(" . ", "");
|
||||
test_clean_filename("!@#$%^&*()_+-=[]{;|:\"}'<>?,.`~", "!@#$%^ ()_+-=[]{; } ,.~");
|
||||
test_clean_filename("!@#$%^&*()_+-=[]{}\\|:\";'<>?,.`~", "; ,.~");
|
||||
test_clean_filename("عرفها بعد قد. هذا مع تاريخ اليميني واندونيسيا،, لعدم تاريخ لهيمنة الى",
|
||||
"عرفها بعد قد.هذا مع تاريخ اليميني");
|
||||
test_clean_filename(
|
||||
"012345678901234567890123456789012345678901234567890123456789adsasdasdsaa.01234567890123456789asdasdasdasd",
|
||||
"012345678901234567890123456789012345678901234567890123456789.01234567890123456789");
|
||||
test_clean_filename(
|
||||
"01234567890123456789012345678901234567890123456789<>*?: <>*?:0123456789adsasdasdsaa. "
|
||||
"0123456789`<><<>><><>0123456789asdasdasdasd",
|
||||
"01234567890123456789012345678901234567890123456789.0123456789");
|
||||
test_clean_filename(
|
||||
"01234567890123456789012345678901234567890123456789<>*?: <>*?:0123456789adsasdasdsaa. "
|
||||
"0123456789`<><><>0123456789asdasdasdasd",
|
||||
"01234567890123456789012345678901234567890123456789.0123456789 012");
|
||||
test_clean_filename("C:/document.tar.gz", "document.tar.gz");
|
||||
test_clean_filename("test....", "test");
|
||||
test_clean_filename("....test", "test");
|
||||
test_clean_filename("test.exe....", "test.exe"); // extension has changed
|
||||
test_clean_filename("test.exe01234567890123456789....",
|
||||
"test.exe01234567890123456789"); // extension may be more than 20 characters
|
||||
test_clean_filename("....test....asdf", "test.asdf");
|
||||
test_clean_filename("കറുപ്പ്.txt", "കറപപ.txt");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue