Skip to content

Commit 3cb98f3

Browse files
committed
test: add tests for full branch coverage
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 71a48b0 commit 3cb98f3

File tree

1 file changed

+108
-6
lines changed
  • lib/node_modules/@stdlib/ndarray/base/dtype-alignment/test

1 file changed

+108
-6
lines changed

lib/node_modules/@stdlib/ndarray/base/dtype-alignment/test/test.js

Lines changed: 108 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// MODULES //
2222

2323
var tape = require( 'tape' );
24+
var DataType = require( '@stdlib/ndarray/dtype-ctor' );
25+
var structFactory = require( '@stdlib/dstructs/struct' );
2426
var dtypeAlignment = require( './../lib' );
2527

2628

@@ -37,8 +39,6 @@ var DTYPES = [
3739
'uint16',
3840
'int32',
3941
'uint32',
40-
'int64',
41-
'uint64',
4242
'binary',
4343
'generic',
4444
'complex32',
@@ -73,8 +73,6 @@ tape( 'the function returns an object mapping data type strings to alignments if
7373
2,
7474
4,
7575
4,
76-
8,
77-
8,
7876
1,
7977
null,
8078
2,
@@ -91,7 +89,7 @@ tape( 'the function returns an object mapping data type strings to alignments if
9189
t.end();
9290
});
9391

94-
tape( 'the function returns the alignment for an underlying array data type', function test( t ) {
92+
tape( 'the function returns the alignment for an underlying array data type (string)', function test( t ) {
9593
var expected;
9694
var out;
9795
var i;
@@ -107,8 +105,36 @@ tape( 'the function returns the alignment for an underlying array data type', fu
107105
2,
108106
4,
109107
4,
108+
1,
109+
null,
110+
2,
111+
4,
110112
8,
113+
1
114+
];
115+
for ( i = 0; i < DTYPES.length; i++ ) {
116+
out = dtypeAlignment( DTYPES[ i ] );
117+
t.strictEqual( out, expected[ i ], 'returns '+expected[i]+' when provided '+DTYPES[i] );
118+
}
119+
t.end();
120+
});
121+
122+
tape( 'the function returns the alignment for an underlying array data type (data type, string)', function test( t ) {
123+
var expected;
124+
var out;
125+
var i;
126+
127+
expected = [
111128
8,
129+
4,
130+
2,
131+
1,
132+
1,
133+
1,
134+
2,
135+
2,
136+
4,
137+
4,
112138
1,
113139
null,
114140
2,
@@ -117,12 +143,88 @@ tape( 'the function returns the alignment for an underlying array data type', fu
117143
1
118144
];
119145
for ( i = 0; i < DTYPES.length; i++ ) {
120-
out = dtypeAlignment( DTYPES[ i ] );
146+
out = dtypeAlignment( new DataType( DTYPES[ i ] ) );
121147
t.strictEqual( out, expected[ i ], 'returns '+expected[i]+' when provided '+DTYPES[i] );
122148
}
123149
t.end();
124150
});
125151

152+
tape( 'the function returns the alignment for an underlying array data type (struct)', function test( t ) {
153+
var expected;
154+
var schemas;
155+
var values;
156+
var out;
157+
var i;
158+
159+
schemas = [
160+
[
161+
{
162+
'name': 'foo',
163+
'type': 'float64'
164+
}
165+
],
166+
[
167+
{
168+
'name': 'foo',
169+
'type': 'float32'
170+
}
171+
]
172+
];
173+
174+
values = [
175+
structFactory( schemas[ 0 ] ),
176+
structFactory( schemas[ 1 ] )
177+
];
178+
179+
expected = [
180+
8,
181+
4
182+
];
183+
for ( i = 0; i < values.length; i++ ) {
184+
out = dtypeAlignment( values[ i ] );
185+
t.strictEqual( out, expected[ i ], 'returns '+expected[i]+' when provided '+values[i].layout );
186+
}
187+
t.end();
188+
});
189+
190+
tape( 'the function returns the alignment for an underlying array data type (data type, struct)', function test( t ) {
191+
var expected;
192+
var schemas;
193+
var values;
194+
var out;
195+
var i;
196+
197+
schemas = [
198+
[
199+
{
200+
'name': 'foo',
201+
'type': 'float64'
202+
}
203+
],
204+
[
205+
{
206+
'name': 'foo',
207+
'type': 'float32'
208+
}
209+
]
210+
];
211+
212+
values = [
213+
new DataType( structFactory( schemas[ 0 ] ) ),
214+
new DataType( structFactory( schemas[ 1 ] ) )
215+
];
216+
217+
expected = [
218+
8,
219+
4
220+
];
221+
for ( i = 0; i < values.length; i++ ) {
222+
out = dtypeAlignment( values[ i ] );
223+
t.strictEqual( out, expected[ i ], 'returns '+expected[i]+' when provided '+values[i].layout );
224+
}
225+
t.end();
226+
});
227+
126228
tape( 'the function returns `null` if provided an unknown/unsupported data type', function test( t ) {
127229
var values;
128230
var out;

0 commit comments

Comments
 (0)