Skip to content

Commit 6f1c867

Browse files
committed
build: fix test build failed
1 parent b6d2b17 commit 6f1c867

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

build.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ pub fn build(b: *std.Build) void {
145145
.optimize = optimize,
146146
});
147147

148+
tests.root_module.addOptions("budopts", bopts);
149+
148150
if (kcov) |args| {
149151
const run = b.addSystemCommand(&.{"kcov"});
150152
const includeArg = std.fmt.allocPrint(

src/root.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ pub const AnyArray = @import("./values/AnyArray.zig");
152152
pub const AnyMap = @import("./values/AnyMap.zig");
153153
pub const AnyExt = @import("./values/AnyExt.zig");
154154

155+
test {
156+
_ = @import("./values/numbers.zig");
157+
}
158+
155159
/// The value container type.
156160
///
157161
/// Every represented value is stored in a container.

src/values/numbers.zig

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ test Int {
133133
const t = std.testing;
134134
{ // Emit i32 as-is
135135
var dst: std.BoundedArray(u8, 8) = .{};
136-
Int(i32).pipe(dst.writer(), 15);
137-
try t.expectEqual(15, std.mem.readInt(dst.buffer[1..5], .big));
136+
_ = try Int(i32).pipe(dst.writer(), 15);
137+
try t.expectEqual(15, std.mem.readInt(i32, dst.buffer[1..5], .big));
138138
}
139139
{ // Emit i32 as the smallest type
140140
var dst: std.BoundedArray(u8, 8) = .{};
141-
Int(i32).pipeSm(dst.writer(), 15);
141+
_ = try Int(i32).pipeSm(dst.writer(), 15);
142142
try t.expectEqual(1, dst.len);
143143
}
144144
}
@@ -209,3 +209,18 @@ pub fn Float(T: type) type {
209209
}
210210
};
211211
}
212+
213+
test Float {
214+
const t = std.testing;
215+
216+
{ // Write f32 as-is
217+
var dst: std.BoundedArray(u8, 8) = .{};
218+
_ = try Float(f32).pipe(dst.writer(), 1);
219+
try t.expectEqual(1, readFloatBig(f32, dst.buffer[1..5]));
220+
}
221+
{ // Write f64 as the smallest type
222+
var dst: std.BoundedArray(u8, 8) = .{};
223+
_ = try Float(f64).pipeSm(dst.writer(), 1);
224+
try t.expectEqual(5, dst.len);
225+
}
226+
}

0 commit comments

Comments
 (0)