:unittest.StartsWith

Test cases for the :StartsWith function

Description: call:unittest.StartsWith
Dependencies: :StartsWith, :Format
Script:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
:unittest.StartsWith
:$created 20080320 :$changed 20080320
:$source https://www.dostips.com
set "text=Hi there"
for %%C in (
        "Hi"
        "hi"
        "h"
        ""
        "la"
        " hi"
    ) do (
    call:StartsWith "%text%" "%%~C" && (
        call:Format "[12] starts with [10] - [5]." "'%text%'" "'%%~C'" "TRUE"
        rem
    ) || (
        call:Format "[12] starts with [10] - [5]." "'%text%'" "'%%~C'" "FALSE"
    )
)
EXIT /b
Script Output:
 DOS Script Output
---- :unittest.StartsWith - output
'Hi there'   starts with 'Hi'       - TRUE .
'Hi there'   starts with 'hi'       - TRUE .
'Hi there'   starts with 'h'        - TRUE .
'Hi there'   starts with ''         - FALSE.
'Hi there'   starts with 'la'       - FALSE.
'Hi there'   starts with ' hi'      - FALSE.
----