no message

master
zcy 2021-12-20 15:24:06 +08:00
parent 3802e5a66d
commit eecb67b88a
1 changed files with 17 additions and 9 deletions

View File

@ -18,33 +18,40 @@ void TestRingBuffer(){
} }
RingBuffer<int> x(1024); RingBuffer<int> x(1024);
int ret = x.Add(in,512); int ret = x.Add(in,512);
std::cout<<"add "<<ret<<"\r\n"<<std::endl;
std::cout<<"recv "<<ret<<"\r\n"<<std::endl; for(uint32_t i = 0;i < x.Length();i++){
for(uint32_t i = 0;i < x.Size();i++){
printf("%d ",x.At(i)); printf("%d ",x.At(i));
} }
std::cout<<"\r\n----------------------------------"<<std::endl;
x.SetEmpty(); x.SetEmpty();
ret = x.Add(in,516); ret = x.Add(in,516);
std::cout<<"recv "<<ret<<"\r\n"<<std::endl; std::cout<<"add "<<ret<<"\r\n"<<std::endl;
for(uint32_t i = 0;i < x.Size();i++){ for(uint32_t i = 0;i < x.Length();i++){
printf("%d ",x.At(i)); printf("%d ",x.At(i));
} }
std::cout<<"\r\n----------------------------------"<<std::endl;
ret = x.Add(in,20); ret = x.Add(in,20);
std::cout<<"recv "<<ret<<"\r\n"<<std::endl; std::cout<<"add "<<ret<<"\r\n"<<std::endl;
for(uint32_t i = 0;i < x.Size();i++){ for(uint32_t i = 0;i < x.Length();i++){
printf("%d ",x.At(i)); printf("%d ",x.At(i));
} }
std::cout<<"\r\n----------------------------------"<<std::endl;
ret = x.Copy(in,516); ret = x.Copy(in,516);
std::cout<<"\r\ncopy "<<ret<<"\r\n"<<std::endl; std::cout<<"\r\ncopy "<<ret<<"\r\n"<<std::endl;
std::cout<<"\r\n----------------------------------"<<std::endl;
for(uint32_t i = 0;i < ret;i++){ for(uint32_t i = 0;i < ret;i++){
printf("%d ",in[i]); printf("%d ",in[i]);
} }
std::cout<<"\r\n----------------------------------"<<std::endl;
ret = x.Take(in,516); ret = x.Take(in,516);
std::cout<<"take "<<ret<<"\r\n"<<std::endl; std::cout<<"take "<<ret<<"\r\n"<<std::endl;
for(uint32_t i = 0;i < ret;i++){ for(uint32_t i = 0;i < ret;i++){
printf("%d ",in[i]); printf("%d ",in[i]);
} }
std::cout<<"\r\n----------------------------------"<<std::endl;
ret = x.Take(in,20); ret = x.Take(in,20);
std::cout<<"take "<<ret<<"\r\n"<<std::endl; std::cout<<"take "<<ret<<"\r\n"<<std::endl;
for(uint32_t i = 0;i < ret;i++){ for(uint32_t i = 0;i < ret;i++){
@ -55,5 +62,6 @@ void TestRingBuffer(){
int main() { int main() {
std::cout<<"main"<<std::endl; std::cout<<"main"<<std::endl;
TestRingBuffer();
} }