@@ -2732,8 +2732,6 @@ func TestFromBitSet(t *testing.T) {
2732
2732
func TestRoaringArrayValidation (t * testing.T ) {
2733
2733
a := newRoaringArray ()
2734
2734
2735
- assert .ErrorIs (t , a .validate (), ErrEmptyKeys )
2736
-
2737
2735
a .keys = append (a .keys , uint16 (3 ), uint16 (1 ))
2738
2736
assert .ErrorIs (t , a .validate (), ErrKeySortOrder )
2739
2737
a .clear ()
@@ -2744,7 +2742,7 @@ func TestRoaringArrayValidation(t *testing.T) {
2744
2742
a .containers = append (a .containers , & runContainer16 {}, & runContainer16 {}, & runContainer16 {})
2745
2743
assert .ErrorIs (t , a .validate (), ErrCardinalityConstraint )
2746
2744
a .needCopyOnWrite = append (a .needCopyOnWrite , true , false , true )
2747
- assert .Errorf (t , a .validate (), "zero intervals" )
2745
+ assert .ErrorIs (t , a .validate (), ErrRunIntervalsEmpty )
2748
2746
}
2749
2747
2750
2748
func TestBitMapValidation (t * testing.T ) {
@@ -2805,11 +2803,9 @@ func TestBitMapValidationFromDeserialization(t *testing.T) {
2805
2803
bm .AddRange (100 , 110 )
2806
2804
},
2807
2805
corruptor : func (s []byte ) {
2808
- // 13 is the length of the run
2809
- // Setting to zero causes an invalid run
2810
2806
s [13 ] = 0
2811
2807
},
2812
- err : ErrRunIntervalLength ,
2808
+ err : ErrRunIntervalSize ,
2813
2809
},
2814
2810
{
2815
2811
name : "Creates Interval Overlap" ,
@@ -3310,3 +3306,59 @@ func TestIssue467CaseLarge(t *testing.T) {
3310
3306
b .RunOptimize ()
3311
3307
require .NoError (t , b .Validate ())
3312
3308
}
3309
+
3310
+ func TestValidateEmpty (t * testing.T ) {
3311
+ require .NoError (t , New ().Validate ())
3312
+ }
3313
+
3314
+ func TestValidate469 (t * testing.T ) {
3315
+ b := New ()
3316
+ b .RemoveRange (0 , 180 )
3317
+ b .AddRange (0 , 180 )
3318
+ require .NoError (t , b .Validate ())
3319
+ b .RemoveRange (180 , 217 )
3320
+ b .AddRange (180 , 217 )
3321
+ require .NoError (t , b .Validate ())
3322
+ b .RemoveRange (217 , 2394 )
3323
+ b .RemoveRange (2394 , 2427 )
3324
+ b .AddRange (2394 , 2427 )
3325
+ require .NoError (t , b .Validate ())
3326
+ b .RemoveRange (2427 , 2428 )
3327
+ b .AddRange (2427 , 2428 )
3328
+ require .NoError (t , b .Validate ())
3329
+ b .RemoveRange (2428 , 3345 )
3330
+ require .NoError (t , b .Validate ())
3331
+ b .RemoveRange (3345 , 3346 )
3332
+ require .NoError (t , b .Validate ())
3333
+ b .RemoveRange (3346 , 3597 )
3334
+ require .NoError (t , b .Validate ())
3335
+ b .RemoveRange (3597 , 3815 )
3336
+ require .NoError (t , b .Validate ())
3337
+ b .RemoveRange (3815 , 3816 )
3338
+ require .NoError (t , b .Validate ())
3339
+ b .AddRange (3815 , 3816 )
3340
+ require .NoError (t , b .Validate ())
3341
+ b .RemoveRange (3816 , 3856 )
3342
+ b .RemoveRange (3856 , 4067 )
3343
+ b .RemoveRange (4067 , 4069 )
3344
+ b .RemoveRange (4069 , 4071 )
3345
+ b .RemoveRange (4071 , 4095 )
3346
+ b .RemoveRange (4095 , 4096 )
3347
+ require .NoError (t , b .Validate ())
3348
+ b .RunOptimize ()
3349
+ require .False (t , b .IsEmpty ())
3350
+ require .NoError (t , b .Validate ())
3351
+ }
3352
+
3353
+ func TestValidateFromV1 (t * testing.T ) {
3354
+ v1 := New ()
3355
+ for i := 0 ; i <= 2 ; i ++ {
3356
+ v1 .Add (uint32 (i ))
3357
+ }
3358
+ v1 .RunOptimize ()
3359
+ b , err := v1 .MarshalBinary ()
3360
+ require .NoError (t , err )
3361
+ v2 := New ()
3362
+ require .NoError (t , v2 .UnmarshalBinary (b ))
3363
+ require .NoError (t , v2 .Validate ())
3364
+ }
0 commit comments