// Copyright 2020 Misha Brukman
// SPDX-License-Identifier: Apache-2.0
// https://misha.brukman.net/blog/2020/03/oo-style-testing-in-go/

// Note: the `-self_package` value here is synthetic; there isn't actually a
// Git repo at that URL. Feel free to change this to anything you want, but be
// sure to run `go mod init [...path..]` with that same path.
//
// In my case, I actually have `go.mod` and `go.sum` one level higher than this
// package:
//
// workdir
// ├── go.mod
// ├── go.sum
// ├── oo1/
// |   ├── oo.go  <-- this file
// |   └── oo_test.go
// └── oo2/
//
// Thus, I ran:
//
//     $ cd workdir
//     $ go mod init gitlab.com/mbrukman/oo-testing-in-go
//
//go:generate mockgen -source oo.go -destination mock_oo.go -package oo1 -self_package gitlab.com/mbrukman/oo-testing-in-go/oo1

package oo1

type MyInterface interface {
	IsOdd(n uint) bool
	IsEven(n uint) bool
}

type MyImpl struct{}

func (m *MyImpl) IsOdd(n uint) bool {
	if n == 0 {
		return false
	} else if n == 1 {
		return true
	}
	return m.IsEven(n - 1)
}

func (m *MyImpl) IsEven(n uint) bool {
	if n == 0 {
		return true
	} else if n == 1 {
		return false
	}
	return m.IsOdd(n - 1)
}
