-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_test.go
More file actions
47 lines (38 loc) · 1.05 KB
/
Copy pathexample_test.go
File metadata and controls
47 lines (38 loc) · 1.05 KB
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
package signal_test
import (
"fmt"
signal "github.com/hugoh/cellular-signal/v2"
)
func ExampleRater_RateRSRP() {
rater := signal.NewRater()
rating := rater.RateRSRP(-92)
fmt.Println(rating)
// Output: RSRP: -92 dBm (Good ★★★★☆)
}
func ExampleRating_Format() {
rater := signal.NewRater()
rating := rater.RateSINR(13.5)
fmt.Println(rating.Format("%m=%v%u %s"))
// Output: SINR=13.5dB ★★★★★
}
func ExampleRater_Rate() {
rater := signal.NewRater()
fmt.Println(rater.Rate(signal.MetricRSRQ, -11).Quality)
// Output: Good
}
func ExampleNewRaterWithThresholds() {
// Each threshold is the lower bound of a quality level, ordered
// from best quality to worst.
thresholds := []signal.Threshold{
{MinValue: -80, Quality: signal.QualityExcellent},
{MinValue: -100, Quality: signal.QualityGood},
{MinValue: -200, Quality: signal.QualityPoor},
}
rater, err := signal.NewRaterWithThresholds(signal.WithRSRPThresholds(thresholds))
if err != nil {
fmt.Println(err)
return
}
fmt.Println(rater.RateRSRP(-90).Quality)
// Output: Good
}