aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorM. J. Fromberger <michael.j.fromberger@gmail.com>2019-06-09 09:17:54 -0700
committerM. J. Fromberger <michael.j.fromberger@gmail.com>2019-06-09 09:17:54 -0700
commite7aaa29f38dcf9c5943eb319c7b26c51a42d64c0 (patch)
treecde62bc76dbb60ee1d344a02274b213c32d485f2
parent222e24888b1fa9a54ef2622be0345be1019bca50 (diff)
downloadgo-creachadair-stringset-e7aaa29f38dcf9c5943eb319c7b26c51a42d64c0.tar.gz
Add examples for the top-level Contains function.
-rw-r--r--examples_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/examples_test.go b/examples_test.go
index ff1d36e..08eeaf4 100644
--- a/examples_test.go
+++ b/examples_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"path/filepath"
"regexp"
+ "strings"
"bitbucket.org/creachadair/stringset"
)
@@ -108,6 +109,27 @@ func ExampleSet_SymDiff() {
// Output: {"b", "t"}
}
+func ExampleContains_slice() {
+ s := strings.Fields("four fine fat fishes fly far")
+ fmt.Println(stringset.Contains(s, "fishes"))
+ // Output:
+ // true
+}
+
+func ExampleContains_map() {
+ s := map[string]int{"apples": 12, "pears": 2, "plums": 0, "cherries": 18}
+ fmt.Println(stringset.Contains(s, "pears"))
+ // Output:
+ // true
+}
+
+func ExampleContains_set() {
+ s := stringset.New("lead", "iron", "copper", "chromium")
+ fmt.Println(stringset.Contains(s, "chromium"))
+ // Output:
+ // true
+}
+
func ExampleFromKeys() {
s := stringset.FromKeys(map[string]int{
"one": 1,