count less

This commit is contained in:
Shish
2023-01-11 11:41:13 +00:00
parent 9587bedae0
commit f91daba264
5 changed files with 24 additions and 15 deletions

View File

@ -116,15 +116,10 @@ class Tag
$tags1 = array_map("strtolower", $tags1);
$tags2 = array_map("strtolower", $tags2);
natcasesort($tags1);
natcasesort($tags2);
sort($tags1);
sort($tags2);
for ($i = 0; $i < count($tags1); $i++) {
if ($tags1[$i]!==$tags2[$i]) {
return false;
}
}
return true;
return $tags1 == $tags2;
}
public static function get_diff_tags(array $source, array $remove): array

View File

@ -23,4 +23,13 @@ class TagTest extends TestCase
$this->assertEquals("foo^q", Tag::caret("foo?"));
$this->assertEquals("a^^b^sc^bd^qe^af", Tag::caret("a^b/c\\d?e&f"));
}
public function test_compare()
{
$this->assertFalse(Tag::compare(["foo"], ["bar"]));
$this->assertFalse(Tag::compare(["foo"], ["foo", "bar"]));
$this->assertTrue(Tag::compare([], []));
$this->assertTrue(Tag::compare(["foo"], ["FoO"]));
$this->assertTrue(Tag::compare(["foo", "bar"], ["bar", "FoO"]));
}
}