Пример #1
0
func TestBigratToInt(t *testing.T) {
	for i, test := range testsBigratToInt {
		ret, err := evaler.BigratToInt(test.in)
		if test.ok && (ret != test.out) {
			t.Errorf("#%d: got %d expected %d", i, ret, test.out)
		}
		if (err == nil) != test.ok {
			t.Errorf("#%d: %s: unexpected err result: %t vs %t", i, test.in, (err == nil), test.ok)
		}
	}
}
Пример #2
0
func main() {
	stdin := bufio.NewReader(os.Stdin)
	for true {
		numbers := generate_numbers()
		fmt.Println("Your numbers: ", strings.Join(numbers[:], " "))

		line, _, _ := stdin.ReadLine()
		if valid_expression(string(line), numbers) {
			result, err := evaler.Eval(string(line))
			if err != nil {
				fmt.Println(ERROR_MSG)
			} else if r, _ := evaler.BigratToInt(result); r == 24 {
				fmt.Println("You got it!")
			} else {
				fmt.Println("That wasn't correct :(")
			}

		} else {
			fmt.Println(ERROR_MSG)
		}
	}
}