Skip to content

Commit

Permalink
fix bug from prior commit and add test (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidaty authored Mar 22, 2023
1 parent 0b2dd42 commit 903749b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/prop.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ enum zsv_prop_mode {
zsv_prop_mode_export = 'e',
zsv_prop_mode_import = 'i',
zsv_prop_mode_copy = 'c',
zsv_prop_mode_clear = 'l'
zsv_prop_mode_clear = 'r'
};

static enum zsv_prop_mode zsv_prop_get_mode(const char *opt) {
Expand Down
17 changes: 9 additions & 8 deletions app/test/prop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,44 @@ test-1:
@touch .zsv/data/dummy.csv/hello.json
@${PREFIX} ${EXE} dummy.csv --clear ${SUFFIX}
@ls .zsv/data/dummy.csv/hello.json 2>/dev/null && ${TEST_FAIL} || ${TEST_PASS}
@${CHECK} [ "`${EXE} dummy.csv`" == "{}" ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv`" = "{}" ] && ${TEST_PASS} || ${TEST_FAIL}

test-2:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv -R 2 ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" == '{"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" = '{"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}

test-3:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv -d 3 ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" == '{"header-row-span":3,"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" = '{"header-row-span":3,"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}

test-4:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv -R - ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" == '{"header-row-span":3}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" = '{"header-row-span":3}' ] && ${TEST_PASS} || ${TEST_FAIL}

test-5:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv -d - ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" == '{}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" = '{}' ] && ${TEST_PASS} || ${TEST_FAIL}

test-6:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv -d 3 ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" == '{"header-row-span":3}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv|jq -c -S`" = '{"header-row-span":3}' ] && ${TEST_PASS} || ${TEST_FAIL}

test-7:
@${TEST_INIT}
@${PREFIX} ${EXE} dummy.csv --clear ${SUFFIX}
@${CHECK} [ "`${EXE} dummy.csv`" == "{}" ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} dummy.csv`" = "{}" ] && ${TEST_PASS} || ${TEST_FAIL}

test-8:
@${TEST_INIT}
@${CHECK} ${EXE} detect.csv --clear
@${PREFIX} ${EXE} detect.csv --auto --save ${SUFFIX}
@${CHECK} [ "`${EXE} detect.csv|jq -c -S`" == '{"header-row-span":2,"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} detect.csv --list-files`" = "props.json" ] && ${TEST_PASS} || ${TEST_FAIL}
@${CHECK} [ "`${EXE} detect.csv|jq -c -S`" = '{"header-row-span":2,"skip-head":2}' ] && ${TEST_PASS} || ${TEST_FAIL}
@${EXE} detect.csv --clear

test-copy:
Expand Down

0 comments on commit 903749b

Please sign in to comment.