15 lines
297 B
Zig
15 lines
297 B
Zig
const expect = @import("std").testing.expect;
|
|
|
|
pub export fn addUpTo(to: u32) u32 {
|
|
var res: u32 = 0;
|
|
for (0..to) |i| {
|
|
res += @intCast(i);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
test "addUpTo" {
|
|
const expected: u32 = 15;
|
|
const actual = addUpTo(6);
|
|
try expect(actual == expected);
|
|
}
|