Changeset 468 for trunk/TestCase


Ignore:
Timestamp:
Mar 9, 2008, 12:00:01 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

TextWriter, StreamWriterの追加。
SPrintfの浮動小数点数変換で、NaN, Infiniteの出力に対応。
PathとDirectoryInfoのCreateDirectoryで、対象が既に存在するときには例外を投げないように修正。
SimpleTestCase内で使用する一時フォルダの場所にGetTempPathで取得する版を追加(コメントアウト)。

Location:
trunk/TestCase/SimpleTestCase
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/TestCase/SimpleTestCase/SPrintFTest.ab

    r385 r468  
    118118    s = FormatFloatG(0.0000123456, 4, 0, None)
    119119    UnitTest("FormatFloatG(0.0000123456, precision = 4) = 1.234e-05", s, "1.234e-05")
     120    s = FormatFloatG(ActiveBasic.Math.Detail.GetNaN(), DWORD_MAX, 0, None)
     121    UnitTest(Ex"FormatFloatG(NaN) = \qnan\q", s, "nan")
     122    s = FormatFloatG(ActiveBasic.Math.Detail.GetInf(False), DWORD_MAX, 0, Sign)
     123    UnitTest(Ex"FormatFloatG(Inf, Sign) = \q+infinity\q", s, "+infinity")
    120124
    121125    s = FormatFloatA(1, DWORD_MAX, 0, None)
     
    127131    s = FormatFloatA(3.1415926535897932384626433832795, DWORD_MAX, 0, None)
    128132    UnitTest("FormatFloatA(π) = 0x1.921fb54442d18p+1", s, "0x1.921fb54442d18p+1")
     133    s = FormatFloatA(3.1415926535897932384626433832795, 4, 0, None)
     134    UnitTest("FormatFloatA(π, precision = 4) = 0x1.921fp+1", s, "0x1.921fp+1")
    129135    s = FormatFloatA(0, DWORD_MAX, 0, None)
    130136    UnitTest("FormatFloatA(0)", s, "0x0p+0")
  • trunk/TestCase/SimpleTestCase/SimpleTestCase.ab

    r465 r468  
    55Dim hStdOut = _System_hConsoleOut
    66
     7Function GetTempDirectory() As String
     8    Return System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp\"
     9'   Return System.IO.Path.GetTempPath()
     10End Function
     11
    712Sub Initialize()
    813    ' 初期化関数
    914
    1015    ' 一時ディレクトリを空にしておく
    11     Dim tempDir = System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp"
     16    Dim tempDir = GetTempDirectory()
    1217    If System.IO.Directory.Exists( tempDir ) Then
    13         ' 存在するときは一旦消す
    14         System.IO.Directory.Delete( tempDir, True )
     18        Try
     19            ' 存在するときは一旦消す
     20            System.IO.Directory.Delete( tempDir, True )
     21        Catch e As System.IO.IOException
     22            OutputDebugString(e.ToString)
     23        End Try
    1524    End If
    1625    System.IO.Directory.CreateDirectory( tempDir )
     
    2433#include "SimpleTestCase.idx"
    2534
     35Dim failureCount = 0 As DWord
     36
    2637Sub UnitTest( msg As String, isSuccessful As Boolean )
    2738    Dim resultStr = Nothing As String
     
    3041    Else
    3142        resultStr = Ex"FAILURE!"
     43        failureCount++
    3244    End If
    3345
     
    4961        SetConsoleTextAttribute(hStdOut, BACKGROUND_RED Or BACKGROUND_GREEN Or BACKGROUND_INTENSITY)
    5062        Print Ex"FAILURE!"; msg
    51         Print "  test string = '" + test + "'"
     63        Print "  期待 = '" + expectation + "'" + " 結果 = '" + test + "'"
    5264        SetConsoleTextAttribute(hStdOut, csbi.wAttributes)
     65        failureCount++
    5366    End If
    5467End Sub
    5568
    5669Function GetExclusiveTempDirPath( testCaseName As String ) As String
    57     Dim tempDir = System.IO.Path.GetDirectoryName( System.Windows.Forms.Application.ExecutablePath ) + "\temp"
    58     Dim exclusiveTempDirPath = tempDir + "\" + testCaseName
     70    Dim tempDir = GetTempDirectory()
     71    Dim exclusiveTempDirPath = tempDir + testCaseName
    5972
    6073    If Not System.IO.Directory.Exists( exclusiveTempDirPath ) Then
     
    6679End Function
    6780
     81Print "失敗"; failureCount; "個"
    6882Print "Please Enter key"
    6983System.Console.ReadLine()
  • trunk/TestCase/SimpleTestCase/StringBuilderTest.ab

    r457 r468  
    1818    sb.Replace("こい", "いけ").Replace("いけ", "こい")
    1919    UnitTest("StringBuilder.Replace (String)", sb.ToString, "でてこいでてこいこいのこい")
     20    sb.Length = 0
     21    sb.Append(123)
     22    UnitTest("StringBuilder.Append (Long)", sb.ToString, "123")
    2023End Sub
    2124
     
    2326
    2427StringBuilderTest.TestMain()
    25 
  • trunk/TestCase/SimpleTestCase/XmlTest.ab

    r465 r468  
    1919
    2020    ' 書いて
    21     doc.Save( tempDir + "\test.xml" )
     21    doc.Save( tempDir + "test.xml" )
    2222
    2323    ' 読んで
    2424    Dim clone = New System.Xml.XmlDocument
    25     clone.Load( tempDir + "\test.xml" )
     25    clone.Load( tempDir + "test.xml" )
    2626
    2727    ' 比較してみる
Note: See TracChangeset for help on using the changeset viewer.