| 31 | |
| 32 | |
| 33 | int ACE_TMAIN(int, ACE_TCHAR*[]) |
| 34 | { |
| 35 | using namespace OpenDDS::FileSystemStorage; |
| 36 | |
| 37 | bool ok(true); |
| 38 | |
| 39 | // From RFC 4648 |
| 40 | ok &= encode_test("", ""); |
| 41 | ok &= encode_test("f", "CO======"); |
| 42 | ok &= encode_test("fo", "CPNG===="); |
| 43 | ok &= encode_test("foo", "CPNMU==="); |
| 44 | ok &= encode_test("foob", "CPNMUOG="); |
| 45 | ok &= encode_test("fooba", "CPNMUOJ1"); |
| 46 | ok &= encode_test("foobar", "CPNMUOJ1E8======"); |
| 47 | |
| 48 | ok &= encode_test("The[quIck]brOwn-fox?jumPes\\oVer The/lazy dog!", |
| 49 | "AHK6AMRHEL4M6QQTC9P4UTRE5LJ6UU1VD9QMQK35EDE6ULJ5E8G58Q355TM62UJP41I6UPP1"); |
| 50 | //^-> verified with Tcl's Base32hex encoder |
| 51 | |
| 52 | const char big_name[] = |
| 53 | "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod " |
| 54 | "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim " |
| 55 | "veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea " |
| 56 | "commodo consequat. Duis aute irure dolor in reprehenderit in voluptate " |
| 57 | "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint " |
| 58 | "occaecat cupidatat non proident, sunt in culpa qui officia deserunt " |
| 59 | "mollit anim id est laborum."; |
| 60 | |
| 61 | ACE_DEBUG((LM_DEBUG, "Testing file and directory operations...\n")); |
| 62 | try |
| 63 | { |
| 64 | std::vector<std::string> path; |
| 65 | path.push_back("subdir2"); |
| 66 | path.push_back("subsubdir"); |
| 67 | { |
| 68 | Directory::Ptr d = Directory::create("test"); |
| 69 | Directory::Ptr d2 = d->get_subdir(big_name); |
| 70 | { |
| 71 | File::Ptr f1 = d->get_file("00my/file"); |
| 72 | std::ofstream os; |
| 73 | if (!f1->write(os)) |
| 74 | throw std::runtime_error("Can't write"); |
| 75 | os << "Hello world.\n"; |
| 76 | } |
| 77 | for (int i(0); i < OPENDDS_FILESYSTEMSTORAGE_MAX_FILES_PER_DIR * 2; ++i) |
| 78 | { |
| 79 | std::ostringstream fname; |
| 80 | fname << "File" << i; |
| 81 | d->get_file(fname.str().c_str()); |
| 82 | } |
| 83 | Directory::Ptr subdir2 = d->get_subdir(path[0].c_str()); |
| 84 | Directory::Ptr d3 = subdir2->create_next_dir(); |
| 85 | if (d3->parent() != subdir2) |
| 86 | throw std::runtime_error("parent is inconsistent"); |
| 87 | d3->create_next_file(); |
| 88 | File::Ptr f2 = subdir2->get_subdir(path[1].c_str())->get_file("foo"); |
| 89 | std::ofstream os2; |
| 90 | if (!f2->write(os2)) |
nothing calls this directly
no test coverage detected