* Merged in jbm's changes for Linux compatibility, fixing Mac compatibility in the process :)
* Fixed two regressions having to do with the _previousTrailerPosition in VersionDictionary.cpp.
* Made sure RTTI is enabled in the OttomanTest target because gtest requires it.
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) {
28 #ifdef _DARWIN_C_SOURCE
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 sWords[sNWords++] = strdup(word);
69 Timer::Timer (const char *operation, int divisor) {
70 _operation = operation;
77 double elapsedCPU = (clock() - _cpuTime) / 1.0e6;
78 double elapsed = now() - _time;
79 printf("### %s took %.6lf sec (used %.6lf sec CPU)", _operation, elapsed, elapsedCPU);
81 printf(" ... per item: %.3lf usec, %.3lf usec CPU", elapsed/_divisor*1e6, elapsedCPU/_divisor*1e6);
87 gettimeofday(&t,NULL);
88 return (double)t.tv_sec + t.tv_usec/1.0e6;
94 using namespace Mooseyard;
96 int main(int argc, char **argv) {
97 #ifdef _DARWIN_C_SOURCE
101 ::testing::InitGoogleTest(&argc, argv);
102 return RUN_ALL_TESTS();
103 } catch (const File::Error &err) {
104 fprintf(stderr, "\n*** File::Error thrown: %i/%s\n", err.code,err.message);