'--------------------------------------------------------------------
' Test case of String Class
'--------------------------------------------------------------------

Namespace StringTest

Sub TestMain()
	Dim s1 = Nothing As String


	s1 = New String("hello")

	UnitTest("String.GetType", s1.GetType().Name = "String")


	UnitTest("String.String (case 0)", (memcmp(s1.StrPtr, "hello", SizeOf (StrChar) * 6) = 0))

	UnitTest("String.String (case 1)", (s1 = "hello"))

	Dim nsz[2] = [&h31, &h32, &h33] As SByte
	s1 = New String(nsz, 3)
	UnitTest("String.String (case 2)", (s1 = "123"))

	Dim wsz[4] = [&h31, &h32, &h33, &h34, &h35] As WCHAR
	s1 = New String(wsz, 5)
	UnitTest("String.String (case 3)", (s1 = "12345"))

	s1 = New String(&h30 As StrChar, 4)
	UnitTest("String.String (case 4)", (s1 = "0000"))

	s1 = "literal"
	UnitTest("String.String (case 5)", (s1 = "literal"))

	UnitTest("String.Length", (s1.Length = 7))

	UnitTest("String.ToString", (s1.ToString() = "literal"))
	UnitTest("String.Clone", (s1.Clone() = "literal"))

	UnitTest("String.Operator []", (s1[7] = 0))

	s1 = New String("abc")

	UnitTest("String.IsNullOrEmpty (case 1)", (String.IsNullOrEmpty(Nothing) = True))
	UnitTest("String.IsNullOrEmpty (case 2)", (String.IsNullOrEmpty("") = True))
	UnitTest("String.IsNullOrEmpty (case 3)", (String.IsNullOrEmpty(s1) = False))

	UnitTest("String.Compare (case 1)", (String.Compare("ABC", "ABC") = 0))
	UnitTest("String.Compare (case 2)", (String.Compare("ABD", "ABC") > 0))
	UnitTest("String.Compare (case 3)", (String.Compare("ABC", "ABCD") < 0))

	Dim o1 = New Object
	Dim o2 = s1 As Object
	UnitTest("String.Concat", (String.Concat(o1, o2) = "Objectabc"))

	UnitTest("String.Operator +", ((s1 + "def") = "abcdef"))
	UnitTest("String.Operator &", ((s1 + "xyz") = "abcxyz"))

	s1 = "へのへの"
	UnitTest("String.Contains (case 1)", (s1.Contains("のへ") = True))
	UnitTest("String.Contains (case 2)", (s1.Contains("もへ") = False))

	' まだまだ追加求む

End Sub

End Namespace

StringTest.TestMain()
