Sha256: 4425b9600e13dd86e77a4577a6711749410cac5ea41f8c7b3bd08851db6017aa
Contents?: true
Size: 1.92 KB
Versions: 396
Compression:
Stored size: 1.92 KB
Contents
package counter // NOTE: This file is called example.go and not example_test.go because if it's // called example_test.go it will get picked up by the test suite and fail // because COUNTER_IMPL isn't set (see maker.go). import "testing" func TestNoAdd(t *testing.T) { counter := makeCounter() if counter.Lines() != 0 { t.Errorf("Lines mismatch: got %d, expected %d", counter.Lines(), 0) } if counter.Letters() != 0 { t.Errorf("Letters mismatch: got %d, expected %d", counter.Letters(), 0) } if counter.Characters() != 0 { t.Errorf("Characters mismatch: got %d, expected %d", counter.Characters(), 0) } } func TestEmptyString(t *testing.T) { counter := makeCounter() counter.AddString("") if counter.Lines() != 0 { t.Errorf("Lines mismatch: got %d, expected %d", counter.Lines(), 0) } if counter.Letters() != 0 { t.Errorf("Letters mismatch: got %d, expected %d", counter.Letters(), 0) } if counter.Characters() != 0 { t.Errorf("Characters mismatch: got %d, expected %d", counter.Characters(), 0) } } func TestASCIIString(t *testing.T) { counter := makeCounter() counter.AddString("Hello\nworld!") if counter.Lines() != 2 { t.Errorf("Lines mismatch: got %d, expected %d", counter.Lines(), 2) } if counter.Letters() != 10 { t.Errorf("Letters mismatch: got %d, expected %d", counter.Letters(), 10) } if counter.Characters() != 12 { t.Errorf("Characters mismatch: got %d, expected %d", counter.Characters(), 12) } } func TestRussianString(t *testing.T) { counter := makeCounter() // Lifted this translation from the ru.po file of GNU hello counter.AddString("здравствуй, мир\n") if counter.Lines() != 1 { t.Errorf("Lines mismatch: got %d, expected %d", counter.Lines(), 2) } if counter.Letters() != 13 { t.Errorf("Letters mismatch: got %d, expected %d", counter.Letters(), 10) } if counter.Characters() != 16 { t.Errorf("Characters mismatch: got %d, expected %d", counter.Characters(), 12) } }
Version data entries
396 entries across 396 versions & 1 rubygems