forked from HCL-TECH-SOFTWARE/voltscript-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VoltScriptTesting.bss
2367 lines (2013 loc) · 56.8 KB
/
VoltScriptTesting.bss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%REM
Copyright 2022-2023 HCL America, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License
%END REM
%REM
Library BaliUnit
Created Mar 14, 2022 by Paul Withers/UK/PNPHCL
Unit Testing Framework for Bali and LotusScript
%END REM
Option Public
Option Declare
%REM
Type used to hold results of an individual unit test
%END REM
Type TestCase
description As String
outcome As String
errorMsg As String
errorStack As String
End Type
' Default location for writing reports
Const BASE_REPORT_LOC = |unit-test-reports/|
' Core unit testing suite
Class TestSuite
'{{SETI_AUTHOR_CODE_Internal_Member_Init
Public customBeforeAfter As AbstractCustomBeforeAfter
Public displayName As String
Public errors As Integer
Public failures As Integer
Public missingAssertions As Integer
Public results List As TestCase
Public runTime As String
Public suppressReport As Boolean
Public tests As Integer
Public title As String
Private description As String
Private outputLoc As String
Private outputFormat As String
Private stTime As Double
Private endTime As Double
Private started As Boolean
Private isDelegatedAssertion As Boolean
Private hasTestRunner As Boolean
Private testRunnerName As String
'}}
%REM
Adds object containing custom beforeAll, beforeEach, afterEach and/or afterAll code.
@param customBeforeAfter Containing before and after functions
@return Fluent
%END REM
Function addCustomBeforeAfter(customBeforeAfter As AbstractCustomBeforeAfter) As TestSuite
'{{SETI_AUTHOR_CODE_addCustomBeforeAfter
Set Me.customBeforeAfter = customBeforeAfter
Set addCustomBeforeAfter = Me
'}}
End Function
%REM
Checks whether an assertion has been run yet and, if not, starts the timer
and runs beforeAll if a BaliCustomBeforeAfter has been passed in.
%END REM
Sub checkStarted()
'{{SETI_AUTHOR_CODE_checkStarted
If (Not started) Then
stTime = Timer
started = True
If (Not Me.customBeforeAfter Is Nothing) Then
Me.customBeforeAfter.beforeAll
End If
End If
'}}
End Sub
%REM
Ends timer, triggers afterAll if a BaliCustomBeforeAfter has been passed in,
and prints out the report.
%END REM
Sub completeReport()
'{{SETI_AUTHOR_CODE_completeReport
On Error GoTo trapError
Call endTimer
If (Not Me.customBeforeAfter Is Nothing) Then
Me.customBeforeAfter.afterAll
End If
If suppressReport Then Exit Sub
Call printSummary()
If (Me.outputFormat = "HTML" Or Me.outputFormat = "BOTH") Then
If (Not hasTestRunner) Then
Me.title = Me.title & |-| & FormatTimeForOutput(Now)
End If
Dim testSuiteReport As New BaliTestSuiteReport(Me.outputLoc)
Call testSuiteReport.printoutReport(Me)
End If
exitSub:
Exit Sub
trapError:
MsgBox |Error | & Error(Err) & | on line | & CStr(Erl)
Resume exitSub
'}}
End Sub
%REM
Destructor.
%END REM
Sub Delete
'{{SETI_AUTHOR_CODE_delete
Call Me.completeReport()
'}}
End Sub
%REM
Adds a unique description for the next test.
@param description Proposed description
@return Fluent
%END REM
Function describe(description As String) As TestSuite
'{{SETI_AUTHOR_CODE_describe
Dim uniqueDesc As String
uniqueDesc = makeDescriptionUnique(description)
Me.description = uniqueDesc
Me.tests = Me.tests + 1
' Add placeholder in case no assertion is run
Me.missingAssertions = Me.missingAssertions + 1
Me.results(Me.description).description = Me.description
Me.results(Me.description).outcome = |Failed|
Me.results(Me.description).errorMsg = "No assertion"
Set describe = Me
'}}
End Function
%REM
Duration of tests.
@return Time the test ran for in seconds, as a string
%END REM
Function duration As String
'{{SETI_AUTHOR_CODE_duration
Dim dur As Double
dur = endTime - stTime
duration = CStr(Round(dur, |0.01|))
'}}
End Function
%REM
Sets endTime to Timer.
%END REM
Sub endTimer
'{{SETI_AUTHOR_CODE_endTimer
endTime = Timer
'}}
End Sub
%REM
Converts error message to human readable format.
@return Human readable error description, number and line
%END REM
Function getErrorMsg As String
'{{SETI_AUTHOR_CODE_getErrorMsg
getErrorMsg = |Error | & Error & |(| & Err() & |) on line | & Erl
'}}
End Function
%REM
Getter for output format, default is HTML.
@return "HTML", "XML" or "BOTH"
%END REM
Function getOutputFormat() As String
'{{SETI_AUTHOR_CODE_getOutputFormat
getOutputFormat = outputFormat
'}}
End Function
%REM
Sets this test as included in a BaliTestRunner. Called by BaliTestRunner.addTestSuite.
@param testRunnerName TestRunner name test is included in
@returns Fluent
%END REM
Function includeInTestRunner(testRunnerName As String) As TestSuite
'{{SETI_AUTHOR_CODE_includeInTestRunner
Me.hasTestRunner = True
Me.testRunnerName = testRunnerName
Set includeInTestRunner = Me
'}}
End Function
%REM
Constructor
@param title Title for the report
%END REM
Sub New(title As String)
'{{SETI_AUTHOR_CODE_constructor
Me.title = title
Me.errors = 0
Me.failures = 0
Me.tests = 0
Me.missingAssertions = 0
Me.outputFormat = "HTML"
'}}
End Sub
%REM
Sets a directory to write reports to, overriding default "unit-test-reports".
@param outputLoc Directory to write reports
@return Fluent
%END REM
Function outputTo(outputLoc As String) As TestSuite
'{{SETI_AUTHOR_CODE_outputTo
Dim lastChar As String
lastChar = Right(FullTrim(outputLoc), 1)
If (lastChar <> |\\| And lastChar <> |/|) Then
outputLoc = outputLoc & |/|
End If
Me.outputLoc = outputLoc
Set outputTo = Me
'}}
End Function
%REM
Whether there are errors, failures or missing assertions.
@return True if no errors, failures or missing assertions
%END REM
Function ranSuccessfully As Boolean
'{{SETI_AUTHOR_CODE_ranSuccessfully
If (Me.errors = 0 And Me.failures = 0 And Me.missingAssertions = 0) Then
ranSuccessfully = True
End If
'}}
End Function
%REM
Tests whether a AbstractBaliCustomBeforeAfter has been passed in and, if so, calls afterEach.
Triggered automatically from all in-built assertiopns.
%END REM
Sub runAfterEach()
'{{SETI_AUTHOR_CODE_runAfterEach
If (Not Me.customBeforeAfter Is Nothing) Then
Me.customBeforeAfter.afterEach
End If
'}}
End Sub
%REM
Tests whether a AbstractBaliCustomBeforeAfter has been passed in and, if so, calls beforeEach.
%END REM
Sub runBeforeEach()
'{{SETI_AUTHOR_CODE_runBeforeEach
If (Not Me.customBeforeAfter Is Nothing) Then
Me.customBeforeAfter.beforeEach
End If
'}}
End Sub
%REM
Sets the display name to show in reports.
@param displayName A more readable explanation of the report. Used in XML output for Jenkins.
@return Fluent
%END REM
Public Function setDisplayName(displayName As String) As TestSuite
'{{SETI_AUTHOR_CODE_setDisplayName
Me.displayName = displayName
Set setDisplayName = Me
'}}
End Function
%REM
Sets the output format for the reports.
@param formatType Format for reports, "HTML", "XML" or "BOTH"
@return Fluent
@throws Error 1400, invalid format type if formatType is not "HTML", "XML" or "BOTH"
%END REM
Function setOutputFormat(formatType As String) As TestSuite
'{{SETI_AUTHOR_CODE_setOutputFormat
Select Case formatType
Case "HTML", "XML", "BOTH":
Case Else
Error 1400, "Invalid format type, only HTML, XML or BOTH are supported"
End Select
outputFormat = formatType
Set setOutputFormat = Me
'}}
End Function
%REM
********************************************************
START OF ASSERTIONS
All assertions run beforeEach and afterEach, if required
********************************************************
%END REM
%REM
Tests whether the value passed is a boolean True and returns assertion outcome.
@param actual Value to be tested
@return Assertion outcome
%END REM
Function assertTrue(actual As Boolean) As Boolean
'{{SETI_AUTHOR_CODE_assertTrue
checkStarted
' runBeforeEach will already have been called
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (actual) Then
addResult True, ||
assertTrue = True
Else
addResult False, |Expected: true, but was: false|
assertTrue = False
End If
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
'}}
End Function
%REM
Tests whether the value passed is a boolean False.
@param actual Value to be tested
@return Assertion outcome
%END REM
Function assertFalse(actual As Boolean) As Boolean
'{{SETI_AUTHOR_CODE_assertFalse
checkStarted
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (Not actual) Then
addResult True, ||
assertFalse = True
Else
addResult False, |Expected: false, but was: true|
assertFalse = True
End If
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
'}}
End Function
%REM
Tests whether two strings match, applying basic case sensitivity as required (LCase-ing expected and actual).
@param expected String to test against
@param actual String to test
@param caseInsensitive Whether to compare in current case or as lower case
@return Assertion outcome
%END REM
Function assertEqualsString(expected As String, actual As Variant, caseInsensitive As Boolean) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsString
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
Dim expectedForReport As String, actualForReport As String
Dim expectedForComparison As String, actualForComparison As String
If (TypeName(expected) <> "STRING") Then
addResult False, |Expected is not a String, instead is: | & TypeName(expected)
assertEqualsString = False
GoTo getOut
ElseIf(TypeName(actual) <> "STRING") Then
addResult False, |Actual is not a String, instead is: | & TypeName(actual)
assertEqualsString = False
GoTo getOut
End If
expectedForReport = expected
actualForReport = actual
If (caseInsensitive) Then
expectedForComparison = LCase(expected)
actualForComparison = LCase(actual)
Else
expectedForComparison = expected
actualForComparison = actual
End If
If (expectedForComparison = actualForComparison) Then
addResult True, ||
assertEqualsString = True
Else
addResult False, |Expected: | & expectedForReport & | but was: | & actualForReport
assertEqualsString = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two strings do not match.
@param expected String to test against
@param actual String to test
@return Assertion outcome
%END REM
Function assertNotEqualString(expected As Variant, actual As Variant) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualString
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (TypeName(expected) <> "STRING") Then
addResult False, |Expected is not a String, instead is: | & TypeName(expected)
assertNotEqualString = False
GoTo getOut
ElseIf(TypeName(actual) <> "STRING") Then
addResult False, |Actual is not a String, instead is: | & TypeName(actual)
assertNotEqualString = False
GoTo getOut
End If
If (expected <> actual) Then
addResult True, ||
assertNotEqualString = True
Else
addResult False, |Expected: | & expected & | matches actual: | & actual
assertNotEqualString = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two integers match.
@param expected Integer to test against
@param actual Integer to test
@return Assertion outcome
%END REM
Function assertEqualsInteger(expected As Integer, actual As Integer) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsInteger
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (expected = actual) Then
addResult True, ||
assertEqualsInteger = True
Else
addResult False, |Expected: | & CStr(expected) & |, but was: | & CStr(actual)
assertEqualsInteger = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two integers do not match.
@param expected Integer to test against
@param actual Integer to test
@return Assertion outcome
%END REM
Function assertNotEqualInteger(expected As Integer, actual As Integer) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualInteger
checkStarted
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
On Error GoTo errCatch
If (expected <> actual) Then
addResult True, ||
assertNotEqualInteger = True
Else
addResult False, |Expected: | & CStr(expected) & | matches actual: | & CStr(actual)
assertNotEqualInteger = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two doubles match, CStr-ing expected and actual to avoid bit-level issues.
@param expected Double to test against
@param actual Double to test
@return Assertion outcome
%END REM
Function assertEqualsDouble(expected As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsDouble
checkStarted
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
On Error GoTo errCatch
If (CStr(expected) = CStr(actual)) Then
addResult True, ||
assertEqualsDouble = True
Else
addResult False, |Expected: | & CStr(expected) & |, but was: | & CStr(actual)
assertEqualsDouble = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two doubles do not match, CStr-ing to avoid false positives.
@param expected Double to test against
@param actual Double to test
@return Assertion outcome
%END REM
Function assertNotEqualDouble(expected As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualDouble
checkStarted
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
On Error GoTo errCatch
If (CStr(expected) <> CStr(actual)) Then
addResult True, ||
assertNotEqualDouble = True
Else
addResult False, |Expected: | & CStr(expected) & | matches actual: | & CStr(actual)
assertNotEqualDouble = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether a double is between two bounds ("between", not "strictly between").
Note, this cannot be a delegated assertion.
@param expected1 Lower bound to test, the actual must be greater than or equal to this
@param expected2 Upper bound to test, the actual must be less than or equal to this
@param actual Double to test
@return Assertion outcome
%END REM
Function assertIsBetween(expected1 As Double, expected2 As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertIsBetween
checkStarted
On Error GoTo errCatch
runBeforeEach
If (actual >= expected1 And actual <= expected2) Then
addResult True, ||
assertIsBetween = True
Else
addResult False, |Expected: Between | & CStr(expected1) & | and | & CStr(expected2) & |, but was: | & CStr(actual)
assertIsBetween = False
End If
getOut:
runAfterEach
Exit Function
errCatch:
addError getErrorMsg(), ||
Resume getOut
'}}
End Function
%REM
Tests whether a double is NOT between two bounds ("between", not "strictly between").
Note, this cannot be a delegated assertion.
@param expected1 Lower bound to test, the actual must be less than this
@param expected2 Upper bound to test, the actual must be greater than this
@param actual Double to test
@return Assertion outcome
%END REM
Function assertIsNotBetween(expected1 As Double, expected2 As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertIsNotBetween
checkStarted
On Error GoTo errCatch
runBeforeEach
If (actual < expected1) Then
addResult True, ||
assertIsNotBetween = True
ElseIf (actual > expected2) Then
addResult True, ||
assertIsNotBetween = True
Else
addResult False, |Expected: Not between | & CStr(expected1) & | and | & CStr(expected2) & |, but was: | & CStr(actual)
assertIsNotBetween = False
End If
getOut:
runAfterEach
Exit Function
errCatch:
addError getErrorMsg(), ||
Resume getOut
'}}
End Function
%REM
Tests whether a double is greater than an expected value. Note, this cannot be a delegated assertion.
@param expected Lower bound to test
@param actual Double to test
@return Assertion outcome
%END REM
Function assertIsGreaterThan(expected As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertIsGreaterThan
checkStarted
On Error goto errCatch
runBeforeEach
If (actual > expected) Then
addResult True, ||
assertIsGreaterThan = True
Else
addResult False, |Expected: Greater than | & CStr(expected) & |, but was: | & CStr(actual)
assertIsGreaterThan = False
End If
getOut:
runAfterEach
Exit Function
errCatch:
addError getErrorMsg(), ||
Resume getOut
'}}
End Function
%REM
Tests whether a double is less than an expected value.
@param expected Upper bound to test
@param actual Double to test
@return Assertion outcome
%END REM
Function assertIsLessThan(expected As Double, actual As Double) As Boolean
'{{SETI_AUTHOR_CODE_assertIsLessThan
checkStarted
On Error GoTo ErrCatch
runBeforeEach
If (actual < expected) Then
addResult True, ||
assertIsLessThan = True
Else
addResult False, |Expected: Greater than | & CStr(expected) & |, but was: | & CStr(actual)
assertIsLessThan = False
End If
getOut:
runAfterEach
Exit Function
errCatch:
addError getErrorMsg(), ||
Resume getOut
'}}
End Function
%REM
Tests whether two Longs match.
@param expected Long to test against
@param actual Long to test
@return Assertion outcome
%END REM
Function assertEqualsLong(expected As Long, actual As Long) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsLong
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (expected = actual) Then
addResult True, ||
assertEqualsLong = True
Else
addResult False, |Expected: | & CStr(expected) & |, but was: | & CStr(actual)
assertEqualsLong = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two Longs do not match.
@param expected Long to test against
@param actual Long to test
@return Assertion outcome
%END REM
Function assertNotEqualLong(expected As Long, actual As Long) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualLong
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (expected <> actual) Then
addResult True, ||
assertNotEqualLong = True
Else
addResult False, |Expected: | & CStr(expected) & | matches actual: | & CStr(actual)
assertNotEqualLong = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two Singles match.
@param expected Single to test against
@param actual Single to test
@return Assertion outcome
%END REM
Function assertEqualsSingle(expected As Single, actual As Single) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsSingle
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (CStr(expected) = CStr(actual)) Then
addResult True, ||
assertEqualsSingle = True
Else
addResult False, |Expected: | & CStr(expected) & |, but was: | & CStr(actual)
assertEqualsSingle = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two Singles do not match.
@param expected Single to test against
@param actual Single to test
@return Assertion outcome
%END REM
Function assertNotEqualSingle(expected As Single, actual As Single) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualSingle
checkStarted
On Error GoTo errCatch
If (Not Me.isDelegatedAssertion) Then
runBeforeEach
End If
If (CStr(expected) <> CStr(actual)) Then
addResult True, ||
assertNotEqualSingle = True
Else
addResult False, |Expected: | & CStr(expected) & | matches actual: | & CStr(actual)
assertNotEqualSingle = False
End If
getOut:
If (Not Me.isDelegatedAssertion) Then
runAfterEach
End If
Exit Function
errCatch:
If (Not Me.isDelegatedAssertion) Then
addError getErrorMsg(), ||
Else
Error 1501, getErrorMsg()
End If
Resume getOut
'}}
End Function
%REM
Tests whether two numeric values match, converting them to double and calling assertEqualsDouble.
@param expected Numeric to test against
@param actual Numeric to test
@return Assertion outcome
%END REM
Function assertEqualsNumeric(expected As Variant, actual As Variant) As Boolean
'{{SETI_AUTHOR_CODE_assertEqualsNumeric
checkStarted
On Error GoTo errCatch
runBeforeEach
If (Not IsNumeric(actual)) Then
addResult False, |Actual is not numeric: | & CStr(actual)
assertEqualsNumeric = False
Else
Me.isDelegatedAssertion = True
assertEqualsNumeric = assertEqualsDouble(CDbl(expected), CDbl(actual))
Me.isDelegatedAssertion = False
End If
getOut:
runAfterEach
Exit Function
errCatch:
addError Error(), ||
Resume getOut
'}}
End Function
%REM
Tests whether two numeric values do not match, converting them to double and calling assertNotEqualDouble.
@param expected Numeric to test against
@param actual Numeric to test
@return Assertion outcome
%END REM
Function assertNotEqualNumeric(expected As Variant, actual As Variant) As Boolean
'{{SETI_AUTHOR_CODE_assertNotEqualNumeric
checkStarted
On Error GoTo errCatch
runBeforeEach
If (Not IsNumeric(actual)) Then
addResult False, |Actual is not numeric: | & CStr(actual)
assertNotEqualNumeric = False
Else
Me.isDelegatedAssertion = True
assertNotEqualNumeric = assertNotEqualDouble(CDbl(expected), CDbl(actual))
Me.isDelegatedAssertion = False
End If
getOut: