2021-10-27 12:42:25 +00:00
|
|
|
package asciitxt_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/aldy505/asciitxt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNew(t *testing.T) {
|
2021-10-28 04:33:33 +00:00
|
|
|
s := asciitxt.New("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 æ` the quick brown fox jumps over the lazy dog")
|
2021-10-27 12:42:25 +00:00
|
|
|
|
|
|
|
if s == "" {
|
|
|
|
t.Error("should not be empty")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestWithConfig(t *testing.T) {
|
2021-10-28 04:33:33 +00:00
|
|
|
s := asciitxt.WithConfig("THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789 æ` the quick brown fox jumps over the lazy dog", asciitxt.Config{})
|
|
|
|
|
|
|
|
if s == "" {
|
|
|
|
t.Error("should not be empty")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSymbols(t *testing.T) {
|
2021-10-28 04:37:18 +00:00
|
|
|
s := asciitxt.WithConfig(`!@"#$%&'()*+,-./:;<=>?[\]^_{|}~¡¢£¥¨§©±`, asciitxt.Config{Style: asciitxt.StyleStandard})
|
2021-10-27 14:20:09 +00:00
|
|
|
|
2021-10-27 12:42:25 +00:00
|
|
|
if s == "" {
|
|
|
|
t.Error("should not be empty")
|
|
|
|
}
|
|
|
|
}
|
2021-10-27 17:08:45 +00:00
|
|
|
|
|
|
|
func TestEmpty(t *testing.T) {
|
|
|
|
s := asciitxt.New("")
|
|
|
|
if s != "" {
|
|
|
|
t.Error("should be empty, got:", s)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInvalidStyle(t *testing.T) {
|
|
|
|
// this should panic
|
|
|
|
assertPanic(t, func() { asciitxt.WithConfig("hello", asciitxt.Config{Style: 2}) })
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertPanic(t *testing.T, f func()) {
|
|
|
|
defer func() {
|
|
|
|
if r := recover(); r == nil {
|
|
|
|
t.Errorf("The code did not panic")
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
f()
|
|
|
|
}
|