src/server/test/vfs.c

changeset 579
e10457d74fe1
parent 490
d218607f5a7e
equal deleted inserted replaced
578:eb48f716b31c 579:e10457d74fe1
54 } TestVFSFile; 54 } TestVFSFile;
55 55
56 typedef struct TestVFSDir { 56 typedef struct TestVFSDir {
57 VFSDir dir; 57 VFSDir dir;
58 TestVFSFile *file; 58 TestVFSFile *file;
59 CxIterator i; 59 CxMapIterator i;
60 cxmutstr name; 60 cxmutstr name;
61 } TestVFSDir; 61 } TestVFSDir;
62 62
63 /* dir io */ 63 /* dir io */
64 64
319 319
320 if(!dir->isdir) { 320 if(!dir->isdir) {
321 return 1; 321 return 1;
322 } 322 }
323 323
324 CxIterator i = cxMapIteratorValues(vfs->files); 324 CxMapIterator i = cxMapIteratorValues(vfs->files);
325 cx_foreach(TestVFSFile *, f, i) { 325 cx_foreach(TestVFSFile *, f, i) {
326 if(f->path.length > dir->path.length && cx_strprefix(cx_strcast(f->path), cx_strcast(dir->path))){ 326 if(f->path.length > dir->path.length && cx_strprefix(cx_strcast(f->path), cx_strcast(dir->path))){
327 return 1; // dir not empty 327 return 1; // dir not empty
328 } 328 }
329 } 329 }
452 VFSEntry entry; 452 VFSEntry entry;
453 while(vfs_readdir(dir, &entry)) { 453 while(vfs_readdir(dir, &entry)) {
454 cxMapPut(files, cx_hash_key_str(entry.name), dir); 454 cxMapPut(files, cx_hash_key_str(entry.name), dir);
455 } 455 }
456 456
457 UCX_TEST_ASSERT(files->size == 4, "wrong files count"); 457 UCX_TEST_ASSERT(cxMapSize(files)== 4, "wrong files count");
458 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file1")), "file1 missing"); 458 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file1")), "file1 missing");
459 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file2")), "file2 missing"); 459 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file2")), "file2 missing");
460 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file3")), "file3 missing"); 460 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file3")), "file3 missing");
461 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file4")), "file4 missing"); 461 UCX_TEST_ASSERT(cxMapGet(files, cx_hash_key_str("file4")), "file4 missing");
462 462
463 cxMapDestroy(files); 463 cxMapFree(files);
464 464
465 UCX_TEST_END; 465 UCX_TEST_END;
466 466
467 testutil_destroy_session(sn); 467 testutil_destroy_session(sn);
468 } 468 }

mercurial