-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
916e9d6
commit b4892a7
Showing
5 changed files
with
87 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,38 @@ | ||
package text | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
) | ||
|
||
var rng = rand.New(rand.NewSource(time.Now().UnixNano())) | ||
|
||
type Text struct { | ||
} | ||
|
||
var exampleSentences = []string{ | ||
"زبان رسمی ایران فارسی است.", | ||
"شیر نماد ملی ایران است و در بسیاری از هنرها و معماریها دیده میشود.", | ||
"ایران دارای چهار فصل کاملاً متمایز است.", | ||
"تخت جمشید یکی از معروفترین آثار باستانی ایران است.", | ||
"ایران یکی از بزرگترین تولیدکنندگان خاویار در جهان است.", | ||
"کویر لوت بزرگترین کویر ایران است و به عنوان گرمترین نقطه زمین شناخته شده است.", | ||
"نوروز، که عید نو شمسی است، مهمترین جشن سنتی ایرانیان است.", | ||
"چای ایرانی بخش مهمی از فرهنگ چای در ایران است و عمدتا در زمان میان وعدهها نوشیده میشود.", | ||
"هفتسین نمادی از جشن نوروز است که شامل هفت مورد با نامهایی است که با 'س' شروع میشود.", | ||
"ایران یکی از قدیمیترین تمدنها در جهان را داراست و تاریخ آن به بیش از ۷۰۰۰ سال پیش بازمیگردد.", | ||
"پل ورسک، که در سال ۱۳۱۵ خورشیدی ساخته شده، یکی از شاهکارهای مهندسی ایران است.", | ||
"زعفران ایرانی به عنوان باکیفیتترین زعفران جهان شناخته میشود.", | ||
"بازار تبریز یکی از بزرگترین و قدیمیترین بازارهای سرپوشیده در جهان است.", | ||
"فیلمسازی در ایران به عنوان یکی از پیشروان صنعت سینما در خاورمیانه شناخته میشود.", | ||
"موزه جواهرات ملی ایران شامل مجموعهای از گرانبهاترین جواهرات جهان است که بخشی از ذخایر ملی ایران به شمار میرود.", | ||
"دانشگاه تهران، بزرگترین و قدیمیترین دانشگاه مدرن ایران، در سال ۱۳۱۳ خورشیدی تأسیس شد.", | ||
"غذاهای سنتی ایرانی مانند فسنجان، کباب و دیزی شهرت جهانی دارند.", | ||
"البرز مرکزی، که شامل قله دماوند است، بلندترین نقطه در ایران و خاورمیانه محسوب میشود.", | ||
"فردوسی، شاعر ایرانی، معروف به حماسهسرای شاهنامه، اثری که به حفظ زبان فارسی کمک شایانی کرد.", | ||
} | ||
|
||
// Sentence returns a random Persian sentence from the predefined list. | ||
func (Text) Sentence() string { | ||
return exampleSentences[rng.Intn(len(exampleSentences))] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package text | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSentence(t *testing.T) { | ||
text := &Text{} | ||
sentence := text.Sentence() | ||
|
||
// Check if the returned sentence is non-empty | ||
if sentence == "" { | ||
t.Error("Expected a non-empty string, got an empty string") | ||
} | ||
|
||
// Check if the returned sentence is in the predefined list | ||
found := false | ||
for _, s := range exampleSentences { | ||
if s == sentence { | ||
found = true | ||
break | ||
} | ||
} | ||
if !found { | ||
t.Errorf("The sentence '%s' is not in the predefined list of sentences", sentence) | ||
} | ||
} |