counter

package
v0.0.0-...-427ddc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 4 Imported by: 0

README

Counter

NOTE: This exercise has been deprecated.

Please see the discussion in https://github.com/exercism/problem-specifications/issues/80 for more context.


Design a test suite for a line/letter/character counter tool.

This is a special exercise. Instead of creating code that works with an existing test suite you get to define the test suite. To help you several variations of the code under test have been provided, your test suite should at least be able to detect the problems (or lack thereof) with them.

The system under test is supposed to be a system to count the number of lines, letters and total characters in supplied strings. The idea is that you perform the "add string" operation a number of times, passing in strings, and afterwards call the "lines", "letters" and "characters" functions to get the totals.

Running the tests

To run the tests run the command go test from within the exercise directory.

If the test suite contains benchmarks, you can run these with the -bench flag:

go test -bench .

Keep in mind that each reviewer will run benchmarks on a different machine, with different specs, so the results from these benchmark tests may vary.

Further information

For more detailed information about the Go track, including how to get help if you're having trouble, please visit the exercism.io Go language page.

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestASCIIString

func TestASCIIString(t *testing.T)

func TestEmptyString

func TestEmptyString(t *testing.T)

func TestNoAdd

func TestNoAdd(t *testing.T)

func TestRussianString

func TestRussianString(t *testing.T)

Types

type Counter

type Counter interface {
	AddString(string)

	Lines() int
	Letters() int
	Characters() int
}

type Impl1

type Impl1 struct {
	// contains filtered or unexported fields
}

Incorrect implementation: wrongly counts lines.

func (*Impl1) AddString

func (c *Impl1) AddString(s string)

func (Impl1) Characters

func (c Impl1) Characters() int

func (Impl1) Letters

func (c Impl1) Letters() int

func (Impl1) Lines

func (c Impl1) Lines() int

type Impl2

type Impl2 struct {
	// contains filtered or unexported fields
}

Incorrect implementation: wrongly determines characters.

func (*Impl2) AddString

func (c *Impl2) AddString(s string)

func (Impl2) Characters

func (c Impl2) Characters() int

func (Impl2) Letters

func (c Impl2) Letters() int

func (Impl2) Lines

func (c Impl2) Lines() int

type Impl3

type Impl3 struct {
	// contains filtered or unexported fields
}

Incorrect implementation: assumes ASCII.

func (*Impl3) AddString

func (c *Impl3) AddString(s string)

func (Impl3) Characters

func (c Impl3) Characters() int

func (Impl3) Letters

func (c Impl3) Letters() int

func (Impl3) Lines

func (c Impl3) Lines() int

type Impl4

type Impl4 struct {
	// contains filtered or unexported fields
}

Correct implementation

func (*Impl4) AddString

func (c *Impl4) AddString(s string)

func (Impl4) Characters

func (c Impl4) Characters() int

func (Impl4) Letters

func (c Impl4) Letters() int

func (Impl4) Lines

func (c Impl4) Lines() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL