summaryrefslogtreecommitdiff
path: root/modules/string/tests/unit_tests/stripblanks.tst
blob: 47a2a8b61723738199ac796bdb8c4896c2f4895e (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
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
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2007-2008 - INRIA
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================

// <-- CLI SHELL MODE -->

//===============================
ierr = execstr('r = stripblanks(1);','errcatch');
if ierr <> 999 then pause,end
//===============================
a = '  123   ';
r = stripblanks(a);
if ( r <> '123' ) then pause,end
//===============================
b = '!'+ a +'!';
r = stripblanks(b);
if ( r <> b ) then pause,end
//===============================
b = [];
r = stripblanks(b);
if ( r <> b ) then pause,end
//===============================
a=['  123   ',' xyz'];
r = stripblanks(a);
if ( r <> ['123','xyz'] ) then pause,end
//===============================
a=['',''];
r = stripblanks(a);
if ( r <> ['',''] ) then pause,end
//===============================
a=' S C I L A B ';
r = stripblanks(a);
if ( r <> 'S C I L A B' ) then pause,end
//===============================
TAB_CHAR = ascii(9);
//===============================
a = TAB_CHAR + '  123   ' + TAB_CHAR;
r = stripblanks(a,%T);
if ( r <> '123' ) then pause,end
//===============================
r = stripblanks(a,%F);
if ( r <> a ) then pause,end
//===============================
a=[TAB_CHAR + '  123   '+TAB_CHAR,' xyz'];
r = stripblanks(a);
if ( r <> [TAB_CHAR + '  123   '+TAB_CHAR,'xyz'] ) then pause,end
//===============================
a=[TAB_CHAR + '  123   '+TAB_CHAR,' xyz'];
r = stripblanks(a,%F);
if ( r <> [TAB_CHAR + '  123   '+TAB_CHAR,'xyz'] ) then pause,end
//===============================
a=[TAB_CHAR + '  123   '+TAB_CHAR,' xyz'];
r = stripblanks(a,%T);
if ( r <> [TAB_CHAR + '  123   '+TAB_CHAR,'xyz'] ) then pause,end
//===============================
STRING = ' '+ascii(9)+' '+'S'+' '+ascii(9)+'C'+' '+ascii(9)+'I'+' '+ascii(9)+'L'+' '+ascii(9)+'A'+' '+ascii(9)+'B'+' '+ascii(9)+' ';
//===============================
R1 = ascii('!'+stripblanks(STRING,%T)+'!');
W1 = [33.    83.    32.    9.    67.    32.    9.    73.    32.    9.    76.    32.    9.    65.    32.    9.    66.    33.]; 
if (R1 <> W1) then pause,end
//===============================
R2 = ascii('!'+stripblanks(STRING,%F)+'!');
W2 = [33.    9.    32.    83.    32.    9.    67.    32.    9.    73.    32.    9.    76.    32.    9.    65.    32.    9.    66.    32.    9.    33. ];
if (R2 <> W2) then pause,end

// = strings with only blank character =========================================

if(stripblanks("")<>"")              then pause,end
if(stripblanks(" ")<>"")             then pause,end
if(stripblanks("      ")<>"")        then pause,end

if(stripblanks("",%T)<>"")           then pause,end
if(stripblanks(" ",%T)<>"")          then pause,end
if(stripblanks("      ",%T)<>"")     then pause,end

if(stripblanks(ascii(9))<>ascii(9))  then pause,end
if(stripblanks(ascii(9),%T)<>"")     then pause,end