@@ -29,7 +29,7 @@ test "nil write and read" {
29
29
);
30
30
31
31
try p .write (Payload { .nil = void {} });
32
- var val = try p .read (allocator );
32
+ const val = try p .read (allocator );
33
33
defer val .free (allocator );
34
34
}
35
35
@@ -48,10 +48,10 @@ test "bool write and read" {
48
48
try p .write (.{ .bool = test_val_1 });
49
49
try p .write (.{ .bool = test_val_2 });
50
50
51
- var val_1 = try p .read (allocator );
51
+ const val_1 = try p .read (allocator );
52
52
defer val_1 .free (allocator );
53
53
54
- var val_2 = try p .read (allocator );
54
+ const val_2 = try p .read (allocator );
55
55
defer val_2 .free (allocator );
56
56
57
57
try expect (val_1 .bool == test_val_1 );
@@ -69,13 +69,13 @@ test "int/uint write and read" {
69
69
70
70
const test_val_1 : u8 = 21 ;
71
71
try p .write (.{ .uint = test_val_1 });
72
- var val_1 = try p .read (allocator );
72
+ const val_1 = try p .read (allocator );
73
73
defer val_1 .free (allocator );
74
74
try expect (val_1 .uint == test_val_1 );
75
75
76
76
const test_val_2 : i8 = -6 ;
77
77
try p .write (.{ .int = test_val_2 });
78
- var val_2 = try p .read (allocator );
78
+ const val_2 = try p .read (allocator );
79
79
defer val_2 .free (allocator );
80
80
try expect (val_2 .int == test_val_2 );
81
81
}
@@ -91,7 +91,7 @@ test "float write and read" {
91
91
92
92
const test_val : f64 = 3.5e+38 ;
93
93
try p .write (.{ .float = test_val });
94
- var val = try p .read (allocator );
94
+ const val = try p .read (allocator );
95
95
defer val .free (allocator );
96
96
try expect (val .float == test_val );
97
97
}
@@ -107,7 +107,7 @@ test "str write and read" {
107
107
108
108
const test_str = "Hello, world!" ;
109
109
try p .write (.{ .str = msgpack .wrapStr (test_str ) });
110
- var val = try p .read (allocator );
110
+ const val = try p .read (allocator );
111
111
defer val .free (allocator );
112
112
try expect (u8eql (test_str , val .str .value ()));
113
113
}
@@ -125,9 +125,9 @@ test "bin write and read" {
125
125
// u8 bin
126
126
var test_bin = "This is a string that is more than 32 bytes long." .* ;
127
127
try p .write (.{ .bin = msgpack .wrapBin (& test_bin ) });
128
- var val_1 = try p .read (allocator );
129
- defer val_1 .free (allocator );
130
- try expect (u8eql (& test_bin , val_1 .bin .value ()));
128
+ const val = try p .read (allocator );
129
+ defer val .free (allocator );
130
+ try expect (u8eql (& test_bin , val .bin .value ()));
131
131
}
132
132
133
133
test "map write and read" {
@@ -167,7 +167,7 @@ test "map write and read" {
167
167
168
168
try p .write (test_val_1 );
169
169
170
- var val = try p .read (allocator );
170
+ const val = try p .read (allocator );
171
171
defer val .free (allocator );
172
172
173
173
try expect (val == .map );
@@ -204,7 +204,7 @@ test "array write and read" {
204
204
}
205
205
206
206
try p .write (.{ .arr = & test_payload });
207
- var val = try p .read (allocator );
207
+ const val = try p .read (allocator );
208
208
defer val .free (allocator );
209
209
210
210
for (val .arr , 0.. ) | v , i | {
@@ -225,7 +225,7 @@ test "ext write and read" {
225
225
const test_type : u8 = 1 ;
226
226
227
227
try p .write (.{ .ext = msgpack.EXT { .type = test_type , .data = & test_data } });
228
- var val = try p .read (allocator );
228
+ const val = try p .read (allocator );
229
229
defer val .free (allocator );
230
230
try expect (u8eql (& test_data , val .ext .data ));
231
231
try expect (test_type == val .ext .type );
0 commit comments