// This script will test all the string functions
// fret@memecode.com
#include "../Resources/resdefs.h"

// Global methods
	s = LoadString(IDS_TEST_STRING);
	if (s != "This is a test")
	{
		Print("Error: LoadString failed.\n");
		return false;
	}

	s = FormatSize(123456);
	if (s != "120 KiB")
	{
		Print("Error: FormatSize failed (" + s + ")\n");
		return false;
	}

	s = Sprintf("%x", 0xffaa);
	if (s != "ffaa")
	{
		Print("Error: Sprintf failed.\n");
		return false;
	}
	Print("s: ", s, "\n");

// obj.Find
	s = "Test string";
	if (s.Find("str") != 5)
	{
		Print("Error: Find1 failed.\n");
		return false;
	}
	if (s.Find("asd") != -1)
	{
		Print("Error: Find2 failed.\n");
		return false;
	}
	if (s.Find("Str") != -1)
	{
		Print("Error: Find3 failed.\n");
		return false;
	}

// obj.Split
	s = "123,456,789";

	parts = s.Split(",", 1);
	if (parts.Length != 2)
	{
		Print("Error: Split.length != 2.\n");
		return false;
	}
	if (parts[0] != "123" ||
		parts[1] != "456,789")
	{
		Print("Error: Split content failed (" + parts + ")\n");
		return false;
	}

	parts = s.Split(",");
	if (parts.Length != 3)
	{
		Print("Error: Split.length != 3.\n");
		return false;
	}
	if (parts[0] != 123 ||
		parts[1] != 456 ||
		parts[2] != 789)
	{
		Print("Error: Split2 content failed (" + parts + ")\n");
		return false;
	}
	Print("Parts: ", parts, "\n");

// obj.Join
	sep = ",";
	j = sep.join(parts);
	if (j != s)
	{
		Print("Error: Join1 failed.\n");
		return false;
	}
	Print("j: ", j, "\n");

// obj.Upper
	s = "Test";
	if (s.Upper() != "TEST")
	{
		Print("Error: Upper failed.\n");
		return false;
	}

// obj.Lower
	if (s.Lower() != "test")
	{
		Print("Error: Lower failed.\n");
		return false;
	}

// obj.Sub
	s = "Test String";
	j = s.Sub(5, 8);
	if (j != "Str")
	{
		Print("Error: Sub1 failed.\n");
		return false;
	}
	j = s.Sub(8);
	if (j != "ing")
	{
		Print("Error: Sub2 failed.\n");
		return false;
	}
	j = s.Sub(12);
	Print("j: ", j, "\n");
	if (j != Null)
	{
		Print("Error: Sub3 failed.\n");
		return false;
	}
	j = s.Sub(5, 4);
	if (j != Null)
	{
		Print("Error: Sub4 failed.\n");
		return false;
	}

Print("All tests passed.\n");
return true;