66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package nomino_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"codeberg.org/danjones000/nomino"
|
|
)
|
|
|
|
func ExampleSlug() {
|
|
conf := nomino.NewConfig(
|
|
nomino.WithOriginal("My name is Jimmy"),
|
|
nomino.WithGenerator(nomino.Slug()),
|
|
)
|
|
str, _ := nomino.Make(conf)
|
|
fmt.Println(str)
|
|
|
|
// Output: my-name-is-jimmy.txt
|
|
}
|
|
|
|
func ExampleSlug_withLang() {
|
|
conf := nomino.NewConfig(
|
|
nomino.WithOriginal("Diese & Dass"),
|
|
nomino.WithGenerator(nomino.Slug("de")),
|
|
)
|
|
|
|
str, _ := nomino.Make(conf)
|
|
fmt.Println(str)
|
|
|
|
// Output: diese-und-dass.txt
|
|
}
|
|
|
|
func ExampleHash_mD5() {
|
|
conf := nomino.NewConfig(
|
|
nomino.WithOriginal("foobar"),
|
|
nomino.WithGenerator(
|
|
nomino.Hash(nomino.HashMD5),
|
|
),
|
|
)
|
|
str, _ := nomino.Make(conf)
|
|
fmt.Println(str)
|
|
// Output: 3858f62230ac3c915f300c664312c63f.txt
|
|
}
|
|
|
|
func ExampleHash_sHA1() {
|
|
conf := nomino.NewConfig(
|
|
nomino.WithOriginal("foobar"),
|
|
nomino.WithGenerator(
|
|
nomino.Hash(nomino.HashSHA1),
|
|
),
|
|
)
|
|
str, _ := nomino.Make(conf)
|
|
fmt.Println(str)
|
|
// Output: 8843d7f92416211de9ebb963ff4ce28125932878.txt
|
|
}
|
|
|
|
func ExampleHash_sHA256() {
|
|
conf := nomino.NewConfig(
|
|
nomino.WithOriginal("foobar"),
|
|
nomino.WithGenerator(
|
|
nomino.Hash(nomino.HashSHA256),
|
|
),
|
|
)
|
|
str, _ := nomino.Make(conf)
|
|
fmt.Println(str)
|
|
// Output: c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2.txt
|
|
}
|