Browse Source

Rename `ToPlainString()` method into `ToString()`

pull/8/head
Anton Tarasenko 3 years ago
parent
commit
ad3d786960
  1. 2
      docs/API/collections.md
  2. 4
      docs/API/text.md
  3. 2
      docs/objects.md
  4. 2
      docs/old_docs/API/Collections.md
  5. 2
      docs/old_docs/API/Databases/index.md
  6. 6
      sources/Aliases/AliasSource.uc
  7. 8
      sources/Aliases/Aliases.uc
  8. 14
      sources/Aliases/Tests/TEST_Aliases.uc
  9. 4
      sources/Avarice/Avarice.uc
  10. BIN
      sources/Avarice/Tests/TEST_AvariceStreamReader.uc
  11. 4
      sources/Commands/CommandParser.uc
  12. 28
      sources/Commands/Tests/TEST_Command.uc
  13. 58
      sources/Commands/Tests/TEST_CommandDataBuilder.uc
  14. 4
      sources/Config/AcediaConfig.uc
  15. 6
      sources/Config/Tests/TEST_AcediaConfig.uc
  16. 16
      sources/Data/Collections/Tests/TEST_AssociativeArray.uc
  17. 4
      sources/Data/Collections/Tests/TEST_CollectionsMixed.uc
  18. 4
      sources/Data/Collections/Tests/TEST_DynamicArray.uc
  19. 12
      sources/Data/Database/Local/DBRecord.uc
  20. 4
      sources/Data/Database/Local/LocalDatabase.uc
  21. 48
      sources/Data/Database/Tests/TEST_LocalDatabase.uc
  22. 2
      sources/Logger/ConsoleLogger.uc
  23. 2
      sources/Logger/Logger.uc
  24. 36
      sources/Logger/Tests/TEST_LogMessage.uc
  25. 2
      sources/Memory/MemoryAPI.uc
  26. 2
      sources/Testing/Service/TestingService.uc
  27. 10
      sources/Text/Parser.uc
  28. 112
      sources/Text/Tests/TEST_JSON.uc
  29. BIN
      sources/Text/Tests/TEST_Parser.uc
  30. 106
      sources/Text/Tests/TEST_Text.uc
  31. BIN
      sources/Text/Tests/TEST_TextAPI.uc
  32. 4
      sources/Text/Tests/TEST_TextCache.uc
  33. BIN
      sources/Text/Tests/TEST_UTF8EncoderDecoder.uc
  34. 4
      sources/Text/Text.uc
  35. 2
      sources/Text/TextAPI.uc
  36. 12
      sources/Types/Tests/TEST_Base.uc
  37. 10
      sources/Users/Tests/TEST_User.uc

2
docs/API/collections.md

