File: examples_test.go

package info (click to toggle)
golang-golang-x-text 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 41,604 kB
  • sloc: xml: 1,022; makefile: 6
file content (28 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (10)
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
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package number_test

import (
	"golang.org/x/text/language"
	"golang.org/x/text/message"
	"golang.org/x/text/number"
)

func ExampleMaxIntegerDigits() {
	const year = 1999
	p := message.NewPrinter(language.English)
	p.Println("Year:", number.Decimal(year, number.MaxIntegerDigits(2)))

	// Output:
	// Year: 99
}

func ExampleIncrementString() {
	p := message.NewPrinter(language.English)

	p.Println(number.Decimal(1.33, number.IncrementString("0.50")))

	// Output: 1.50
}