-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for distribution utility and fix loose ends
- Loading branch information
1 parent
1a70ac7
commit 6249078
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*++ | ||
Copyright (c) 2023 Microsoft Corporation | ||
Module Name: | ||
distribution.cpp | ||
Abstract: | ||
Test distribution | ||
Author: | ||
Nikolaj Bjorner (nbjorner) 2023-04-13 | ||
--*/ | ||
#include "util/distribution.h" | ||
#include <iostream> | ||
|
||
static void tst1() { | ||
distribution dist(1); | ||
dist.push(1, 3); | ||
dist.push(2, 1); | ||
dist.push(3, 1); | ||
dist.push(4, 1); | ||
|
||
unsigned counts[4] = { 0, 0, 0, 0 }; | ||
for (unsigned i = 0; i < 1000; ++i) | ||
counts[dist.choose()-1]++; | ||
for (unsigned i = 1; i <= 4; ++i) | ||
std::cout << "count " << i << ": " << counts[i-1] << "\n"; | ||
|
||
for (unsigned i = 0; i < 5; ++i) { | ||
std::cout << "enum "; | ||
for (auto j : dist) | ||
std::cout << j << " "; | ||
std::cout << "\n"; | ||
} | ||
|
||
} | ||
|
||
void tst_distribution() { | ||
tst1(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,4 +264,5 @@ int main(int argc, char ** argv) { | |
//TST_ARGV(hs); | ||
TST(finder); | ||
TST(totalizer); | ||
TST(distribution); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters