From a7e21c9ddf587c4a6510bab783e16ad4c71570dd Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Wed, 9 Aug 2023 17:14:54 +0800 Subject: [PATCH] upgraded StackTest, test OK! --- CMakeLists.txt | 26 +++++---- datatype/StackTest.cpp | 127 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 133 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83ab21f..547864c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,13 +21,6 @@ endmacro() add_executable(HalfFloatTest datatype/HalfFloatTest.cpp) cm_example_project("DataType" HalfFloatTest) -add_executable(LifetimeTest datatype/LifetimeTest.cpp) -#cm_example_project("DataType" LifetimeTest) -set_property(TARGET LifetimeTest PROPERTY FOLDER "CM/Examples/DataType") - -add_executable(CollectionTest datatype/CollectionTest.cpp) -cm_example_project("DataType" CollectionTest) - add_executable(SplitStringTest datatype/SplitStringTest.cpp) cm_example_project("DataType" SplitStringTest) @@ -53,17 +46,26 @@ cm_example_project("DataType/RAM" RuntimeAssetManagerTest) add_executable(Size2Test datatype/Size2Test.cpp) 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(LifetimeTest datatype/LifetimeTest.cpp) +#cm_example_project("DataType" LifetimeTest) +set_property(TARGET LifetimeTest PROPERTY FOLDER "CM/Examples/DataType/DataArray") + +add_executable(CollectionTest datatype/CollectionTest.cpp) +cm_example_project("DataType/DataArray" CollectionTest) + +add_executable(DataArrayTest datatype/DataArrayTest.cpp) +cm_example_project("DataType/DataArray" DataArrayTest) + add_executable(StackTest datatype/StackTest.cpp) -cm_example_project("DataType" StackTest) +set_property(TARGET StackTest PROPERTY FOLDER "CM/Examples/DataType/DataArray") add_executable(QueueTest datatype/QueueTest.cpp) -set_property(TARGET QueueTest PROPERTY FOLDER "CM/Examples/DataType") +set_property(TARGET QueueTest PROPERTY FOLDER "CM/Examples/DataType/DataArray") #################################################################################################### diff --git a/datatype/StackTest.cpp b/datatype/StackTest.cpp index f898aa4..d1ce515 100644 --- a/datatype/StackTest.cpp +++ b/datatype/StackTest.cpp @@ -1,11 +1,15 @@ -#include +#include #include using namespace hgl; using namespace std; -void TestStack() +void TestStackOrdered() { + cout< tab; int i; @@ -30,17 +34,110 @@ void TestStack() cout<<"Stack Count: "< tab; + int i; + int val; + + for(i=0;i<20;i++) + { + if(rand()&1) + { + if(tab.Pop(val)) + cout<<"pop "< ui_queue; + + for(uint i=0;i tab; int i; for(i=0;i<10;i++) { - tab.Push(new StackTestObject(i)); + StackTestObject *obj=new StackTestObject; + + obj->Set(i); + + tab.Push(obj); } cout<<"Stack Count: "<