3 # $(substr str, start[, length[, pad]])
7 # Copyright (c) 2008-2009 knut st. osmundsen <bird-kBuild-spamix@anduin.net>
9 # This file is part of kBuild.
11 # kBuild is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
16 # kBuild is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with kBuild. If not, see <http://www.gnu.org/licenses/>
26 $description = "Tests the $(substr ) function";
28 $details = "A few simple tests and edge cases.";
32 # TEST #0 - check that the feature is present.
33 # --------------------------------------------
35 ifneq ($(substr asdf,4),f)
36 $(error sub-test 0 failed)
44 # TEST #1 - the real test.
45 # ------------------------
47 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,20),tuvwxyz)
48 $(error sub-test 0 failed)
50 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,20,1),t)
51 $(error sub-test 1 failed)
53 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,20,2),tu)
54 $(error sub-test 2 failed)
56 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,20,0),)
57 $(error sub-test 3 failed)
59 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-1),z)
60 $(error sub-test 4 failed)
62 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-2),yz)
63 $(error sub-test 5 failed)
65 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-2,2),yz)
66 $(error sub-test 6 failed)
68 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-2,3),yz)
69 $(error sub-test 7 failed)
71 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-2,5,XYZ),yzXYZ)
72 $(error sub-test 8 failed)
74 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-25,1),b)
75 $(error sub-test 9 failed)
77 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-26,1),a)
78 $(error sub-test 10 failed)
80 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-27,1),)
81 $(error sub-test 11 failed)
83 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-27,2),a)
84 $(error sub-test 12 failed)
86 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-27,3),ab)
87 $(error sub-test 13 failed)
89 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-27,3,_),_ab)
90 $(error sub-test 14 failed)
92 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-28,4,.^),.^ab)
93 $(error sub-test 15 failed)
95 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-50,4),)
96 $(error sub-test 16 failed)
98 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,-50,4,.^),.^.^)
99 $(error sub-test 17 failed)
101 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,27,4,.^),.^.^)
102 $(error sub-test 18 failed)
104 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,28,3,.^),.^.)
105 $(error sub-test 19 failed)
108 ifneq (.$(substr abcdefghijklmnopqrstuvwxyz,100,3, ).,. .)
109 $(error sub-test 20 failed)
111 ifneq ($(substr abcdefghijklmnopqrstuvwxyz,100,3, ),$(SP)$(SP)$(SP))
112 $(error sub-test 21 failed)
123 # Indicate that we're done.