2020-07-14 04:07:30 +02:00
|
|
|
package utils
|
|
|
|
|
2022-01-21 05:01:05 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
2020-07-14 04:07:30 +02:00
|
|
|
|
2022-01-21 05:01:05 +01:00
|
|
|
func TestGetHashtagsFromText(t *testing.T) {
|
|
|
|
text := `Some text with a #hashtag goes here.\n\n
|
|
|
|
Another #secondhashtag, goes here.\n\n
|
|
|
|
#thirdhashtag`
|
|
|
|
|
|
|
|
hashtags := GetHashtagsFromText(text)
|
|
|
|
|
|
|
|
if hashtags[0] != "#hashtag" || hashtags[1] != "#secondhashtag" || hashtags[2] != "#thirdhashtag" {
|
|
|
|
t.Error("Incorrect hashtags fetched from text.")
|
|
|
|
}
|
|
|
|
}
|
2022-04-07 09:14:23 +02:00
|
|
|
|
|
|
|
func TestPercentageUtilsTest(t *testing.T) {
|
|
|
|
total := 42
|
|
|
|
number := 18
|
|
|
|
|
|
|
|
percent := IntPercentage(number, total)
|
|
|
|
|
|
|
|
if percent != 42 {
|
|
|
|
t.Error("Incorrect percentage calculation.")
|
|
|
|
}
|
|
|
|
}
|