go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/iter/permutations_test.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package iter 9 10 import ( 11 "testing" 12 13 . "go.charczuk.com/sdk/assert" 14 ) 15 16 func Test_Permutations(t *testing.T) { 17 output := Permutations[string]() 18 ItsEqual(t, 0, len(output)) 19 20 output = Permutations("a") 21 ItsEqual(t, 1, len(output)) 22 23 output = Permutations("a", "b", "c") 24 ItsEqual(t, 6, len(output)) 25 ItsEqual(t, []string{"c", "b", "a"}, output[0]) 26 ItsEqual(t, []string{"b", "c", "a"}, output[1]) 27 ItsEqual(t, []string{"b", "a", "c"}, output[2]) 28 ItsEqual(t, []string{"c", "a", "b"}, output[3]) 29 ItsEqual(t, []string{"a", "c", "b"}, output[4]) 30 ItsEqual(t, []string{"a", "b", "c"}, output[5]) 31 }