File: test_parseTools.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (59 lines) | stat: -rw-r--r-- 1,546 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <limits.h>
#include <stdio.h>
#include <inttypes.h>
#include <emscripten/emscripten.h>

void test_makeGetValue(int64_t* ptr);
void test_makeSetValue(int64_t* ptr);
int  test_receiveI64ParamAsI53(int64_t arg1, int64_t arg2);
int  test_receiveI64ParamAsDouble(int64_t arg1, int64_t arg2);

#define MAX_SAFE_INTEGER (1ll << 53)
#define MIN_SAFE_INTEGER (-MAX_SAFE_INTEGER)

EMSCRIPTEN_KEEPALIVE void printI64(int64_t* ptr) {
  printf("printI64: 0x%llx\n", *ptr);
}

EMSCRIPTEN_KEEPALIVE void clearI64(int64_t* ptr) {
  *ptr = 0;
}

int main() {
  int rtn;
  printf("MAX_SAFE_INTEGER: %lld\n", MAX_SAFE_INTEGER);
  printf("MIN_SAFE_INTEGER: %lld\n", MIN_SAFE_INTEGER);

  int64_t num = -0x0000aabb12345678ll;
  printI64(&num);
  test_makeGetValue(&num);

  test_makeSetValue(&num);

  rtn = test_receiveI64ParamAsI53(42, -42);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsI53(MAX_SAFE_INTEGER, MIN_SAFE_INTEGER);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsI53(MAX_SAFE_INTEGER + 1, 0);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsI53(MIN_SAFE_INTEGER - 1, 0);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsDouble(42, -42);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsDouble(MAX_SAFE_INTEGER, MIN_SAFE_INTEGER);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsDouble(MAX_SAFE_INTEGER + 1, 0);
  printf("rtn = %d\n", rtn);

  rtn = test_receiveI64ParamAsDouble(MIN_SAFE_INTEGER - 1, 0);
  printf("rtn = %d\n", rtn);

  printf("\ndone\n");
  return 0;
}