int pct
This commit is contained in:
parent
3ac4fd6d1b
commit
2dfdd0d09c
@ -811,7 +811,7 @@ pub fn cryp_recover(cryp_bytes: Vec<u8>, tx: &mut Transaction) -> Result<Cryp, E
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use cryp::*;
|
||||
use spec::IntPct;
|
||||
use util::IntPct;
|
||||
|
||||
#[test]
|
||||
fn create_cryp_test() {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use cryp::{Stat, Colours};
|
||||
use util::{IntPct};
|
||||
|
||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
||||
pub enum Spec {
|
||||
@ -28,16 +29,6 @@ pub enum Spec {
|
||||
RBDI,
|
||||
}
|
||||
|
||||
pub trait IntPct {
|
||||
fn pct(self, pct: u64) -> u64;
|
||||
}
|
||||
|
||||
impl IntPct for u64 {
|
||||
fn pct(self, pct: u64) -> u64 {
|
||||
self * pct / 100
|
||||
}
|
||||
}
|
||||
|
||||
impl Spec {
|
||||
pub fn affects(&self) -> Vec<Stat> {
|
||||
match *self {
|
||||
|
||||
@ -18,4 +18,27 @@ pub fn startup(db: Db) -> Result<(), Error> {
|
||||
},
|
||||
Err(e) => Err(format_err!("failed to commit startup tx {:?}", e)),
|
||||
}
|
||||
}
|
||||
|
||||
pub trait IntPct {
|
||||
fn pct(self, pct: u64) -> u64;
|
||||
}
|
||||
|
||||
impl IntPct for u64 {
|
||||
fn pct(self, pct: u64) -> u64 {
|
||||
self * pct / 100
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn int_pct_test() {
|
||||
assert_eq!(100.pct(110), 110);
|
||||
assert_eq!(100.pct(50), 50);
|
||||
assert_eq!(1.pct(200), 2);
|
||||
assert_eq!(1.pct(50), 0);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user