aboutsummaryrefslogtreecommitdiff
path: root/test/float_test.gleam
blob: 161f6dfa935b6daaddb480fb962c3e14d2c1de39 (plain)
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
import expect
import float

pub fn parse_test() {
  "1.23"
  |> float:parse
  |> expect:equal(_, Ok(1.23))

  "5.0"
  |> float:parse
  |> expect:equal(_, Ok(5.0))

  "0.123456789"
  |> float:parse
  |> expect:equal(_, Ok(0.123456789))

  ""
  |> float:parse
  |> expect:is_error

  "what"
  |> float:parse
  |> expect:is_error

  "1"
  |> float:parse
  |> expect:is_error
}

pub fn to_string_test() {
  123.0
  |> float:to_string
  |> expect:equal(_, "123.0")

  -8.1
  |> float:to_string
  |> expect:equal(_, "-8.1")
}