summaryrefslogtreecommitdiff
path: root/test/reserved-names.test
blob: 13d3b0109692c4560d55975ccb702a1dc33faef2 (plain) (blame)
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
#
# Copyright (c) 2020 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
#   drh@hwaci.com
#   http://www.hwaci.com/drh/
#
############################################################################
#
# Tests for reserved names.
#

test_setup

###############################################################################

set reserved_names_tests [list \
    {0 {}} \
    {0 a.fslckout} \
    {1 .fslckout} \
    {1 .FSlckOUT} \
    {2 a/.fslckout} \
    {0 .fslckout/b} \
    {0 fslckout} \
    {0 .fslckoutx} \
    {1 _FOSSIL_} \
    {0 _FOSSIL} \
    {0 FOSSIL_} \
    {0 FOSSIL_} \
    {0 a_FOSSIL_} \
    {0 _FOSSIL__} \
    {0 __FOSSIL__} \
    {0 __FOssIL__} \
    {0 _FOSSIL_/a} \
    {2 a/_FOSSIL_} \
    {2 _FOSSIL_/c/.fslckout} \
    {2 _FOSSIL_/c/.fslckout/_FOSSIL_} \
    {0 _FOSSIL_/c/.fslckout/._FOSSIL_t} \
    {0 _FOSSIL_/c/.fslckout/t._FOSSIL_} \
    {0 a} \
    {0 a/b} \
    {0 a/b/c} \
    {0 a/b/c/} \
    {0 a/_FOSSIL/} \
    {0 a/fslckout/} \
    {0 a/_fslckout/} \
    {0 _FOSSIL-wal} \
    {0 _FOSSIL-shm} \
    {0 _FOSSIL-journal} \
    {0 _FOSSIL_-wal/a} \
    {0 _FOSSIL_-shm/a} \
    {0 _FOSSIL_-journal/a} \
    {1 _FOSSIL_-wal} \
    {1 _FOSSIL_-shm} \
    {1 _FOSSIL_-journal} \
    {2 a/_FOSSIL_-wal} \
    {2 a/_FOSSIL_-shm} \
    {2 a/_FOSSIL_-journal} \
    {0 .fslckout-wal/a} \
    {0 .fslckout-shm/a} \
    {0 .fslckout-journal/a} \
    {1 .fslckout-wal} \
    {1 .fslckout-shm} \
    {1 .fslckout-journal} \
    {2 a/.fslckout-wal} \
    {2 a/.fslckout-shm} \
    {2 a/.fslckout-journal} \
]

###############################################################################

set testNo 0

foreach reserved_names_test $reserved_names_tests {
  incr testNo

  set reserved_result [lindex $reserved_names_test 0]
  set reserved_name [lindex $reserved_names_test 1]

  fossil test-is-reserved-name $reserved_name

  test reserved-result-$testNo {
    [lindex [normalize_result] 0] eq $reserved_result
  }

  test reserved-name-$testNo {
    [lindex [normalize_result] 1] eq $reserved_name
  }

  fossil test-is-reserved-name [string toupper $reserved_name]

  test reserved-result-upper-$testNo {
    [lindex [normalize_result] 0] eq $reserved_result
  }

  test reserved-name-upper-$testNo {
    [lindex [normalize_result] 1] eq [string toupper $reserved_name]
  }

  fossil test-is-reserved-name [string tolower $reserved_name]

  test reserved-result-lower-$testNo {
    [lindex [normalize_result] 0] eq $reserved_result
  }

  test reserved-name-lower-$testNo {
    [lindex [normalize_result] 1] eq [string tolower $reserved_name]
  }
}

###############################################################################

test_cleanup