aboutsummaryrefslogtreecommitdiff
path: root/telegram/formatter/formatter_test.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-11 19:12:36 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-11 19:12:36 +0300
commitf6e62fe1fd208cba8214db70fe1ebbdc9bb41115 (patch)
treedff45ff812970bf738e40f1f3274bd49b9f61eec /telegram/formatter/formatter_test.go
parent7ddc3c448278191f19d616cf3b730bdbe8dc63cd (diff)
Merge adjacent formatting entities of same kind
Diffstat (limited to 'telegram/formatter/formatter_test.go')
-rw-r--r--telegram/formatter/formatter_test.go79
1 files changed, 79 insertions, 0 deletions
diff --git a/telegram/formatter/formatter_test.go b/telegram/formatter/formatter_test.go
index 8453851..5ac6262 100644
--- a/telegram/formatter/formatter_test.go
+++ b/telegram/formatter/formatter_test.go
@@ -269,3 +269,82 @@ func TestFormattingXEP0393AdjacentAndNested(t *testing.T) {
t.Errorf("Wrong adjacent&nested formatting: %v", markup)
}
}
+
+func TestFormattingXEP0393AdjacentItalicBoldItalic(t *testing.T) {
+ markup := Format("раса двуногих крысолюдей, которую так редко замечают, что многие отрицают само их существование", []*client.TextEntity{
+ &client.TextEntity{
+ Offset: 0,
+ Length: 26,
+ Type: &client.TextEntityTypeItalic{},
+ },
+ &client.TextEntity{
+ Offset: 26,
+ Length: 69,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 26,
+ Length: 69,
+ Type: &client.TextEntityTypeItalic{},
+ },
+ }, EntityToXEP0393)
+ if markup != "_раса двуногих крысолюдей, *которую так редко замечают, что многие отрицают само их существование*_" {
+ t.Errorf("Wrong adjacent italic/bold-italic formatting: %v", markup)
+ }
+}
+
+func TestFormattingXEP0393MultipleAdjacent(t *testing.T) {
+ markup := Format("abcde", []*client.TextEntity{
+ &client.TextEntity{
+ Offset: 1,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 2,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 3,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 4,
+ Length: 1,
+ Type: &client.TextEntityTypeItalic{},
+ },
+ }, EntityToXEP0393)
+ if markup != "a*bcd*_e_" {
+ t.Errorf("Wrong multiple adjacent formatting: %v", markup)
+ }
+}
+
+func TestFormattingXEP0393Intersecting(t *testing.T) {
+ markup := Format("abcde", []*client.TextEntity{
+ &client.TextEntity{
+ Offset: 1,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 2,
+ Length: 3,
+ Type: &client.TextEntityTypeItalic{},
+ },
+ &client.TextEntity{
+ Offset: 2,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ &client.TextEntity{
+ Offset: 3,
+ Length: 1,
+ Type: &client.TextEntityTypeBold{},
+ },
+ }, EntityToXEP0393)
+ if markup != "a*b*_*cd*e_" {
+ t.Errorf("Wrong intersecting formatting: %v", markup)
+ }
+}