1#[rustfmt::skip]
2pub(crate) static DECOMPOSED_AMOUNTS: [u64; 172] = [
4 1, 2, 3, 4, 5, 6, 7, 8, 9,
5 10, 20, 30, 40, 50, 60, 70, 80, 90,
6 100, 200, 300, 400, 500, 600, 700, 800, 900,
7 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000,
8 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000,
9 100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000,
10 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000,
11 10000000, 20000000, 30000000, 40000000, 50000000, 60000000, 70000000, 80000000, 90000000,
12 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000,
13 1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000,
14 10000000000, 20000000000, 30000000000, 40000000000, 50000000000, 60000000000, 70000000000, 80000000000, 90000000000,
15 100000000000, 200000000000, 300000000000, 400000000000, 500000000000, 600000000000, 700000000000, 800000000000, 900000000000,
16 1000000000000, 2000000000000, 3000000000000, 4000000000000, 5000000000000, 6000000000000, 7000000000000, 8000000000000, 9000000000000,
17 10000000000000, 20000000000000, 30000000000000, 40000000000000, 50000000000000, 60000000000000, 70000000000000, 80000000000000, 90000000000000,
18 100000000000000, 200000000000000, 300000000000000, 400000000000000, 500000000000000, 600000000000000, 700000000000000, 800000000000000, 900000000000000,
19 1000000000000000, 2000000000000000, 3000000000000000, 4000000000000000, 5000000000000000, 6000000000000000, 7000000000000000, 8000000000000000, 9000000000000000,
20 10000000000000000, 20000000000000000, 30000000000000000, 40000000000000000, 50000000000000000, 60000000000000000, 70000000000000000, 80000000000000000, 90000000000000000,
21 100000000000000000, 200000000000000000, 300000000000000000, 400000000000000000, 500000000000000000, 600000000000000000, 700000000000000000, 800000000000000000, 900000000000000000,
22 1000000000000000000, 2000000000000000000, 3000000000000000000, 4000000000000000000, 5000000000000000000, 6000000000000000000, 7000000000000000000, 8000000000000000000, 9000000000000000000,
23 10000000000000000000
24];
25
26#[inline]
33pub fn is_decomposed_amount(amount: &u64) -> bool {
34 DECOMPOSED_AMOUNTS.binary_search(amount).is_ok()
35}
36
37#[cfg(test)]
38mod tests {
39 use super::*;
40
41 #[test]
42 fn decomposed_amounts_return_decomposed() {
43 for amount in &DECOMPOSED_AMOUNTS {
44 assert!(is_decomposed_amount(amount));
45 }
46 }
47
48 #[test]
49 fn non_decomposed_amounts_return_not_decomposed() {
50 assert!(!is_decomposed_amount(&21));
51 assert!(!is_decomposed_amount(&345431));
52 assert!(!is_decomposed_amount(&20000001));
53 }
54}