Improve consistency tests.

This commit is contained in:
Philippe PITTOLI 2024-05-22 17:36:45 +02:00
parent 7272b9fe6f
commit 5a6a3abc2c
2 changed files with 17 additions and 7 deletions

View File

@ -25,12 +25,12 @@ class Car
] ]
# Equality is true if every property is identical. # Equality is true if every property is identical.
def ==(other) def ==(other : Car)
@name == other.name && @color == other.color && @keywords == other.keywords @name == other.name && @color == other.color && @keywords == other.keywords
end end
# Equality is true if every property is identical. # Equality is true if every property is identical.
def <=>(other) def <=>(other : Car)
@name <=> other.name @name <=> other.name
end end
end end
@ -96,6 +96,7 @@ def add_cars(storage : DODB::Storage, nb_iterations : Int32, max_indexes = 5000)
storage.unsafe_add car3.clone storage.unsafe_add car3.clone
storage.unsafe_add car4.clone storage.unsafe_add car4.clone
storage.unsafe_add car5.clone storage.unsafe_add car5.clone
i += 1 i += 1
#STDOUT.write "\radding value #{i}".to_slice #STDOUT.write "\radding value #{i}".to_slice
end end

View File

@ -57,25 +57,34 @@ describe "tracking inconsistencies between implementations" do
# Searches should be consistent between all implementations of basic indexes, partitions and tags. # Searches should be consistent between all implementations of basic indexes, partitions and tags.
# Basic index. # Basic index.
uncached_corvet_car = uncached_searchby_color.get_with_keys? "Corvet-0" uncached_corvet_car = uncached_searchby_name.get? "Corvet-0"
cached_corvet_car = cached_searchby_color.get_with_keys? "Corvet-0" cached_corvet_car = cached_searchby_name.get? "Corvet-0"
ram_corvet_car = ram_searchby_color.get_with_keys? "Corvet-0" ram_corvet_car = ram_searchby_name.get? "Corvet-0"
uncached_corvet_car.should eq cached_corvet_car uncached_corvet_car.should eq cached_corvet_car
uncached_corvet_car.should eq ram_corvet_car uncached_corvet_car.should eq ram_corvet_car
uncached_corvet_car.should eq corvet0
# Partitions. # Partitions.
red_cars = [ Car.new("Corvet-0", "red", [ "shiny", "impressive", "fast", "elegant" ]),
Car.new("Ford-5-0", "red", [ "unknown" ])
]
uncached_red_cars = uncached_searchby_color.get? "red" uncached_red_cars = uncached_searchby_color.get? "red"
cached_red_cars = cached_searchby_color.get? "red" cached_red_cars = cached_searchby_color.get? "red"
ram_red_cars = ram_searchby_color.get? "red" ram_red_cars = ram_searchby_color.get? "red"
uncached_red_cars.sort.should eq cached_red_cars.sort uncached_red_cars.sort.should eq cached_red_cars.sort
uncached_red_cars.sort.should eq ram_red_cars.sort uncached_red_cars.sort.should eq ram_red_cars.sort
uncached_red_cars.sort.should eq red_cars.sort
# Tags. # Tags.
fast_cars = [ Car.new("Corvet-0", "red", [ "shiny", "impressive", "fast", "elegant" ]),
Car.new("Bullet-GT-0", "blue", [ "shiny", "fast", "expensive" ])
]
uncached_fast_cars = uncached_searchby_keywords.get? "fast" uncached_fast_cars = uncached_searchby_keywords.get? "fast"
cached_fast_cars = cached_searchby_keywords.get? "fast" cached_fast_cars = cached_searchby_keywords.get? "fast"
ram_fast_cars = ram_searchby_keywords.get? "fast" ram_fast_cars = ram_searchby_keywords.get? "fast"
uncached_fast_cars.sort.should eq cached_fast_cars.sort uncached_fast_cars.sort.should eq cached_fast_cars.sort
uncached_fast_cars.sort.should eq ram_fast_cars.sort uncached_fast_cars.sort.should eq ram_fast_cars.sort
uncached_fast_cars.sort.should eq fast_cars.sort
cars_ram0.rm_storage_dir cars_ram0.rm_storage_dir
cars_ram1.rm_storage_dir cars_ram1.rm_storage_dir