@ -201,7 +201,7 @@ storage.SetItem( _.text.FromString("comment"),
item = storage.GetItem(_.text.FromString("year"));
TEST_ExpectTrue(IntRef(item).Get() == 2021);
item = storage.GetItem(_.text.FromString("comment"));
TEST_ExpectTrue(Text(item).ToPlainString() == "What year it is?");
TEST_ExpectTrue(Text(item).ToString() == "What year it is?");
```
In above example we've created separate text instances (with the same contents)

4
docs/API/text.md

@ -95,7 +95,7 @@ auxiliary = _.text.FromFormattedString("{$gold Hello}, {$crimson world}!");
// Produces a string colored with 4-byte codes, a native way for UnrealScript
auxiliary.ToColoredString();
// Strings all color and produces "Hello, world!"
auxiliary.ToPlainString();
auxiliary.ToString();
// Don't forget the cleanup!
_.memory.Free(auxiliary);
```
@ -145,7 +145,7 @@ text variants from a plain `string` and their analogues
for colored and formatted `string`s.
You can also get a `string` back by calling either of
`self.ToPlainString()` / `self.ToColoredString()` / `self.ToFormattedString()`
`self.ToString()` / `self.ToColoredString()` / `self.ToFormattedString()`
methods.
To duplicate `Text` / `MutableText` themselves you can use `Copy()`

2
docs/objects.md

@ -52,7 +52,7 @@ If you need to turn a `Text` object into a `string`, then you can either do:
```unrealscript
if (textToConvert != none)
{
result = textToConvert.ToPlainString();
result = textToConvert.ToString();
textToConvert.FreeSelf();
}
```

2
docs/old_docs/API/Collections.md

@ -151,7 +151,7 @@ storage.SetItem( _.text.FromString("comment"),
item = storage.GetItem(_.text.FromString("year"));
TEST_ExpectTrue(IntRef(item).Get() == 2021);
item = storage.GetItem(_.text.FromString("comment"));
TEST_ExpectTrue(Text(item).ToPlainString() == "What year it is?");
TEST_ExpectTrue(Text(item).ToString() == "What year it is?");
```
In above example we've created separate text instances (with the same contents) to store and retrieve items in `AssociativeArray`. However it's inefficient to each time create `Text` anew:

2
docs/old_docs/API/Databases/index.md

@ -75,7 +75,7 @@ private function DoPrint(DBQueryResult result, AcediaObject data)
{
nextNote = loadedArray.GetText(i);
if (nextNote != none) {
Log("Note" @ (i+1) $ "." @ loadedArray.GetText(i).ToPlainString());
Log("Note" @ (i+1) $ "." @ loadedArray.GetText(i).ToString());
}
else {
hadBadNotes = true;

6
sources/Aliases/AliasSource.uc

@ -242,8 +242,8 @@ public final function bool AddAlias(
}
else
{
newPair.alias = aliasToAdd.ToPlainString();
newPair.value = aliasValue.ToPlainString();
newPair.alias = aliasToAdd.ToString();
newPair.value = aliasValue.ToString();
record[record.length] = newPair;
}
aliasHash.SetItem(lowerCaseAlias, aliasValue);
@ -281,7 +281,7 @@ public final function RemoveAlias(Text aliasToRemove)
while (i < record.length)
{
isMatchingRecord = aliasToRemove
.CompareToPlainString(record[i].alias, SCASE_INSENSITIVE);
.CompareToString(record[i].alias, SCASE_INSENSITIVE);
if (isMatchingRecord)
{
record.Remove(i, 1);

8
sources/Aliases/Aliases.uc

@ -50,7 +50,7 @@ var protected config array<string> alias;
// `ToStorageVersion()` and `ToActualVersion()` do that.
private final static function string ToStorageVersion(Text actualValue)
{
return Repl(actualValue.ToPlainString(), ".", ":");
return Repl(actualValue.ToString(), ".", ":");
}
// See comment to `ToStorageVersion()`.
@ -147,11 +147,11 @@ public final function AddAlias(Text aliasToAdd)
if (aliasToAdd == none) return;
for (i = 0; i < alias.length; i += 1)
{
if (aliasToAdd.CompareToPlainString(alias[i], SCASE_INSENSITIVE)) {
if (aliasToAdd.CompareToString(alias[i], SCASE_INSENSITIVE)) {
return;
}
}
alias[alias.length] = aliasToAdd.ToPlainString();
alias[alias.length] = aliasToAdd.ToString();
AliasService(class'AliasService'.static.Require())
.PendingSaveObject(self);
}
@ -172,7 +172,7 @@ public final function RemoveAlias(Text aliasToRemove)
if (aliasToRemove == none) return;
while (i < alias.length)
{
if (aliasToRemove.CompareToPlainString(alias[i], SCASE_INSENSITIVE))
if (aliasToRemove.CompareToString(alias[i], SCASE_INSENSITIVE))
{
alias.Remove(i, 1);
removedAlias = true;

14
sources/Aliases/Tests/TEST_Aliases.uc

@ -32,14 +32,14 @@ protected static function SubTest_AliasLoadingCorrect()
local AliasSource source;
Issue("`Resolve()` fails to return alias value that should be loaded.");
source = __().alias.GetCustomSource(class'MockAliasSource');
TEST_ExpectTrue(source.Resolve(P("Global")).ToPlainString() == "value");
TEST_ExpectTrue(source.Resolve(P("ford")).ToPlainString() == "car");
TEST_ExpectTrue(source.Resolve(P("Global")).ToString() == "value");
TEST_ExpectTrue(source.Resolve(P("ford")).ToString() == "car");
Issue("`Resolve()` fails to return passed alias after failure to"
@ "load it's value.");
TEST_ExpectTrue( source.Resolve(P("nothinMuch"), true).ToPlainString()
TEST_ExpectTrue( source.Resolve(P("nothinMuch"), true).ToString()
== "nothinMuch");
TEST_ExpectTrue( source.Resolve(P("random"), true).ToPlainString()
TEST_ExpectTrue( source.Resolve(P("random"), true).ToString()
== "random");
Issue("`HasAlias()` reports alias, that should be present,"
@ -48,13 +48,13 @@ protected static function SubTest_AliasLoadingCorrect()
TEST_ExpectTrue(source.HasAlias(P("audi")));
Issue("Aliases in per-object-configs incorrectly handle ':'.");
TEST_ExpectTrue( source.Resolve(P("HardToBeAGod")).ToPlainString()
TEST_ExpectTrue( source.Resolve(P("HardToBeAGod")).ToString()
== "sci.fi");
Issue("Aliases with empty values in alias name or their value are handled"
@ "incorrectly.");
TEST_ExpectTrue(source.Resolve(P("")).ToPlainString() == "empty");
TEST_ExpectTrue(source.Resolve(P("also")).ToPlainString() == "");
TEST_ExpectTrue(source.Resolve(P("")).ToString() == "empty");
TEST_ExpectTrue(source.Resolve(P("also")).ToString() == "");
}
protected static function SubTest_AliasLoadingIncorrect()

4
sources/Avarice/Avarice.uc

@ -87,11 +87,11 @@ protected function FromData(AssociativeArray source)
}
nextText = nextLink.GetText(P("name"));
if (nextText != none) {
nextRecord.name = nextText.ToPlainString();
nextRecord.name = nextText.ToString();
}
nextText = nextLink.GetText(P("address"));
if (nextText != none) {
nextRecord.address = nextText.ToPlainString();
nextRecord.address = nextText.ToString();
}
link[i] = nextRecord;
}

BIN
sources/Avarice/Tests/TEST_AvariceStreamReader.uc

Binary file not shown.

4
sources/Commands/CommandParser.uc

@ -464,7 +464,7 @@ private final function bool ParseBooleanValue(
// Try to match parsed literal to any recognizable boolean literals
for (i = 0; i < booleanTrueEquivalents.length; i += 1)
{
if (parsedLiteral.CompareToPlainString( booleanTrueEquivalents[i],
if (parsedLiteral.CompareToString( booleanTrueEquivalents[i],
SCASE_INSENSITIVE))
{
isValidBooleanLiteral = true;
@ -475,7 +475,7 @@ private final function bool ParseBooleanValue(
for (i = 0; i < booleanFalseEquivalents.length; i += 1)
{
if (isValidBooleanLiteral) break;
if (parsedLiteral.CompareToPlainString( booleanFalseEquivalents[i],
if (parsedLiteral.CompareToString( booleanFalseEquivalents[i],
SCASE_INSENSITIVE))
{
isValidBooleanLiteral = true;

28
sources/Commands/Tests/TEST_Command.uc

@ -96,13 +96,13 @@ protected static function SubTest_CommandCallErrorNoRequiredParam()
.ProcessInput(PRS(default.queryAFailure1), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_NoRequiredParam);
TEST_ExpectTrue( result.GetErrorCause().ToPlainString()
TEST_ExpectTrue( result.GetErrorCause().ToString()
== "integer variable");
result = class'MockCommandA'.static.GetInstance()
.ProcessInput(PRS(default.queryAFailure2), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_NoRequiredParam);
TEST_ExpectTrue( result.GetErrorCause().ToPlainString()
TEST_ExpectTrue( result.GetErrorCause().ToString()
== "isItSimple?");
}
@ -114,7 +114,7 @@ protected static function SubTest_CommandCallErrorUnknownOption()
.ProcessInput(PRS(default.queryBFailureUnknownOptionLong), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_UnknownOption);
TEST_ExpectTrue( result.GetErrorCause().ToPlainString()
TEST_ExpectTrue( result.GetErrorCause().ToString()
== "kest");
Issue("`CET_UnknownShortOption` errors are incorrectly reported.");
result = class'MockCommandB'.static.GetInstance()
@ -132,7 +132,7 @@ protected static function SubTest_CommandCallErrorRepeatedOption()
.ProcessInput(PRS(default.queryBFailure2), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_RepeatedOption);
TEST_ExpectTrue( result.GetErrorCause().ToPlainString()
TEST_ExpectTrue( result.GetErrorCause().ToString()
== "forced");
}
@ -144,7 +144,7 @@ protected static function SubTest_CommandCallErrorUnusedCommandParameters()
.ProcessInput(PRS(default.queryBFailureUnused), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_UnusedCommandParameters);
TEST_ExpectTrue( result.GetErrorCause().ToPlainString()
TEST_ExpectTrue( result.GetErrorCause().ToString()
== "text -j");
}
@ -156,7 +156,7 @@ protected static function SubTest_CommandCallErrorMultipleOptionsWithParams()
.ProcessInput(PRS(default.queryBFailure1), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_MultipleOptionsWithParams);
TEST_ExpectTrue(result.GetErrorCause().ToPlainString() == "tv");
TEST_ExpectTrue(result.GetErrorCause().ToString() == "tv");
}
protected static function SubTest_CommandCallErrorNoRequiredParamForOption()
@ -167,12 +167,12 @@ protected static function SubTest_CommandCallErrorNoRequiredParamForOption()
.ProcessInput(PRS(default.queryBFailureNoReqParamOption1), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_NoRequiredParamForOption);
TEST_ExpectTrue(result.GetErrorCause().ToPlainString() == "long");
TEST_ExpectTrue(result.GetErrorCause().ToString() == "long");
result = class'MockCommandB'.static.GetInstance()
.ProcessInput(PRS(default.queryBFailureNoReqParamOption2), none);
TEST_ExpectFalse(result.IsSuccessful());
TEST_ExpectTrue(result.GetError() == CET_NoRequiredParamForOption);
TEST_ExpectTrue(result.GetErrorCause().ToPlainString() == "values");
TEST_ExpectTrue(result.GetErrorCause().ToString() == "values");
}
protected static function Test_SubCommandName()
@ -181,7 +181,7 @@ protected static function Test_SubCommandName()
Issue("Cannot determine subcommands.");
result = class'MockCommandA'.static.GetInstance()
.ProcessInput(PRS(default.queryASuccess1), none);
TEST_ExpectTrue(result.GetSubCommand().ToPlainString() == "simple");
TEST_ExpectTrue(result.GetSubCommand().ToString() == "simple");
Issue("Cannot determine when subcommands are missing.");
result = class'MockCommandA'.static.GetInstance()
@ -274,8 +274,8 @@ protected static function SubTest_MockAQ3()
// `Text`s
paramArray = DynamicArray(result.GetItem(P("another list")));
TEST_ExpectTrue(paramArray.GetLength() == 3);
TEST_ExpectTrue(Text(paramArray.GetItem(0)).ToPlainString() == "dk");
TEST_ExpectTrue(Text(paramArray.GetItem(1)).ToPlainString() == "someone");
TEST_ExpectTrue(Text(paramArray.GetItem(0)).ToString() == "dk");
TEST_ExpectTrue(Text(paramArray.GetItem(1)).ToString() == "someone");
TEST_ExpectTrue( Text(paramArray.GetItem(2)).ToFormattedString()
== "complex {rgb(123,45,72) string}");
}
@ -337,7 +337,7 @@ protected static function SubTest_MockBQ1()
TEST_ExpectTrue(subArray.GetLength() == 2);
TEST_ExpectTrue(IntBox(subArray.GetItem(0)).Get() == 7);
TEST_ExpectNone(subArray.GetItem(1));
TEST_ExpectTrue( Text(params.GetItem(P("just_text"))).ToPlainString()
TEST_ExpectTrue( Text(params.GetItem(P("just_text"))).ToString()
== "text");
options = result.GetOptions();
TEST_ExpectTrue(options.GetLength() == 1);
@ -372,7 +372,7 @@ protected static function SubTest_MockBQ2()
TEST_ExpectTrue(options.HasKey(P("forced")));
TEST_ExpectNone(options.GetItem(P("forced")));
subObject = AssociativeArray(options.GetItem(P("type")));
TEST_ExpectTrue( Text(subObject.GetItem(P("type"))).ToPlainString()
TEST_ExpectTrue( Text(subObject.GetItem(P("type"))).ToString()
== "value");
subObject = AssociativeArray(options.GetItem(P("Test")));
TEST_ExpectTrue(Text(subObject.GetItem(P("to_test"))).IsEmpty());
@ -398,7 +398,7 @@ protected static function SubTest_MockBQ3Remainder()
TEST_ExpectTrue(options.GetLength() == 1);
TEST_ExpectTrue(options.HasKey(P("remainder")));
subObject = AssociativeArray(options.GetItem(P("remainder")));
TEST_ExpectTrue( Text(subObject.GetItem(P("everything"))).ToPlainString()
TEST_ExpectTrue( Text(subObject.GetItem(P("everything"))).ToString()
== "--type \"value\" -va 8 -sV --forced -T \"\" 32");
}
// [1, 2, 3, 6]

58
sources/Commands/Tests/TEST_CommandDataBuilder.uc

@ -55,7 +55,7 @@ protected static function Command.SubCommand GetSubCommand(
local Command.SubCommand emptySubCommand;
for (i = 0; i < data.subcommands.length; i += 1)
{
if (data.subcommands[i].name.CompareToPlainString(subCommandName)) {
if (data.subcommands[i].name.CompareToString(subCommandName)) {
return data.subcommands[i];
}
}
@ -70,7 +70,7 @@ protected static function Command.Option GetOption(
local Command.Option emptyOption;
for (i = 0; i < data.options.length; i += 1)
{
if (data.options[i].longName.CompareToPlainString(subCommandName)) {
if (data.options[i].longName.CompareToString(subCommandName)) {
return data.options[i];
}
}
@ -113,9 +113,9 @@ protected static function Test_Full()
TEST_ExpectTrue(data.requiresTarget);
// Test empty sub command.
Issue("\"empty\" command was filled incorrectly.");
TEST_ExpectTrue( GetSubCommand(data, "empty").name.ToPlainString()
TEST_ExpectTrue( GetSubCommand(data, "empty").name.ToString()
== "empty");
TEST_ExpectTrue( GetSubCommand(data, "empty").description.ToPlainString()
TEST_ExpectTrue( GetSubCommand(data, "empty").description.ToString()
== "Empty one!");
TEST_ExpectTrue(GetSubCommand(data, "empty").required.length == 0);
TEST_ExpectTrue(GetSubCommand(data, "empty").optional.length == 0);
@ -133,26 +133,26 @@ protected static function SubTest_DefaultSubCommand(Command.Data data)
Issue("Default sub-command was filled incorrectly.");
subCommand = GetSubCommand(data, "");
TEST_ExpectTrue(subCommand.name.IsEmpty());
TEST_ExpectTrue(subCommand.description.ToPlainString() == "Simple command");
TEST_ExpectTrue(subCommand.description.ToString() == "Simple command");
TEST_ExpectTrue(subCommand.required.length == 2);
TEST_ExpectTrue(subCommand.optional.length == 1);
// Required
TEST_ExpectTrue( subCommand.required[0].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].displayName.ToString()
== "var");
TEST_ExpectTrue( subCommand.required[0].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].variableName.ToString()
== "var");
TEST_ExpectTrue(subCommand.required[0].type == CPT_Number);
TEST_ExpectFalse(subCommand.required[0].allowsList);
TEST_ExpectTrue( subCommand.required[1].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[1].displayName.ToString()
== "str_var");
TEST_ExpectTrue( subCommand.required[1].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[1].variableName.ToString()
== "otherName");
TEST_ExpectTrue(subCommand.required[1].type == CPT_Text);
TEST_ExpectFalse(subCommand.required[1].allowsList);
// Optional
TEST_ExpectTrue( subCommand.optional[0].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.optional[0].displayName.ToString()
== "list");
TEST_ExpectTrue( subCommand.optional[0].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.optional[0].variableName.ToString()
== "list");
TEST_ExpectTrue(subCommand.optional[0].type == CPT_Boolean);
TEST_ExpectTrue(subCommand.optional[0].booleanFormat == PBF_OnOff);
@ -164,27 +164,27 @@ protected static function SubTest_subSubCommand(Command.Data data)
local Command.SubCommand subCommand;
Issue("\"sub\" sub-command was filled incorrectly.");
subCommand = GetSubCommand(data, "sub");
TEST_ExpectTrue(subCommand.name.ToPlainString() == "sub");
TEST_ExpectTrue( subCommand.description.ToPlainString()
TEST_ExpectTrue(subCommand.name.ToString() == "sub");
TEST_ExpectTrue( subCommand.description.ToString()
== "Alternative command! Updated!");
TEST_ExpectTrue(subCommand.required.length == 3);
TEST_ExpectTrue(subCommand.optional.length == 0);
// Required
TEST_ExpectTrue( subCommand.required[0].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].displayName.ToString()
== "array_var");
TEST_ExpectTrue( subCommand.required[0].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].variableName.ToString()
== "array_var");
TEST_ExpectTrue(subCommand.required[0].type == CPT_Array);
TEST_ExpectFalse(subCommand.required[0].allowsList);
TEST_ExpectTrue( subCommand.required[1].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[1].displayName.ToString()
== "int");
TEST_ExpectTrue( subCommand.required[1].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[1].variableName.ToString()
== "int");
TEST_ExpectTrue(subCommand.required[1].type == CPT_Integer);
TEST_ExpectTrue(subCommand.required[1].allowsList);
TEST_ExpectTrue( subCommand.required[2].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[2].displayName.ToString()
== "one_more");
TEST_ExpectTrue( subCommand.required[2].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[2].variableName.ToString()
== "but");
TEST_ExpectTrue(subCommand.required[2].type == CPT_Object);
TEST_ExpectTrue(subCommand.required[2].allowsList);
@ -195,14 +195,14 @@ protected static function SubTest_huhSubCommand(Command.Data data)
local Command.SubCommand subCommand;
Issue("\"huh\" sub-command was filled incorrectly.");
subCommand = GetSubCommand(data, "huh");
TEST_ExpectTrue(subCommand.name.ToPlainString() == "huh");
TEST_ExpectTrue(subCommand.name.ToString() == "huh");
TEST_ExpectNone(subCommand.description);
TEST_ExpectTrue(subCommand.required.length == 1);
TEST_ExpectTrue(subCommand.optional.length == 0);
// Required
TEST_ExpectTrue( subCommand.required[0].displayName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].displayName.ToString()
== "list");
TEST_ExpectTrue( subCommand.required[0].variableName.ToPlainString()
TEST_ExpectTrue( subCommand.required[0].variableName.ToString()
== "list");
TEST_ExpectTrue(subCommand.required[0].type == CPT_Number);
TEST_ExpectFalse(subCommand.required[0].allowsList);
@ -213,9 +213,9 @@ protected static function SubTest_silentOption(Command.Data data)
local Command.Option option;
Issue("\"silent\" option was filled incorrectly.");
option = GetOption(data, "silent");
TEST_ExpectTrue(option.longName.ToPlainString() == "silent");
TEST_ExpectTrue(option.longName.ToString() == "silent");
TEST_ExpectTrue(option.shortName.codePoint == 0x73); // s
TEST_ExpectTrue( option.description.ToPlainString()
TEST_ExpectTrue( option.description.ToString()
== "Just an option, I dunno.");
TEST_ExpectTrue(option.required.length == 0);
TEST_ExpectTrue(option.optional.length == 0);
@ -226,21 +226,21 @@ protected static function SubTest_ParamsOption(Command.Data data)
local Command.Option option;
Issue("\"Params\" option was filled incorrectly.");
option = GetOption(data, "Params");
TEST_ExpectTrue(option.longName.ToPlainString() == "Params");
TEST_ExpectTrue(option.longName.ToString() == "Params");
TEST_ExpectTrue(option.shortName.codePoint == 0x64);
TEST_ExpectNone(option.description);
TEST_ExpectTrue(option.required.length == 1);
TEST_ExpectTrue(option.optional.length == 1);
// Required
TEST_ExpectTrue(option.required[0].displayName.ToPlainString() == "www");
TEST_ExpectTrue( option.required[0].variableName.ToPlainString()
TEST_ExpectTrue(option.required[0].displayName.ToString() == "www");
TEST_ExpectTrue( option.required[0].variableName.ToString()
== "random");
TEST_ExpectTrue(option.required[0].type == CPT_Boolean);
TEST_ExpectTrue(option.required[0].booleanFormat == PBF_YesNo);
TEST_ExpectFalse(option.required[0].allowsList);
// Optional
TEST_ExpectTrue(option.optional[0].displayName.ToPlainString() == "www2");
TEST_ExpectTrue(option.optional[0].variableName.ToPlainString() == "www2");
TEST_ExpectTrue(option.optional[0].displayName.ToString() == "www2");
TEST_ExpectTrue(option.optional[0].variableName.ToString() == "www2");
TEST_ExpectTrue(option.optional[0].type == CPT_Integer);
TEST_ExpectTrue(option.optional[0].allowsList);
}

4
sources/Config/AcediaConfig.uc

@ -167,7 +167,7 @@ public final static function bool NewConfig(Text name)
return false;
}
newConfig =
new(none, NameToStorageVersion(name.ToPlainString())) default.class;
new(none, NameToStorageVersion(name.ToString())) default.class;
newConfig._ = __();
newConfig.DefaultIt();
newConfig.SaveConfig();
@ -262,7 +262,7 @@ public final static function AcediaConfig GetConfigInstance(Text name)
if (configEntry.value == none && configEntry.key != none)
{
configEntry.value =
new(none, NameToStorageVersion(name.ToPlainString())) default.class;
new(none, NameToStorageVersion(name.ToString())) default.class;
configEntry.value._ = __();
default.existingConfigs.SetItem(configEntry.key, configEntry.value);
}

6
sources/Config/Tests/TEST_AcediaConfig.uc

@ -42,7 +42,7 @@ protected static function TEST_AvailableConfigs()
Issue("Configs with incorrect names or values are loaded.");
for (i = 0; i < configNames.length; i += 1)
{
if (configNames[i].CompareToPlainString("default", SCASE_INSENSITIVE)) {
if (configNames[i].CompareToString("default", SCASE_INSENSITIVE)) {
foundConfig = true;
}
}
@ -50,7 +50,7 @@ protected static function TEST_AvailableConfigs()
foundConfig = false;
for (i = 0; i < configNames.length; i += 1)
{
if (configNames[i].CompareToPlainString("other", SCASE_INSENSITIVE)) {
if (configNames[i].CompareToString("other", SCASE_INSENSITIVE)) {
foundConfig = true;
}
}
@ -58,7 +58,7 @@ protected static function TEST_AvailableConfigs()
foundConfig = false;
for (i = 0; i < configNames.length; i += 1)
{
if (configNames[i].CompareToPlainString("another.config",
if (configNames[i].CompareToString("another.config",
SCASE_INSENSITIVE)) {
foundConfig = true;
}

16
sources/Data/Collections/Tests/TEST_AssociativeArray.uc

@ -48,7 +48,7 @@ protected static function Test_GetSet()
array.SetItem(__().text.FromString("key"), textObject);
array.SetItem(__().box.int(13), __().text.FromString("value #2"));
array.SetItem(__().box.float(345.2), __().box.bool(true));
TEST_ExpectTrue( Text(array.GetItem(__().box.int(13))).ToPlainString()
TEST_ExpectTrue( Text(array.GetItem(__().box.int(13))).ToString()
== "value #2");
TEST_ExpectTrue(array.GetItem(__().text.FromString("key")) == textObject);
TEST_ExpectTrue(BoolBox(array.GetItem(__().box.float(345.2))).Get());
@ -58,7 +58,7 @@ protected static function Test_GetSet()
array.SetItem(__().box.int(13), __().box.int(11));
TEST_ExpectFalse(array.GetItem(__().text.FromString("key")) == textObject);
TEST_ExpectTrue( Text(array.GetItem(__().text.FromString("key")))
.ToPlainString() == "value");
.ToString() == "value");
TEST_ExpectTrue( IntBox(array.GetItem(__().box.int(13))).Get()
== 11);
@ -144,10 +144,10 @@ protected static function Test_CopyTextKeys()
keys = array.CopyTextKeys();
TEST_ExpectTrue(keys.length == 2);
TEST_ExpectTrue(
(keys[0].ToPlainString() == "key"
&& keys[1].ToPlainString() == "second key")
|| (keys[0].ToPlainString() == "second key"
&& keys[1].ToPlainString() == "key"));
(keys[0].ToString() == "key"
&& keys[1].ToString() == "second key")
|| (keys[0].ToString() == "second key"
&& keys[1].ToString() == "key"));
Issue("Deallocating keys returned by `CopyTextKeys()` affects their"
@ "source collection.");
@ -156,7 +156,7 @@ protected static function Test_CopyTextKeys()
TEST_ExpectNotNone(array.GetItem(__().text.FromString("key")));
TEST_ExpectNotNone(array.GetItem(__().text.FromString("second key")));
TEST_ExpectTrue(
array.GetText(__().text.FromString("key")).ToPlainString() == "value");
array.GetText(__().text.FromString("key")).ToString() == "value");
}
protected static function Test_Remove()
@ -193,7 +193,7 @@ protected static function Test_CreateItem()
array.CreateItem(__().box.float(17.895), class'IntRef');
array.CreateItem(__().text.FromString("key #2"), class'BoolBox');
TEST_ExpectTrue(Text(array.GetItem(__().text.FromString("key")))
.ToPlainString() == "");
.ToString() == "");
TEST_ExpectTrue( IntRef(array.GetItem(__().box.float(17.895))).Get()
== 0);
TEST_ExpectFalse(BoolBox(array.GetItem(__().text.FromString("key #2")))

4
sources/Data/Collections/Tests/TEST_CollectionsMixed.uc

@ -50,7 +50,7 @@ protected static function Test_GetBy()
@ "'~'-escaped sequences.");
result = obj.GetItemBy(P("/another~01var"));
TEST_ExpectNotNone(Text(result));
TEST_ExpectTrue(Text(result).ToPlainString() == "aye!");
TEST_ExpectTrue(Text(result).ToString() == "aye!");
result = obj.GetItemBy(P("/innerObject/one more/no~1pe"));
TEST_ExpectNotNone(IntBox(result));
TEST_ExpectTrue(IntBox(result).Get() == 324532);
@ -83,7 +83,7 @@ protected static function Test_GetTypeBy()
.GetFloatBy(P("/innerObject/array/4"), 2.34)
== 56.6);
TEST_ExpectTrue(obj
.GetTextBy(P("/innerObject/one more/o rly?")).ToPlainString()
.GetTextBy(P("/innerObject/one more/o rly?")).ToString()
== "ya rly");
Issue("`Get<Type>By()` methods do not return default value for"
@ "incorrect pointers.");

4
sources/Data/Collections/Tests/TEST_DynamicArray.uc

@ -44,7 +44,7 @@ protected static function Test_GetSet()
TEST_ExpectTrue(array.GetLength() == 3);
TEST_ExpectTrue(IntBox(array.GetItem(0)).Get() == -9);
TEST_ExpectNone(array.GetItem(1));
TEST_ExpectTrue(Text(array.GetItem(2)).ToPlainString() == "text");
TEST_ExpectTrue(Text(array.GetItem(2)).ToString() == "text");
Issue("Setters do not correctly overwrite items of `DynamicArray`.");
array.SetItem(1, __().box.float(34.76));
@ -67,7 +67,7 @@ protected static function Test_CreateItem()
array.CreateItem(4, class'BoolBox');
TEST_ExpectNone(array.GetItem(0));
TEST_ExpectNone(array.GetItem(2));
TEST_ExpectTrue(Text(array.GetItem(1)).ToPlainString() == "");
TEST_ExpectTrue(Text(array.GetItem(1)).ToString() == "");
TEST_ExpectTrue(IntRef(array.GetItem(3)).Get() == 0);
TEST_ExpectFalse(BoolBox(array.GetItem(4)).Get());

12
sources/Data/Database/Local/DBRecord.uc

@ -271,7 +271,7 @@ public final static function DBRecord NewRecord(Text dbPackageName)
if (dbPackageName == none) {
return none;
}
return NewRecordFor(dbPackageName.ToPlainString());
return NewRecordFor(dbPackageName.ToString());
}
// Auxiliary method that does what `NewRecord()` does, but for `string`
@ -309,8 +309,8 @@ public final static function DBRecord LoadRecord(
if (dbPackageName == none) return none;
if (recordName == none) return none;
return LoadRecordFor( recordName.ToPlainString(),
dbPackageName.ToPlainString());
return LoadRecordFor( recordName.ToString(),
dbPackageName.ToString());
}
// Auxiliary method that does what `LoadRecord()` does, but for `string`
@ -921,7 +921,7 @@ private final function FromAssociativeArray(AssociativeArray source)
if (iter.GetKey() == none) {
continue;
}
nextKey = Text(iter.GetKey()).ToPlainString();
nextKey = Text(iter.GetKey()).ToString();
isNewKey = true;
for (i = 0; i < originalStorageLength; i += 1)
{
@ -945,7 +945,7 @@ private final function StorageItem ConvertObjectToItem(AcediaObject data)
if (Text(data) != none)
{
result.t = DBAT_String;
result.s = Text(data).ToPlainString();
result.s = Text(data).ToString();
}
else if(Collection(data) != none)
{
@ -1052,7 +1052,7 @@ private final function bool IncrementItemByObject(
}
else if (item.t == DBAT_String && Text(object) != none)
{
item.s $= Text(object).ToPlainString();
item.s $= Text(object).ToString();
return true;
}
else if(item.t == DBAT_Reference && Collection(object) != none)

4
sources/Data/Database/Local/LocalDatabase.uc

@ -53,7 +53,7 @@ public final function SetRootName(Text rootName)
return;
}
if (rootName != none) {
root = rootName.ToPlainString();
root = rootName.ToString();
}
else {
root = "";
@ -63,7 +63,7 @@ public final function SetRootName(Text rootName)
public final static function LocalDatabase Load(Text databaseName)
{
if (!__().text.IsEmpty(databaseName)) {
return new(none, databaseName.ToPlainString()) class'LocalDatabase';
return new(none, databaseName.ToString()) class'LocalDatabase';
}
return none;
}

48
sources/Data/Database/Tests/TEST_LocalDatabase.uc

@ -250,7 +250,7 @@ protected static function SubTest_LoadingPreparedSuccessRoot(
.GetLength() == 42);
TEST_ExpectTrue(default.resultData
.GetTextBy(P("/web-app/servlet/2/servlet-class"))
.ToPlainString() == "org.cofax.cds.AdminServlet");
.ToString() == "org.cofax.cds.AdminServlet");
TEST_ExpectFalse(default.resultData
.GetBoolBy(P("/web-app/servlet/0/init-param/useJSP")));
TEST_ExpectTrue(default.resultData
@ -266,19 +266,19 @@ protected static function SubTest_LoadingPreparedSuccessSubValues(
TEST_ExpectTrue(default.resultType == DBR_Success);
TEST_ExpectTrue(default.resultData.GetLength() == 5);
TEST_ExpectTrue(
default.resultData.GetText(P("cofaxCDS")).ToPlainString() == "/");
default.resultData.GetText(P("cofaxCDS")).ToString() == "/");
TEST_ExpectTrue(
default.resultData.GetText(P("cofaxEmail")).ToPlainString()
default.resultData.GetText(P("cofaxEmail")).ToString()
== "/cofaxutil/aemail/*");
TEST_ExpectTrue(
default.resultData.GetText(P("cofaxAdmin")).ToPlainString()
default.resultData.GetText(P("cofaxAdmin")).ToString()
== "/admin/*");
Issue("Simple values are being read incorrectly.");
ReadFromDB(db, "/web-app/servlet/3/servlet-class");
TEST_ExpectTrue(default.resultType == DBR_Success);
TEST_ExpectTrue(
Text(default.resultObject).ToPlainString()
Text(default.resultObject).ToString()
== "org.cofax.cds.FileServlet");
ReadFromDB(db, "/web-app/servlet/4/init-param/adminGroupID");
TEST_ExpectTrue(default.resultType == DBR_Success);
@ -409,7 +409,7 @@ protected static function SubTest_LoadingPreparedGetKeysSuccess(
task.TryCompleting();
for (i = 0; i < default.resultKeys.GetLength(); i += 1)
{
nextKey = default.resultKeys.GetText(i).ToPlainString();
nextKey = default.resultKeys.GetText(i).ToString();
if (nextKey == "cofaxCDS") rCDS = true;
if (nextKey == "cofaxEmail") rEmail = true;
if (nextKey == "cofaxAdmin") rAdmin = true;
@ -599,10 +599,10 @@ protected static function SubTest_WritingDataCheck(LocalDatabaseInstance db)
TEST_ExpectTrue(default.resultType == DBR_Success);
TEST_ExpectTrue(default.resultData.GetLength() == 2);
TEST_ExpectTrue(
default.resultData.GetTextBy(P("/B/A/1//2")).ToPlainString()
default.resultData.GetTextBy(P("/B/A/1//2")).ToString()
== "huh");
TEST_ExpectTrue(
default.resultData.GetTextBy(P("/A")).ToPlainString()
default.resultData.GetTextBy(P("/A")).ToString()
== "simpleValue");
TEST_ExpectTrue(default.resultData.GetFloatBy(P("/B/B")) == 11.12);
TEST_ExpectTrue(default.resultData.GetBoolBy(P("/B/A/0"), false));
@ -745,7 +745,7 @@ protected static function SubTest_TaskChaining(LocalDatabaseInstance db)
Issue("Chaining several tasks for the database leads to a failure.");
TEST_ExpectTrue(default.resultType == DBR_Success);
TEST_ExpectTrue(default.resultObject.class == class'Text');
TEST_ExpectTrue(Text(default.resultObject).ToPlainString() == "huh");
TEST_ExpectTrue(Text(default.resultObject).ToString() == "huh");
ReadFromDB(db, "/B/2");
TEST_ExpectTrue(default.resultType == DBR_Success);
TEST_ExpectTrue(default.resultObject.class == class'DynamicArray');
@ -820,7 +820,7 @@ protected static function SubTest_RemovalCheckValuesAfter(
default.resultData.GetDynamicArray(P("A")).GetLength() == 2);
TEST_ExpectTrue(default.resultData.GetDynamicArray(P("A")).GetBool(0));
TEST_ExpectTrue(default.resultData.GetDynamicArray(P("A"))
.GetText(1).ToPlainString()
.GetText(1).ToString()
== "huh");
}
@ -979,7 +979,7 @@ protected static function SubTest_IncrementString(LocalDatabaseInstance db)
TEST_ExpectTrue(default.resultType == DBR_Success);
ReadFromDB(db, "/A");
TEST_ExpectTrue(
Text(default.resultObject).ToPlainString() == "simpleValue");
Text(default.resultObject).ToString() == "simpleValue");
task = db.IncrementData(__().json.Pointer(P("/A")),
__().text.FromString("!"));
task.connect = DBIncrementHandler;
@ -987,7 +987,7 @@ protected static function SubTest_IncrementString(LocalDatabaseInstance db)
TEST_ExpectTrue(default.resultType == DBR_Success);
ReadFromDB(db, "/A");
TEST_ExpectTrue(
Text(default.resultObject).ToPlainString() == "simpleValue!");
Text(default.resultObject).ToString() == "simpleValue!");
task = db.IncrementData(__().json.Pointer(P("/A")),
__().text.FromStringM("?"));
task.connect = DBIncrementHandler;
@ -995,7 +995,7 @@ protected static function SubTest_IncrementString(LocalDatabaseInstance db)
TEST_ExpectTrue(default.resultType == DBR_Success);
ReadFromDB(db, "/A");
TEST_ExpectTrue(
Text(default.resultObject).ToPlainString() == "simpleValue!?");
Text(default.resultObject).ToString() == "simpleValue!?");
}
protected static function AssociativeArray GetHelperObject()
@ -1022,7 +1022,7 @@ protected static function SubTest_IncrementObject(LocalDatabaseInstance db)
TEST_ExpectTrue(default.resultData.GetLength() == 4);
// Check that value was not overwritten
TEST_ExpectTrue(
default.resultData.GetText(P("A")).ToPlainString() == "simpleValue!?");
default.resultData.GetText(P("A")).ToString() == "simpleValue!?");
task = db.IncrementData(__().json.Pointer(P("")),
GetHelperObject());
task.connect = DBIncrementHandler;
@ -1032,13 +1032,13 @@ protected static function SubTest_IncrementObject(LocalDatabaseInstance db)
TEST_ExpectNotNone(default.resultData);
TEST_ExpectTrue(default.resultData.GetLength() == 6);
TEST_ExpectTrue(
default.resultData.GetText(P("E")).ToPlainString() == "str");
default.resultData.GetText(P("E")).ToString() == "str");
TEST_ExpectTrue(default.resultData.GetFloat(P("F")) == 45);
TEST_ExpectTrue(
default.resultData.GetItem(P("B")).class == class'AssociativeArray');
Issue("Incrementing JSON objects can overwrite existing data.");
TEST_ExpectTrue(
default.resultData.GetText(P("A")).ToPlainString() == "simpleValue!?");
default.resultData.GetText(P("A")).ToString() == "simpleValue!?");
}
protected static function DynamicArray GetHelperArray()
@ -1064,7 +1064,7 @@ protected static function SubTest_IncrementArray(LocalDatabaseInstance db)
ReadFromDB(db, "/B/A");
TEST_ExpectTrue(DynamicArray(default.resultObject).GetLength() == 3);
TEST_ExpectTrue(
DynamicArray(default.resultObject).GetText(2).ToPlainString() == "huh");
DynamicArray(default.resultObject).GetText(2).ToString() == "huh");
task = db.IncrementData(__().json.Pointer(P("/B/A")),
GetHelperArray());
task.connect = DBIncrementHandler;
@ -1076,9 +1076,9 @@ protected static function SubTest_IncrementArray(LocalDatabaseInstance db)
TEST_ExpectNotNone(
DynamicArray(default.resultObject).GetAssociativeArray(1));
TEST_ExpectTrue(
DynamicArray(default.resultObject).GetText(2).ToPlainString() == "huh");
DynamicArray(default.resultObject).GetText(2).ToString() == "huh");
TEST_ExpectTrue(
DynamicArray(default.resultObject).GetText(3).ToPlainString()
DynamicArray(default.resultObject).GetText(3).ToString()
== "complexString");
TEST_ExpectTrue(DynamicArray(default.resultObject).GetFloat(4) == 45);
TEST_ExpectNone(DynamicArray(default.resultObject).GetItem(5));
@ -1091,23 +1091,23 @@ protected static function CheckValuesAfterIncrement(AssociativeArray root)
TEST_ExpectTrue(root.GetBoolBy(P("/D")));
TEST_ExpectTrue(root.GetFloatBy(P("/B/B")) == 10.12);
TEST_ExpectTrue(
root.GetTextBy(P("/A")).ToPlainString()
root.GetTextBy(P("/A")).ToString()
== "simpleValue!?");
jsonArray = root.GetDynamicArrayBy(P("/B/A"));
TEST_ExpectTrue(jsonArray.GetBool(0));
TEST_ExpectNotNone(jsonArray.GetAssociativeArray(1));
TEST_ExpectTrue(jsonArray.GetText(2).ToPlainString() == "huh");
TEST_ExpectTrue(jsonArray.GetText(3).ToPlainString() == "complexString");
TEST_ExpectTrue(jsonArray.GetText(2).ToString() == "huh");
TEST_ExpectTrue(jsonArray.GetText(3).ToString() == "complexString");
TEST_ExpectTrue(jsonArray.GetFloat(4) == 45);
TEST_ExpectNone(jsonArray.GetItem(5));
TEST_ExpectTrue(jsonArray.GetBool(6));
// Test root itself
TEST_ExpectTrue(root.GetLength() == 6);
TEST_ExpectTrue(root.GetText(P("A")).ToPlainString() == "simpleValue!?");
TEST_ExpectTrue(root.GetText(P("A")).ToString() == "simpleValue!?");
TEST_ExpectTrue(root.GetItem(P("B")).class == class'AssociativeArray');
TEST_ExpectTrue(root.GetFloat(P("C")) == 5.5);
TEST_ExpectTrue(root.GetBool(P("D")));
TEST_ExpectTrue(root.GetText(P("E")).ToPlainString() == "str");
TEST_ExpectTrue(root.GetText(P("E")).ToString() == "str");
TEST_ExpectTrue(root.GetFloat(P("F")) == 45);
}

2
sources/Logger/ConsoleLogger.uc

@ -31,7 +31,7 @@ public function Write(Text message, LoggerAPI.LogLevel messageLevel)
{
builder = GetPrefix(messageLevel);
builder.Append(message);
Log(builder.ToPlainString());
Log(builder.ToString());
builder.FreeSelf();
}
}

2
sources/Logger/Logger.uc

@ -74,7 +74,7 @@ public final static function Logger GetLogger(Text loggerName)
loggerInstance = Logger(default.loadedLoggers.GetItem(loggerKey));
if (loggerInstance == none)
{
loggerInstance = new(none, loggerName.ToPlainString()) default.class;
loggerInstance = new(none, loggerName.ToString()) default.class;
loggerInstance._constructor();
default.loadedLoggers.SetItem(loggerKey, loggerInstance);
}

36
sources/Logger/Tests/TEST_LogMessage.uc

@ -52,28 +52,28 @@ protected static function Test_SimpleArgumentCollection()
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Message %1and%2: %3"));
message.Arg(A("umbra")).Arg(A("mumbra")).Arg(A("eleven! "));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "Message umbraandmumbra: eleven! ");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("%1 - was pasted."));
message.Arg(A("Heheh"));
TEST_ExpectTrue(message.Collect().ToPlainString() == "Heheh - was pasted.");
TEST_ExpectTrue(message.Collect().ToString() == "Heheh - was pasted.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("This %%%1 and that %2"));
message.Arg(A("one")).Arg(A("two"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "This %%one and that two");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("%1%2"));
message.Arg(A("one")).Arg(A("two"));
TEST_ExpectTrue(message.Collect().ToPlainString() == "onetwo");
TEST_ExpectTrue(message.Collect().ToString() == "onetwo");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("%1"));
message.Arg(A("only"));
TEST_ExpectTrue(message.Collect().ToPlainString() == "only");
TEST_ExpectTrue(message.Collect().ToString() == "only");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Just some string."));
TEST_ExpectTrue(message.Collect().ToPlainString() == "Just some string.");
TEST_ExpectTrue(message.Collect().ToString() == "Just some string.");
}
protected static function Test_ArgumentCollection()
@ -83,7 +83,7 @@ protected static function Test_ArgumentCollection()
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("This %1 and that %2"));
message.Arg(A("one")).Arg(A("two")).Reset().Arg(A("huh")).Arg(A("muh"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "This huh and that muh");
Issue("`Text` arguments are not correctly collected after specifying"
@ -92,22 +92,22 @@ protected static function Test_ArgumentCollection()
message.Initialize(DEF("Just %1, %2, %3, %4 and %5"));
message.Arg(A("1")).Arg(A("2")).Arg(A("3")).Arg(A("4")).Arg(A("5"))
.Arg(A("6")).Arg(A("7"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "Just 1, 2, 3, 4 and 5");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Just"));
TEST_ExpectTrue(message.Arg(A("arg")).Collect().ToPlainString() == "Just");
TEST_ExpectTrue(message.Arg(A("arg")).Collect().ToString() == "Just");
Issue("`Text` arguments are not correctly collected after specifying"
@ "too little.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Just %1, %2, %3, %4 and %5"));
message.Arg(A("1")).Arg(A("2")).Arg(A("3"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "Just 1, 2, 3, and ");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Maybe %1"));
TEST_ExpectTrue(message.Collect().ToPlainString() == "Maybe ");
TEST_ExpectTrue(message.Collect().ToString() == "Maybe ");
}
protected static function Test_ArgumentCollectionOrder()
@ -118,12 +118,12 @@ protected static function Test_ArgumentCollectionOrder()
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("This %2 and that %1"));
message.Arg(A("huh")).Arg(A("muh"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "This muh and that huh");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Just %5, %3, %4, %1 and %2"));
message.Arg(A("1")).Arg(A("2")).Arg(A("3")).Arg(A("4")).Arg(A("5"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "Just 5, 3, 4, 1 and 2");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
@ -131,7 +131,7 @@ protected static function Test_ArgumentCollectionOrder()
@ "in order and not enough of them was specified.");
message.Initialize(DEF("Just %5, %3, %4, %1 and %2"));
message.Arg(A("1")).Arg(A("2")).Arg(A("3"));
TEST_ExpectTrue( message.Collect().ToPlainString()
TEST_ExpectTrue( message.Collect().ToString()
== "Just , 3, , 1 and 2");
}
@ -141,26 +141,26 @@ protected static function Test_TypedArgumentCollection()
Issue("`int` arguments are not correctly collected.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Int: %1"));
TEST_ExpectTrue(message.ArgInt(-7).Collect().ToPlainString()
TEST_ExpectTrue(message.ArgInt(-7).Collect().ToString()
== "Int: -7");
Issue("`float` arguments are not correctly collected.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Float: %1"));
TEST_ExpectTrue(message.ArgFloat(3.14).Collect().ToPlainString()
TEST_ExpectTrue(message.ArgFloat(3.14).Collect().ToString()
== "Float: 3.14");
Issue("`bool` arguments are not correctly collected.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Bool: %1 and %2"));
TEST_ExpectTrue(message.ArgBool(true).ArgBool(false).Collect()
.ToPlainString() == "Bool: true and false");
.ToString() == "Bool: true and false");
Issue("`Class` arguments are not correctly collected.");
message = LogMessage(__().memory.Allocate(class'LogMessage'));
message.Initialize(DEF("Class: %1"));
TEST_ExpectTrue(message.ArgClass(class'M14EBRBattleRifle').Collect()
.ToPlainString() == "Class: KFMod.M14EBRBattleRifle");
.ToString() == "Class: KFMod.M14EBRBattleRifle");
}
defaultproperties

2
sources/Memory/MemoryAPI.uc

@ -35,7 +35,7 @@ public final function class<Object> LoadClass(Text classReference)
if (classReference == none) {
return none;
}
return class<Object>( DynamicLoadObject(classReference.ToPlainString(),
return class<Object>( DynamicLoadObject(classReference.ToString(),
class'Class', true));
}

2
sources/Testing/Service/TestingService.uc

@ -239,7 +239,7 @@ private function ReportTestingResult()
{
nextLine.Clear();
nextLine.AppendFormattedString(textSummary[i]);
Log(nextLine.ToPlainString());
Log(nextLine.ToString());
}
}

10
sources/Text/Parser.uc

@ -747,7 +747,7 @@ public final function Parser MStringLiteralS(out string result)
wrapper = _.text.Empty();
if (MStringLiteral(wrapper).Ok()) {
result = wrapper.ToPlainString();
result = wrapper.ToString();
}
wrapper.FreeSelf();
return self;
@ -833,7 +833,7 @@ public final function Parser MUntilS(
wrapper = _.text.Empty();
MUntil(wrapper, characterBreak, whitespacesBreak, quotesBreak);
result = wrapper.ToPlainString();
result = wrapper.ToString();
wrapper.FreeSelf();
return self;
}
@ -945,7 +945,7 @@ public final function Parser MUntilManyS(
wrapper = _.text.Empty();
MUntilMany(wrapper, separators, whitespacesBreak, quotesBreak);
result = wrapper.ToPlainString();
result = wrapper.ToString();
wrapper.FreeSelf();
return self;
}
@ -1008,7 +1008,7 @@ public final function Parser MStringS(out string result)
wrapper = _.text.Empty();
MString(wrapper);
result = wrapper.ToPlainString();
result = wrapper.ToString();
wrapper.FreeSelf();
return self;
}
@ -1067,7 +1067,7 @@ public final function Parser MWhitespacesS(out string result)
wrapper = _.text.Empty();
MWhitespaces(wrapper);
result = wrapper.ToPlainString();
result = wrapper.ToString();
wrapper.FreeSelf();
return self;
}

112
sources/Text/Tests/TEST_JSON.uc

@ -54,22 +54,22 @@ protected static function SubTest_PointerCreate()
Issue("Normal JSON pointers are not handled correctly.");
pointer = __().json.Pointer(P("/a~1b/c%d/e^f//g|h/i\\j/m~0n/"));
TEST_ExpectTrue(pointer.GetLength() == 8);
TEST_ExpectTrue(pointer.GetComponent(0).ToPlainString() == "a/b");
TEST_ExpectTrue(pointer.GetComponent(1).ToPlainString() == "c%d");
TEST_ExpectTrue(pointer.GetComponent(2).ToPlainString() == "e^f");
TEST_ExpectTrue(pointer.GetComponent(3).ToPlainString() == "");
TEST_ExpectTrue(pointer.GetComponent(4).ToPlainString() == "g|h");
TEST_ExpectTrue(pointer.GetComponent(5).ToPlainString() == "i\\j");
TEST_ExpectTrue(pointer.GetComponent(6).ToPlainString() == "m~n");
TEST_ExpectTrue(pointer.GetComponent(7).ToPlainString() == "");
TEST_ExpectTrue(pointer.GetComponent(0).ToString() == "a/b");
TEST_ExpectTrue(pointer.GetComponent(1).ToString() == "c%d");
TEST_ExpectTrue(pointer.GetComponent(2).ToString() == "e^f");
TEST_ExpectTrue(pointer.GetComponent(3).ToString() == "");
TEST_ExpectTrue(pointer.GetComponent(4).ToString() == "g|h");
TEST_ExpectTrue(pointer.GetComponent(5).ToString() == "i\\j");
TEST_ExpectTrue(pointer.GetComponent(6).ToString() == "m~n");
TEST_ExpectTrue(pointer.GetComponent(7).ToString() == "");
Issue("Initializing JSON pointers with values, not starting with \"/\","
@ "is not handled correctly.");
pointer = __().json.Pointer(P("huh/send~0/pics~1"));
TEST_ExpectTrue(pointer.GetLength() == 3);
TEST_ExpectTrue(pointer.GetComponent(0).ToPlainString() == "huh");
TEST_ExpectTrue(pointer.GetComponent(1).ToPlainString() == "send~");
TEST_ExpectTrue(pointer.GetComponent(2).ToPlainString() == "pics/");
TEST_ExpectTrue(pointer.GetComponent(0).ToString() == "huh");
TEST_ExpectTrue(pointer.GetComponent(1).ToString() == "send~");
TEST_ExpectTrue(pointer.GetComponent(2).ToString() == "pics/");
}
protected static function SubTest_PointerToText()
@ -77,15 +77,15 @@ protected static function SubTest_PointerToText()
local JSONPointer pointer;
Issue("`JSONPointer` is not converted to `Text` correctly.");
pointer = __().json.Pointer(P(""));
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "");
TEST_ExpectTrue(pointer.ToTextM().ToPlainString() == "");
TEST_ExpectTrue(pointer.ToText().ToString() == "");
TEST_ExpectTrue(pointer.ToTextM().ToString() == "");
pointer = __().json.Pointer(P("///"));
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "///");
TEST_ExpectTrue(pointer.ToTextM().ToPlainString() == "///");
TEST_ExpectTrue(pointer.ToText().ToString() == "///");
TEST_ExpectTrue(pointer.ToTextM().ToString() == "///");
pointer = __().json.Pointer(P("/a~1b/c%d/e^f//g|h/i\\j/m~0n/"));
TEST_ExpectTrue( pointer.ToText().ToPlainString()
TEST_ExpectTrue( pointer.ToText().ToString()
== "/a~1b/c%d/e^f//g|h/i\\j/m~0n/");
TEST_ExpectTrue( pointer.ToTextM().ToPlainString()
TEST_ExpectTrue( pointer.ToTextM().ToString()
== "/a~1b/c%d/e^f//g|h/i\\j/m~0n/");
pointer = __().json.Pointer(P("/a/b/c"));
@ -103,31 +103,31 @@ protected static function SubTest_PointerPushPop()
Issue("`Push()`/`PushNumeric()` incorrectly affect `JSONPointer`.");
pointer = __().json.Pointer(P("//lets/go"));
pointer.Push(P("one")).PushNumeric(404).Push(P("More"));
TEST_ExpectTrue( pointer.ToText().ToPlainString()
TEST_ExpectTrue( pointer.ToText().ToString()
== "//lets/go/one/404/More");
Issue("`Pop()` incorrectly affects `JSONPointer`.");
value6 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "//lets/go/one/404");
TEST_ExpectTrue(pointer.ToText().ToString() == "//lets/go/one/404");
value5 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "//lets/go/one");
TEST_ExpectTrue(pointer.ToText().ToString() == "//lets/go/one");
value4 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "//lets/go");
TEST_ExpectTrue(pointer.ToText().ToString() == "//lets/go");
value3 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "//lets");
TEST_ExpectTrue(pointer.ToText().ToString() == "//lets");
value2 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "/");
TEST_ExpectTrue(pointer.ToText().ToString() == "/");
value1 = pointer.Pop();
TEST_ExpectTrue(pointer.ToText().ToPlainString() == "");
TEST_ExpectTrue(pointer.ToText().ToString() == "");
value0 = pointer.Pop();
Issue("`Pop()` returns incorrect value.");
TEST_ExpectTrue(value6.ToPlainString() == "More");
TEST_ExpectTrue(value5.ToPlainString() == "404");
TEST_ExpectTrue(value4.ToPlainString() == "one");
TEST_ExpectTrue(value3.ToPlainString() == "go");
TEST_ExpectTrue(value2.ToPlainString() == "lets");
TEST_ExpectTrue(value1.ToPlainString() == "");
TEST_ExpectTrue(value6.ToString() == "More");
TEST_ExpectTrue(value5.ToString() == "404");
TEST_ExpectTrue(value4.ToString() == "one");
TEST_ExpectTrue(value3.ToString() == "go");
TEST_ExpectTrue(value2.ToString() == "lets");
TEST_ExpectTrue(value1.ToString() == "");
TEST_ExpectNone(value0);
}
@ -171,20 +171,20 @@ protected static function SubTest_PopWithoutRemoving()
local JSONPointer pointer;
Issue("`Pop(true)` removes the value from the pointer.");
pointer = __().json.Pointer(P("/just/a/simple/test"));
TEST_ExpectTrue(pointer.Pop(true).ToPlainString() == "test");
TEST_ExpectTrue(pointer.Pop(true).ToPlainString() == "test");
TEST_ExpectTrue(pointer.Pop(true).ToString() == "test");
TEST_ExpectTrue(pointer.Pop(true).ToString() == "test");
Issue("`Pop(true)` returns actually stored value instead of a copy.");
pointer.Pop(true).FreeSelf();
TEST_ExpectTrue(pointer.Pop(true).ToPlainString() == "test");
TEST_ExpectTrue(pointer.Pop(true).ToString() == "test");
component = pointer.Pop();
TEST_ExpectNotNone(component);
TEST_ExpectTrue(component.ToPlainString() == "test");
TEST_ExpectTrue(component.ToString() == "test");
TEST_ExpectTrue(component.IsAllocated());
Issue("`Pop(true)` breaks after regular `Pop()` call.");
TEST_ExpectTrue(pointer.Pop(true).ToPlainString() == "simple");
TEST_ExpectTrue(pointer.Pop(true).ToPlainString() == "simple");
TEST_ExpectTrue(pointer.Pop(true).ToString() == "simple");
TEST_ExpectTrue(pointer.Pop(true).ToString() == "simple");
}
protected static function Test_Print()
@ -198,8 +198,8 @@ protected static function SubTest_SimplePrint()
{
local string complexString;
Issue("Simple JSON values are not printed as expected.");
TEST_ExpectTrue(__().json.Print(none).ToPlainString() == "null");
TEST_ExpectTrue( __().json.Print(__().box.bool(false)).ToPlainString()
TEST_ExpectTrue(__().json.Print(none).ToString() == "null");
TEST_ExpectTrue( __().json.Print(__().box.bool(false)).ToString()
== "false");
TEST_ExpectTrue( __().json.Print(__().ref.bool(true)).ToFormattedString()
== "true");
@ -207,11 +207,11 @@ protected static function SubTest_SimplePrint()
== "-752");
TEST_ExpectTrue( __().json.Print(__().ref.int(36235)).ToFormattedString()
== "36235");
TEST_ExpectTrue( __().json.Print(__().box.float(5.673)).ToPlainString()
TEST_ExpectTrue( __().json.Print(__().box.float(5.673)).ToString()
== "5.673");
TEST_ExpectTrue( __().json.Print(__().ref.float(-3.502)).ToPlainString()
TEST_ExpectTrue( __().json.Print(__().ref.float(-3.502)).ToString()
== "-3.502");
TEST_ExpectTrue( __().json.Print(F("{#ff000 col}ored")).ToPlainString()
TEST_ExpectTrue( __().json.Print(F("{#ff000 col}ored")).ToString()
== "\"colored\"");
TEST_ExpectTrue( __().json.Print(P("simple text")).ToFormattedString()
== "\"simple text\"");
@ -239,10 +239,10 @@ protected static function SubTest_ArrayPrint()
array.AddItem(__().text.FromString(" "));
Issue("JSON arrays are not printed as expected.");
TEST_ExpectTrue(
__().json.PrintArray(array).ToPlainString()
__().json.PrintArray(array).ToString()
== "[34.1,null,[-752,true,3.44,\"\\\"quoted text\\\"\"],\"\\t\"]");
TEST_ExpectTrue(
__().json.Print(array).ToPlainString()
__().json.Print(array).ToString()
== "[34.1,null,[-752,true,3.44,\"\\\"quoted text\\\"\"],\"\\t\"]");
}
@ -432,10 +432,10 @@ protected static function SubTest_ParseString()
{
local Parser parser;
Issue("`ParseString()` fails to parse correct JSON strings.");
TEST_ExpectTrue( __().json.ParseString(P("\"string !\"")).ToPlainString()
TEST_ExpectTrue( __().json.ParseString(P("\"string !\"")).ToString()
== "string !");
TEST_ExpectTrue(
MutableText(__().json.ParseString(P("\"\""), true)).ToPlainString()
MutableText(__().json.ParseString(P("\"\""), true)).ToString()
== "");
Issue("`ParseString()` returns non-`none` values for invalid"
@ -446,9 +446,9 @@ protected static function SubTest_ParseString()
parser = __().text.Parse(P("\"str\"\" also a kind `of` a string\"not"));
Issue("`ParseStringWith()` fails to parse correct JSON strings.");
TEST_ExpectTrue(__().json.ParseStringWith(parser).ToPlainString() == "str");
TEST_ExpectTrue(__().json.ParseStringWith(parser).ToString() == "str");
TEST_ExpectTrue(
MutableText(__().json.ParseStringWith(parser, true)).ToPlainString()
MutableText(__().json.ParseStringWith(parser, true)).ToString()
== " also a kind `of` a string");
TEST_ExpectTrue(parser.Ok());
@ -479,7 +479,7 @@ protected static function SubTest_ParseArraySuccess()
TEST_ExpectTrue(result.GetLength() == 5);
TEST_ExpectTrue(BoolBox(result.GetItem(0)).Get());
TEST_ExpectTrue(FloatBox(result.GetItem(1)).Get() == 76.4);
TEST_ExpectTrue(Text(result.GetItem(2)).ToPlainString() == "val");
TEST_ExpectTrue(Text(result.GetItem(2)).ToString() == "val");
TEST_ExpectNone(result.GetItem(3));
TEST_ExpectTrue(IntBox(result.GetItem(4)).Get() == 5);
@ -491,7 +491,7 @@ protected static function SubTest_ParseArraySuccess()
TEST_ExpectTrue(result.GetLength() == 5);
TEST_ExpectTrue(BoolRef(result.GetItem(0)).Get());
TEST_ExpectTrue(FloatRef(result.GetItem(1)).Get() == 76.4);
TEST_ExpectTrue(MutableText(result.GetItem(2)).ToPlainString() == "val");
TEST_ExpectTrue(MutableText(result.GetItem(2)).ToString() == "val");
TEST_ExpectNone(result.GetItem(3));
TEST_ExpectTrue(IntRef(result.GetItem(4)).Get() == 5);
}
@ -532,7 +532,7 @@ protected static function SubTest_ParseSimpleValueSuccess()
TEST_ExpectTrue(IntRef(api.ParseWith(parser, true)).Get() == 42);
parser.MatchS(",").Skip();
TEST_ExpectTrue(
MutableText(api.ParseWith(parser, true)).ToPlainString()
MutableText(api.ParseWith(parser, true)).ToString()
== "hmmm");
parser.MatchS(",").Skip();
TEST_ExpectNone(api.ParseWith(parser));
@ -576,7 +576,7 @@ protected static function SubTest_ParseObjectSuccess()
TEST_ExpectTrue(result.GetLength() == 4);
TEST_ExpectTrue(IntBox(result.GetItem(P("var"))).Get() == 13);
TEST_ExpectTrue(BoolBox(result.GetItem(P("another"))).Get() == true);
TEST_ExpectTrue( Text(result.GetItem(P("string one"))).ToPlainString()
TEST_ExpectTrue( Text(result.GetItem(P("string one"))).ToString()
== "string!");
TEST_ExpectNone(MutableText(result.GetItem(P("string one"))));
TEST_ExpectNone(result.GetItem(P("last")));
@ -588,7 +588,7 @@ protected static function SubTest_ParseObjectSuccess()
TEST_ExpectTrue(IntRef(result.GetItem(P("var"))).Get() == 13);
TEST_ExpectTrue(BoolRef(result.GetItem(P("another"))).Get() == true);
TEST_ExpectTrue(
MutableText(result.GetItem(P("string one"))).ToPlainString()
MutableText(result.GetItem(P("string one"))).ToString()
== "string!");
TEST_ExpectNone(result.GetItem(P("last")));
}
@ -627,7 +627,7 @@ protected static function SubTest_ParseComplex()
root = AssociativeArray(__().json.ParseWith(parser));
TEST_ExpectTrue(root.GetLength() == 3);
TEST_ExpectTrue(FloatBox(root.GetItem(P("some_var"))).Get() == -7.32);
TEST_ExpectTrue( Text(root.GetItem(P("another_var"))).ToPlainString()
TEST_ExpectTrue( Text(root.GetItem(P("another_var"))).ToString()
== "aye!");
mainObj = AssociativeArray(root.GetItem(P("innerObject")));
TEST_ExpectTrue(root.GetLength() == 3);
@ -638,15 +638,15 @@ protected static function SubTest_ParseComplex()
TEST_ExpectTrue(subObj.GetLength() == 3);
TEST_ExpectTrue(IntBox(subObj.GetItem(P("nope"))).Get() == 324532);
TEST_ExpectTrue(BoolBox(subObj.GetItem(P("whatever"))).Get() == false);
TEST_ExpectTrue( Text(subObj.GetItem(P("o rly?"))).ToPlainString()
TEST_ExpectTrue( Text(subObj.GetItem(P("o rly?"))).ToString()
== "ya rly");
inner = AssociativeArray(subArr.GetItem(3));
TEST_ExpectTrue(Text(subArr.GetItem(0)).ToPlainString() == "Engine.Actor");
TEST_ExpectTrue(Text(subArr.GetItem(0)).ToString() == "Engine.Actor");
TEST_ExpectTrue(BoolBox(subArr.GetItem(1)).Get() == false);
TEST_ExpectNone(subArr.GetItem(2));
TEST_ExpectTrue(FloatBox(subArr.GetItem(4)).Get() == 56.6);
TEST_ExpectTrue(
Text(inner.GetItem(P("something \"here\""))).ToPlainString()
Text(inner.GetItem(P("something \"here\""))).ToString()
== "yes");
TEST_ExpectTrue(FloatBox(inner.GetItem(P("maybe"))).Get() == 0.003);
}

BIN
sources/Text/Tests/TEST_Parser.uc

Binary file not shown.

106
sources/Text/Tests/TEST_Text.uc

@ -52,7 +52,7 @@ protected static function Test_TextCreation()
plainString = "Prepare to DIE and be reborn!";
plain = class'Text'.static.ConstFromPlainString(plainString);
TEST_ExpectNotNone(plain);
TEST_ExpectTrue(plain.ToPlainString() == plainString);
TEST_ExpectTrue(plain.ToString() == plainString);
Issue("`Text` object is not properly created from the colored string.");
coloredString = __().color.GetColorTagRGB(0, 0, 0) $ "Prepare to "
@ -92,7 +92,7 @@ protected static function SubTest_TextCompleteCopy()
formatted = class'Text'.static.ConstFromFormattedString(formattedString);
Issue("`Text` object is not properly copied (immutable).");
TEST_ExpectTrue(plain.Copy().ToPlainString() == plainString);
TEST_ExpectTrue(plain.Copy().ToString() == plainString);
TEST_ExpectTrue(colored.Copy().ToColoredString() == coloredString);
TEST_ExpectTrue(formatted.Copy().ToFormattedString() == formattedString);
TEST_ExpectNone(MutableText(plain));
@ -103,7 +103,7 @@ protected static function SubTest_TextCompleteCopy()
TEST_ExpectFalse(formatted.Copy() == formatted);
Issue("`Text` object is not properly copied (mutable).");
TEST_ExpectTrue(plain.MutableCopy().ToPlainString() == plainString);
TEST_ExpectTrue(plain.MutableCopy().ToString() == plainString);
TEST_ExpectTrue(colored.MutableCopy().ToColoredString() == coloredString);
TEST_ExpectFalse(plain.class == class'MutableText');
TEST_ExpectFalse(colored.class == class'MutableText');
@ -127,18 +127,18 @@ protected static function SubTest_TextSubCopy()
Issue("Part of `Text`'s contents is not properly copied (immutable).");
TEST_ExpectTrue( formatted.Copy(-2, 100).ToFormattedString()
== formattedString);
TEST_ExpectTrue(plain.Copy(-2, 5).ToPlainString() == "Pre");
TEST_ExpectTrue(plain.Copy(-2, 5).ToString() == "Pre");
TEST_ExpectTrue( formatted.Copy(13, -10).ToFormattedString()
== "{rgb(255,0,0) E} and be reborn!");
TEST_ExpectTrue(formatted.Copy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.Copy(32).ToString() == "");
Issue("Part of `Text`'s contents is not properly copied (mutable).");
TEST_ExpectTrue( formatted.MutableCopy(-2, 100).ToFormattedString()
== formattedString);
TEST_ExpectTrue(plain.MutableCopy(-2, 5).ToPlainString() == "Pre");
TEST_ExpectTrue(plain.MutableCopy(-2, 5).ToString() == "Pre");
TEST_ExpectTrue( formatted.MutableCopy(13, -10).ToFormattedString()
== "{rgb(255,0,0) E} and be reborn!");
TEST_ExpectTrue(formatted.MutableCopy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.MutableCopy(32).ToString() == "");
}
protected static function SubTest_TextLowerCompleteCopy()
@ -154,7 +154,7 @@ protected static function SubTest_TextLowerCompleteCopy()
formatted = class'Text'.static.ConstFromFormattedString(formattedString);
Issue("`Text` object is not properly copied (immutable) in lower case.");
TEST_ExpectTrue(plain.LowerCopy().ToPlainString() == Locs(plainString));
TEST_ExpectTrue(plain.LowerCopy().ToString() == Locs(plainString));
TEST_ExpectTrue( colored.LowerCopy().ToColoredString()
== Locs(coloredString));
TEST_ExpectTrue( formatted.LowerCopy().ToFormattedString()
@ -167,7 +167,7 @@ protected static function SubTest_TextLowerCompleteCopy()
TEST_ExpectFalse(formatted.LowerCopy() == formatted);
Issue("`Text` object is not properly copied (mutable) in lower case.");
TEST_ExpectTrue( plain.LowerMutableCopy().ToPlainString()
TEST_ExpectTrue( plain.LowerMutableCopy().ToString()
== Locs(plainString));
TEST_ExpectTrue( colored.LowerMutableCopy().ToColoredString()
== Locs(coloredString));
@ -194,19 +194,19 @@ protected static function SubTest_TextLowerSubCopy()
@ "lower case.");
TEST_ExpectTrue( formatted.LowerCopy(-2, 100).ToFormattedString()
== Locs(formattedString));
TEST_ExpectTrue(plain.LowerCopy(-2, 5).ToPlainString() == "pre");
TEST_ExpectTrue(plain.LowerCopy(-2, 5).ToString() == "pre");
TEST_ExpectTrue( formatted.LowerCopy(13, -10).ToFormattedString()
== "{rgb(255,0,0) e} and be reborn!");
TEST_ExpectTrue(formatted.LowerCopy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.LowerCopy(32).ToString() == "");
Issue("Part of `Text`'s contents is not properly copied (mutable) in"
@ "lower case.");
TEST_ExpectTrue( formatted.LowerMutableCopy(-2, 100).ToFormattedString()
== Locs(formattedString));
TEST_ExpectTrue(plain.LowerMutableCopy(-2, 5).ToPlainString() == "pre");
TEST_ExpectTrue(plain.LowerMutableCopy(-2, 5).ToString() == "pre");
TEST_ExpectTrue( formatted.LowerMutableCopy(13, -10).ToFormattedString()
== "{rgb(255,0,0) e} and be reborn!");
TEST_ExpectTrue(formatted.LowerMutableCopy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.LowerMutableCopy(32).ToString() == "");
}
protected static function SubTest_TextUpperCompleteCopy()
@ -222,7 +222,7 @@ protected static function SubTest_TextUpperCompleteCopy()
formatted = class'Text'.static.ConstFromFormattedString(formattedString);
Issue("`Text` object is not properly copied (immutable) in upper case.");
TEST_ExpectTrue(plain.UpperCopy().ToPlainString() == Caps(plainString));
TEST_ExpectTrue(plain.UpperCopy().ToString() == Caps(plainString));
TEST_ExpectTrue( colored.UpperCopy().ToColoredString()
== Caps(coloredString));
TEST_ExpectNone(MutableText(plain));
@ -233,7 +233,7 @@ protected static function SubTest_TextUpperCompleteCopy()
TEST_ExpectFalse(formatted.UpperCopy() == formatted);
Issue("`Text` object is not properly copied (mutable) in upper case.");
TEST_ExpectTrue( plain.UpperMutableCopy().ToPlainString()
TEST_ExpectTrue( plain.UpperMutableCopy().ToString()
== Caps(plainString));
TEST_ExpectTrue( colored.UpperMutableCopy().ToColoredString()
== Caps(coloredString));
@ -258,17 +258,17 @@ protected static function SubTest_TextUpperSubCopy()
Issue("Part of `Text`'s contents is not properly copied (immutable) in"
@ "lower case.");
TEST_ExpectTrue(plain.UpperCopy(-2, 5).ToPlainString() == "PRE");
TEST_ExpectTrue(plain.UpperCopy(-2, 5).ToString() == "PRE");
TEST_ExpectTrue( formatted.UpperCopy(13, -10).ToFormattedString()
== "{rgb(255,0,0) E} AND BE REBORN!");
TEST_ExpectTrue(formatted.UpperCopy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.UpperCopy(32).ToString() == "");
Issue("Part of `Text`'s contents is not properly copied (mutable) in"
@ "upper case.");
TEST_ExpectTrue(plain.UpperMutableCopy(-2, 5).ToPlainString() == "PRE");
TEST_ExpectTrue(plain.UpperMutableCopy(-2, 5).ToString() == "PRE");
TEST_ExpectTrue( formatted.UpperMutableCopy(13, -10).ToFormattedString()
== "{rgb(255,0,0) E} AND BE REBORN!");
TEST_ExpectTrue(formatted.UpperMutableCopy(32).ToPlainString() == "");
TEST_ExpectTrue(formatted.UpperMutableCopy(32).ToString() == "");
}
protected static function Test_TextLength()
@ -364,15 +364,15 @@ protected static function SubTest_EqualityCaseFormatting()
protected static function SubTest_EqualityStringSimple()
{
Issue("Comparisons with empty `Text` are not working as expected.");
TEST_ExpectTrue(default.emptyText.CompareToPlainString(""));
TEST_ExpectTrue(default.emptyText.CompareToString(""));
TEST_ExpectTrue(default.emptyText.CompareToColoredString(""));
TEST_ExpectFalse(default.emptyText.
CompareToPlainString(default.justString));
TEST_ExpectFalse(default.justText.CompareToPlainString(""));
CompareToString(default.justString));
TEST_ExpectFalse(default.justText.CompareToString(""));
Issue("Simple case-sensitive check is not working as expected.");
TEST_ExpectTrue(default.justText.CompareToPlainString(default.justString));
TEST_ExpectFalse(default.justText.CompareToPlainString(default.altString));
TEST_ExpectTrue(default.justText.CompareToString(default.justString));
TEST_ExpectFalse(default.justText.CompareToString(default.altString));
TEST_ExpectFalse(default.justText.
CompareToFormattedString(default.rndCaseString));
TEST_ExpectTrue(default.bothText.
@ -384,9 +384,9 @@ protected static function SubTest_EqualityStringSimple()
protected static function SubTest_EqualityStringCaseFormatting()
{
Issue("Case-insensitive check are not working as expected.");
TEST_ExpectTrue(default.justText.CompareToPlainString( default.justString,
TEST_ExpectTrue(default.justText.CompareToString( default.justString,
SCASE_INSENSITIVE));
TEST_ExpectFalse(default.justText.CompareToPlainString( default.altString,
TEST_ExpectFalse(default.justText.CompareToString( default.altString,
SCASE_INSENSITIVE));
TEST_ExpectTrue(default.justText.CompareToColoredString(
default.rndCaseString, SCASE_INSENSITIVE));
@ -396,7 +396,7 @@ protected static function SubTest_EqualityStringCaseFormatting()
Issue("Format-sensitive check are not working as expected.");
TEST_ExpectTrue(default.justText.CompareToColoredString(
default.justString,, SFORM_SENSITIVE));
TEST_ExpectTrue(default.justText.CompareToPlainString(
TEST_ExpectTrue(default.justText.CompareToString(
default.rndCaseString, SCASE_INSENSITIVE, SFORM_SENSITIVE));
TEST_ExpectFalse(default.justText.CompareToFormattedString(
default.formattedString,, SFORM_SENSITIVE));
@ -462,8 +462,8 @@ protected static function Test_Substring()
txt.AppendFormattedString("Prepare to {rgb(198,23,7) DIE} and"
@ "be {rgb(0,255,0) reborn}!");
Issue("Substrings are not extracted as expected.");
TEST_ExpectTrue(txt.ToPlainString(3, 5) == "pare ");
TEST_ExpectTrue(txt.ToPlainString(100, 200) == "");
TEST_ExpectTrue(txt.ToString(3, 5) == "pare ");
TEST_ExpectTrue(txt.ToString(100, 200) == "");
TEST_ExpectTrue( txt.ToColoredString(1, 9)
== (defaultTag $ "repare to"));
TEST_ExpectTrue( txt.ToColoredString(9, 3)
@ -477,7 +477,7 @@ protected static function Test_Substring()
== "{rgb(198,23,7) E} and be {rgb(0,255,0) re}");
TEST_ExpectTrue( txt.ToFormattedString(-20, 34)
== "Prepare to {rgb(198,23,7) DIE}");
TEST_ExpectTrue( txt.ToPlainString(-2, 100)
TEST_ExpectTrue( txt.ToString(-2, 100)
== "Prepare to DIE and be reborn!");
}
@ -502,7 +502,7 @@ protected static function Test_AppendGet()
part4 = __().text.FromFormattedString(" Also {rgb(0,255,0) this}.");
txt.Append(part1).Append(part2).Append(part3).Append(none);
txt.Append(part4, __().text.FormattingFromColor(testColor));
TEST_ExpectTrue( txt.ToPlainString()
TEST_ExpectTrue( txt.ToString()
== "Prepare to DIE and be reborn! Also this.");
TEST_ExpectTrue( txt.ToColoredString()
== ( defaultTag $ "Prepare to " $ colorTag $ "DIE"
@ -523,7 +523,7 @@ protected static function Test_AppendStringGet()
Context("Testing functionality of `MutableText` to append strings.");
txt = MutableText(__().memory.Allocate(class'MutableText'));
Issue("New `Text` returns non-empty string as a result.");
TEST_ExpectTrue(txt.ToPlainString() == "");
TEST_ExpectTrue(txt.ToString() == "");
TEST_ExpectTrue(txt.ToColoredString() == "");
Issue("Appended strings are not returned as expected.");
@ -534,7 +534,7 @@ protected static function Test_AppendStringGet()
txt.AppendPlainString("Prepare to ");
txt.AppendColoredString(colorTag $ "DIE");
txt.AppendFormattedString(" and be {#00ff00 reborn}!");
TEST_ExpectTrue( txt.ToPlainString()
TEST_ExpectTrue( txt.ToString()
== "Prepare to DIE and be reborn!");
TEST_ExpectTrue( txt.ToColoredString()
== ( defaultTag $ "Prepare to " $ colorTag $ "DIE"
@ -557,14 +557,14 @@ protected static function Test_SeparateByCharacter()
Issue("Returned `MutableText`s have incorrect text content.");
TEST_ExpectTrue(slashResult.length == 4);
TEST_ExpectTrue(slashResult[0].CompareToPlainString(""));
TEST_ExpectTrue(slashResult[1].CompareToPlainString("usr"));
TEST_ExpectTrue(slashResult[2].CompareToPlainString("bin"));
TEST_ExpectTrue(slashResult[3].CompareToPlainString("stuff"));
TEST_ExpectTrue(slashResult[0].CompareToString(""));
TEST_ExpectTrue(slashResult[1].CompareToString("usr"));
TEST_ExpectTrue(slashResult[2].CompareToString("bin"));
TEST_ExpectTrue(slashResult[3].CompareToString("stuff"));
TEST_ExpectTrue(fResult.length == 3);
TEST_ExpectTrue(fResult[0].CompareToPlainString("/usr/bin/stu"));
TEST_ExpectTrue(fResult[1].CompareToPlainString(""));
TEST_ExpectTrue(fResult[2].CompareToPlainString(""));
TEST_ExpectTrue(fResult[0].CompareToString("/usr/bin/stu"));
TEST_ExpectTrue(fResult[1].CompareToString(""));
TEST_ExpectTrue(fResult[2].CompareToString(""));
Issue("Returned `MutableText`s have incorrect formatting.");
TEST_ExpectTrue(slashResult[1].CompareToFormattedString("{#ff0000 usr}"));
@ -898,30 +898,30 @@ protected static function SubTest_ReplaceEdgeCases(Text.FormatSensitivity flag)
local MutableText builder;
builder = __().text.Empty();
Issue("`Replace()` works incorrectly when replacing empty `Text`s.");
TEST_ExpectTrue(builder.Replace(P(""), P(""),, flag).ToPlainString() == "");
TEST_ExpectTrue(builder.Replace(P(""), P(""),, flag).ToString() == "");
TEST_ExpectTrue(
builder.Replace(P(""), P("huh"),, flag).ToPlainString() == "");
builder.Replace(P(""), P("huh"),, flag).ToString() == "");
builder.AppendPlainString("word");
TEST_ExpectTrue(
builder.Replace(P(""), P(""),, flag).ToPlainString() == "word");
builder.Replace(P(""), P(""),, flag).ToString() == "word");
TEST_ExpectTrue(
builder.Replace(P(""), P("huh"),, flag).ToPlainString() == "word");
builder.Replace(P(""), P("huh"),, flag).ToString() == "word");
Issue("`Replace()` works incorrectly when replacing something inside"
@ "an empty `Text`s.");
builder.Clear();
TEST_ExpectTrue(
builder.Replace(P("huh"), P(""),, flag).ToPlainString() == "");
builder.Replace(P("huh"), P(""),, flag).ToString() == "");
Issue("`Replace()` cannot replace whole `Text`s.");
TEST_ExpectTrue(builder.Clear()
.AppendFormattedString("Just {#54af4c something}")
.Replace(F("Just {#54af4c something}"), P("Nothing really"),, flag)
.ToPlainString()
.ToString()
== "Nothing really");
TEST_ExpectTrue(builder.Clear().AppendPlainString("CraZy")
.Replace(P("CRaZy"), P("calm"), SCASE_INSENSITIVE, flag)
.ToPlainString()
.ToString()
== "calm");
}
@ -932,31 +932,31 @@ protected static function SubTest_ReplaceMainCases(Text.FormatSensitivity flag)
Issue("`Replace()` works incorrectly changes `Text` when replacing"
@ "non-existent sub-`Text`.");
TEST_ExpectTrue(builder.Replace(P("word"), P("another"),, flag)
.ToPlainString()
.ToString()
== "Mate eight said");
TEST_ExpectTrue(builder
.Replace(P("word"), P("another"), SCASE_INSENSITIVE, flag)
.ToPlainString()
.ToString()
== "Mate eight said");
Issue("`Replace()` replaces sub-`Text` incorrectly.");
builder.Clear().AppendPlainString("Do it bay bee");
TEST_ExpectTrue(builder.Replace(P("it"), P("this"),, flag).ToPlainString()
TEST_ExpectTrue(builder.Replace(P("it"), P("this"),, flag).ToString()
== "Do this bay bee");
builder.Clear().AppendPlainString("dO It bAy BEe");
TEST_ExpectTrue(
builder.Replace(P("it"), P("tHis"), SCASE_INSENSITIVE, flag)
.ToPlainString()
.ToString()
== "dO tHis bAy BEe");
Issue("`Replace()` replaces sub-`Text` incorrectly.");
builder.Clear().AppendPlainString("he and she and it");
TEST_ExpectTrue(builder.Replace(P("and"), P("OR"),, flag)
.ToPlainString()
.ToString()
== "he OR she OR it");
builder.Clear().AppendFormattedString("{#54af4c HE} aNd sHe aND iT");
TEST_ExpectTrue(builder.Replace(P("AND"), P("Or"), SCASE_INSENSITIVE, flag)
.ToPlainString()
.ToString()
== "HE Or sHe Or iT");
}

BIN
sources/Text/Tests/TEST_TextAPI.uc

Binary file not shown.

4
sources/Text/Tests/TEST_TextCache.uc

@ -59,9 +59,9 @@ protected static function Test_Plain()
|| lifeVersion != newText.GetLifeVersion());
Issue("Cache returns `Text` with wrong data.");
TEST_ExpectTrue( cache.GetPlainText("First string").ToPlainString()
TEST_ExpectTrue( cache.GetPlainText("First string").ToString()
== "First string");
TEST_ExpectTrue( cache.GetPlainText("New string").ToPlainString()
TEST_ExpectTrue( cache.GetPlainText("New string").ToString()
== "New string");
}

BIN
sources/Text/Tests/TEST_UTF8EncoderDecoder.uc

Binary file not shown.

4
sources/Text/Text.uc

@ -799,7 +799,7 @@ private final function bool CompareFormatting(Text otherText)
* @return `true` if the caller `Text` is equal to the `stringToCompare` under
* specified parameters and `false` otherwise.
*/
public final function bool CompareToPlainString(
public final function bool CompareToString(
string stringToCompare,
optional CaseSensitivity caseSensitivity,
optional FormatSensitivity formatSensitivity)
@ -1121,7 +1121,7 @@ private final function NormalizeFormatting()
* @return Plain `string` representation of the caller `Text`,
* i.e. `string` without any color information inside.
*/
public final function string ToPlainString(
public final function string ToString(
optional int startIndex,
optional int maxLength)
{

2
sources/Text/TextAPI.uc

@ -297,7 +297,7 @@ public final function string ToString(Text toConvert)
{
local string result;
if (toConvert != none) {
result = toConvert.ToPlainString();
result = toConvert.ToString();
}
_.memory.Free(toConvert);
return result;

12
sources/Types/Tests/TEST_Base.uc

@ -39,7 +39,7 @@ protected static function Test_QuickText()
formatted = "{#ff0000 Plain str}i{#00ff00 ng}";
Context("Testing `P()`/`C()`/`F()` methods for creating texts.");
Issue("Methods return `Text`s with incorrect data.");
TEST_ExpectTrue(P(plain).ToPlainString() == "Plain string");
TEST_ExpectTrue(P(plain).ToString() == "Plain string");
TEST_ExpectTrue(C(colored).ToFormattedString()
== "Colored {rgb(1,1,128) string!}");
TEST_ExpectTrue(F(formatted).ToFormattedString()
@ -72,11 +72,11 @@ protected static function Test_Constants()
Context("Testing `T()` for returning `Text` generated from"
@ "`stringConstants`.");
Issue("Expected `Text`s are not correctly generated.");
TEST_ExpectTrue(T(0).ToPlainString() == default.stringConstants[0]);
TEST_ExpectTrue(T(1).ToPlainString() == default.stringConstants[1]);
TEST_ExpectTrue(T(2).ToPlainString() == default.stringConstants[2]);
TEST_ExpectTrue(T(3).ToPlainString() == default.stringConstants[3]);
TEST_ExpectTrue(T(4).ToPlainString() == default.stringConstants[4]);
TEST_ExpectTrue(T(0).ToString() == default.stringConstants[0]);
TEST_ExpectTrue(T(1).ToString() == default.stringConstants[1]);
TEST_ExpectTrue(T(2).ToString() == default.stringConstants[2]);
TEST_ExpectTrue(T(3).ToString() == default.stringConstants[3]);
TEST_ExpectTrue(T(4).ToString() == default.stringConstants[4]);
Issue("`T()` does not return `none` for invalid indices.");
TEST_ExpectNone(T(-1));

10
sources/Users/Tests/TEST_User.uc

@ -40,14 +40,14 @@ protected static function Test_UserID()
TEST_ExpectFalse(testID.Initialize(P("76561198044316328")));
Issue("`UserID` incorrectly handles SteamID.");
TEST_ExpectTrue( testID.GetUniqueID().ToPlainString()
TEST_ExpectTrue( testID.GetUniqueID().ToString()
== "76561198025127722");
TEST_ExpectTrue( testID.GetSteamIDString().ToPlainString()
TEST_ExpectTrue( testID.GetSteamIDString().ToString()
== "STEAM_1:0:32430997");
TEST_ExpectTrue( testID.GetSteamID3String().ToPlainString()
TEST_ExpectTrue( testID.GetSteamID3String().ToString()
== "U:1:64861994");
TEST_ExpectTrue(testID.GetSteamID32() == 64861994);
TEST_ExpectTrue( testID.GetSteamID64String().ToPlainString()
TEST_ExpectTrue( testID.GetSteamID64String().ToString()
== "76561198025127722");
Issue("Two `UserID` equality check is incorrect.");
@ -65,7 +65,7 @@ protected static function Test_UserID()
TEST_ExpectTrue(SteamID.universe == 1);
TEST_ExpectTrue(SteamID.instance == 1);
TEST_ExpectTrue(SteamID.steamID32 == 84050600);
TEST_ExpectTrue(SteamID.steamID64.ToPlainString() == "76561198044316328");
TEST_ExpectTrue(SteamID.steamID64.ToString() == "76561198044316328");
}
defaultproperties

Loading…
Cancel
Save