File: report_formatting.sh

package info (click to toggle)
percona-toolkit 3.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 68,916 kB
  • sloc: perl: 241,287; sql: 22,868; sh: 19,746; javascript: 6,799; makefile: 353; awk: 38; python: 30; sed: 1
file content (113 lines) | stat: -rw-r--r-- 2,654 bytes parent folder | download | duplicates (2)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env bash

plan 20

. "$LIB_DIR/report_formatting.sh"

is                         \
   "$(shorten 10485760 1)" \
   "10.0M"                 \
   "10485760, 1 precision, default divisor => 10.0M"

is                           \
   "$(shorten 3145728000 1)" \
   "2.9G"                 \
   "3145728000, 1 precision, default divisor => 2.9G"

is                                \
   "$(shorten 3145728000 1 1000)" \
   "3.1G"                         \
   "3145728000, 1 precision, divisor 1000 => 3.1G"

is                  \
   "$(shorten 0 0)" \
   "0"                 \
   "0, 0 precision, default divisor => 0"

is                           \
   "$(shorten 1572864000 1)" \
   "1.5G"                 \
   "1572864000, 1 precision, default divisor => 1.5G"

is                           \
   "$(shorten 1572864000 1 1000)" \
   "1.6G"                 \
   "1572864000, 1 precision, divisor 1000 => 1.6G"

is                           \
   "$(shorten 364 0)" \
   "364"                 \
   "364, 0 precision, default divisor => 364"

is                           \
   "$(shorten 364 1)" \
   "364.0"                 \
   "364, 1 precision, default divisor => 364"

is                           \
   "$(shorten 649216 1)" \
   "634.0k"                 \
   "649216, 1 precision, default divisor => 634.0k"

is                           \
   "$(shorten 6492100000006 1)" \
   "5.9T"                 \
   "6492100000006, 1 precision, default divisor => 5.9T"

is                           \
   "$(shorten 6492100000006 1 1000)" \
   "6.5T"                 \
   "6492100000006, 1 precision, divisor 1000 => 6.5T"

is "$(shorten 1059586048 1)" \
   "1010.5M" \
   "1059586048 => 1010.5M (bug 993436)"

# section

is \
   "$(section "A")" \
   "# A ##########################################################" \
   "Sanity check, section works"

is \
   "$(section "A B C")" \
   "# A B C ######################################################" \
   "section doesn't replaces spaces with #s"

is \
   "$(section "A_B_C")" \
   "# A#B#C#######################################################" \
   "replace extra underscores with #s"

# name_val

NAME_VAL_LEN=0

is \
   "$(name_val "A" "B")" \
   "A | B" \
   "name_val and NAME_VAL_LEN work"

# fuzz

is $(fuzz 11) "10" "fuzz 11"
is $(fuzz 49) "50" "fuzz 49"

# fuzzy_pct

is \
   "$( fuzzy_pct  28 64 )" \
   "45%" \
   "fuzzy_pct of 64 and 28 is 45"


is \
   "$( fuzzy_pct  40 400 )" \
   "10%" \
   "fuzzy_pct of 40 and 400 is 10"


# ###########################################################################
# Done
# ###########################################################################