Ex02 Task 2.1: idsAreUnique

Moderatoren: pmueller, SE - Design and Construction

GS-812
Windoof-User
Windoof-User
Beiträge: 30
Registriert: 25. Apr 2015 12:47

Ex02 Task 2.1: idsAreUnique

Beitrag von GS-812 » 9. Nov 2017 08:59

Hi,

how should we do
no id is returned more than once (name of the test method: idsAreUnique)
?

Are testing 1.000.000 calls enough?
This function will fail as the numbers can not be increased infinitely.

Should the test work only in this case.
Generally solutions with storing all results will fail because of storage/heap/memory overflow depending on the number of calls.
Specific solutions may take a long time.

Here would be a proof good which is saying it would not fail for infinite data types.

GS-812
Windoof-User
Windoof-User
Beiträge: 30
Registriert: 25. Apr 2015 12:47

Re: Ex02 Task 2.1: idsAreUnique

Beitrag von GS-812 » 9. Nov 2017 09:10

Test independing from the generation function.

10 million iterations:
10m.PNG
10m.PNG (7.34 KiB) 553 mal betrachtet


using 1 million iteration it takes only ~ 160 ms

eichberg
Moderator
Moderator
Beiträge: 448
Registriert: 25. Sep 2007 12:12
Kontaktdaten:

Re: Ex02 Task 2.1: idsAreUnique

Beitrag von eichberg » 9. Nov 2017 09:15

This test was originally intended to test that - if we have concurrent access to the „id generator“ - no id is returned twice due to a concurrency bug. However, we explicility dropped the requirement that you should think about concurrency. Therefore „just“ test for the case that there is some (externally given) natural upper bound for the number of unique ids. You can assume for this test that this number is larger than 1 and below 100..

Besides you definitively identified a critial point that „just testing the ids are unique“ is not possible (you won‘t even be able to prove it!).

Btw. Technically Ints can be increased infinitely - they just overflow - there will be no exception or something like that.

GS-812
Windoof-User
Windoof-User
Beiträge: 30
Registriert: 25. Apr 2015 12:47

Re: Ex02 Task 2.1: idsAreUnique

Beitrag von GS-812 » 9. Nov 2017 09:23

Btw. Technically Ints can be increased infinitely - they just overflow - there will be no exception or something like that.
Yes, but it will not unique any more ;-)

0b101101101
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 179
Registriert: 15. Apr 2015 18:24

Re: Ex02 Task 2.1: idsAreUnique

Beitrag von 0b101101101 » 9. Nov 2017 14:45

Actually I thought at first the test is supposed to fail, because of overflows... :)
But I understand, we should only test for a small number of ids, Ok.

Edit: Ah. It seems, I overloooked: "... and do not worry about overflow of int values" in the original assignment.

Antworten

Zurück zu „Software Engineering - Design and Construction“