Skip to content

Commit 15c095c

Browse files
committed
SetAxiomsTest: new test cases added.
1 parent 6f89740 commit 15c095c

File tree

1 file changed

+91
-1
lines changed

1 file changed

+91
-1
lines changed

tests/SetTheory/SetAxiomsTest.php

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,17 @@ public function testPartialIntersectionDefinition(int $m, Set ...$sets)
744744
// Given
745745
$allSets = $sets;
746746
$s = array_shift($sets);
747+
$totalElementsCount = array_reduce($allSets, static function (int $carry, Set $set) {
748+
return $carry + count($set);
749+
}, 0);
750+
$partialIntersection = $s->intersectPartial($m, ...$sets);
747751

748752
// When
749-
$partialIntersection = $s->intersectPartial($m, ...$sets);
753+
if ($totalElementsCount === 0) {
754+
// Then
755+
// Assert than for any M and N M-partial intersection of N empty sets is an empty set.
756+
$this->assertCount(0, $partialIntersection);
757+
}
750758

751759
// Then
752760
foreach ($partialIntersection as $value) {
@@ -775,6 +783,14 @@ public function testPartialIntersectionDefinition(int $m, Set ...$sets)
775783
public function dataProviderForPartialIntersectionDefinition(): array
776784
{
777785
return [
786+
[
787+
1,
788+
new Set(),
789+
],
790+
[
791+
2,
792+
new Set(),
793+
],
778794
[
779795
1,
780796
new Set([1]),
@@ -783,6 +799,21 @@ public function dataProviderForPartialIntersectionDefinition(): array
783799
2,
784800
new Set([1]),
785801
],
802+
[
803+
1,
804+
new Set(),
805+
new Set(),
806+
],
807+
[
808+
2,
809+
new Set(),
810+
new Set(),
811+
],
812+
[
813+
3,
814+
new Set(),
815+
new Set(),
816+
],
786817
[
787818
1,
788819
new Set([1]),
@@ -848,6 +879,30 @@ public function dataProviderForPartialIntersectionDefinition(): array
848879
new Set([1, 2, 3, 4, 5]),
849880
new Set([6, 7, 8, 9, 10]),
850881
],
882+
[
883+
1,
884+
new Set(),
885+
new Set(),
886+
new Set(),
887+
],
888+
[
889+
2,
890+
new Set(),
891+
new Set(),
892+
new Set(),
893+
],
894+
[
895+
3,
896+
new Set(),
897+
new Set(),
898+
new Set(),
899+
],
900+
[
901+
4,
902+
new Set(),
903+
new Set(),
904+
new Set(),
905+
],
851906
[
852907
1,
853908
new Set([1, 2, 3, 4, 5]),
@@ -920,6 +975,41 @@ public function dataProviderForPartialIntersectionDefinition(): array
920975
new Set([2, 3, 4, 5]),
921976
new Set([3, 4, 5, 6, 7]),
922977
],
978+
[
979+
1,
980+
new Set(),
981+
new Set(),
982+
new Set(),
983+
new Set(),
984+
],
985+
[
986+
2,
987+
new Set(),
988+
new Set(),
989+
new Set(),
990+
new Set(),
991+
],
992+
[
993+
3,
994+
new Set(),
995+
new Set(),
996+
new Set(),
997+
new Set(),
998+
],
999+
[
1000+
4,
1001+
new Set(),
1002+
new Set(),
1003+
new Set(),
1004+
new Set(),
1005+
],
1006+
[
1007+
5,
1008+
new Set(),
1009+
new Set(),
1010+
new Set(),
1011+
new Set(),
1012+
],
9231013
[
9241014
1,
9251015
new Set([1, 2, 3]),

0 commit comments

Comments
 (0)