2010-08-24 09:09:04 -07:00
|
|
|
use std;
|
|
|
|
|
|
|
|
import std._int;
|
|
|
|
import std._str.eq;
|
|
|
|
|
|
|
|
fn test_to_str() {
|
2011-05-02 16:24:09 -07:00
|
|
|
check (eq(_int.to_str(0, 10u), "0"));
|
|
|
|
check (eq(_int.to_str(1, 10u), "1"));
|
|
|
|
check (eq(_int.to_str(-1, 10u), "-1"));
|
|
|
|
check (eq(_int.to_str(255, 16u), "ff"));
|
|
|
|
check (eq(_int.to_str(100, 10u), "100"));
|
2010-08-24 09:09:04 -07:00
|
|
|
}
|
|
|
|
|
2011-03-13 18:29:10 -04:00
|
|
|
fn test_pow() {
|
2011-05-02 16:24:09 -07:00
|
|
|
check (_int.pow(0, 0u) == 1);
|
|
|
|
check (_int.pow(0, 1u) == 0);
|
|
|
|
check (_int.pow(0, 2u) == 0);
|
|
|
|
check (_int.pow(-1, 0u) == -1);
|
|
|
|
check (_int.pow(1, 0u) == 1);
|
|
|
|
check (_int.pow(-3, 2u) == 9);
|
|
|
|
check (_int.pow(-3, 3u) == -27);
|
|
|
|
check (_int.pow(4, 9u) == 262144);
|
2011-03-13 18:29:10 -04:00
|
|
|
}
|
|
|
|
|
2010-08-24 09:09:04 -07:00
|
|
|
fn main() {
|
|
|
|
test_to_str();
|
|
|
|
}
|