@@ -2732,8 +2732,6 @@ func TestFromBitSet(t *testing.T) {
27322732func TestRoaringArrayValidation (t * testing.T ) {
27332733 a := newRoaringArray ()
27342734
2735- assert .ErrorIs (t , a .validate (), ErrEmptyKeys )
2736-
27372735 a .keys = append (a .keys , uint16 (3 ), uint16 (1 ))
27382736 assert .ErrorIs (t , a .validate (), ErrKeySortOrder )
27392737 a .clear ()
@@ -2744,7 +2742,7 @@ func TestRoaringArrayValidation(t *testing.T) {
27442742 a .containers = append (a .containers , & runContainer16 {}, & runContainer16 {}, & runContainer16 {})
27452743 assert .ErrorIs (t , a .validate (), ErrCardinalityConstraint )
27462744 a .needCopyOnWrite = append (a .needCopyOnWrite , true , false , true )
2747- assert .Errorf (t , a .validate (), "zero intervals" )
2745+ assert .ErrorIs (t , a .validate (), ErrRunIntervalsEmpty )
27482746}
27492747
27502748func TestBitMapValidation (t * testing.T ) {
@@ -2805,11 +2803,9 @@ func TestBitMapValidationFromDeserialization(t *testing.T) {
28052803 bm .AddRange (100 , 110 )
28062804 },
28072805 corruptor : func (s []byte ) {
2808- // 13 is the length of the run
2809- // Setting to zero causes an invalid run
28102806 s [13 ] = 0
28112807 },
2812- err : ErrRunIntervalLength ,
2808+ err : ErrRunIntervalSize ,
28132809 },
28142810 {
28152811 name : "Creates Interval Overlap" ,
@@ -3310,3 +3306,59 @@ func TestIssue467CaseLarge(t *testing.T) {
33103306 b .RunOptimize ()
33113307 require .NoError (t , b .Validate ())
33123308}
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