File: test_array_equal.pro

package info (click to toggle)
gnudatalanguage 1.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 80,368 kB
  • sloc: cpp: 189,797; ansic: 46,721; sh: 677; python: 474; makefile: 146; xml: 69; f90: 28
file content (214 lines) | stat: -rw-r--r-- 5,887 bytes parent folder | download | duplicates (3)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
;
; Some tests for ARRAY_EQUAL()
;
; Alain Coulais, 30 August 2013
;
; In fact, we may have tricky results when using 
; ARRAY_EQUAL() without taking into account dimentions:
;
; print, ARRAY_EQUAL([1],[1,1]) ; should return 0
; print, ARRAY_EQUAL(1,[1,1]) ; should return 1
;
; --------------------------------------------
;
; Modifications history :
;
;* AC 2017-10-01 : 
; - removed internal BANNER_FOR_TESTSUITE & MY_MESS (now ADD_ERROR)
; 
; --------------------------------------------
;
pro TEST_ARRAY_EQUAL_DIFF_TYPE, cumul_errors, verbose=verbose, test=test, help=help
;
case_name='TEST_ARRAY_EQUAL_DIFF_TYPE'
;
if KEYWORD_SET(help) then begin
   print, 'pro '+case_name+', cumul_errors, verbose=verbose, test=test, help=help'
   return
endif
;
line="======================================="
MESSAGE, /Continue, line
MESSAGE, /Continue, "this case suite TEST_ARRAY_EQUAL_DIFF_TYPE is not ready !"
MESSAGE, /Continue, "please contribute"
MESSAGE, /Continue, line
;
nb_pbs=0
;
;BANNER_FOR_TESTSUITE, case_name, nb_pbs
;ERRORS_CUMUL, cumul_errors, nb_pbs
;
end
; --------------------------------------------
;
pro TEST_ARRAY_EQUAL_NOT_EQUAL, cumul_errors, verbose=verbose, $
                                test=test, help=help
;
case_name='TEST_ARRAY_EQUAL_NOT_EQUAL'
;
if KEYWORD_SET(help) then begin
   print, 'pro '+case_name+', cumul_errors, verbose=verbose, test=test, help=help'
   return
endif
;
line="======================================="
MESSAGE, /Continue, line
MESSAGE, /Continue, "this case suite TEST_ARRAY_EQUAL_NOT_EQUAL is not finished !"
MESSAGE, /Continue, "please contribute"
MESSAGE, /Continue, line
;
nb_pbs=0
if ~ARRAY_EQUAL(findgen(20), findgen(20)+20.,/not_equal) then $
   ERRORS_ADD, nb_pbs, 'keyword /not_equal'
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, case_name, nb_pbs, /status
ERRORS_CUMUL, cumul_errors, nb_pbs
if KEYWORD_SET(test) then STOP
;
end
;
; --------------------------------------------
;
pro TEST_ARRAY_EQUAL_CHECK_DIM, cumul_errors, verbose=verbose, test=test, help=help
;
case_name='TEST_ARRAY_EQUAL_CHECK_DIM'
;
if KEYWORD_SET(help) then begin
   print, 'pro '+case_name+', cumul_errors, verbose=verbose, test=test, help=help'
   return
endif
;
nb_pbs=0
indice=0
;
a_singleton=1
a_array=[1]
a_full_array=REPLICATE(1, 5)
;
if ARRAY_EQUAL(a_singleton, a_singleton) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_singleton, a_singleton)'
endif
if ARRAY_EQUAL(a_array, a_array) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_array, a_array)'
endif
if ARRAY_EQUAL(a_full_array, a_full_array) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_full_array, a_full_array)'
endif
;
if ARRAY_EQUAL(a_singleton, a_array) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_singleton, a_array)'
endif
if ARRAY_EQUAL(a_array, a_singleton) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_array, a_singleton)'
endif
;
if ARRAY_EQUAL(a_singleton, a_full_array) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_singleton, a_full_array)'
endif
if ARRAY_EQUAL(a_full_array, a_singleton) NE 1 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_full_array, a_singleton)'
endif
;
; When both inputs are arrays, if n_elements differents, should return ZERO
;
if ARRAY_EQUAL(a_array, a_full_array) NE 0 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_array, a_full_array)'
endif
if ARRAY_EQUAL(a_full_array, a_array) NE 0 then begin
   ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_full_array, a_array)'
endif
;
; ----- final ----
;
BANNER_FOR_TESTSUITE, case_name, nb_pbs, /status
ERRORS_CUMUL, cumul_errors, nb_pbs
if KEYWORD_SET(test) then STOP
;
end
;
; --------------------------------------------
;
pro TEST_ARRAY_EQUAL_SAME_TYPE, cumul_errors, verbose=verbose, $
                                test=test, help=help
;
case_name='TEST_ARRAY_EQUAL_SAME_TYPE'
;
if KEYWORD_SET(help) then begin
   print, 'pro '+case_name+', cumul_errors, verbose=verbose, test=test, help=help'
   return
endif
;
nb_pbs=0
indice=0
;
a_singleton=1
a_array=[1]
a_full_array=REPLICATE(1, 5)
;
b_singleton=10
b_array=[10]
b_full_array=REPLICATE(10, 5)
;
if ARRAY_EQUAL(a_singleton, b_array) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_singleton, b_array)'
endif
if ARRAY_EQUAL(a_array, b_singleton) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_array, b_singleton)'
endif
;
;
if ARRAY_EQUAL(a_singleton, b_full_array) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_singleton, b_full_array)'
endif
if ARRAY_EQUAL(a_full_array, b_singleton) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_full_array, b_singleton)'
endif
;
; When both inputs are arrays, if n_elements differents, should return ZERO
;
if ARRAY_EQUAL(a_array, b_full_array) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_array, b_full_array)'
endif
if ARRAY_EQUAL(a_full_array, b_array) NE 0 then begin
    ERRORS_ADD, nb_pbs, 'ARRAY_EQUAL(a_full_array, b_array)'
endif
;
BANNER_FOR_TESTSUITE, case_name, nb_pbs, /status
ERRORS_CUMUL, cumul_errors, nb_pbs
if KEYWORD_SET(test) then STOP
;
end
;
; ---------------------------------------------------------------------
;
pro TEST_ARRAY_EQUAL, no_exit=no_exit, verbose=verbose, test=test, help=help
;
if KEYWORD_SET(help) then begin
   print, 'pro TEST_ARRAY_EQUAL, no_exit=no_exit, verbose=verbose, test=test, help=help'
   return
endif
;
nb_errors=0
;
; TB continue
;
TEST_ARRAY_EQUAL_DIFF_TYPE, nb_errors, verbose=verbose, test=test, help=help
TEST_ARRAY_EQUAL_NOT_EQUAL, nb_errors, verbose=verbose, test=test, help=help
;
; ready
;
TEST_ARRAY_EQUAL_CHECK_DIM, nb_errors, verbose=verbose, test=test, help=help
TEST_ARRAY_EQUAL_SAME_TYPE, nb_errors, verbose=verbose, test=test, help=help
;
; ----------------- final message ----------
;
BANNER_FOR_TESTSUITE, "TEST_ARRAY_EQUAL", nb_errors
;
if (nb_errors GT 0) AND ~KEYWORD_SET(no_exit) then EXIT, status=1
;
if KEYWORD_SET(test) then STOP
;
end