Create userdata without user values in Lua 5.4
[liba.git] / test / polytraj3.h
blob5c4e96bc3968c8ff1f74b62817e5ef4f625814c3
1 #define MAIN_(x) A_CAST_2(x, _polytraj3)
2 #include "test.h"
3 #include "a/polytraj3.h"
5 int MAIN(int argc, char *argv[]) // NOLINT(misc-definitions-in-headers)
7 int start = 1;
8 if (argc > 1)
10 char *endptr = A_NULL;
11 #if A_FLOAT_TYPE + 0 == A_FLOAT_SINGLE
12 (void)strtof(argv[1], &endptr);
13 #elif A_FLOAT_TYPE + 0 == A_FLOAT_DOUBLE
14 (void)strtod(argv[1], &endptr);
15 #elif A_FLOAT_TYPE + 0 == A_FLOAT_EXTEND
16 (void)strtold(argv[1], &endptr);
17 #endif /* A_FLOAT_TYPE */
18 if (argv[1] == endptr)
20 test_init(argc, argv, 1);
21 ++start;
25 a_float_t arg[6] = {0};
26 for (int i = start; i < argc; ++i)
28 #if A_FLOAT_TYPE + 0 == A_FLOAT_SINGLE
29 arg[i - start] = strtof(argv[i], A_NULL);
30 #elif A_FLOAT_TYPE + 0 == A_FLOAT_DOUBLE
31 arg[i - start] = strtod(argv[i], A_NULL);
32 #elif A_FLOAT_TYPE + 0 == A_FLOAT_EXTEND
33 arg[i - start] = strtold(argv[i], A_NULL);
34 #endif /* A_FLOAT_TYPE */
36 a_polytraj3_s ctx;
37 a_polytraj3_gen(&ctx, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]);
38 for (a_float_t dt = arg[0], delta = (arg[1] - arg[0]) / 1000; dt < arg[1]; dt += delta) // NOLINT
40 debug(A_FLOAT_PRI("+", "f ") A_FLOAT_PRI("+", "f ") A_FLOAT_PRI("+", "f ") A_FLOAT_PRI("+", "f\n"),
41 dt, a_polytraj3_pos(&ctx, dt), a_polytraj3_vel(&ctx, dt), a_polytraj3_acc(&ctx, dt));
44 return 0;