File: impls.rs

package info (click to toggle)
rust-g2p 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 160 kB
  • sloc: makefile: 2
file content (72 lines) | stat: -rw-r--r-- 944 bytes parent folder | download
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
use g2p::{g2p, GaloisField};

use core::ops::{
    Add,
    AddAssign,
    Sub,
    SubAssign,
    Mul,
    MulAssign,
    Div,
    DivAssign,
};
use core::fmt::{
    Debug,
    Display,
};
use core::marker::{
    Sync,
    Send,
    Sized,
    Copy,
};
use core::clone::Clone;
use core::convert::{
    From,
    Into,
};

g2p!(GF4, 2);

#[test]
fn test_impls() {
    static_assertions::assert_impl_all!(GF4:
        Clone,
        Copy,
        Send,
        Sync,
        Sized,
        Debug,
        Display,
        Add,
        AddAssign,
        Sub,
        SubAssign,
        Mul,
        MulAssign,
        Div,
        DivAssign,
        Eq,
        PartialEq,
        Into<u8>,
        From<u8>,
    );
}

#[test]
fn test_div_impl() {
    let z = GF4::ZERO;
    let a = GF4::from(3);

    assert_eq!(z, z / a);
}


#[test]
#[should_panic]
fn test_div_panic() {
    let z = GF4::ZERO;
    let a = GF4::from(3);

    let _ = a / z;
}