From 1b1b4bc9c678f94cf703f7084fd363cc617a1d41 Mon Sep 17 00:00:00 2001 From: Andreas Waidler Date: Sat, 30 Apr 2011 18:38:06 +0200 Subject: [PATCH] Fixed acceptance tests and requiring now that item title/desc comes first. --- TODO | 1 - src/fs.c | 7 ++++ .../{no_title.rss => feed_title_after_items.rss} | 3 +- tests_usr/{late_title.rss => no_feed_title.rss} | 4 +-- tests_usr/tests | 39 ++++++++++++---------- .../{no_title.rss => title_after_description.rss} | 3 +- 6 files changed, 35 insertions(+), 22 deletions(-) copy tests_usr/{no_title.rss => feed_title_after_items.rss} (67%) rename tests_usr/{late_title.rss => no_feed_title.rss} (57%) rename tests_usr/{no_title.rss => title_after_description.rss} (66%) diff --git a/TODO b/TODO index a3e6e16..ec84d20 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ * QA - * fail if item title is not called at first * test for buffer overflows when reading from global buffer into special ones (item, etc). * test whether nomtime can handle complicated filenames diff --git a/src/fs.c b/src/fs.c index 0e009c8..c679134 100644 --- a/src/fs.c +++ b/src/fs.c @@ -47,6 +47,7 @@ void sanitize(char* str) void set_item_date(const char* date) { struct tm t; + assert(item_title[0]); /* Has to be set first. */ assert(strptime(date, "%a, %d %b %Y %T %z", &t)); item_date = mktime(&t); assert(item_date != -1); @@ -60,6 +61,7 @@ void set_item_date(const char* date) void set_item_link(const char* link) { + assert(item_title[0]); /* Has to be set first. */ strncpy(item_link, link, TEXT_BUFFER_SIZE); } @@ -72,6 +74,7 @@ void set_item_title(const char* title) { strncpy(item_title, title, TEXT_BUFFER_SIZE - 1); + assert(item_desc[0] == 0); /* Has to be set first. */ if (strlen(title) >= TEXT_BUFFER_SIZE) { item_title[TEXT_BUFFER_SIZE - 4] = '.'; item_title[TEXT_BUFFER_SIZE - 3] = '.'; @@ -149,4 +152,8 @@ void item_flush() times[1].tv_usec = 0; assert(!utimes(buf, times)); + + item_title[0] = 0; + item_desc[0] = 0; + item_link[0] = 0; } diff --git a/tests_usr/no_title.rss b/tests_usr/feed_title_after_items.rss similarity index 67% copy from tests_usr/no_title.rss copy to tests_usr/feed_title_after_items.rss index 3491138..39d74d2 100644 --- a/tests_usr/no_title.rss +++ b/tests_usr/feed_title_after_items.rss @@ -1,9 +1,10 @@ - Feed without title. + feed item + feed diff --git a/tests_usr/late_title.rss b/tests_usr/no_feed_title.rss similarity index 57% rename from tests_usr/late_title.rss rename to tests_usr/no_feed_title.rss index 0d2117a..39d74d2 100644 --- a/tests_usr/late_title.rss +++ b/tests_usr/no_feed_title.rss @@ -1,10 +1,10 @@ - Feed with title after items. + feed item - Lazy Title + feed diff --git a/tests_usr/tests b/tests_usr/tests index 8c9d4c7..cf31af7 100755 --- a/tests_usr/tests +++ b/tests_usr/tests @@ -11,13 +11,15 @@ ITEM1="Item 1" ITEM2="Item 2" ITEM3="Item 3" +FAILURES=0 + function agg_run() { cat "$1" | ../src/agg res=$? if [ $res -ne 0 ]; then echo "Failed to run agg ($res)." - exit 1 + FAILURES=`expr $FAILURES + 1 ` fi } @@ -27,7 +29,7 @@ function agg_fail() res=$? if [ $res -eq 0 ]; then echo "Failed to fail running agg." - exit 1 + FAILURES=`expr $FAILURES + 1 ` fi } @@ -37,16 +39,15 @@ function agg_clean() res=$? if [ $res -ne 0 ]; then echo "Failed to run nomtime." - exit 1 + FAILURES=`expr $FAILURES + 1 ` fi } function cleanup() { - rm -rf "$FEED" item "simple feed" "simple feed t" "simple feed d" "long feed" || exit 1 + rm -rf "$FEED" item "feed" "simple feed" "simple feed t" "simple feed d" "long feed" || exit 1 } -FAILURES=0 function t() { printf " %-32s: " "$1" @@ -124,31 +125,23 @@ No item. Link: /dev/null" test_item_contents "$FEED/$ITEM3" "$exp" } +function test_fail_item_missing() { test_item_missing "feed/item"; } ############################################### -echo "Cleaning directory..." -cleanup - -echo "Running agg on feed without title..." -agg_fail no_title.rss -t test_item_missing - -echo "Running agg on feed with title after items..." -agg_fail late_title.rss -t test_item_missing - echo "Running agg on simple feed (titles)..." agg_run simple_t.rss t test_simple_t_feed_exists t test_simple_t_item_exists t test_simple_t_item_date t test_simple_t_item_contents +cleanup echo "Running agg on simple feed (descriptions)..." agg_run simple_d.rss t test_simple_d_feed_exists t test_simple_d_item_contents +cleanup echo "Running agg on sample feed (directory missing)..." agg_run sample.rss @@ -206,14 +199,26 @@ t test_complete_item3_date t test_complete_item1_contents t test_complete_item2_contents t test_complete_item3_contents +cleanup echo "Running agg on feed with long items..." agg_run long.rss t test_long_feed_exists t test_long_item_exists t test_long_item_contents +cleanup + +echo "Running agg on feed without title..." +agg_fail no_feed_title.rss +t test_fail_item_missing + +echo "Running agg on feed with title after items..." +agg_fail feed_title_after_items.rss +t test_fail_item_missing -echo "Cleaning up..." +echo "Running agg on feed with item title after description..." +agg_fail title_after_description.rss +t test_fail_item_missing cleanup echo "Failed $FAILURES times!" diff --git a/tests_usr/no_title.rss b/tests_usr/title_after_description.rss similarity index 66% rename from tests_usr/no_title.rss rename to tests_usr/title_after_description.rss index 3491138..e459317 100644 --- a/tests_usr/no_title.rss +++ b/tests_usr/title_after_description.rss @@ -1,8 +1,9 @@ - Feed without title. + feed + item item -- 2.11.4.GIT