jobid format and parse
This commit is contained in:
parent
26e3c21c87
commit
3488b62716
6 changed files with 212 additions and 15 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <unity/unity.h>
|
||||
|
||||
#include "idgen.h"
|
||||
#include "utils.h"
|
||||
#include <errno.h>
|
||||
|
||||
static void test_idgen_invalid(void)
|
||||
|
|
@ -35,9 +36,13 @@ static void test_idgen1(void)
|
|||
TEST_ASSERT_TRUE(rc >= 0);
|
||||
|
||||
for (i = 0; i < 20; i++) {
|
||||
char buf[256];
|
||||
|
||||
rc = idgen(&ctx, 0x0, 0x0, 1, &idx);
|
||||
TEST_ASSERT_TRUE(rc >= 0);
|
||||
printf("\tidx = %lx\n", idx);
|
||||
memset(buf, 0x0, sizeof(buf));
|
||||
fmt_jobid(buf, sizeof(buf), idx);
|
||||
printf("\tjob = %s idx %lx\n", buf, idx);
|
||||
}
|
||||
|
||||
idgen_ctx_fini(&ctx);
|
||||
|
|
@ -56,12 +61,24 @@ static void test_idgen_array(void)
|
|||
int k;
|
||||
|
||||
for (k = 0; k < 5; k++) {
|
||||
int j;
|
||||
|
||||
rc = idgen(&ctx, 0x0, 0x0, i + 1, &idx);
|
||||
TEST_ASSERT_TRUE(rc >= 0);
|
||||
if (i >= 1) {
|
||||
TEST_ASSERT_TRUE((idx & MAX_ARRAY_IDX) == 0);
|
||||
}
|
||||
printf("\tidx = %lx\n", idx);
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
char buf[256];
|
||||
|
||||
memset(buf, 0x0, sizeof(buf));
|
||||
|
||||
fmt_jobid(buf, sizeof(buf), idx + j);
|
||||
printf("\tjob = %s idx %lx \n", buf, idx + j);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue