summaryrefslogtreecommitdiff
path: root/test/unit/find_unique_completion_pair.exp
blob: ec7f040d75b3598f98484a36c8d5cce7df20535c (plain)
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
# Note: This test actually tests a function in the test library. It doesn't
# need bash running; but it doesn't hurt either.

# Run one test. Look below for usage.
proc test_find_ucp {{list} {epart} {econt} {eret 1}} {
    set efull "$epart$econt"
    set rret [find_unique_completion_pair $list rpart rfull]
    if {$eret != $rret} {
        if {$eret} {
            fail "find_unique_completion_pair: Nothing found for {$list}"
        } else {
            fail "find_unique_completion_pair: Expected failure for {$list}"
        }
    } elseif {!$eret} {
        pass "find_unique_completion_pair: No results for list {$list}"
    } elseif {$rpart != $epart || $rfull != $efull} {
        fail "find_unique_completion_pair: Got \"$rpart\", \"$rfull\" \
                instead of \"$epart\", \"$efull\" for list {$list}"
    } else {
        pass "find_unique_completion_pair: Got \"$epart\", \"$efull\" \
                for list {$list}"
    }
}

test_find_ucp {a} 0 0 0
test_find_ucp {ab} a b
test_find_ucp {a ab abcd abc} 0 0 0
test_find_ucp {a ab abcde abc} abcd e
test_find_ucp {user1 user2} 0 0 0
test_find_ucp {root username2 username1} ro ot
test_find_ucp {root username21 username2} ro ot
test_find_ucp {long_user_name lang_user_name long_usor_name} lang_us er_name
test_find_ucp {lang_user_name1 long_user_name lang_user_name long_usor_name} \
          long_use r_name
test_find_ucp {root username} user name
test_find_ucp {a aladin} ala din
test_find_ucp {ala aladin} alad in