1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Copyright (c) 2006-2011 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "gdcmSystem.h"
#include "gdcmTesting.h"
#include <cstring> // strdup
#include <vector>
int TestSystem3(int, char *[])
{
const char isostr[] = "\\ISO 2022 IR 13\\ISO 2022 IR 87";
const char delim[] = "\\";
char *token;
{
char *query = strdup( isostr );
char *str1;
char *saveptr1;
std::vector< std::string > v;
for (str1 = query; ; str1 = nullptr)
{
token = gdcm::System::StrTokR(str1, delim, &saveptr1);
if (token == nullptr)
break;
//std::cout << "[" << token << "]" << std::endl;
v.emplace_back(token );
}
free( query );
if( v.size() != 2 ) return 1;
if( v[0] != "ISO 2022 IR 13" ) return 1;
if( v[1] != "ISO 2022 IR 87" ) return 1;
}
{
std::vector< std::string > v;
char *string = strdup( isostr );
if(!string) return 1;
char *copy = string;
while ((token = gdcm::System::StrSep(&string, delim)) != nullptr)
{
//printf("token=%s\n", token);
v.emplace_back(token );
}
free( copy );
if( v.size() != 3 ) return 1;
if( !v[0].empty() ) return 1;
if( v[1] != "ISO 2022 IR 13" ) return 1;
if( v[2] != "ISO 2022 IR 87" ) return 1;
}
return 0;
}
|