|
1 | 1 | /** |
2 | 2 | * @license Apache-2.0 |
3 | 3 | * |
4 | | -* Copyright (c) 2018 The Stdlib Authors. |
| 4 | +* Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | * |
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | * you may not use this file except in compliance with the License. |
|
21 | 21 | // MODULES // |
22 | 22 |
|
23 | 23 | var tape = require( 'tape' ); |
24 | | -var toBinaryStringUint32 = require( '@stdlib/number-uint32-base-to-binary-string' ); |
25 | | -var fromBinaryStringUint32 = require( './../../dist' ); |
26 | | - |
27 | | - |
28 | | -// FIXTURES // |
29 | | - |
30 | | -var data = require( './../fixtures/julia/data.json' ); |
| 24 | +var main = require( './../../dist' ); |
31 | 25 |
|
32 | 26 |
|
33 | 27 | // TESTS // |
34 | 28 |
|
35 | | -tape( 'main export is a function', function test( t ) { |
| 29 | +tape( 'main export is defined', function test( t ) { |
36 | 30 | t.ok( true, __filename ); |
37 | | - t.strictEqual( typeof fromBinaryStringUint32, 'function', 'main export is a function' ); |
38 | | - t.end(); |
39 | | -}); |
40 | | - |
41 | | -tape( 'if provided a string with a length other than `32`, the function throws an error', function test( t ) { |
42 | | - var values; |
43 | | - var i; |
44 | | - |
45 | | - values = [ |
46 | | - 'beep', |
47 | | - '1010101', |
48 | | - '', |
49 | | - '101', |
50 | | - '111111111', |
51 | | - '1111111111111111111111111111111', |
52 | | - '111111111111111111111111111111111', |
53 | | - '11111111111111111111111111111111111111111111111111111111111111111', |
54 | | - '111111111111111111111111111111111111111111111111111111111111111' |
55 | | - ]; |
56 | | - |
57 | | - for ( i = 0; i < values.length; i++ ) { |
58 | | - t.throws( badValue( values[i] ), Error, 'throws an error when provided '+values[i] ); |
59 | | - } |
60 | | - t.end(); |
61 | | - |
62 | | - function badValue( value ) { |
63 | | - return function badValue() { |
64 | | - fromBinaryStringUint32( value ); |
65 | | - }; |
66 | | - } |
67 | | -}); |
68 | | - |
69 | | -tape( 'if provided all zeros, the function returns `0`', function test( t ) { |
70 | | - t.strictEqual( fromBinaryStringUint32( toBinaryStringUint32( 0 ) ), 0, 'returns 0' ); |
71 | | - t.end(); |
72 | | -}); |
73 | | - |
74 | | -tape( 'if provided all ones, the function returns `4294967295`', function test( t ) { |
75 | | - t.strictEqual( fromBinaryStringUint32( toBinaryStringUint32( 4294967295 ) ), 4294967295, 'returns 4294967295' ); |
76 | | - t.end(); |
77 | | -}); |
78 | | - |
79 | | -tape( 'the function creates unsigned 32-bit integers from literal bit representations', function test( t ) { |
80 | | - var expected; |
81 | | - var x; |
82 | | - var y; |
83 | | - var i; |
84 | | - |
85 | | - x = data.x; |
86 | | - expected = data.expected; |
87 | | - for ( i = 0; i < x.length; i++ ) { |
88 | | - y = fromBinaryStringUint32( x[ i ] ); |
89 | | - t.strictEqual( y, expected[ i ], 'returns expected value' ); |
90 | | - } |
| 31 | + t.strictEqual( main !== void 0, true, 'main export is defined' ); |
91 | 32 | t.end(); |
92 | 33 | }); |
0 commit comments