mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add is_even and is_odd to math module
This commit is contained in:
committed by
Christoffer Lerno
parent
5aae9f3204
commit
49ea950f78
23
test/unit/stdlib/math/math_is_even_odd.c3
Normal file
23
test/unit/stdlib/math/math_is_even_odd.c3
Normal file
@@ -0,0 +1,23 @@
|
||||
module math_is_even_odd_tests;
|
||||
import std::math;
|
||||
import std::io;
|
||||
|
||||
macro test(start, ...)
|
||||
{
|
||||
$for (var $i = 0; $i < $vacount; $i++)
|
||||
for ($vatype($i) i = ($vatype($i))start; i < 5; i+=2)
|
||||
{
|
||||
assert(math::is_even(i));
|
||||
assert(i.is_even());
|
||||
|
||||
assert(!math::is_odd(i));
|
||||
assert(!i.is_odd());
|
||||
}
|
||||
$endfor;
|
||||
}
|
||||
|
||||
fn void! tests() @test
|
||||
{
|
||||
test(0, char, ushort, uint, ulong, uptr, usz, uint128);
|
||||
test(-4, ichar, short, int, long, iptr, isz, int128);
|
||||
}
|
||||
Reference in New Issue
Block a user