76 lines
2.4 KiB
Plaintext
76 lines
2.4 KiB
Plaintext
Option Explicit
|
|
|
|
Dim Fso
|
|
Dim ScriptRoot
|
|
Dim CommonPath
|
|
Dim CommonText
|
|
Dim Stream
|
|
Dim TempRoot
|
|
Dim Utf8Path
|
|
Dim Actual
|
|
Dim Sequence
|
|
Dim BridgeId
|
|
Dim Op
|
|
Dim PropertyName
|
|
Dim ExpectedRefdes
|
|
Dim NewRefdes
|
|
Dim FinalRefdes
|
|
|
|
Set Fso = CreateObject("Scripting.FileSystemObject")
|
|
ScriptRoot = Fso.GetParentFolderName(WScript.ScriptFullName)
|
|
CommonPath = Fso.GetAbsolutePathName( _
|
|
Fso.BuildPath(ScriptRoot, "..\..\integration\dxdesigner795\BridgeCommon.vbs"))
|
|
|
|
Set Stream = Fso.OpenTextFile(CommonPath, 1, False, 0)
|
|
CommonText = Stream.ReadAll
|
|
Stream.Close
|
|
ExecuteGlobal CommonText
|
|
|
|
Call AssertEqual(DxToolsQuote("C:\Tools Path\DxDesignerTools.exe"), _
|
|
Chr(34) & "C:\Tools Path\DxDesignerTools.exe" & Chr(34), "quote")
|
|
Call AssertEqual(DxToolsJson(Chr(34) & Chr(92) & vbCrLf & vbTab), _
|
|
Chr(92) & Chr(34) & Chr(92) & Chr(92) & Chr(92) & "r" & _
|
|
Chr(92) & "n" & Chr(92) & "t", "json")
|
|
|
|
TempRoot = Fso.BuildPath(Fso.GetSpecialFolder(2), _
|
|
"dx-tools-vbs-" & Replace(CStr(Timer), ".", "-"))
|
|
Fso.CreateFolder TempRoot
|
|
Utf8Path = Fso.BuildPath(TempRoot, "round-trip.txt")
|
|
Call DxToolsWriteUtf8Atomic(Utf8Path, ChrW(&H81EA) & ChrW(&H5B9A) & _
|
|
ChrW(&H4F4D) & ChrW(&H53F7))
|
|
Actual = DxToolsReadUtf8(Utf8Path)
|
|
Call AssertEqual(Actual, ChrW(&H81EA) & ChrW(&H5B9A) & ChrW(&H4F4D) & _
|
|
ChrW(&H53F7), "utf8")
|
|
|
|
If Not DxToolsParseScheduleRow("1" & vbTab & "refdes" & vbTab & _
|
|
"c000001" & vbTab & "" & vbTab & "R?" & vbTab & "R1" & vbTab & _
|
|
"R1", Sequence, Op, BridgeId, PropertyName, _
|
|
ExpectedRefdes, NewRefdes, FinalRefdes) Then
|
|
Call Fail("valid schedule row")
|
|
End If
|
|
Call AssertEqual(Sequence, 1, "sequence")
|
|
Call AssertEqual(Op, "refdes", "schedule op")
|
|
Call AssertEqual(BridgeId, "c000001", "bridge id")
|
|
Call AssertEqual(ExpectedRefdes, "R?", "expected value")
|
|
|
|
If DxToolsParseScheduleRow("1" & vbTab & "c000001" & vbTab & "R?", _
|
|
Sequence, Op, BridgeId, PropertyName, _
|
|
ExpectedRefdes, NewRefdes, FinalRefdes) Then
|
|
Call Fail("malformed schedule row")
|
|
End If
|
|
|
|
Fso.DeleteFolder TempRoot, True
|
|
WScript.Echo "BridgeCommon assertions passed"
|
|
|
|
Sub AssertEqual(actualValue, expectedValue, label)
|
|
If CStr(actualValue) <> CStr(expectedValue) Then
|
|
Call Fail(label & ": expected [" & CStr(expectedValue) & _
|
|
"] got [" & CStr(actualValue) & "]")
|
|
End If
|
|
End Sub
|
|
|
|
Sub Fail(message)
|
|
WScript.Echo "FAIL: " & message
|
|
WScript.Quit 1
|
|
End Sub
|