This repository was archived by the owner on Aug 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathzerowidth_test.go
More file actions
66 lines (57 loc) · 1.88 KB
/
zerowidth_test.go
File metadata and controls
66 lines (57 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2018 Nikola Trubitsyn. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package zerowidth
import "testing"
func TestHasZeroWidthCharacters(t *testing.T) {
samples := []string{"\u200B", "\u200C", "\u200D", "\uFEFF"}
for _, s := range samples {
expected := true
actual := HasZeroWidthCharacters(s)
if actual != expected {
t.Errorf("String was incorrect, got: %t, want: %t", actual, expected)
}
}
}
func TestHasNoZeroWidthCharacters(t *testing.T) {
expected := false
actual := HasZeroWidthCharacters("HERE>string<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %t, want: %t", actual, expected)
}
}
func TestRemoveZeroWidthCharacters(t *testing.T) {
expected := "HERE><HERE"
actual := RemoveZeroWidthCharacters("HERE>\u200B\u200C\u200D\uFEFF<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %s, want: %s.", actual, expected)
}
}
func TestRemoveZeroWidthSpace(t *testing.T) {
expected := "HERE><HERE"
actual := RemoveZeroWidthSpace("HERE>\u200B<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %s, want: %s.", actual, expected)
}
}
func TestRemoveZeroWidthNoBreakSpace(t *testing.T) {
expected := "HERE><HERE"
actual := RemoveZeroWidthNoBreakSpace("HERE>\uFEFF<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %s, want: %s.", actual, expected)
}
}
func TestRemoveZeroWidthJoiner(t *testing.T) {
expected := "HERE><HERE"
actual := RemoveZeroWidthJoiner("HERE>\u200D<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %s, want: %s.", actual, expected)
}
}
func TestRemoveZeroWidthNonJoiner(t *testing.T) {
expected := "HERE><HERE"
actual := RemoveZeroWidthNonJoiner("HERE>\u200C<HERE")
if actual != expected {
t.Errorf("String was incorrect, got: %s, want: %s.", actual, expected)
}
}