Skip to content

Commit

Permalink
Merge branch 'release/3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ktekinay committed May 1, 2016
2 parents 51506fe + beab726 commit 9099c27
Show file tree
Hide file tree
Showing 16 changed files with 675 additions and 178 deletions.
5 changes: 3 additions & 2 deletions JSONItem_MTC Harness/JSONItem_MTC Harness.xojo_project
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Type=Desktop
RBProjectVersion=2015.031
RBProjectVersion=2016.011
MinIDEVersion=20070100
Class=App;App.xojo_code;&h14C611D3;&h0;false
MenuBar=MenuBar1;MenuBar1.xojo_menu;&h18745784;&h0;false
Expand All @@ -14,10 +14,11 @@ Class=DesktopTestController;Tests/DesktopTestController.xojo_code;&h3FC78D4E;&h1
Class=BasicTests_JSONItem;Tests/BasicTests_JSONItem.xojo_code;&h6BEECF33;&h1962C3CC;false
Class=BasicTests_JSONItem_MTC;Tests/BasicTests_JSONItem_MTC.xojo_code;&h2324D4BF;&h1962C3CC;false
Class=BasicTests_NewFramework;Tests/BasicTests_NewFramework.xojo_code;&h28A07FF;&h1962C3CC;false
Class=CompareTests;Tests/CompareTests.xojo_code;&h30843965;&h1962C3CC;false
Class=LongTests_JSONItem_MTC;Tests/LongTests_JSONItem_MTC.xojo_code;&h513E8F7E;&h1962C3CC;false
Class=JsonOrgExampleTests;Tests/JsonOrgExampleTests.xojo_code;&h260C54C7;&h1962C3CC;false
Class=StressTests;Tests/StressTests.xojo_code;&h1D5DEFFF;&h1962C3CC;false
Class=XojoJSONItemTests;Tests/XojoJSONItemTests.xojo_code;&h794C237D;&h1962C3CC;false
Class=CompareTests;Tests/CompareTests.xojo_code;&h30843965;&h1962C3CC;false
RawData=json_sample;Text Files/json_sample.txt;&h5E7609A1;&h0;false
Module=M_Global;M_Global.xojo_code;&h3616CFFF;&h0;false
Folder=Tests;XojoUnit/Tests;&h44C729E7;&h2516B04D;false
Expand Down
20 changes: 20 additions & 0 deletions JSONItem_MTC Harness/Tests/BasicTests_JSONItem.xojo_code
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#tag Class
Protected Class BasicTests_JSONItem
Inherits TestGroup
#tag Method, Flags = &h21
Private Sub CaseSensitiveKeyTest()
dim j as new JSONItem
j.Value( "a" ) = 1
j.Value( "A" ) = 2

Assert.AreEqual( 2, j.Count, "Should be 2 objects" )
Assert.AreEqual( 1, j.Value( "a" ).IntegerValue )

j.Value( "Man" ) = 3
Assert.IsFalse( j.HasName( "MaT" ), "Keys with same Base64 encoding return incorrect results" )

End Sub
#tag EndMethod

#tag Method, Flags = &h21
Private Sub IllegalStringTest()
dim j as JSONItem
Expand Down Expand Up @@ -227,6 +242,11 @@ Inherits TestGroup
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NotImplementedCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="PassedTestCount"
Group="Behavior"
Expand Down
9 changes: 9 additions & 0 deletions JSONItem_MTC Harness/Tests/BasicTests_JSONItem_MTC.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ Inherits TestGroup

Assert.AreEqual( 2, j.Count, "Should be 2 objects" )
Assert.AreEqual( 1, j.Value( "a" ).IntegerValue )

j.Value( "Man" ) = 3
Assert.IsFalse( j.HasName( "MaT" ), "Keys with same Base64 encoding return incorrect results" )

End Sub
#tag EndMethod

Expand Down Expand Up @@ -647,6 +651,11 @@ Inherits TestGroup
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NotImplementedCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="PassedTestCount"
Group="Behavior"
Expand Down
20 changes: 15 additions & 5 deletions JSONItem_MTC Harness/Tests/BasicTests_NewFramework.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ Inherits TestGroup
Private Sub CaseSensitiveKeyTest()
Using Xojo.Core

dim j as Dictionary = NewCaseSensitiveDictionary
dim j as Dictionary = Xojo.Data.ParseJSON( kCaseSensitiveJSON )

j.Value( "a" ) = 1
j.Value( "A" ) = 2

Assert.AreEqual( 2, j.Count, "Should be 2 objects" )
Assert.AreEqual( 3, j.Count, "Should be 3 objects" )
dim r as integer = j.Value( "a" )
Assert.AreEqual( 1, r )

