1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import std::int;
import std::str::eq;
#[test]
fn test_to_str() {
assert (eq(int::to_str(0, 10u), "0"));
assert (eq(int::to_str(1, 10u), "1"));
assert (eq(int::to_str(-1, 10u), "-1"));
assert (eq(int::to_str(255, 16u), "ff"));
assert (eq(int::to_str(100, 10u), "100"));
}
#[test]
fn test_pow() {
assert (int::pow(0, 0u) == 1);
assert (int::pow(0, 1u) == 0);
assert (int::pow(0, 2u) == 0);
assert (int::pow(-1, 0u) == 1);
assert (int::pow(1, 0u) == 1);
assert (int::pow(-3, 2u) == 9);
assert (int::pow(-3, 3u) == -27);
assert (int::pow(4, 9u) == 262144);
}
|