about summary refs log tree commit diff
path: root/src/test/stdtest/int.rs
blob: 185c9db4a2e53531bab42d82c7d8a22903893521 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

use std;
import std::int;
import std::istr::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);
}