package collatz import ( "math/big" "testing" ) type MockParser struct { value *big.Int } func (m *MockParser) Parse() (*big.Int, error) { return m.value, nil } func TestNewCalculator(t *testing.T) { parser := &MockParser{} calculator := NewCalculator(parser) if calculator.parser != parser { t.Errorf("Expected parser to be %v, got %v", parser, calculator.parser) } if calculator.one.Cmp(big.NewInt(1)) != 0 { t.Errorf("Expected one to be 1, got %v", calculator.one) } if calculator.two.Cmp(big.NewInt(2)) != 0 { t.Errorf("Expected two to be 2, got %v", calculator.two) } if calculator.three.Cmp(big.NewInt(3)) != 0 { t.Errorf("Expected three to be 3, got %v", calculator.three) } } func TestCalculateCollatz(t *testing.T) { parser := &MockParser{value: big.NewInt(6)} calculator := NewCalculator(parser) sequence, err := calculator.CalculateCollatz() if err != nil { t.Errorf("Expected no error, got %v", err) } if sequence.Iterations != 8 { t.Errorf("Expected 8 iterations, got %v", sequence.Iterations) } }