@@ -151,13 +151,17 @@ func TestStringSetEquals(t *testing.T) {
151
151
if ! a .Equal (b ) {
152
152
t .Errorf ("Expected to be equal: %v vs %v" , a , b )
153
153
}
154
-
154
+ a = New [string ]("1" , "2" , "3" )
155
+ b = New [string ]("2" , "1" )
156
+ if a .Equal (b ) {
157
+ t .Errorf ("Expected to be not-equal: %v vs %v" , a , b )
158
+ }
155
159
// It is a set; duplicates are ignored
160
+ a = New [string ]("1" , "2" )
156
161
b = New [string ]("2" , "2" , "1" )
157
162
if ! a .Equal (b ) {
158
163
t .Errorf ("Expected to be equal: %v vs %v" , a , b )
159
164
}
160
-
161
165
// Edge cases around empty sets / empty strings
162
166
a = New [string ]()
163
167
b = New [string ]()
@@ -369,3 +373,32 @@ func clearSetAndAdd[T ordered](s Set[T], a T) {
369
373
s .Clear ()
370
374
s .Insert (a )
371
375
}
376
+
377
+ func TestPopAny (t * testing.T ) {
378
+ a := New [string ]("1" , "2" )
379
+ _ , popped := a .PopAny ()
380
+ if ! popped {
381
+ t .Errorf ("got len(%d): wanted 1" , a .Len ())
382
+ }
383
+ _ , popped = a .PopAny ()
384
+ if ! popped {
385
+ t .Errorf ("got len(%d): wanted 0" , a .Len ())
386
+ }
387
+ zeroVal , popped := a .PopAny ()
388
+ if popped {
389
+ t .Errorf ("got len(%d): wanted 0" , a .Len ())
390
+ }
391
+ if zeroVal != "" {
392
+ t .Errorf ("should have gotten zero value when popping an empty set" )
393
+ }
394
+ }
395
+
396
+ func TestClone (t * testing.T ) {
397
+ a := New [string ]("1" , "2" )
398
+ a .Insert ("3" )
399
+
400
+ got := a .Clone ()
401
+ if ! reflect .DeepEqual (got , a ) {
402
+ t .Errorf ("Expected to be equal: %v vs %v" , got , a )
403
+ }
404
+ }
0 commit comments