| 884 | } |
| 885 | |
| 886 | func TestRotate(t *testing.T) { |
| 887 | t.Parallel() |
| 888 | |
| 889 | assert := internal.NewAssert(t, "TestRotate") |
| 890 | |
| 891 | tests := []struct { |
| 892 | input string |
| 893 | shift int |
| 894 | expected string |
| 895 | }{ |
| 896 | {"", 1, ""}, |
| 897 | {"a", 0, "a"}, |
| 898 | {"a", 1, "a"}, |
| 899 | {"a", -1, "a"}, |
| 900 | |
| 901 | {"Hello", -2, "lloHe"}, |
| 902 | {"Hello", 1, "oHell"}, |
| 903 | {"Hello, world!", 3, "ld!Hello, wor"}, |
| 904 | } |
| 905 | |
| 906 | for _, tt := range tests { |
| 907 | assert.Equal(tt.expected, Rotate(tt.input, tt.shift)) |
| 908 | } |
| 909 | } |
| 910 | |
| 911 | func TestTemplateReplace(t *testing.T) { |
| 912 | t.Parallel() |