jbm: it compiles... but bombs in unit tests
5 * Created by Jens Alfke on 9/12/09.
6 * Copyright 2009 Jens Alfke. All rights reserved.
7 * BSD-Licensed: See the file "LICENSE.txt" for details.
10 #include "TestUtils.h"
18 std::ostream& operator<< (std::ostream &out, const Blob &blob) {
19 char str[blob.length+1];
20 memcpy(str,blob.bytes,blob.length);
26 void shuffle(int a[], int n, unsigned seed) {
33 fprintf(stderr,"shuffle(n=%i, seed=%u)\n", n,seed);
35 for (int i=0; i<n-1; i++) {
36 int j = i + (random() % (n-i));
48 sWords = new char*[250000];
51 FILE *in = fopen("/usr/share/dict/words", "r");
54 while (NULL != ::fgets(word, 4096, in)) {
55 wordLen = ::strlen(word);
56 if (word[wordLen-1]=='\n') {
57 word[wordLen-1] = '\0';
61 if (wordLen == 0) continue;
63 sWords[sNWords] = strdup(word);
64 //if( sNWords % 10000 == 0)
65 // printf("'%s' ... ", sWords[sNWords]->string());
74 Timer::Timer (const char *operation, int divisor) {
75 _operation = operation;
82 double elapsedCPU = (clock() - _cpuTime) / 1.0e6;
83 double elapsed = now() - _time;
84 printf("### %s took %.6lf sec (used %.6lf sec CPU)", _operation, elapsed, elapsedCPU);
86 printf(" ... per item: %.3lf usec, %.3lf usec CPU", elapsed/_divisor*1e6, elapsedCPU/_divisor*1e6);
92 gettimeofday(&t,NULL);
93 return (double)t.tv_sec + t.tv_usec/1.0e6;
99 using namespace Mooseyard;
101 int main(int argc, char **argv) {
106 ::testing::InitGoogleTest(&argc, argv);
107 return RUN_ALL_TESTS();
108 } catch (const File::Error &err) {
109 fprintf(stderr, "\n*** File::Error thrown: %i/%s\n", err.code,err.message);