@@ -328,6 +328,57 @@ func TestTreeSet_Subset(t *testing.T) {
328328 })
329329}
330330
331+ func TestTreeSet_ProperSubset (t * testing.T ) {
332+ t .Run ("empty empty" , func (t * testing.T ) {
333+ t1 := NewTreeSet [int ](Compare [int ])
334+ t2 := NewTreeSet [int ](Compare [int ])
335+ must .False (t , t1 .ProperSubset (t2 ))
336+ })
337+
338+ t .Run ("empty full" , func (t * testing.T ) {
339+ t1 := NewTreeSet [int ](Compare [int ])
340+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
341+ must .False (t , t1 .ProperSubset (t2 ))
342+ })
343+
344+ t .Run ("full empty" , func (t * testing.T ) {
345+ t1 := NewTreeSet [int ](Compare [int ])
346+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
347+ must .True (t , t2 .ProperSubset (t1 ))
348+ })
349+
350+ t .Run ("same" , func (t * testing.T ) {
351+ t1 := TreeSetFrom [int ]([]int {2 , 1 , 3 }, Compare [int ])
352+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
353+ must .False (t , t1 .ProperSubset (t2 ))
354+ must .False (t , t2 .ProperSubset (t1 ))
355+ })
356+
357+ t .Run ("subset" , func (t * testing.T ) {
358+ t1 := TreeSetFrom [int ]([]int {2 , 1 , 3 }, Compare [int ])
359+ t2 := TreeSetFrom [int ]([]int {5 , 4 , 1 , 2 , 3 }, Compare [int ])
360+ must .False (t , t1 .ProperSubset (t2 ))
361+ })
362+
363+ t .Run ("superset" , func (t * testing.T ) {
364+ t1 := TreeSetFrom [int ]([]int {9 , 7 , 8 , 5 , 4 , 2 , 1 , 3 }, Compare [int ])
365+ t2 := TreeSetFrom [int ]([]int {5 , 1 , 2 , 8 , 3 }, Compare [int ])
366+ must .True (t , t1 .ProperSubset (t2 ))
367+ })
368+
369+ t .Run ("diff set" , func (t * testing.T ) {
370+ t1 := TreeSetFrom [int ]([]int {1 , 2 , 3 , 4 , 5 }, Compare [int ])
371+ t2 := TreeSetFrom [int ]([]int {6 , 7 , 8 , 9 , 10 }, Compare [int ])
372+ must .False (t , t1 .ProperSubset (t2 ))
373+ })
374+
375+ t .Run ("exhaust" , func (t * testing.T ) {
376+ s1 := TreeSetFrom [string ]([]string {"a" , "b" , "c" , "d" , "e" }, Compare [string ])
377+ s2 := TreeSetFrom [string ]([]string {"a" , "z" }, Compare [string ])
378+ must .False (t , s1 .ProperSubset (s2 ))
379+ })
380+ }
381+
331382func TestTreeSet_Union (t * testing.T ) {
332383 t .Run ("empty empty" , func (t * testing.T ) {
333384 t1 := TreeSetFrom [int ](nil , Compare [int ])
@@ -523,6 +574,35 @@ func TestTreeSet_Equal(t *testing.T) {
523574 })
524575}
525576
577+ func TestTreeSet_EqualSet (t * testing.T ) {
578+ t .Run ("empty empty" , func (t * testing.T ) {
579+ t1 := TreeSetFrom [int ](nil , Compare [int ])
580+ t2 := TreeSetFrom [int ](nil , Compare [int ])
581+ must .True (t , t1 .EqualSet (t2 ))
582+ })
583+
584+ t .Run ("empty full" , func (t * testing.T ) {
585+ t1 := TreeSetFrom [int ](nil , Compare [int ])
586+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
587+ must .False (t , t1 .EqualSet (t2 ))
588+ must .False (t , t2 .EqualSet (t1 ))
589+ })
590+
591+ t .Run ("different" , func (t * testing.T ) {
592+ t1 := TreeSetFrom [int ]([]int {1 , 2 , 4 }, Compare [int ])
593+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
594+ must .False (t , t1 .EqualSet (t2 ))
595+ must .False (t , t2 .EqualSet (t1 ))
596+ })
597+
598+ t .Run ("same" , func (t * testing.T ) {
599+ t1 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
600+ t2 := TreeSetFrom [int ]([]int {1 , 2 , 3 }, Compare [int ])
601+ must .True (t , t1 .EqualSet (t2 ))
602+ must .True (t , t2 .EqualSet (t1 ))
603+ })
604+ }
605+
526606func TestTreeSet_TopK (t * testing.T ) {
527607 t .Run ("empty" , func (t * testing.T ) {
528608 ts := NewTreeSet [int ](Compare [int ])
0 commit comments