| 2959 | } |
| 2960 | |
| 2961 | func TestStats(t *testing.T) { |
| 2962 | t.Run("Test Stats with empty bitmap", func(t *testing.T) { |
| 2963 | expectedStats := Statistics{} |
| 2964 | rr := NewBitmap() |
| 2965 | |
| 2966 | assert.EqualValues(t, expectedStats, rr.Stats()) |
| 2967 | }) |
| 2968 | |
| 2969 | t.Run("Test Stats with bitmap Container", func(t *testing.T) { |
| 2970 | // Given a bitmap that should have a single bitmap container |
| 2971 | expectedStats := Statistics{ |
| 2972 | Cardinality: 60000, |
| 2973 | Containers: 1, |
| 2974 | |
| 2975 | BitmapContainers: 1, |
| 2976 | BitmapContainerValues: 60000, |
| 2977 | BitmapContainerBytes: 8192, |
| 2978 | |
| 2979 | RunContainers: 0, |
| 2980 | RunContainerBytes: 0, |
| 2981 | RunContainerValues: 0, |
| 2982 | } |
| 2983 | |
| 2984 | rr := NewBitmap() |
| 2985 | |
| 2986 | for i := uint32(0); i < 60000; i++ { |
| 2987 | rr.Add(i) |
| 2988 | } |
| 2989 | |
| 2990 | assert.EqualValues(t, expectedStats, rr.Stats()) |
| 2991 | }) |
| 2992 | |
| 2993 | t.Run("Test Stats with Array Container", func(t *testing.T) { |
| 2994 | // Given a bitmap that should have a single array container |
| 2995 | expectedStats := Statistics{ |
| 2996 | Cardinality: 2, |
| 2997 | Containers: 1, |
| 2998 | |
| 2999 | ArrayContainers: 1, |
| 3000 | ArrayContainerValues: 2, |
| 3001 | ArrayContainerBytes: 4, |
| 3002 | } |
| 3003 | rr := NewBitmap() |
| 3004 | rr.Add(2) |
| 3005 | rr.Add(4) |
| 3006 | |
| 3007 | assert.EqualValues(t, expectedStats, rr.Stats()) |
| 3008 | }) |
| 3009 | } |
| 3010 | |
| 3011 | func TestFlipVerySmall(t *testing.T) { |
| 3012 | rb := NewBitmap() |