bool Tester::RSSReceiverTest6() { TestRSSReceiver testObj; ifstream test_xml("test_xml.txt"); string test_str; getline(test_xml, test_str, '\0'); test_str = "HTTP/1.1 200 OK\r\n\r\n" + test_str; inputArgs.directions = generateDirections(test_str); InRecord reference_record; reference_record.data = "Here is some text containing an interesting description."; reference_record.link = "http://www.wikipedia.org/"; reference_record.title = "Example entry"; try { testObj(inputArgs); InRecord test_record = inputArgs.itemsQueue->front(); if (reference_record.data == test_record.data && reference_record.link == test_record.link && reference_record.title == test_record.title) return true; else return false; } catch (RSSReceiverException& e) { return false; } }
static int execute_test(const char *dir_name) { DIR *d; struct dirent *dent; char path[PATH_MAX]; int ret = 0, exit_code = 0; struct nftnl_parse_err *err; d = opendir(dir_name); if (d == NULL) { perror("opendir"); exit(EXIT_FAILURE); } err = nftnl_parse_err_alloc(); if (err == NULL) { perror("error"); exit(EXIT_FAILURE); } while ((dent = readdir(d)) != NULL) { int len = strlen(dent->d_name); if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; snprintf(path, sizeof(path), "%s/%s", dir_name, dent->d_name); if (strcmp(&dent->d_name[len-4], ".xml") == 0) { if ((ret = test_xml(path, err)) == 0) { if (!update) { printf("parsing and validating %s: ", path); printf("\033[32mOK\e[0m\n"); } } exit_code += ret; } if (strcmp(&dent->d_name[len-5], ".json") == 0) { if ((ret = test_json(path, err)) == 0) { if (!update) { printf("parsing and validating %s: ", path); printf("\033[32mOK\e[0m\n"); } } exit_code += ret; }