diff options
author | Lev Walkin <vlm@lionet.info> | 2005-07-04 02:20:26 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2005-07-04 02:20:26 +0000 |
commit | 10dd97c70c40f76b6f269ff4d4c9aab89816c2db (patch) | |
tree | d1077d18ff8461d8867e3fe124b7cf5ad6cbad1e | |
parent | d4e4e612d93aa111265610156a41f39a462284e6 (diff) |
even more tests for invalid fractions
-rw-r--r-- | skeletons/GeneralizedTime.c | 3 | ||||
-rw-r--r-- | skeletons/tests/check-GeneralizedTime.c | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c index e9aa4781..4e60f6a2 100644 --- a/skeletons/GeneralizedTime.c +++ b/skeletons/GeneralizedTime.c @@ -561,8 +561,7 @@ asn_time2GT_frac(GeneralizedTime_t *opt_gt, const struct tm *tm, long frac_value */ if(frac_base >= 10 && frac_value > 0 - /* 1001 ms? should ignore or adjust seconds */ - && (frac_value/frac_base) == 0 + && (frac_value/(frac_base/10)) < 10 /* 98/99 */ ) { char *end = p + 1 + 6; /* '.' + maximum 6 digits */ char *z = p; diff --git a/skeletons/tests/check-GeneralizedTime.c b/skeletons/tests/check-GeneralizedTime.c index c39904e7..7a805b07 100644 --- a/skeletons/tests/check-GeneralizedTime.c +++ b/skeletons/tests/check-GeneralizedTime.c @@ -133,6 +133,21 @@ check_fractions() { printf("[%s]\n", gt->buf); assert(strcmp((char *)gt->buf, "19700101000000Z") == 0); + gt = asn_time2GT_frac(gt, &tm, 98, 99, 1); + assert(gt); + printf("[%s]\n", gt->buf); + assert(strcmp((char *)gt->buf, "19700101000000Z") == 0); + + gt = asn_time2GT_frac(gt, &tm, 90, 91, 1); + assert(gt); + printf("[%s]\n", gt->buf); + assert(strcmp((char *)gt->buf, "19700101000000Z") == 0); + + gt = asn_time2GT_frac(gt, &tm, 89, 91, 1); + assert(gt); + printf("[%s]\n", gt->buf); + assert(strcmp((char *)gt->buf, "19700101000000.9Z") == 0); + FREEMEM(gt->buf); FREEMEM(gt); } |