|
Revision 425, 0.9 kB
(checked in by vbarta, 16 years ago)
|
|
moved logger test to testsuite, updated logger docs (a bit)
|
-
Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 | #define BDMLIB // not an ideal way to prevent double registration of UI factories... |
|---|
| 2 | #include "base/loggers.h" |
|---|
| 3 | #include "test_util.h" |
|---|
| 4 | #include "UnitTest++.h" |
|---|
| 5 | #include <string> |
|---|
| 6 | #include <sys/stat.h> |
|---|
| 7 | #include <sys/types.h> |
|---|
| 8 | |
|---|
| 9 | using namespace bdm; |
|---|
| 10 | |
|---|
| 11 | TEST(test_dirfilelog) |
|---|
| 12 | { |
|---|
| 13 | RV th = RV("{alog blog }"); |
|---|
| 14 | RV r = RV("{r }", "2"); |
|---|
| 15 | |
|---|
| 16 | if (mkdir("exp", 0777)) { |
|---|
| 17 | remove_all("exp/dirfile"); |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | dirfilelog L("exp/dirfile", 10); |
|---|
| 21 | |
|---|
| 22 | int rid; |
|---|
| 23 | int thid; |
|---|
| 24 | |
|---|
| 25 | rid = L.add(r, ""); |
|---|
| 26 | thid = L.add(th, "th"); |
|---|
| 27 | |
|---|
| 28 | L.init(); |
|---|
| 29 | |
|---|
| 30 | for (int i = 0; i < 150; i++) { |
|---|
| 31 | L.logit(rid, vec_2((double)i, (double)(i + 1))); |
|---|
| 32 | L.logit(thid, vec_2((double)(100 - i), (double)(i - 50))); |
|---|
| 33 | L.step(); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | L.finalize(); |
|---|
| 37 | |
|---|
| 38 | std::string expected(load_test_file("dirfile-format.matrix")); |
|---|
| 39 | std::string actual(load_test_file("exp/dirfile/format")); |
|---|
| 40 | CHECK_EQUAL(expected, actual); |
|---|
| 41 | } |
|---|