swgen.cpp 697 B

123456789101112131415161718192021222324
  1. /*
  2. * Outputs random token.
  3. *
  4. * Token contains latin letters and digits and have length
  5. * between 1 and 1000 characters, inclusive.
  6. *
  7. * To generate different values, call "swgen.exe <weight>".
  8. * See "iwgen.cpp" and "wnext()" documentation for details.
  9. * For example, "swgen.exe -1000" generates short strings and "swgen.exe 1000"
  10. * generates long strings.
  11. *
  12. * It is typical behaviour of testlib generator to setup randseed by command line.
  13. */
  14. #include "testlib.h"
  15. using namespace std;
  16. int main(int argc, char *argv[]) {
  17. registerGen(argc, argv, 1);
  18. int length = rnd.wnext(1, 1000, opt<int>(1));
  19. println(rnd.next("[a-zA-Z0-9]{1,%d}", length));
  20. }