-
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.
Added more test, changed for real JSON library
- Loading branch information
Showing
3 changed files
with
92 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestEmojiReplacer(t *testing.T) { | ||
emoji = *emojiReplacer() | ||
|
||
if &emoji == nil { | ||
t.Error("Emoji replacer is empty") | ||
} | ||
} | ||
|
||
func TestEmojiToDescription(t *testing.T) { | ||
if &emoji == nil { | ||
emoji = *emojiReplacer() | ||
} | ||
|
||
if strings.ToLower(emoji.Replace("🕴️")) != "uomo con completo che levita" { | ||
t.Error("Emoji replacer gave wrong description") | ||
} | ||
} |
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
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,61 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func BenchmarkBestemmia(b *testing.B) { | ||
// Read adjectives if they are not loaded before | ||
if len(adjectives) == 0 { | ||
initializeAdjectives() | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
bestemmia() | ||
} | ||
} | ||
|
||
func TestInitializeAdjectives(t *testing.T) { | ||
initializeAdjectives() | ||
|
||
if len(adjectives) == 0 { | ||
t.Error("Adjectives slice is empty") | ||
} | ||
} | ||
|
||
func TestBestemmia(t *testing.T) { | ||
// Read adjectives if they are not loaded before | ||
if len(adjectives) == 0 { | ||
initializeAdjectives() | ||
} | ||
|
||
if strings.TrimSpace(bestemmia()) == "" { | ||
t.Error("Generated string is empty") | ||
} | ||
} | ||
|
||
func TestGenAudio(t *testing.T) { | ||
if runtime.GOOS == "windows" { | ||
_ = os.Remove("./temp/NP5M2VS4G9AQEEIPC6V6DQH5J1RGS4PE.dca") | ||
uuid := genAudio("AGAGAGAGAGA") | ||
stat, err := os.Stat("./temp/NP5M2VS4G9AQEEIPC6V6DQH5J1RGS4PE.dca") | ||
|
||
if uuid != "NP5M2VS4G9AQEEIPC6V6DQH5J1RGS4PE.dca" { | ||
t.Error("Hash mismatch") | ||
} else { | ||
if err != nil { | ||
t.Error("File doesn't exist") | ||
} else { | ||
if !(stat.Size() > 0) { | ||
t.Error("File is empty") | ||
} | ||
} | ||
} | ||
} else { | ||
t.Skip("Audio generation is only supported by windows") | ||
} | ||
|
||
} |