1234567891011121314151617181920212223242526272829303132333435 |
- package kata_test
- import (
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
- . "code.osinet.fr/fgm/codewars/kyu5/some_egyptian_fractions"
- )
- func doTest(s string, exp []string) {
- var ans = Decompose(s)
- Expect(ans).To(Equal(exp))
- }
- var _ = Describe("Tests Decompose", func() {
- It("should handle 21/23", func() {
- doTest("21/23", []string{"1/2", "1/3", "1/13", "1/359", "1/644046"})
- })
- It("should handle 12/4", func() {
- doTest("12/4", []string{"3"})
- })
- It("should handle 0.66", func() {
- doTest("0.66", []string{"1/2", "1/7", "1/59", "1/5163", "1/53307975"})
- })
- It("should handle 0", func() {
- doTest("0", []string{})
- })
- It("should handle 1", func() {
- doTest("1", []string{"1"})
- })
- It("should handle 1.25", func() {
- doTest("1.25", []string{"1", "1/4"})
- })
- })
|