@@ -7,7 +7,7 @@ DataTypes = require("../src/index").DataTypes;
7
7
DataReader = require ( "../src/index" ) . DataReader ;
8
8
DataWriter = require ( "../src/index" ) . DataWriter ;
9
9
10
- describe ( "DataStruct" , function ( ) {
10
+ suite ( "DataStruct" , function ( ) {
11
11
12
12
var dataBundle = {
13
13
'basic types' : {
@@ -16,7 +16,7 @@ describe("DataStruct", function(){
16
16
buffer : new Buffer ( [ 0x00 , 0x2a ] )
17
17
} ,
18
18
19
- 'flat structure' : {
19
+ 'flat structure (basic types) ' : {
20
20
object : {
21
21
boolean : true ,
22
22
int8 : - 126 ,
@@ -26,10 +26,7 @@ describe("DataStruct", function(){
26
26
int32 : - 100000 ,
27
27
uint32 : 100000 ,
28
28
float : 1230000 ,
29
- double : - 123.456 ,
30
- string : 'Some text + юникод' ,
31
- shortBuffer : new Buffer ( [ 1 , 2 , 3 ] ) ,
32
- buffer : new Buffer ( [ 0xaa , 0xbb , 0xcc ] )
29
+ double : - 123.456
33
30
} ,
34
31
35
32
scheme : {
@@ -41,10 +38,7 @@ describe("DataStruct", function(){
41
38
int32 : DataTypes . int32 ,
42
39
uint32 : DataTypes . uint32 ,
43
40
float : DataTypes . float ,
44
- double : DataTypes . double ,
45
- string : DataTypes . string ,
46
- shortBuffer : DataTypes . shortBuffer ,
47
- buffer : DataTypes . buffer
41
+ double : DataTypes . double
48
42
} ,
49
43
50
44
buffer : new Buffer ( [
@@ -57,6 +51,23 @@ describe("DataStruct", function(){
57
51
0x00 , 0x01 , 0x86 , 0xa0 , // uint32
58
52
0x49 , 0x96 , 0x25 , 0x80 , // float
59
53
0xc0 , 0x5e , 0xdd , 0x2f , 0x1a , 0x9f , 0xbe , 0x77 , // double
54
+ ] )
55
+ } ,
56
+
57
+ 'flat structure (composite types)' : {
58
+ object : {
59
+ string : 'Some text + юникод' ,
60
+ shortBuffer : new Buffer ( [ 1 , 2 , 3 ] ) ,
61
+ buffer : new Buffer ( [ 0xaa , 0xbb , 0xcc ] )
62
+ } ,
63
+
64
+ scheme : {
65
+ string : DataTypes . string ,
66
+ shortBuffer : DataTypes . shortBuffer ,
67
+ buffer : DataTypes . buffer
68
+ } ,
69
+
70
+ buffer : new Buffer ( [
60
71
0x00 , 0x18 , // string length (uint16 BE)
61
72
0x53 , 0x6f , 0x6d , 0x65 , 0x20 , 0x74 , 0x65 , 0x78 , 0x74 , 0x20 , 0x2b , 0x20 , 0xd1 , 0x8e , 0xd0 , 0xbd , 0xd0 , 0xb8 , 0xd0 , 0xba , 0xd0 , 0xbe , 0xd0 , 0xb4 , // string
62
73
0x00 , 0x03 , // short buffer length (uint16 BE)
@@ -139,23 +150,23 @@ describe("DataStruct", function(){
139
150
140
151
} ;
141
152
142
- describe ( "Buffer to Object convert" , function ( ) {
153
+ suite ( "Buffer to Object convert" , function ( ) {
143
154
for ( var suite in dataBundle ) {
144
155
var data = dataBundle [ suite ] ;
145
156
( function ( suite , data ) {
146
- it ( "should return buffer for '" + suite + "' suite" , function ( ) {
157
+ test ( "should return buffer for '" + suite + "' suite" , function ( ) {
147
158
var res = DataReader ( data . buffer , data . scheme ) ;
148
159
assert . deepEqual ( res , data . object ) ;
149
160
} ) ;
150
161
} ) ( suite , data ) ;
151
162
}
152
163
} ) ;
153
164
154
- describe ( "Object to Buffer convert" , function ( ) {
165
+ suite ( "Object to Buffer convert" , function ( ) {
155
166
for ( var suite in dataBundle ) {
156
167
var data = dataBundle [ suite ] ;
157
168
( function ( suite , data ) {
158
- it ( "should return buffer for '" + suite + "' suite" , function ( ) {
169
+ test ( "should return buffer for '" + suite + "' suite" , function ( ) {
159
170
var res = DataWriter ( data . object , data . scheme ) ;
160
171
assert . deepEqual ( res , data . buffer ) ;
161
172
} ) ;
0 commit comments