Skip to content

Commit

Permalink
Sortメソッドで使っている整数除算演算子(\)がWindows版ExcelとMac版Excelに互換性がないためInt関数に置き換えた。
Browse files Browse the repository at this point in the history
テストを調整。
  • Loading branch information
Shinichi Nanbu committed Sep 1, 2011
1 parent 376c208 commit f0006c9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion XArray.cls
Expand Up @@ -204,7 +204,8 @@ Private Function QuickSort(Target, Min As Long, Max As Long, Optional Comparer)
Dim Index2 As Long
Dim Temp

Middle = (Min + Max) \ 2
'Middle = (Min + Max) \ 2
Middle = Int((Min + Max) / 2)
Call SetValue(Temp, Target(Middle))
Call SetValue(Target(Middle), Target(Min))
Index2 = Min
Expand Down
32 changes: 27 additions & 5 deletions test/XArrayTest.bas
Expand Up @@ -2,6 +2,10 @@ Attribute VB_Name = "XArrayTest"
Option Explicit

Sub Test()
Dim StartTime As Currency
Dim EndTime As Currency
Debug.Print "**** XArrayTest.Test ****"
StartTime = Timer()
Call TestAdd
Call TestInsert
Call TestRemove
Expand All @@ -14,6 +18,8 @@ Sub Test()
Call TestReverse
Call TestClone
Call TestItems
EndTime = Timer() - StartTime
Debug.Print "Total: " & EndTime & " seconds. "
End Sub

Sub TestAdd()
Expand Down Expand Up @@ -143,7 +149,7 @@ Sub TestRemove()
EndTime = Timer() - StartTime
Debug.Assert a.Count = 0
Debug.Print EndTime
Debug.Assert EndTime < 1
Debug.Assert EndTime < 10
End Sub

Sub TestItem()
Expand Down Expand Up @@ -187,7 +193,7 @@ Sub TestItem()
EndTime = Timer() - StartTime
Debug.Assert b.Count = Count
Debug.Print EndTime
Debug.Assert EndTime < 1
Debug.Assert EndTime < 10
End Sub

Sub TestCount()
Expand Down Expand Up @@ -277,7 +283,7 @@ Sub TestExists()
EndTime = Timer() - StartTime

Debug.Print EndTime
Debug.Assert EndTime < 1
Debug.Assert EndTime < 10
End Sub

Sub TestIndexOf()
Expand Down Expand Up @@ -354,7 +360,7 @@ Sub TestIndexOf()
EndTime = Timer() - StartTime

Debug.Print EndTime
Debug.Assert EndTime < 1
Debug.Assert EndTime < 10
End Sub

Sub TestExchange()
Expand Down Expand Up @@ -483,6 +489,22 @@ Sub TestSort()
Dim c As New XArray
c.Sort
Debug.Assert c.Count = 0

Dim d As New XArray
Dim i As Long
Dim Count As Long
Dim StartTime As Currency
Dim EndTime As Currency

Count = 10000
For i = Count - 1 To 0 Step -1
d.Add i
Next
StartTime = Timer()
d.Sort
EndTime = Timer() - StartTime
Debug.Print EndTime
Debug.Assert EndTime < 10
End Sub

Sub TestReverse()
Expand Down Expand Up @@ -578,7 +600,7 @@ Sub TestItems()
Values = b.Items
EndTime = Timer() - StartTime
Debug.Print EndTime
Debug.Assert EndTime < 1
Debug.Assert EndTime < 10
Debug.Assert IsArray(Values)
Debug.Assert UBound(Values) = Count - 1
End Sub

0 comments on commit f0006c9

Please sign in to comment.