a collection of examples for ob-zig tests
const stdout = std .io .getStdOut ().writer ();
try stdout .print ("{s}" , .{"hello" });
const stdout = std .io .getStdOut ().writer ();
try stdout .print ("{}" , .{q });
const stdout = std .io .getStdOut ().writer ();
var p_plus_q : isize = p + q ;
try stdout .print ("{}" , .{p_plus_q });
const stdout = std .io .getStdOut ().writer ();
try stdout .print ("{s} {d}" , .{q , q .len });
test "simple test" {
const stdout = std .io .getStdOut ().writer ();
const hello = "hello" ;
try std .testing .expectEqual ("hello" , hello );
try stdout .print ("{s}" , .{hello });
}
fn helloFn () []const u8 {
return "hello" ;
}
test "fn test" {
const stdout = std .io .getStdOut ().writer ();
var hello = helloFn ();
try std .testing .expectEqualStrings ("hello" , hello );
try stdout .print ("{s}" , .{hello });
}
fn helloFn () []const u8 {
return "hello" ;
}
test "fn test" {
const stdout = std .io .getStdOut ().writer ();
var hello = helloFn ();
try std .testing .expectEqualStrings ("hello" , hello );
try stdout .print ("{s}" , .{hello });
}
test "simple test" {
const stdout = std .io .getStdOut ().writer ();
var hello = "hello" ;
try std .testing .expectEqual ("hello" , hello );
try stdout .print ("{s}" , .{hello });
}
const stdout = std .io .getStdOut ().writer ();
try stdout .print ("{s}{s}{d}" , .{a [0 ], a [1 ], a .len });
const stdout = std .io .getStdOut ().writer ();
pub fn main () ! void {
for (int_table ) | row | {
for (row ) | field | {
try stdout .print ("{d} " , .{ field });
}
try stdout .print ("\n " , .{});
}
try stdout .print ("A1 {d}\n " , .{int_table_h (1 , "A" )});
try stdout .print ("B0 {d}\n " , .{int_table_h (0 , "B" )});
}
const stdout = std .io .getStdOut ().writer ();
pub fn main () ! void {
for (float_table ) | row | {
for (row ) | field | {
try stdout .print ("{d} " , .{ field });
}
try stdout .print ("\n " , .{});
}
try stdout .print ("A1 {d}\n " , .{float_table_h (1 , "A" )});
try stdout .print ("B0 {d}\n " , .{float_table_h (0 , "B" )});
}
day quantity
monday 34
tuesday 41
wednesday 56
thursday 17
friday 12
saturday 7
sunday 4
const stdout = std .io .getStdOut ().writer ();
pub fn main () ! void {
for (mixed_table ) | row | {
for (row ) | field | {
try stdout .print ("{s} " , .{ field });
}
try stdout .print ("\n " , .{});
}
try stdout .print ("tuesday_qty {s}\n " , .{mixed_table_h (1 , "quantity" )});
try stdout .print ("day_idx_4 {s}\n " , .{mixed_table_h (4 , "day" )});
}