replace tabs
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@419 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
c9fa59ada0
commit
727b519348
1 changed files with 52 additions and 50 deletions
|
@ -10,6 +10,8 @@
|
||||||
// without express or implied warranty.
|
// without express or implied warranty.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// $Header:
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#pragma warning (disable : 4786) // Get rid of browser information too long names
|
#pragma warning (disable : 4786) // Get rid of browser information too long names
|
||||||
|
@ -105,10 +107,10 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
{
|
{
|
||||||
test = RandomString(&test, maxString);
|
test = RandomString(&test, maxString);
|
||||||
|
|
||||||
static unsigned int functionSelector = 0;
|
static unsigned int functionSelector = 0;
|
||||||
++functionSelector;
|
++functionSelector;
|
||||||
currentTest = functionSelector % 90;
|
currentTest = functionSelector % 90;
|
||||||
//std::cout << currentTest <<"\n";
|
//std::cout << currentTest <<"\n";
|
||||||
switch (currentTest)
|
switch (currentTest)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -215,23 +217,23 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
// exercise empty
|
// exercise empty
|
||||||
{
|
{
|
||||||
const char* kEmptyString = "empty";
|
const char* kEmptyString = "empty";
|
||||||
const char* kNonEmptyString = "not empty";
|
const char* kNonEmptyString = "not empty";
|
||||||
if (test.empty()) test = "empty";
|
if (test.empty()) test = "empty";
|
||||||
else test = "not empty";
|
else test = "not empty";
|
||||||
// the above assignments don't work yet; use iterator assign
|
// the above assignments don't work yet; use iterator assign
|
||||||
if (test.empty()) test = String(kEmptyString, kEmptyString + strlen(kEmptyString));
|
if (test.empty()) test = String(kEmptyString, kEmptyString + strlen(kEmptyString));
|
||||||
else test = String(kNonEmptyString, kNonEmptyString + strlen(kNonEmptyString));
|
else test = String(kNonEmptyString, kNonEmptyString + strlen(kNonEmptyString));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
// exercise element access 21.3.4
|
// exercise element access 21.3.4
|
||||||
if(!test.empty())
|
if(!test.empty())
|
||||||
{
|
{
|
||||||
test[random(0, test.size() - 1)];
|
test[random(0, test.size() - 1)];
|
||||||
test.at(random(0, test.size() - 1));
|
test.at(random(0, test.size() - 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
// 21.3.5 modifiers
|
// 21.3.5 modifiers
|
||||||
|
@ -291,7 +293,7 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
std::list<char> lst(RandomList(maxString));
|
std::list<char> lst(RandomList(maxString));
|
||||||
test.append(lst.begin(), lst.end());
|
test.append(lst.begin(), lst.end());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
// 21.3.5 modifiers
|
// 21.3.5 modifiers
|
||||||
// skip push_back, Dinkumware doesn't support it
|
// skip push_back, Dinkumware doesn't support it
|
||||||
|
@ -382,7 +384,7 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
case 42:
|
case 42:
|
||||||
// 21.3.5 modifiers
|
// 21.3.5 modifiers
|
||||||
if(!test.empty())
|
if(!test.empty())
|
||||||
test.erase(test.begin() + random(0, test.size()));
|
test.erase(test.begin() + random(0, test.size()));
|
||||||
break;
|
break;
|
||||||
case 43:
|
case 43:
|
||||||
// 21.3.5 modifiers
|
// 21.3.5 modifiers
|
||||||
|
@ -535,7 +537,7 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
n = random(0, test.size() - pos);
|
n = random(0, test.size() - pos);
|
||||||
typename String::iterator b = test.begin();
|
typename String::iterator b = test.begin();
|
||||||
const String str = RandomString(&test, maxString);
|
const String str = RandomString(&test, maxString);
|
||||||
const typename String::value_type* s = str.c_str();
|
const typename String::value_type* s = str.c_str();
|
||||||
test.replace(
|
test.replace(
|
||||||
b + pos,
|
b + pos,
|
||||||
b + pos + n,
|
b + pos + n,
|
||||||
|
@ -555,8 +557,8 @@ String Test(String, unsigned int count, bool avoidAliasing)
|
||||||
case 56:
|
case 56:
|
||||||
// 21.3.5 modifiers
|
// 21.3.5 modifiers
|
||||||
{
|
{
|
||||||
std::vector<typename String::value_type>
|
std::vector<typename String::value_type>
|
||||||
vec(random(0, maxString));
|
vec(random(0, maxString));
|
||||||
test.copy(
|
test.copy(
|
||||||
&vec[0],
|
&vec[0],
|
||||||
vec.size(),
|
vec.size(),
|
||||||
|
@ -866,16 +868,16 @@ template<class T>
|
||||||
void checkResults(const std::string& reference, const T& tested)
|
void checkResults(const std::string& reference, const T& tested)
|
||||||
{
|
{
|
||||||
if( (tested.size() != reference.size())||
|
if( (tested.size() != reference.size())||
|
||||||
(std::string(tested.data(), tested.size()) != reference) )
|
(std::string(tested.data(), tested.size()) != reference) )
|
||||||
{
|
{
|
||||||
std::cout << "\nTest " << currentTest << " failed: \n";
|
std::cout << "\nTest " << currentTest << " failed: \n";
|
||||||
std::cout << "reference.size() = " << reference.size() << "\n";
|
std::cout << "reference.size() = " << reference.size() << "\n";
|
||||||
std::cout << "tested.size() = " << tested.size() << "\n";
|
std::cout << "tested.size() = " << tested.size() << "\n";
|
||||||
std::cout << "reference data = " << reference << "\n";
|
std::cout << "reference data = " << reference << "\n";
|
||||||
std::cout << "tested data = " << tested << "\n";
|
std::cout << "tested data = " << tested << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
//assert(tested.size() == reference.size());
|
//assert(tested.size() == reference.size());
|
||||||
//assert(std::string(tested.data(), tested.size()) == reference);
|
//assert(std::string(tested.data(), tested.size()) == reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -892,7 +894,7 @@ void Compare()
|
||||||
srand(t);
|
srand(t);
|
||||||
const std::string reference = Test(std::string(), 1, true);
|
const std::string reference = Test(std::string(), 1, true);
|
||||||
|
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef flex_string<
|
typedef flex_string<
|
||||||
char,
|
char,
|
||||||
|
@ -901,10 +903,10 @@ void Compare()
|
||||||
SimpleStringStorage<char, std::allocator<char> >
|
SimpleStringStorage<char, std::allocator<char> >
|
||||||
> my_string;
|
> my_string;
|
||||||
const my_string tested = Test(my_string(), 1, false);
|
const my_string tested = Test(my_string(), 1, false);
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef flex_string<
|
typedef flex_string<
|
||||||
char,
|
char,
|
||||||
|
@ -913,10 +915,10 @@ void Compare()
|
||||||
AllocatorStringStorage<char, std::allocator<char> >
|
AllocatorStringStorage<char, std::allocator<char> >
|
||||||
> my_string;
|
> my_string;
|
||||||
const my_string tested = Test(my_string(), 1, false);
|
const my_string tested = Test(my_string(), 1, false);
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef flex_string<
|
typedef flex_string<
|
||||||
char,
|
char,
|
||||||
|
@ -925,10 +927,10 @@ void Compare()
|
||||||
AllocatorStringStorage<char, mallocator<char> >
|
AllocatorStringStorage<char, mallocator<char> >
|
||||||
> my_string;
|
> my_string;
|
||||||
const my_string tested = Test(my_string(), 1, false);
|
const my_string tested = Test(my_string(), 1, false);
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef flex_string<
|
typedef flex_string<
|
||||||
char,
|
char,
|
||||||
|
@ -937,9 +939,9 @@ void Compare()
|
||||||
VectorStringStorage<char, std::allocator<char> >
|
VectorStringStorage<char, std::allocator<char> >
|
||||||
> my_string;
|
> my_string;
|
||||||
const my_string tested = Test(my_string(), 1, false);
|
const my_string tested = Test(my_string(), 1, false);
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef VectorStringStorage<char, std::allocator<char> >
|
typedef VectorStringStorage<char, std::allocator<char> >
|
||||||
Storage;
|
Storage;
|
||||||
|
@ -951,7 +953,7 @@ void Compare()
|
||||||
> my_string;
|
> my_string;
|
||||||
static my_string sample;
|
static my_string sample;
|
||||||
const my_string tested(Test(sample, 1, false));
|
const my_string tested(Test(sample, 1, false));
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
|
@ -965,7 +967,7 @@ void Compare()
|
||||||
> my_string;
|
> my_string;
|
||||||
static my_string sample;
|
static my_string sample;
|
||||||
const my_string tested(Test(sample, 1, false));
|
const my_string tested(Test(sample, 1, false));
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
srand(t);
|
srand(t);
|
||||||
|
@ -979,12 +981,12 @@ void Compare()
|
||||||
> my_string;
|
> my_string;
|
||||||
static my_string sample;
|
static my_string sample;
|
||||||
const my_string tested(Test(sample, 1, false));
|
const my_string tested(Test(sample, 1, false));
|
||||||
checkResults(reference, tested);
|
checkResults(reference, tested);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
{ // SimpleStringStorage with UTF16 Encoding
|
{ // SimpleStringStorage with UTF16 Encoding
|
||||||
srand(t);
|
srand(t);
|
||||||
typedef SimpleStringStorage<unicode::UTF16Char>
|
typedef SimpleStringStorage<unicode::UTF16Char>
|
||||||
Storage;
|
Storage;
|
||||||
typedef flex_string<
|
typedef flex_string<
|
||||||
unicode::UTF16Char,
|
unicode::UTF16Char,
|
||||||
|
@ -997,7 +999,7 @@ void Compare()
|
||||||
assert(tested.size() == reference.size());
|
assert(tested.size() == reference.size());
|
||||||
//assert(std::string(tested.data(), tested.size()) == reference);
|
//assert(std::string(tested.data(), tested.size()) == reference);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -1022,10 +1024,10 @@ int main()
|
||||||
|
|
||||||
assert(std::numeric_limits<char_type>::is_specialized);
|
assert(std::numeric_limits<char_type>::is_specialized);
|
||||||
|
|
||||||
assert(std::numeric_limits<std_string_t::iterator::value_type>::is_specialized);
|
assert(std::numeric_limits<std_string_t::iterator::value_type>::is_specialized);
|
||||||
s1.replace<std_string_t::iterator>(s1.begin(), s1.begin(),
|
s1.replace<std_string_t::iterator>(s1.begin(), s1.begin(),
|
||||||
s2.begin(),s2.end());
|
s2.begin(),s2.end());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
int main()
|
int main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue