This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
func ToRoman(in uint16) string { | |
numbers := []struct { | |
arabian uint16 | |
roman string | |
}{ | |
{1, "I"}, | |
{5, "V"}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
import "testing" | |
func TestToRoman(t *testing.T) { | |
testCases := []struct { | |
name string | |
in uint16 | |
want string | |
}{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- FAIL: TestToRoman (0.00s) | |
--- FAIL: TestToRoman/2=>IIと変換できること (0.00s) | |
roman_test.go:38: ToRoman(2) = got _ want II | |
FAIL | |
FAIL sandbox/roman 0.006s | |
Error: Tests failed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
func ToRoman(in uint16) string { | |
numbers := map[uint16]string{ | |
1: "I", | |
5: "V", | |
} | |
return numbers[in] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
import "testing" | |
func TestToRoman(t *testing.T) { | |
testCases := []struct { | |
name string | |
in uint16 | |
want string | |
}{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestToRoman(t *testing.T) { | |
testCases := []struct { | |
in uint16 | |
want string | |
}{ | |
{1, "I"}, | |
{2, "II"}, | |
{5, "V"}, | |
} | |
for _, test := range testCases { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// roman_test.go | |
import ( | |
"fmt" | |
"testing" | |
) | |
func TestToRoman(t *testing.T) { | |
testCases := []struct { | |
in Arabian | |
want string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
type Arabian uint16 | |
func (in Arabian) ToRoman() (out string) { | |
numbers := []struct { | |
arabian Arabian | |
roman string | |
}{ | |
{5, "V"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
type Arabian uint16 | |
var numbers = []struct { | |
arabian Arabian | |
roman string | |
}{ | |
{5, "V"}, | |
{1, "I"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package roman | |
import ( | |
"testing" | |
) | |
func ToRoman(in int16) string { | |
return "_" | |
} |