int main() { PASSFAIL(spsc_new_pass()); PASSFAIL(spsc_new_fail()); PASSFAIL(spsc_trypush_slot_pass()); PASSFAIL(spsc_trypop_slot_pass()); return 0; }
int main(int argc, char **argv) { printf("fsPathExists 0 : %s\n", PASSFAIL(fsPathExists("/") == true)); printf("fsPathExists 1 : %s\n", PASSFAIL(fsPathExists("/fakePath") == false)); char *pathTestFile = "fileSystem.test.file"; char *pathTestDir = "fileSystem.test.dir" ; fsFileDelete(pathTestFile, NULL, NULL); //don't care... printf("fsPathExists 2 : %s\n", PASSFAIL(fsPathExists(pathTestFile) == false)); printf("fsPathIsFile 3 : %s\n", PASSFAIL(fsPathIsFile(pathTestFile) == false)); printf("fsFileCreate 4 : %s\n", PASSFAIL(fsFileCreate(pathTestFile, NULL, NULL) == true)); printf("fsPathExists 5 : %s\n", PASSFAIL(fsPathExists(pathTestFile) == true)); printf("fsPathIsFile 6 : %s\n", PASSFAIL(fsPathIsFile(pathTestFile) == true)); printf("fsPathIsDirectory 7 : %s\n", PASSFAIL(fsPathIsDirectory(pathTestFile) == false)); printf("fsFileMove 8 : %s\n", PASSFAIL(fsFileMove(pathTestFile, "fileSystem.file.test", NULL, NULL) == true)); printf("fsPathIsFile 9 : %s\n", PASSFAIL(fsPathIsFile(pathTestFile) == false)); printf("fsPathIsFile 10 : %s\n", PASSFAIL(fsPathIsFile("fileSystem.file.test") == true)); printf("fsFileMove 11 : %s\n", PASSFAIL(fsFileMove("fileSystem.file.test", pathTestFile, NULL, NULL) == true)); printf("fsPathIsFile 12 : %s\n", PASSFAIL(fsPathIsFile(pathTestFile) == true)); printf("fsPathIsFile 13 : %s\n", PASSFAIL(fsPathIsFile("fileSystem.file.test") == false)); fsDirectoryDelete(pathTestDir, NULL, NULL); //don't care printf("fsPathExists 14 : %s\n", PASSFAIL(fsPathExists(pathTestDir) == false)); printf("fsPathIsDirectory 15 : %s\n", PASSFAIL(fsPathIsDirectory(pathTestDir) == false)); printf("fsDirectoryCreate 16 : %s\n", PASSFAIL(fsDirectoryCreate(pathTestDir, NULL, NULL) == true)); printf("fsPathExists 17 : %s\n", PASSFAIL(fsPathExists(pathTestDir) == true)); printf("fsPathIsDirectory 18 : %s\n", PASSFAIL(fsPathIsDirectory(pathTestDir) == true)); printf("fsPathIsFile 19 : %s\n", PASSFAIL(fsPathIsFile(pathTestDir) == false)); printf("fsDirectoryMove 20 : %s\n", PASSFAIL(fsDirectoryMove(pathTestDir, "fileSystem.dir.test", NULL, NULL) == true)); printf("fsPathIsDirectory 21 : %s\n", PASSFAIL(fsPathIsDirectory(pathTestDir) == false)); printf("fsPathIsDirectory 22 : %s\n", PASSFAIL(fsPathIsDirectory("fileSystem.dir.test") == true)); printf("fsDirectoryMove 23 : %s\n", PASSFAIL(fsDirectoryMove("fileSystem.dir.test", pathTestDir, NULL, NULL) == true)); printf("fsPathIsDirectory 24 : %s\n", PASSFAIL(fsPathIsDirectory(pathTestDir) == true)); printf("fsPathIsDirectory 25 : %s\n", PASSFAIL(fsPathIsDirectory("fileSystem.dir.test") == false)); char *cwd = fsPathCurrent(), *home = fsPathHome(); printf("fsPathCurrent 26 : %s\n", cwd); printf("fsPathHome 27 : %s\n", home); char *base = fsPathBase(cwd), *parent = fsPathParent(cwd); printf("fsPathBase 28 : %s\n", base); printf("fsPathParent 29 : %s\n", parent); char *normal; normal = fsPathNormalize("test/bin"); printf("fsPathNormalize 30 : %s\n", normal); free(normal); normal = fsPathNormalize("./test/bin"); printf("fsPathNormalize 31 : %s\n", normal); free(normal); normal = fsPathNormalize("~/test/bin"); printf("fsPathNormalize 32 : %s\n", normal); free(normal); normal = fsPathNormalize("~"); printf("fsPathNormalize 33 : %s\n", PASSFAIL(strcmp(normal, home) == 0)); free(normal); normal = fsPathNormalize("/"); printf("fsPathNormalize 34 : %s\n", PASSFAIL(strcmp(normal, "/" ) == 0)); free(normal); normal = fsPathNormalize("/test1/test1/test1/.././../test2/./test3"); printf("fsPathNormalize 35 : %s\n", PASSFAIL(strcmp(normal, "/test1/test2/test3") == 0)); free(normal); free(cwd); free(home); free(base); free(parent); char *rwTestData = "Hello\nfileSystem\r\nWord!"; u32 rwTestLength = strlen(rwTestData); printf("fsFileSize 36 : %s\n", PASSFAIL(fsFileSize(pathTestFile) == 0)); printf("fsFileWrite 37 : %s\n", PASSFAIL(fsFileWrite(pathTestFile, rwTestData, rwTestLength, NULL, NULL) == true)); printf("fsFileSize 38 : %s\n", PASSFAIL(fsFileSize(pathTestFile) == rwTestLength)); char *rwTestBuff = fsFileRead(pathTestFile, NULL, NULL); printf("fsFileRead 39 : %s\n", PASSFAIL(strncmp(rwTestData, rwTestBuff, rwTestLength) == 0)); free(rwTestBuff); printf("fsFileDelete 40 : %s\n", PASSFAIL(fsFileDelete(pathTestFile, NULL, NULL) == true)); printf("fsDirectoryCreate 41 : %s\n", PASSFAIL(fsDirectoryCreate("fileSystem.test.dir/subA/subB", NULL, NULL) == true)); printf("fsFileCreate 42 : %s\n", PASSFAIL(fsFileCreate("fileSystem.test.dir/file0", NULL, NULL) == true)); printf("fsFileCreate 43 : %s\n", PASSFAIL(fsFileCreate("fileSystem.test.dir/file1", NULL, NULL) == true)); list *dirStuff = fsDirectoryList(pathTestDir, FS_DIRLIST_DIRSFIRST, NULL); listItem *dirEntry = dirStuff->origin; for(u32 i=0; i<dirStuff->count; i++) { fsDirectoryItem *fsdi = (fsDirectoryItem *)dirEntry->data; printf("fsDirectoryList %02d : (%c) %s\n", 44+i, (fsdi->isDirectory ? 'd' : 'f'), fsdi->name); dirEntry = dirEntry->next; } listFree(&dirStuff); printf("fsDirectoryDelete xx : %s\n", PASSFAIL(fsDirectoryDelete(pathTestDir, NULL, NULL) == true)); return 0; }
void detector_test::test_positive_going_detector(void) { { // test empty container positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL(events == std::list<readings_t>()); PASSFAIL(detector.mData == std::list<readings_t>()); // empty std::list<readings_t> data; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == std::list<readings_t>()); // empty } { // test adding data positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{{timeval_ctor(0,0),0},{timeval_ctor(0,1),1}}; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); } { // test multiple negative input positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{{timeval_ctor(0,0),0},{timeval_ctor(0,1),0}}; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL(events == std::list<readings_t>()); PASSFAIL((detector.mData == std::list<readings_t>{{timeval_ctor(0,1),0}})); // has the last } { // test multiple positive input positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{{timeval_ctor(0,0),1},{timeval_ctor(0,1),1}}; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL(events == std::list<readings_t>()); PASSFAIL((detector.mData == std::list<readings_t>{{timeval_ctor(0,1),1}})); // has the last } { // test single positive going input positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{{timeval_ctor(0,0),0},{timeval_ctor(0,1),1}}; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL((events == std::list<readings_t>{{timeval_ctor(0,1),1}})); PASSFAIL((detector.mData == std::list<readings_t>{{timeval_ctor(0,1),1}})); } { // test positive then negative going input positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{{timeval_ctor(0,0),0},{timeval_ctor(0,1),1},{timeval_ctor(0,2),0}}; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL((events == std::list<readings_t>{{timeval_ctor(0,1),1}})); PASSFAIL((detector.mData == std::list<readings_t>{{timeval_ctor(0,2),0}})); } { // test multiple positive then negative going input positive_going_detector_t detector; std::cout << STR(detector) << '\n'; std::list<readings_t> data{ {timeval_ctor(0,0),0}, {timeval_ctor(0,1),1}, {timeval_ctor(0,2),1}, {timeval_ctor(0,3),0}, {timeval_ctor(0,4),0}, {timeval_ctor(0,5),1}, {timeval_ctor(0,6),0}, {timeval_ctor(0,7),1}, {timeval_ctor(0,8),0}, {timeval_ctor(0,9),1}, }; detector.add(data.begin(), data.end()); std::cout << STR(detector) << '\n'; PASSFAIL(detector.mData == data); std::list<readings_t> events; detector.process(events); std::cout << STR(events) << '\n'; std::cout << STR(detector) << '\n'; PASSFAIL((events == std::list<readings_t>{ {timeval_ctor(0,1),1}, {timeval_ctor(0,5),1}, {timeval_ctor(0,7),1}, {timeval_ctor(0,9),1}})); PASSFAIL((detector.mData == std::list<readings_t>{{timeval_ctor(0,9),1}})); } }