about summary refs log tree commit diff
path: root/src/test/stdtest/char.rs
blob: 7da2443d6c2c1c425de057afc8e26247f68c3cd8 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import core::*;

use std;
import char;

#[test]
fn test_is_lowercase() {
    assert char::is_lowercase('a');
    assert char::is_lowercase('ö');
    assert char::is_lowercase('ß');
    assert !char::is_lowercase('Ü');
    assert !char::is_lowercase('P');
}

#[test]
fn test_is_uppercase() {
    assert !char::is_uppercase('h');
    assert !char::is_uppercase('ä');
    assert !char::is_uppercase('ß');
    assert char::is_uppercase('Ö');
    assert char::is_uppercase('T');
}

#[test]
fn test_is_whitespace() {
    assert char::is_whitespace(' ');
    assert char::is_whitespace('\u2007');
    assert char::is_whitespace('\t');
    assert char::is_whitespace('\n');

    assert !char::is_whitespace('a');
    assert !char::is_whitespace('_');
    assert !char::is_whitespace('\u0000');
}

#[test]
fn test_to_digit() {
    assert (char::to_digit('0') == 0u8);
    assert (char::to_digit('1') == 1u8);
    assert (char::to_digit('2') == 2u8);
    assert (char::to_digit('9') == 9u8);
    assert (char::to_digit('a') == 10u8);
    assert (char::to_digit('A') == 10u8);
    assert (char::to_digit('b') == 11u8);
    assert (char::to_digit('B') == 11u8);
    assert (char::to_digit('z') == 35u8);
    assert (char::to_digit('Z') == 35u8);
}

#[test]
#[should_fail]
#[ignore(cfg(target_os = "win32"))]
fn test_to_digit_fail_1() {
    char::to_digit(' ');
}

#[test]
#[should_fail]
#[ignore(cfg(target_os = "win32"))]
fn test_to_digit_fail_2() {
    char::to_digit('$');
}

#[test]
fn test_to_lower() {
    assert (char::to_lower('H') == 'h');
    assert (char::to_lower('e') == 'e');
    //assert (char::to_lower('Ö') == 'ö');
    assert (char::to_lower('ß') == 'ß');
}

#[test]
fn test_to_upper() {
    assert (char::to_upper('l') == 'L');
    assert (char::to_upper('Q') == 'Q');
    //assert (char::to_upper('ü') == 'Ü');
    assert (char::to_upper('ß') == 'ß');
}