121 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			121 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package nomino_test
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 
 | |
| 	"codeberg.org/danjones000/nomino"
 | |
| )
 | |
| 
 | |
| func ExampleIncremental() {
 | |
| 	conf := nomino.NewConfig(
 | |
| 		nomino.WithPrefix("foo"),
 | |
| 		nomino.WithGenerator(nomino.Incremental()),
 | |
| 	)
 | |
| 
 | |
| 	str, _ := nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output:
 | |
| 	// foo_0.txt
 | |
| 	// foo_1.txt
 | |
| 	// foo_2.txt
 | |
| }
 | |
| 
 | |
| func ExampleIncrementalStart() {
 | |
| 	conf := nomino.NewConfig(
 | |
| 		nomino.WithPrefix("foo"),
 | |
| 		nomino.WithGenerator(nomino.Incremental(
 | |
| 			nomino.IncrementalStart(42),
 | |
| 		)),
 | |
| 	)
 | |
| 
 | |
| 	str, _ := nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output:
 | |
| 	// foo_42.txt
 | |
| 	// foo_43.txt
 | |
| 	// foo_44.txt
 | |
| }
 | |
| 
 | |
| func ExampleIncrementalStep() {
 | |
| 	conf := nomino.NewConfig(
 | |
| 		nomino.WithPrefix("foo"),
 | |
| 		nomino.WithGenerator(nomino.Incremental(
 | |
| 			nomino.IncrementalStep(2),
 | |
| 		)),
 | |
| 	)
 | |
| 
 | |
| 	str, _ := nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output:
 | |
| 	// foo_0.txt
 | |
| 	// foo_2.txt
 | |
| 	// foo_4.txt
 | |
| }
 | |
| 
 | |
| func ExampleIncremental_withStartAndStep() {
 | |
| 	conf := nomino.NewConfig(
 | |
| 		nomino.WithPrefix("foo"),
 | |
| 		nomino.WithGenerator(nomino.Incremental(
 | |
| 			nomino.IncrementalStart(42),
 | |
| 			nomino.IncrementalStep(2),
 | |
| 		)),
 | |
| 	)
 | |
| 
 | |
| 	str, _ := nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output:
 | |
| 	// foo_42.txt
 | |
| 	// foo_44.txt
 | |
| 	// foo_46.txt
 | |
| }
 | |
| 
 | |
| func ExampleIncrementalFormat() {
 | |
| 	conf := nomino.NewConfig(
 | |
| 		nomino.WithPrefix("foo"),
 | |
| 		nomino.WithGenerator(nomino.Incremental(
 | |
| 			nomino.IncrementalFormat("%03d"),
 | |
| 		)),
 | |
| 	)
 | |
| 
 | |
| 	str, _ := nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	str, _ = nomino.Make(conf)
 | |
| 	fmt.Println(str)
 | |
| 
 | |
| 	// Output:
 | |
| 	// foo_000.txt
 | |
| 	// foo_001.txt
 | |
| 	// foo_002.txt
 | |
| }
 |