aboutsummaryrefslogtreecommitdiff
path: root/test_brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-11-01 13:16:41 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-11-01 13:16:41 +0100
commit44079d5cbbab5eeea367e9420b29c5b6f48eede8 (patch)
treeba89ccb0855b7200712b5797de2ca692db7c3766 /test_brandt.c
parente98bb69ce22f1b8680feaf163e34d9a8734652cc (diff)
downloadlibbrandt-44079d5cbbab5eeea367e9420b29c5b6f48eede8.tar.gz
libbrandt-44079d5cbbab5eeea367e9420b29c5b6f48eede8.zip
handle n <= m case in m+1st price auctions
The lowest possible price from the price map will be the price each bidder has to pay. Since the seller can define the price map, he can set the lowest price to the lowest he is willing to sell one item at.
Diffstat (limited to 'test_brandt.c')
-rw-r--r--test_brandt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test_brandt.c b/test_brandt.c
index 1fb985c..46ec90d 100644
--- a/test_brandt.c
+++ b/test_brandt.c
@@ -84,6 +84,29 @@ expected_outcome (uint16_t i)
84 return ret; 84 return ret;
85 } 85 }
86 86
87 /* fewer bidders than needed -> everyone wins with lowest price */
88 if (tcase.n <= tcase.m)
89 {
90 if (tcase.outcome_public || i == tcase.n)
91 {
92 ret = GNUNET_new_array (tcase.n, struct BRANDT_Result);
93 for (uint16_t h = 0; h < tcase.n; h++)
94 {
95 ret[h].bidder = h;
96 ret[h].price = 0;
97 ret[h].status = BRANDT_bidder_won;
98 }
99 }
100 else
101 {
102 ret = GNUNET_new (struct BRANDT_Result);
103 ret->bidder = i;
104 ret->price = 0;
105 ret->status = BRANDT_bidder_won;
106 }
107 return ret;
108 }
109
87 /* find M+1st highest bidder to determine selling price */ 110 /* find M+1st highest bidder to determine selling price */
88 for (uint16_t h = 0; h < tcase.n; h++) 111 for (uint16_t h = 0; h < tcase.n; h++)
89 if (tcase.bids[h] > mpf_highest_bid) 112 if (tcase.bids[h] > mpf_highest_bid)
@@ -387,6 +410,9 @@ main (int argc, char *argv[])
387 test_auction (0, 2, NULL, 0, 1) || 410 test_auction (0, 2, NULL, 0, 1) ||
388 test_auction (0, 2, NULL, 1, 0) || 411 test_auction (0, 2, NULL, 1, 0) ||
389 test_auction (0, 2, NULL, 2, 0) || 412 test_auction (0, 2, NULL, 2, 0) ||
413 test_auction (1, 2, (uint16_t[]) { 1 }, 1, 0) ||
414 test_auction (1, 2, (uint16_t[]) { 0 }, 2, 0) ||
415 test_auction (2, 2, (uint16_t[]) { 1, 0 }, 2, 0) ||
390 test_auction (2, 2, (uint16_t[]) { 1, 0 }, 1, 0) || 416 test_auction (2, 2, (uint16_t[]) { 1, 0 }, 1, 0) ||
391 test_auction (3, 2, (uint16_t[]) { 0, 0, 1 }, 2, 0) || 417 test_auction (3, 2, (uint16_t[]) { 0, 0, 1 }, 2, 0) ||
392 test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 0, 0) || 418 test_auction (3, 2, (uint16_t[]) { 0, 1, 1 }, 0, 0) ||