borked the shitty lexer, tests, new entities
This commit is contained in:
57
main_test.go
Normal file
57
main_test.go
Normal file
@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func LexerTestWrapper(message string, expected string) string {
|
||||
lexer := Lexer{}
|
||||
return Parse(lexer.Process(message)).String()
|
||||
}
|
||||
|
||||
func LexerTestWrapperFail(expected string, result string) {
|
||||
fmt.Println("Expected :", expected)
|
||||
fmt.Println("Got : ", result)
|
||||
}
|
||||
|
||||
func TestLinkNoTag(t *testing.T) {
|
||||
var message string = "** https://pleroma.social/announcements/feed.xml"
|
||||
var expected string = "https://pleroma.social/announcements/feed.xml"
|
||||
result := LexerTestWrapper(message, expected)
|
||||
if result != expected {
|
||||
LexerTestWrapperFail(expected, result)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkTag(t *testing.T) {
|
||||
var message string = "** https://pleroma.social/announcements/feed.xml :software:"
|
||||
var expected string = "https://pleroma.social/announcements/feed.xml software"
|
||||
result := LexerTestWrapper(message, expected)
|
||||
if result != expected {
|
||||
LexerTestWrapperFail(expected, result)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestLinkDescTag(t *testing.T) {
|
||||
var message string = "** [[https://pleroma.social/announcements/feed.xml][Pleroma Social]] :software:"
|
||||
var expected string = "https://pleroma.social/announcements/feed.xml # Pleroma Social"
|
||||
var result string = LexerTestWrapper(message, expected)
|
||||
if result != expected {
|
||||
LexerTestWrapperFail(expected, result)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestLinkDescNoTag(t *testing.T) {
|
||||
var message string = "** [[https://pleroma.social/announcements/feed.xml][Pleroma Social]]"
|
||||
var expected string = "https://pleroma.social/announcements/feed.xml # Pleroma Social"
|
||||
var result string = LexerTestWrapper(message, expected)
|
||||
if result != expected {
|
||||
LexerTestWrapperFail(expected, result)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user