Skip to content

Commit dbed25d

Browse files
committed
more tests, 78.63% line coverage now
git-svn-id: http://svn.php.net/repository/pear/packages/Text_LanguageDetect/trunk@322353 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent abd9d81 commit dbed25d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Text/LanguageDetect.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,7 @@ public function languageSimilarity($lang1 = null, $lang2 = null)
10761076
}
10771077

10781078
if ($lang2 != null) {
1079-
1080-
if ($lang1 == null) {
1081-
// can't only set the second param
1082-
return null;
1083-
} elseif (!isset($this->_lang_db[$lang2])) {
1079+
if (!isset($this->_lang_db[$lang2])) {
10841080
// check if language model exists
10851081
return null;
10861082
}

tests/Text_LanguageDetectTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,6 +1547,16 @@ function testLanguageSimilarityNameMode2()
15471547
$this->assertTrue($eng_dan > $nor_dan); // english is less similar to danish than norwegian is
15481548
}
15491549

1550+
function testLanguageSimilarityUnknownLanguage()
1551+
{
1552+
$this->assertNull($this->x->languageSimilarity('doesnotexist'));
1553+
}
1554+
1555+
function testLanguageSimilarityUnknownLanguage2()
1556+
{
1557+
$this->assertNull($this->x->languageSimilarity('english', 'doesnotexist'));
1558+
}
1559+
15501560
function test_compatibility ()
15511561
{
15521562
$str = "I am the very model of a modern major general.";

0 commit comments

Comments
 (0)