added strchr_test.cpp
This commit is contained in:
parent
e5675377b1
commit
f2cf3f5db4
@ -27,6 +27,9 @@ cm_example_project("DataType" CollectionTest)
|
||||
add_executable(SplitStringTest datatype/SplitStringTest.cpp)
|
||||
cm_example_project("DataType" SplitStringTest)
|
||||
|
||||
add_executable(StrChrTest datatype/strchr_test.cpp)
|
||||
cm_example_project("DataType" StrChrTest)
|
||||
|
||||
add_executable(MultiMapTest datatype/MultiMapTest.cpp)
|
||||
cm_example_project("DataType" MultiMapTest)
|
||||
|
||||
|
43
datatype/strchr_test.cpp
Normal file
43
datatype/strchr_test.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
#include<hgl/type/String.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<iostream>
|
||||
|
||||
void out(const char *source,const char *result)
|
||||
{
|
||||
std::cout<<source<<" return \""<<result<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
void out(const char *source,const hgl::UTF8String ¶m,const hgl::UTF8String &result)
|
||||
{
|
||||
std::cout<<source<<"(\""<<param.c_str()<<"\") return \""<<result.c_str()<<"\""<<std::endl;
|
||||
}
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
constexpr char str[]="hello,world!";
|
||||
|
||||
std::cout<<"str: \""<<str<<"\""<<std::endl;
|
||||
|
||||
out("strchr(str,',')",hgl::strchr(str,','));
|
||||
out("strrchr(str,strlen(str),',')",hgl::strrchr(str,hgl::strlen(str),','));
|
||||
|
||||
out("strchr(str,\"el\",2)",hgl::strchr(str,"el",2));
|
||||
out("strrchr(str,strlen(str),\"el\",2)",hgl::strrchr(str,hgl::strlen(str),"el",2));
|
||||
|
||||
out("strrchr(str,strlen(str),3,'l')",hgl::strrchr(str,hgl::strlen(str),3,'l'));
|
||||
out("strrchr(str,strlen(str),3,\"el\",2)",hgl::strrchr(str,hgl::strlen(str),3,"el",2));
|
||||
|
||||
hgl::UTF8String fn("C:\\1.txt");
|
||||
|
||||
out("ClipFilename",fn,hgl::filesystem::ClipFilename(fn));
|
||||
|
||||
hgl::UTF8String tp1("C:\\1\\2");
|
||||
hgl::UTF8String tp2("C:\\1\\2\\");
|
||||
hgl::UTF8String tp3("C:\\1\\2\\\\");
|
||||
|
||||
out("ClipLastPathname",tp1,hgl::filesystem::ClipLastPathname(tp1));
|
||||
out("ClipLastPathname",tp2,hgl::filesystem::ClipLastPathname(tp2));
|
||||
out("ClipLastPathname",tp3,hgl::filesystem::ClipLastPathname(tp3));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user