From c29f25daeb95eb6ab3780f0b0998589f9de9b1de Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Fri, 21 Jul 2023 18:30:12 +0800 Subject: [PATCH] added Uint2HexStrTest.cpp and MapTest.cpp --- CMakeLists.txt | 6 +++ datatype/MapTest.cpp | 74 ++++++++++++++++++++++++++++++++++++ datatype/Uint2HexStrTest.cpp | 18 +++++++++ 3 files changed, 98 insertions(+) create mode 100644 datatype/MapTest.cpp create mode 100644 datatype/Uint2HexStrTest.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8498ca1..13f98c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ cm_example_project("DataType" SplitStringTest) add_executable(StrChrTest datatype/strchr_test.cpp) cm_example_project("DataType" StrChrTest) +add_executable(MapTest datatype/MapTest.cpp) +cm_example_project("DataType" MapTest) + add_executable(MultiMapTest datatype/MultiMapTest.cpp) cm_example_project("DataType" MultiMapTest) @@ -46,6 +49,9 @@ cm_example_project("DataType" Size2Test) add_executable(DataArrayTest datatype/DataArrayTest.cpp) cm_example_project("DataType" DataArrayTest) +add_executable(Uint2HexStrTest datatype/Uint2HexStrTest.cpp) +cm_example_project("DataType" Uint2HexStrTest) + #################################################################################################### add_executable(FixFilenameTest filesystem/FixFilenameTest.cpp) diff --git a/datatype/MapTest.cpp b/datatype/MapTest.cpp new file mode 100644 index 0000000..973702a --- /dev/null +++ b/datatype/MapTest.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include + +using namespace hgl; +using namespace std; + +void out_id(Map &int_map) +{ + const int count=int_map.GetCount(); + + cout<<"count:"< **p=int_map.GetDataList(); + +// for(int i=0;ileft<<","<<(*p)->right<<"]"; +// ++p; +// } + + //lambda用法 + int_map.Enum([](const int &key,int value) + { + cout<<"["< int_sets; + Map int_map; + + srand(time(nullptr)); + + for(int i=0;i<20;i++) + { + while(true) + { + index=rand()%20; + if(!int_sets.IsMember(index))break; + } + + int_sets.Add(index); + + value=rand()%255; + + cout<<"add index="<