Assert.IsFalse( j.HasKey( "MaT" ), "Keys with same Base64 encoding return incorrect results" )


End Sub
#tag EndMethod

Expand Down Expand Up @@ -165,6 +166,10 @@ Inherits TestGroup
#tag EndMethod


#tag Constant, Name = kCaseSensitiveJSON, Type = Text, Dynamic = False, Default = \"{\n \"a\" : 1\x2C\n \"A\" : 2\x2C\n \"Man\" : 3\n}", Scope = Private
#tag EndConstant


#tag ViewBehavior
#tag ViewProperty
Name="Duration"
Expand Down Expand Up @@ -202,6 +207,11 @@ Inherits TestGroup
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NotImplementedCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="PassedTestCount"
Group="Behavior"
Expand Down
76 changes: 76 additions & 0 deletions JSONItem_MTC Harness/Tests/CompareTests.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,81 @@ Inherits TestGroup
#tag EndMethod


#tag ViewBehavior
#tag ViewProperty
Name="Duration"
Group="Behavior"
Type="Double"
#tag EndViewProperty
#tag ViewProperty
Name="FailedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="IncludeGroup"
Group="Behavior"
InitialValue="True"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NotImplementedCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="PassedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="RunTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="SkippedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="TestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
6 changes: 4 additions & 2 deletions JSONItem_MTC Harness/Tests/DesktopTestController.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ Inherits TestController

'group = New XojoUnitTests(Self, "Assertion")
'group = New XojoUnitFailTests(Self, "Fail Tests")
group = new CompareTests( Self, "Compare JSONItem_MTC to JSONItem" )
group = New BasicTests_JSONItem(Self, "Native JSONItem Tests")
group = New BasicTests_JSONItem_MTC(Self, "Basic JSONItem_MTC Tests")
group = new BasicTests_NewFramework( Self, "Basic New Framework Tests" )
group = new LongTests_JSONItem_MTC( self, "Long JSONItem_MTC Tests" )
group = New JsonOrgExampleTests(Self, "Example Documents from json.org/example")
group = new CompareTests( Self, "Compare JSONItem_MTC to JSONItem" )
group = new LongTests_JSONItem_MTC( self, "Long JSONItem_MTC Tests" )
group = New StressTests(Self, "Stress Tests")
group = new XojoJSONItemTests( self, "Xojo's Unit Tests" )

End Sub
#tag EndEvent

Expand Down
128 changes: 128 additions & 0 deletions JSONItem_MTC Harness/Tests/StressTests.xojo_code
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#tag Class
Protected Class StressTests
Inherits TestGroup
#tag Method, Flags = &h21
Private Sub BigStringTest()
const kSize = 500 * 1024 * 1024
dim halfSize as integer = ( kSize \ 2 ) + 1

dim s as string = "0123456789"

while s.LenB < halfSize
s = s + s
wend

if s.LenB < kSize then
s = s + s.Mid( 1, kSize - s.LenB )
end if

dim length as integer = s.LenB
#pragma unused length

dim j as new JSONItem_MTC
j.Compact = true

try
j.Append s
Assert.Pass
catch err as OutOfMemoryException
Assert.Fail "Ran out of memory"
return
end try

dim expect as string = "[""" + s + """]"
dim jString as string
try
jString = j.ToString
Assert.AreEqual expect.LenB, jString.LenB, "Lengths don't match"
Assert.AreEqual 0, StrComp( expect, jString, 0 ), "Strings don't match"
catch err as OutOfMemoryException
Assert.Fail "Ran out of memory creating string"
return
end try

Assert.IsTrue jString.Encoding = Encodings.UTF8, "Encoding isn't UTF8"

return
End Sub
#tag EndMethod


#tag ViewBehavior
#tag ViewProperty
Name="Duration"
Group="Behavior"
Type="Double"
#tag EndViewProperty
#tag ViewProperty
Name="FailedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="IncludeGroup"
Group="Behavior"
InitialValue="True"
Type="Boolean"
#tag EndViewProperty
#tag ViewProperty
Name="Index"
Visible=true
Group="ID"
InitialValue="-2147483648"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Left"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Name"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="NotImplementedCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="PassedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="RunTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="SkippedTestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Super"
Visible=true
Group="ID"
Type="String"
#tag EndViewProperty
#tag ViewProperty
Name="TestCount"
Group="Behavior"
Type="Integer"
#tag EndViewProperty
#tag ViewProperty
Name="Top"
Visible=true
Group="Position"
InitialValue="0"
Type="Integer"
#tag EndViewProperty
#tag EndViewBehavior
End Class
#tag EndClass
Loading

0 comments on commit 9099c27

Please sign in to comment.