Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CON-2674 [CHECKPOINT-RESTRUCTURE] Update repeatalpha test according to new subject #188

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions solutions/repeatalpha.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package solutions

import "unicode"

func RepeatAlpha(s string) string {
res := ""
for _, r := range s {
if unicode.IsLetter(r) {
rep := unicode.ToLower(r) - 'a' + 1
for i := 0; i < int(rep); i++ {
res += string(r)
}
} else {
res += string(r)
}
}
return res
}
22 changes: 0 additions & 22 deletions solutions/repeatalpha/main.go

This file was deleted.

37 changes: 17 additions & 20 deletions tests/repeatalpha_test/main.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package main

import (
"github.com/01-edu/go-tests/lib/challenge"
"github.com/01-edu/go-tests/lib/chars"
"github.com/01-edu/go-tests/lib/random"
"fmt"
"os"
student "student"
)

func main() {
args := []string{
"",
"Hello",
"World",
"Home",
"Theorem",
"Choumi is the best cat",
"abracadaba 01!",
"abc",
"MaTheMatiCs",
testCases := []struct {
in string
want string
}{
{"abc", "abbccc"},
{"Choumi.", "CCChhhhhhhhooooooooooooooouuuuuuuuuuuuuuuuuuuuummmmmmmmmmmmmiiiiiiiii."},
{"", ""},
{"abacadaba 01!", "abbacccaddddabba 01!"},
}

args = append(args, random.StrSlice(chars.Alnum)...)

for _, v := range args {
challenge.Program("repeatalpha", v)
for _, tc := range testCases {
got := student.RepeatAlpha(tc.in)
if got != tc.want {
fmt.Printf("RepeatAlpha(%q) = %q instead of %q\n", tc.in, got, tc.want)
os.Exit(1)
}
}
challenge.Program("repeatalpha")
challenge.Program("repeatalpha", "", "")
}
Loading