diff options
author | Joe Orton <jorton@apache.org> | 2004-01-06 14:49:11 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2004-01-06 14:49:11 +0000 |
commit | ba7653dd46eac66a054378b82bcb2cc5290149dd (patch) | |
tree | 9949d7c48e2d219ccc98b9dbf1074b47bf2f4be9 /test/testatomic.c | |
parent | e2719e98b5ef20dea2b5a3f297b8d0b2e7d93dc8 (diff) | |
download | apr-ba7653dd46eac66a054378b82bcb2cc5290149dd.tar.gz |
* testatomic.c (check_basic_atomics32): Test wrapping around zero.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@64860 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testatomic.c')
-rw-r--r-- | test/testatomic.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/testatomic.c b/test/testatomic.c index 74d9284f6..e05a783c9 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -84,6 +84,7 @@ static apr_status_t check_basic_atomics32(void) { apr_uint32_t oldval; apr_uint32_t casval = 0; + apr_uint32_t minus1 = -1; apr_atomic_set32(&y32, 2); printf("%-60s", "testing apr_atomic_dec32"); @@ -179,6 +180,30 @@ static apr_status_t check_basic_atomics32(void) } fprintf(stdout, "OK\n"); + printf("%-60s", "testing wrapping around zero"); + + apr_atomic_set32(&y32, 0); + if (apr_atomic_dec32(&y32) == 0) { + fprintf(stderr, "apr_atomic_dec32 on zero returned zero.\n"); + return APR_EGENERAL; + } + if (apr_atomic_read32(&y32) != minus1) { + fprintf(stderr, "zero wrap failed: 0 - 1 = %d\n", + apr_atomic_read32(&y32)); + return APR_EGENERAL; + } + + if (apr_atomic_inc32(&y32) != minus1) { + fprintf(stderr, "apr_atomic_inc32 on -1 returned bad value.\n"); + return APR_EGENERAL; + } + if (apr_atomic_read32(&y32) != 0) { + fprintf(stderr, "zero wrap failed: -1 + 1 = %u\n", + apr_atomic_read32(&y32)); + return APR_EGENERAL; + } + printf("OK\n"); + return APR_SUCCESS; } |